From 88c58650c690841ababd78c943b95a0bc7765d5d Mon Sep 17 00:00:00 2001 From: IThundxr Date: Sat, 26 Oct 2024 10:23:52 -0400 Subject: [PATCH] more changes --- .../mixin/MinecraftServerMixin.java | 17 +++++++++++++++++ .../mixinsupport/LevelLoadAppliers.java | 14 ++++++++++++++ src/main/resources/railwaystweaks.mixins.json | 1 + 3 files changed, 32 insertions(+) create mode 100644 src/main/java/dev/ithundxr/railwaystweaks/mixin/MinecraftServerMixin.java create mode 100644 src/main/java/dev/ithundxr/railwaystweaks/mixinsupport/LevelLoadAppliers.java diff --git a/src/main/java/dev/ithundxr/railwaystweaks/mixin/MinecraftServerMixin.java b/src/main/java/dev/ithundxr/railwaystweaks/mixin/MinecraftServerMixin.java new file mode 100644 index 0000000..1ce9296 --- /dev/null +++ b/src/main/java/dev/ithundxr/railwaystweaks/mixin/MinecraftServerMixin.java @@ -0,0 +1,17 @@ +package dev.ithundxr.railwaystweaks.mixin; + +import dev.ithundxr.railwaystweaks.mixinsupport.LevelLoadAppliers; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.progress.ChunkProgressListener; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(MinecraftServer.class) +public class MinecraftServerMixin { + @Inject(method = "createLevels", at = @At("HEAD")) + private void railwaysTweaks$setupEntityTypeFilters(ChunkProgressListener listener, CallbackInfo ci) { + LevelLoadAppliers.init(); + } +} diff --git a/src/main/java/dev/ithundxr/railwaystweaks/mixinsupport/LevelLoadAppliers.java b/src/main/java/dev/ithundxr/railwaystweaks/mixinsupport/LevelLoadAppliers.java new file mode 100644 index 0000000..66ec291 --- /dev/null +++ b/src/main/java/dev/ithundxr/railwaystweaks/mixinsupport/LevelLoadAppliers.java @@ -0,0 +1,14 @@ +package dev.ithundxr.railwaystweaks.mixinsupport; + +public class LevelLoadAppliers { + private static boolean ran = false; + + public static void init() { + if (ran) { + return; + } + ran = true; + + FlatBlockstateArray.apply(); + } +} diff --git a/src/main/resources/railwaystweaks.mixins.json b/src/main/resources/railwaystweaks.mixins.json index d364b9b..a673798 100644 --- a/src/main/resources/railwaystweaks.mixins.json +++ b/src/main/resources/railwaystweaks.mixins.json @@ -7,6 +7,7 @@ "mixins": [ "DedicatedServerMixin", "LevelChunkSectionMixin", + "MinecraftServerMixin", "ServerPlayerMixin", "ServerStatusPacketListenerImplMixin", "compat.appleskin.SyncHandlerMixin",