From 51b300cdf117317627e67fbd595d00ad61115ae6 Mon Sep 17 00:00:00 2001 From: Pajang Forever <2548531078@qq.com> Date: Mon, 12 Aug 2024 16:46:08 +0800 Subject: [PATCH] fixed bugs about excepted block state change while fluids flow through connectable blocks such as fences or iron bars --- .../java/name/synchro/fluids/FluidUtil.java | 38 ++++++++++++------ .../fluidConcerned/BigDripleafBlockMixin.java | 24 ----------- .../BubbleColumnBlockMixin.java | 40 ------------------- .../fluidConcerned/SpawnLocatingMixin.java | 24 ----------- 4 files changed, 25 insertions(+), 101 deletions(-) delete mode 100644 src/main/java/name/synchro/mixin/fluidConcerned/BigDripleafBlockMixin.java delete mode 100644 src/main/java/name/synchro/mixin/fluidConcerned/BubbleColumnBlockMixin.java delete mode 100644 src/main/java/name/synchro/mixin/fluidConcerned/SpawnLocatingMixin.java diff --git a/src/main/java/name/synchro/fluids/FluidUtil.java b/src/main/java/name/synchro/fluids/FluidUtil.java index a29b48c..13ddaf3 100644 --- a/src/main/java/name/synchro/fluids/FluidUtil.java +++ b/src/main/java/name/synchro/fluids/FluidUtil.java @@ -146,19 +146,31 @@ public static FluidState getFluidStateInRenderedChunk(List 0) { int i = flags & ~(Block.NOTIFY_NEIGHBORS | Block.SKIP_DROPS); - fluidState.getBlockState().updateNeighbors(world, pos, i, maxDepth - 1); + finalBlockState.updateNeighbors(world, pos, i, maxDepth - 1); } world.onBlockChanged(pos, replacedState.getBlockState(), placedState.getBlockState()); } @@ -460,10 +472,10 @@ public static void fluidReact(World world, BlockPos pos, BlockState blockState){ // ModDataContainer container = ((ModDataManager.Provider)world).synchro$getModDataManager().getContents().get(FluidReactionData.ID); // if (container instanceof FluidReactionData fluidReactionData){ // Map map = fluidReactionData.data(); -// long key = FluidReactionData.longKey(fluidState.getFluid(), blockState.getBlock()); +// long key = FluidReactionData.longKey(fluidState.getFluid(), originalBlockState.getBlock()); // FluidReaction entry = map.get(key); // if (entry == null) return; -// if (!entry.match(fluidState, blockState)) return; +// if (!entry.match(fluidState, originalBlockState)) return; // for (LocationAction action: entry.actions()){ // action.act(world, pos); // } diff --git a/src/main/java/name/synchro/mixin/fluidConcerned/BigDripleafBlockMixin.java b/src/main/java/name/synchro/mixin/fluidConcerned/BigDripleafBlockMixin.java deleted file mode 100644 index ef92be1..0000000 --- a/src/main/java/name/synchro/mixin/fluidConcerned/BigDripleafBlockMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package name.synchro.mixin.fluidConcerned; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.block.BigDripleafBlock; -import net.minecraft.block.BlockState; -import net.minecraft.fluid.FluidState; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Deprecated -@Mixin(BigDripleafBlock.class) -public class BigDripleafBlockMixin { - @WrapOperation(method = "grow(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V", at = @At( - value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getFluidState()Lnet/minecraft/fluid/FluidState;")) - private FluidState fixGetFluidState(BlockState instance, Operation original, - @Local(argsOnly = true)ServerWorld world, - @Local(argsOnly = true)BlockPos pos){ - return world.getFluidState(pos); - } -} diff --git a/src/main/java/name/synchro/mixin/fluidConcerned/BubbleColumnBlockMixin.java b/src/main/java/name/synchro/mixin/fluidConcerned/BubbleColumnBlockMixin.java deleted file mode 100644 index 6765ca3..0000000 --- a/src/main/java/name/synchro/mixin/fluidConcerned/BubbleColumnBlockMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -package name.synchro.mixin.fluidConcerned; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import name.synchro.fluids.FluidUtil; -import net.minecraft.block.BlockState; -import net.minecraft.block.BubbleColumnBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldAccess; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Deprecated -@Mixin(BubbleColumnBlock.class) -public class BubbleColumnBlockMixin { - @WrapOperation(method = "getStateForNeighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BubbleColumnBlock;isStillWater(Lnet/minecraft/block/BlockState;)Z")) - private boolean fixIsStillWaterTest(BlockState state, Operation original, - @Local(argsOnly = true)WorldAccess worldAccess, - @Local(argsOnly = true, ordinal = 1)BlockPos neighborPos){ - return FluidUtil.isStillWaterForBubbles(worldAccess, neighborPos); - } - - @WrapOperation(method = "update(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BubbleColumnBlock;isStillWater(Lnet/minecraft/block/BlockState;)Z", ordinal = 0)) - private static boolean fixIsStillWaterTest1(BlockState state, Operation original, - @Local(argsOnly = true) WorldAccess worldAccess, - @Local(argsOnly = true) BlockPos pos){ - return FluidUtil.isStillWaterForBubbles(worldAccess, pos); - } - - @WrapOperation(method = "update(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BubbleColumnBlock;isStillWater(Lnet/minecraft/block/BlockState;)Z", ordinal = 1)) - private static boolean fixIsStillWaterTest2(BlockState state, Operation original, - @Local(argsOnly = true) WorldAccess worldAccess, - @Local BlockPos.Mutable pos){ - return FluidUtil.isStillWaterForBubbles(worldAccess, pos); - } - -} diff --git a/src/main/java/name/synchro/mixin/fluidConcerned/SpawnLocatingMixin.java b/src/main/java/name/synchro/mixin/fluidConcerned/SpawnLocatingMixin.java deleted file mode 100644 index be3d99e..0000000 --- a/src/main/java/name/synchro/mixin/fluidConcerned/SpawnLocatingMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package name.synchro.mixin.fluidConcerned; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.block.BlockState; -import net.minecraft.fluid.FluidState; -import net.minecraft.server.network.SpawnLocating; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Deprecated -@Mixin(SpawnLocating.class) -public class SpawnLocatingMixin { - @WrapOperation(method = "findOverworldSpawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getFluidState()Lnet/minecraft/fluid/FluidState;")) - private static FluidState fixGetFluidState(BlockState instance, Operation original, - @Local(argsOnly = true) ServerWorld world, - @Local BlockPos.Mutable pos){ - - return world.getFluidState(pos); - } -}