diff --git a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java index d06b10bb..8da4755f 100644 --- a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java @@ -28,7 +28,20 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock } private ThreadLocal> list1_BlockEntities = new ThreadLocal<>(); //Unneccessary ThreadLocal if client and server use different PistonBlock instances - + + @Inject(method = "isMovable", at = @At("HEAD"), cancellable = true) + private static void slimeHoney(BlockState blockState_1, World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1, Direction direction_2, CallbackInfoReturnable cir) + { + if (CarpetSettings.stickyHoney && direction_1 != direction_2) + { + Block block = blockState_1.getBlock(); + if (block != Blocks.GOLD_BLOCK && block != Blocks.SLIME_BLOCK) return; + Block otherBlock = world_1.getBlockState(blockPos_1.offset(direction_2.getOpposite(),1)).getBlock(); + if (otherBlock != Blocks.GOLD_BLOCK && otherBlock != Blocks.SLIME_BLOCK) return; + cir.setReturnValue(block == otherBlock); + } + } + @Inject(method = "isMovable", at = @At(value = "RETURN", ordinal = 3, shift = At.Shift.BEFORE)) private static void movableCMD(BlockState blockState_1, World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1, Direction direction_2, CallbackInfoReturnable cir) diff --git a/src/main/java/carpet/mixins/PistonHandler_movableTEMixin.java b/src/main/java/carpet/mixins/PistonHandler_movableTEMixin.java index e8d29602..27612aa9 100644 --- a/src/main/java/carpet/mixins/PistonHandler_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonHandler_movableTEMixin.java @@ -41,6 +41,10 @@ public abstract class PistonHandler_movableTEMixin * @author 2No2Name */ private void stickToStickySide(BlockPos blockPos_1, Direction direction_1, CallbackInfoReturnable cir, BlockState blockState_1, Block block_1, int int_1, int int_2, int int_4, BlockPos blockPos_3, int int_5, int int_6){ + if (CarpetSettings.stickyHoney && this.world.getBlockState(blockPos_1).getBlock() == Blocks.GOLD_BLOCK && !method_11538(blockPos_1)) { + cir.setReturnValue(false); + return; + } if(!stickToStickySide(blockPos_3)){ cir.setReturnValue(false); cir.cancel(); @@ -53,7 +57,13 @@ public abstract class PistonHandler_movableTEMixin * @author 2No2Name */ private void stickToStickySide(CallbackInfoReturnable cir, int int_1){ - if(!stickToStickySide(this.movedBlocks.get(int_1))){ + BlockPos pos = this.movedBlocks.get(int_1); + if (CarpetSettings.stickyHoney && world.getBlockState(pos).getBlock() == Blocks.GOLD_BLOCK && !method_11538(pos)) + { + cir.setReturnValue(false); + return; + } + if(!stickToStickySide(pos)){ cir.setReturnValue(false); cir.cancel(); } @@ -88,6 +98,9 @@ public abstract class PistonHandler_movableTEMixin //Get access to the blockstate to check if it is a chest @Shadow @Final private Direction direction; + + @Shadow protected abstract boolean method_11538(BlockPos blockPos_1); + private BlockState blockState_1; @Redirect(method = "tryMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;", ordinal = 0)) @@ -107,10 +120,11 @@ public abstract class PistonHandler_movableTEMixin * @author 2No2Nameb */ private Block redirectSlimeBlock() { + if (CarpetSettings.stickyHoney && blockState_1.getBlock() == Blocks.GOLD_BLOCK) + return Blocks.GOLD_BLOCK; if (CarpetSettings.movableBlockEntities && isStickyOnSide(blockState_1, this.direction.getOpposite())) return blockState_1.getBlock(); //this makes the comparison in the while condition "while(blockState_1.getBlock() == redirectSlimeBlock())" evaluate to true, so the block is treated as sticky - else - return Blocks.SLIME_BLOCK; //vanilla behavior + return Blocks.SLIME_BLOCK; //vanilla behavior } diff --git a/src/main/java/carpet/settings/CarpetSettings.java b/src/main/java/carpet/settings/CarpetSettings.java index 9d84e793..ae828457 100644 --- a/src/main/java/carpet/settings/CarpetSettings.java +++ b/src/main/java/carpet/settings/CarpetSettings.java @@ -150,6 +150,14 @@ public class CarpetSettings @Rule( desc = "Pistons can push block entities, like hoppers, chests etc.", category = {EXPERIMENTAL, FEATURE} ) public static boolean movableBlockEntities = false; + @Rule( + desc = "Honey blocks can stick to each other and other blocks", + extra = {"... but not to slime blocks and vice versa.", + "In 1.14 that behaviour is applied to gold blocks instead"}, + category = {EXPERIMENTAL, FEATURE} + ) + public static boolean stickyHoney = false; + @Rule( desc = "Saplings turn into dead shrubs in hot climates and no water access", category = FEATURE ) public static boolean desertShrubs = false;