slime is honey 2

This commit is contained in:
gnembon committed 2019-10-09 08:52:52 -03:00
1 parent 7ba4ff6647
commit c9a6d2ef96
3 files changed
+25 -4

No files matched your search

@@ -28,7 +28,20 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
}
private ThreadLocal<List<BlockEntity>> 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<Boolean> 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<Boolean> cir)
@@ -58,7 +58,7 @@ public abstract class PistonHandler_movableTEMixin
*/
private void stickToStickySide(CallbackInfoReturnable<Boolean> 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
}