From 7ba4ff66478caaf493a236aab3ca76d32490fc9a Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 9 Oct 2019 08:48:45 -0300 Subject: [PATCH 1/4] slime is honey 1 --- .../mixins/PistonHandler_movableTEMixin.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/PistonHandler_movableTEMixin.java b/src/main/java/carpet/mixins/PistonHandler_movableTEMixin.java index e8d29602..81e2e7b8 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) + { + 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)) From c9a6d2ef960198fc059f9cd383f546209b315b15 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 9 Oct 2019 08:52:52 -0300 Subject: [PATCH 2/4] 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; From 55f6503807c4536f0ebed62595d4907b3db0fd24 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 9 Oct 2019 08:54:08 -0300 Subject: [PATCH 3/4] just sayin --- src/main/java/carpet/settings/CarpetSettings.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/carpet/settings/CarpetSettings.java b/src/main/java/carpet/settings/CarpetSettings.java index b39e4597..de8864d4 100644 --- a/src/main/java/carpet/settings/CarpetSettings.java +++ b/src/main/java/carpet/settings/CarpetSettings.java @@ -152,7 +152,8 @@ public class CarpetSettings @Rule( desc = "Honey blocks can stick to each other and other blocks", - extra = "but not to slime blocks and vice versa", + 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; From 83d91ede4fb4f05980d4f5202145b3337119328e Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 9 Oct 2019 08:55:13 -0300 Subject: [PATCH 4/4] naming --- src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java index c058907e..8da4755f 100644 --- a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java @@ -36,7 +36,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock { 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(); + 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); }