From 06878c69e4a0c36a618dbd3461ed59b4c146f8ec Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sun, 19 May 2024 15:16:49 -0400 Subject: [PATCH 1/3] Disable biome container compression when WorldEdit is installed --- .../embeddedt/modernfix/core/config/ModernFixEarlyConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java index 08a8e66a..5a18501c 100644 --- a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java +++ b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java @@ -214,7 +214,7 @@ public class ModernFixEarlyConfig { /* Mod compat */ disableIfModPresent("mixin.perf.thread_priorities", "smoothboot", "threadtweak"); disableIfModPresent("mixin.perf.boost_worker_count", "smoothboot", "threadtweak"); - disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge" ,"skyblockbuilder", "modern_beta"); + disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge" ,"skyblockbuilder", "modern_beta", "worldedit"); disableIfModPresent("mixin.bugfix.mc218112", "performant"); disableIfModPresent("mixin.bugfix.remove_block_chunkloading", "performant"); disableIfModPresent("mixin.bugfix.paper_chunk_patches", "c2me"); From f85d31d24d13804323d5ac1512f9f98bf044f5de Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sun, 19 May 2024 19:36:39 -0400 Subject: [PATCH 2/3] Remove redundant patch --- .../perf/remove_spawn_chunks/EntityMixin.java | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/remove_spawn_chunks/EntityMixin.java diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/remove_spawn_chunks/EntityMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/remove_spawn_chunks/EntityMixin.java deleted file mode 100644 index 8a3412c3..00000000 --- a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/remove_spawn_chunks/EntityMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.embeddedt.modernfix.common.mixin.perf.remove_spawn_chunks; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.TicketType; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.ChunkPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(Entity.class) -public class EntityMixin { - /** - * @author embeddedt - * @reason If the spawn chunks are not loaded, end portals linking to the overworld will teleport entities into - * the void at the spawn position, which is not ideal. To solve this, we create a PORTAL ticket if the expected - * overworld chunk is missing. - */ - @ModifyExpressionValue(method = "findDimensionEntryPoint", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;getSharedSpawnPos()Lnet/minecraft/core/BlockPos;"), require = 0) - private BlockPos mfix$triggerChunkloadAtSpawnPos(BlockPos spawnPos, ServerLevel destination) { - // Only apply this change if the overworld is the destination - if (destination.dimension() == ServerLevel.OVERWORLD) { - // No ticket is required if the chunk happens to already be loaded - if(!destination.hasChunk(spawnPos.getX() >> 4, spawnPos.getZ() >> 4)) { - // Create a portal ticket. While we could just load the chunk once, it would immediately unload on the - // next tick, causing churn. The ticket will keep it loaded for a few seconds which should give high - // performance for farms pumping things through portals frequently. - BlockPos key = spawnPos.immutable(); - destination.getChunkSource().addRegionTicket(TicketType.PORTAL, new ChunkPos(key), 3, key); - // Wait for the chunk to be loaded, as adding the ticket is asynchronous - destination.getChunk(key); - } - } - return spawnPos; - } -} From 1728de0f1678ced73076e61406ec29e0bc425b22 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sun, 26 May 2024 15:58:37 -0400 Subject: [PATCH 3/3] Fix CME in BiomeDictionary.Type Thanks @Asek3 for noticing this --- .../BiomeDictionaryTypeMixin.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 forge/src/main/java/org/embeddedt/modernfix/forge/mixin/bugfix/biome_dictionary_cme/BiomeDictionaryTypeMixin.java diff --git a/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/bugfix/biome_dictionary_cme/BiomeDictionaryTypeMixin.java b/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/bugfix/biome_dictionary_cme/BiomeDictionaryTypeMixin.java new file mode 100644 index 00000000..cb5039c5 --- /dev/null +++ b/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/bugfix/biome_dictionary_cme/BiomeDictionaryTypeMixin.java @@ -0,0 +1,30 @@ +package org.embeddedt.modernfix.forge.mixin.bugfix.biome_dictionary_cme; + +import net.minecraftforge.common.BiomeDictionary; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.Map; +import java.util.concurrent.ConcurrentSkipListMap; + +@Mixin(value = BiomeDictionary.Type.class, remap = false) +public class BiomeDictionaryTypeMixin { + @Shadow + @Mutable + @Final + private static Map byName; + + /** + * @author embeddedt + * @reason Biome types are created concurrently so the backing map needs to be thread-safe + */ + @Redirect(method = "", at = @At(value = "FIELD", target = "Lnet/minecraftforge/common/BiomeDictionary$Type;byName:Ljava/util/Map;", opcode = Opcodes.PUTSTATIC)) + private static void useConcurrentMap(Map treeMap) { + byName = new ConcurrentSkipListMap<>(); + } +}