diff --git a/src/main/java/org/dimdev/jeid/core/JEIDMixinLoader.java b/src/main/java/org/dimdev/jeid/core/JEIDMixinLoader.java index 793bb86..675e5e1 100644 --- a/src/main/java/org/dimdev/jeid/core/JEIDMixinLoader.java +++ b/src/main/java/org/dimdev/jeid/core/JEIDMixinLoader.java @@ -100,15 +100,9 @@ public List getMixinConfigs() { if (Loader.isModLoaded("worldedit")) { configs.add("mixins.jeid.worldedit.json"); } - - // Checks if the mod is within the version that has the legacy Biome Spread code - if (Loader.isModLoaded("wyrmsofnyrus")) - //TODO: Doesn't work since this code runs before anything is actually loaded, so we'll need to find another way before v0.6 comes out. - // Loader.instance().getCustomModProperties("wyrmsofnyrus").get("version").matches("0.5.[1-9][0-9]{1,3}") ) - // this checks any version between v0.5.10 (introduced the system) and v0.5.9999 (Impossible number of versions for a LTS version, but let's futureproof it to be safe.) + if (Loader.isModLoaded("wyrmsofnyrus")) { configs.add("mixins.jeid.wyrmsofnyrus.json"); - - + } return configs; } } diff --git a/src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinBiomeSpread.java b/src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinBiomeSpread.java deleted file mode 100644 index 54f7700..0000000 --- a/src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinBiomeSpread.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.dimdev.jeid.mixin.modsupport.wyrmsofnyrus; - -import com.vetpetmon.wyrmsofnyrus.world.biome.BiomeRegistry; -import com.vetpetmon.wyrmsofnyrus.world.biome.SpreadingBiome; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import org.dimdev.jeid.INewChunk; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Pseudo; - -@Pseudo -@Mixin(SpreadingBiome.class) -public class MixinBiomeSpread { - // I would natively implement this considering it doesn't even need anything fancy, - // but I must agree that making a one-off patch is much more performant than making the game - // check for REID, though I am concerned if people are using JEID and don't know about REID... - // - // In 0.6 or a later 0.5.x release I'll probably figure out a way to make a native patch. - // - // WoN's biome alteration code is similar to Thaumcraft's and SRP's biome alteration, - // so these patches are based on those mods' patches. - // I keep calling Mixins patches. I see no difference. - // Can you believe this is the first Mixin I made that actually works? -Modrome, official WoN dev - /** - * @author Modrome - * @reason Patches Wyrms of Nyrus's Biome Spread compatible for WoN 0.5.x; code will need to be updated when 0.6 releases - */ - @Overwrite(remap=false) - public static void setBiome(World w, BlockPos pos, Biome biome) { - if (biome != null) { - int convX = pos.getX() & 15; - int convZ = pos.getZ() & 15; - ((INewChunk)w.getChunk(pos)).getIntBiomeArray()[convZ << 4 | convX] = Biome.getIdForBiome(biome); - } - - } - - /** - * @author Modrome - * @reason The alternative function; code will need to be updated when 0.6 releases. This code in WoN is a default shortcut that has since been removed in 0.6 - */ - @Overwrite(remap=false) - public static void setBiome(World w, BlockPos pos) { - int convX = pos.getX() & 15; - int convZ = pos.getZ() & 15; - ((INewChunk)w.getChunk(pos)).getIntBiomeArray()[convZ << 4 | convX] = Biome.getIdForBiome(BiomeRegistry.CREEPLANDS); - } -} diff --git a/src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinHiveCreepSpreadFurther.java b/src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinHiveCreepSpreadFurther.java new file mode 100644 index 0000000..9ba65e9 --- /dev/null +++ b/src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinHiveCreepSpreadFurther.java @@ -0,0 +1,27 @@ +package org.dimdev.jeid.mixin.modsupport.wyrmsofnyrus; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; + +import com.llamalad7.mixinextras.sugar.Local; +import com.vetpetmon.wyrmsofnyrus.invasion.HiveCreepSpreadFurther; +import com.vetpetmon.wyrmsofnyrus.world.biome.BiomeRegistry; +import org.dimdev.jeid.network.MessageManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(value = HiveCreepSpreadFurther.class, remap = false) +public class MixinHiveCreepSpreadFurther { + /** + * @reason Use REID message to immediately re-render changes on client + */ + @Redirect(method = "decay", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/network/simpleimpl/SimpleNetworkWrapper;sendToDimension(Lnet/minecraftforge/fml/common/network/simpleimpl/IMessage;I)V")) + private static void reid$sendSpreadBiomeChange(SimpleNetworkWrapper instance, IMessage message, int dimensionId, BlockPos pos, World world, + @Local(ordinal = 2) BlockPos spreadPos) { + MessageManager.sendClientsBiomePosChange(world, spreadPos, Biome.getIdForBiome(BiomeRegistry.CREEPLANDS)); + } +} diff --git a/src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinSpreadingBiome.java b/src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinSpreadingBiome.java new file mode 100644 index 0000000..04afc5c --- /dev/null +++ b/src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinSpreadingBiome.java @@ -0,0 +1,52 @@ +package org.dimdev.jeid.mixin.modsupport.wyrmsofnyrus; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.Chunk; + +import com.vetpetmon.wyrmsofnyrus.world.biome.BiomeRegistry; +import com.vetpetmon.wyrmsofnyrus.world.biome.SpreadingBiome; +import org.dimdev.jeid.ducks.INewChunk; +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; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(value = SpreadingBiome.class, remap = false) +public class MixinSpreadingBiome { + // I would natively implement this considering it doesn't even need anything fancy, + // but I must agree that making a one-off patch is much more performant than making the game + // check for REID, though I am concerned if people are using JEID and don't know about REID... + // + // In 0.6 or a later 0.5.x release I'll probably figure out a way to make a native patch. + // + // WoN's biome alteration code is similar to Thaumcraft's and SRP's biome alteration, + // so these patches are based on those mods' patches. + // I keep calling Mixins patches. I see no difference. + // Can you believe this is the first Mixin I made that actually works? -Modrome, official WoN dev + /** + * @author Modrome, jchung01 + * @reason Patches Wyrms of Nyrus's Biome Spread compatible for 0.5.x + */ + @Inject(method = "setBiome(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/biome/Biome;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunk(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/chunk/Chunk;", remap = true), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) + private static void reid$toIntBiomeArray(World w, BlockPos pos, Biome biome, CallbackInfo ci, + int convX, int convZ) { + Chunk chunk = w.getChunk(pos); + chunk.markDirty(); + ((INewChunk) chunk).getIntBiomeArray()[convZ << 4 | convX] = Biome.getIdForBiome(biome); + ci.cancel(); + } + + /** + * @reason Overload for WoN 0.5.x + */ + @Inject(method = "setBiome(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V", at = @At(value = "HEAD"), cancellable = true) + private static void reid$creeplandsToIntBiomeArray(World w, BlockPos pos, CallbackInfo ci) { + SpreadingBiome.setBiome(w, pos, BiomeRegistry.CREEPLANDS); + ci.cancel(); + } + + // TODO: Add mixin for 0.6 if necessary (annotate with @Group and @Dynamic, see AR MixinBiomeHandler for example) +} diff --git a/src/main/resources/mixins.jeid.wyrmsofnyrus.json b/src/main/resources/mixins.jeid.wyrmsofnyrus.json index 8f90e78..14b3bee 100644 --- a/src/main/resources/mixins.jeid.wyrmsofnyrus.json +++ b/src/main/resources/mixins.jeid.wyrmsofnyrus.json @@ -5,6 +5,7 @@ "minVersion": "0.8", "compatibilityLevel": "JAVA_8", "mixins": [ - "MixinBiomeSpread" + "MixinSpreadingBiome", + "MixinHiveCreepSpreadFurther" ] }