From 2ec47c5d59074bd2af6085180f20d024516806df Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 11 Mar 2023 13:29:53 +0700 Subject: [PATCH] Don't use parallelStream because https://github.com/MinecraftForge/EventBus/issues/44 --- src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 3 ++- .../ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt | 2 +- .../ru/dbotthepony/mc/otm/matter/InsertAction.kt | 10 ++++------ .../ru/dbotthepony/mc/otm/matter/MatterManager.kt | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt index e35bea5f9..906cdda22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -246,7 +246,8 @@ fun String.toUUID(): UUID { fun Collection.probablyParallelStream(): Stream { if (size >= 400) { - return parallelStream() + // TODO: https://github.com/MinecraftForge/EventBus/issues/44 + return stream() } return stream() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt index 50e9b1cc9..fa77f9fe6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -392,7 +392,7 @@ class QuantumBatteryItem : Item { companion object { fun clientDisconnect(event: ClientPlayerNetworkEvent.LoggingOut) { - ForgeRegistries.ITEMS.values.parallelStream().forEach { if (it is QuantumBatteryItem) it.clientPowerMap.clear() } + ForgeRegistries.ITEMS.values.stream().forEach { if (it is QuantumBatteryItem) it.clientPowerMap.clear() } } fun readPacket(buff: FriendlyByteBuf): ChargePacket { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt index 31f0ce082..116b9fa2e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt @@ -5,8 +5,6 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.probablyParallelStream -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set class InsertAction : AbstractRegistryAction { @@ -68,7 +66,7 @@ class InsertAction : AbstractRegistryAction { if (key != null) { if (replaceIfExists) { // search & replace in parallel, if possible - val replaced = registry.probablyParallelStream().anyMatch { + val replaced = registry.stream().anyMatch { if (it is MutableKeyEntry && it.key == key) { if (!comparePriority || it.priority < priority!!) { it.matter = matter @@ -93,7 +91,7 @@ class InsertAction : AbstractRegistryAction { ) } } else { - if (registry.probablyParallelStream().anyMatch { it is MutableKeyEntry && it.key == key }) { + if (registry.stream().anyMatch { it is MutableKeyEntry && it.key == key }) { fail { "Value with key $key already exists" } return } @@ -110,7 +108,7 @@ class InsertAction : AbstractRegistryAction { } else { if (replaceIfExists) { // search & replace in parallel, if possible - val replaced = registry.probablyParallelStream().anyMatch { + val replaced = registry.stream().anyMatch { if (it is MutableTagEntry && it.tag == tag) { if (!comparePriority || it.priority < priority!!) { it.matter = matter @@ -135,7 +133,7 @@ class InsertAction : AbstractRegistryAction { ) } } else { - if (registry.probablyParallelStream().anyMatch { it is MutableTagEntry && it.tag == tag }) { + if (registry.stream().anyMatch { it is MutableTagEntry && it.tag == tag }) { fail { "Value with tag $tag already exists" } return } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 3ceaa4060..fd97ccd81 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -490,7 +490,7 @@ object MatterManager { val ignoreDamageables = data["ignore_damageables"]?.asBoolean ?: false val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true - var stream = server.recipeManager.byType(findRecipeType).values.parallelStream().filter { !it.isIncomplete } + var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.isIncomplete } if (ignoreDamageables) { stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } @@ -523,7 +523,7 @@ object MatterManager { val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true val ignoreDamageables = data["ignore_damageables"]?.asBoolean ?: false val isCritical = data["is_critical"]?.asBoolean ?: true - var stream = server.recipeManager.byType(RecipeType.CRAFTING).values.parallelStream().filter { !it.isIncomplete } + var stream = server.recipeManager.byType(RecipeType.CRAFTING).values.stream().filter { !it.isIncomplete } if (ignoreDamageables) { stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } }