diff --git a/src/main/java/de/pilz/plantmegapackfix/PMPFixMixinLoaderLate.java b/src/main/java/de/pilz/plantmegapackfix/PMPFixMixinLoaderLate.java index d4b1fb7..cb1f815 100644 --- a/src/main/java/de/pilz/plantmegapackfix/PMPFixMixinLoaderLate.java +++ b/src/main/java/de/pilz/plantmegapackfix/PMPFixMixinLoaderLate.java @@ -23,6 +23,8 @@ public List getMixins(Set loadedMods) { if (loadedMods.contains("plantmegapack")) { list.add("PMPGenVineMixin"); list.add("PMPWorldGeneratorMixin"); + list.add("PMPGenAquaticMixin"); + list.add("PMPBlockPlantMixin"); } return list; diff --git a/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPBlockPlantMixin.java b/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPBlockPlantMixin.java new file mode 100644 index 0000000..49ccf6e --- /dev/null +++ b/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPBlockPlantMixin.java @@ -0,0 +1,29 @@ +package de.pilz.plantmegapackfix.mixins.late; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; + +import plantmegapack.block.PMPBlockPlant; +import plantmegapack.common.PMPPlantGrowthType; + +@Mixin(PMPBlockPlant.class) +public abstract class PMPBlockPlantMixin { + + @ModifyExpressionValue( + method = "onNeighborBlockChange", + at = @At( + value = "INVOKE", + target = "Lplantmegapack/block/PMPBlockPlant;canBlockStay(Lnet/minecraft/world/World;III)Z"), + remap = false) + private boolean pmpfix$onNeighborBlockChange$ignoreSweared(boolean original, World world, int x, int y, int z, + @Local Block block) { + return original || (block instanceof PMPBlockPlant + && ((PMPBlockPlant) block).plantData.attributes.growthType == PMPPlantGrowthType.SEAWEED); + } +} diff --git a/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPGenAquaticMixin.java b/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPGenAquaticMixin.java new file mode 100644 index 0000000..c49bc15 --- /dev/null +++ b/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPGenAquaticMixin.java @@ -0,0 +1,27 @@ +package de.pilz.plantmegapackfix.mixins.late; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; + +import plantmegapack.block.PMPBlockPlant; +import plantmegapack.worldgen.PMPGenAquatic; + +@Mixin(PMPGenAquatic.class) +public abstract class PMPGenAquaticMixin { + + @WrapWithCondition( + method = "spawnRandomSeaweedCluster", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlock(IIILnet/minecraft/block/Block;II)Z"), + remap = false) + private static boolean pmpfix$spawnRandomSeaweedCluster$checkForWaterAbove(World world, int x, int y, int z, + Block blockIn, int metadataIn, int flags) { + PMPBlockPlant plant = (PMPBlockPlant) blockIn; + if (!plant.canPlaceBlockAt(world, x, y, z)) return false; + return true; + } +} diff --git a/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPWorldGeneratorMixin.java b/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPWorldGeneratorMixin.java index f0bd7cf..dd09108 100644 --- a/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPWorldGeneratorMixin.java +++ b/src/main/java/de/pilz/plantmegapackfix/mixins/late/PMPWorldGeneratorMixin.java @@ -29,7 +29,7 @@ private void generateSurface(World world, Random random, int chunkX, int chunkZ) private void generateEnd(World world, Random random, int chunkX, int chunkZ) {} @Inject(method = "generate", at = @At("RETURN"), cancellable = false, remap = false) - private void pmpfix$$checkWorldProviderSuface(Random random, int chunkX, int chunkZ, World world, + private void pmpfix$generate$checkWorldProviderSuface(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider, CallbackInfo callback) { if (world.provider.dimensionId == 0 || world.provider.dimensionId == -1 || world.provider.dimensionId == 1) { // Handled by original already