From c9a6d2ef960198fc059f9cd383f546209b315b15 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 9 Oct 2019 08:52:52 -0300 Subject: [PATCH] slime is honey 2 --- .../carpet/mixins/PistonBlock_movableTEMixin.java | 15 ++++++++++++++- .../mixins/PistonHandler_movableTEMixin.java | 7 ++++--- src/main/java/carpet/settings/CarpetSettings.java | 7 +++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java index d06b10bb..c058907e 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.method_10079(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 81e2e7b8..27612aa9 100644 --- a/src/main/java/carpet/mixins/PistonHandler_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonHandler_movableTEMixin.java @@ -58,7 +58,7 @@ public abstract class PistonHandler_movableTEMixin */ private void stickToStickySide(CallbackInfoReturnable cir, int int_1){ BlockPos pos = this.movedBlocks.get(int_1); - if (CarpetSettings.stickyHoney && world.getBlockState(pos).getBlock() == Blocks.GOLD_BLOCK) + if (CarpetSettings.stickyHoney && world.getBlockState(pos).getBlock() == Blocks.GOLD_BLOCK && !method_11538(pos)) { cir.setReturnValue(false); return; @@ -120,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 1e5ee71f..b39e4597 100644 --- a/src/main/java/carpet/settings/CarpetSettings.java +++ b/src/main/java/carpet/settings/CarpetSettings.java @@ -150,6 +150,13 @@ 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", + 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;