chainstone supports now properly end rods
This commit is contained in:
1 parent
fc3ceae767
commit
a51c8ca707
1 file changed
+16
-2
@@ -6,6 +6,7 @@ import net.minecraft.block.BlockState;
|
|||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.ChainBlock;
|
import net.minecraft.block.ChainBlock;
|
||||||
import net.minecraft.block.ChestBlock;
|
import net.minecraft.block.ChestBlock;
|
||||||
|
import net.minecraft.block.EndRodBlock;
|
||||||
import net.minecraft.block.enums.ChestType;
|
import net.minecraft.block.enums.ChestType;
|
||||||
import net.minecraft.block.piston.PistonHandler;
|
import net.minecraft.block.piston.PistonHandler;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -113,6 +114,7 @@ public abstract class PistonHandler_customStickyMixin
|
|||||||
if (previousState.getBlock() == Blocks.CHAIN && isChainOnAxis(previousState, motionDirection))
|
if (previousState.getBlock() == Blocks.CHAIN && isChainOnAxis(previousState, motionDirection))
|
||||||
{
|
{
|
||||||
if ( (currentState.getBlock() == Blocks.CHAIN && isChainOnAxis(currentState, motionDirection))
|
if ( (currentState.getBlock() == Blocks.CHAIN && isChainOnAxis(currentState, motionDirection))
|
||||||
|
|| isEndRodOnAxis(currentState, motionDirection.getAxis())
|
||||||
|| Block.sideCoversSmallSquare(world, currentPos, motionDirection.getOpposite()))
|
|| Block.sideCoversSmallSquare(world, currentPos, motionDirection.getOpposite()))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -125,7 +127,7 @@ public abstract class PistonHandler_customStickyMixin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles blocks besides the slimeblock that are sticky. Currently only supports blocks that are sticky on one side.
|
* Handles blocks besides the slimeblock that are sticky. Currently only supports blocks that are sticky on one side.
|
||||||
* This never seems to run
|
* This runs in U style structures with something in the middle on retraction.
|
||||||
* @author 2No2Name
|
* @author 2No2Name
|
||||||
*/
|
*/
|
||||||
@Inject(method = "tryMove", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At(
|
@Inject(method = "tryMove", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At(
|
||||||
@@ -213,7 +215,8 @@ public abstract class PistonHandler_customStickyMixin
|
|||||||
{
|
{
|
||||||
if (CarpetSettings.chainStone)
|
if (CarpetSettings.chainStone)
|
||||||
{
|
{
|
||||||
if (world.getBlockState(blockPos3).getBlock() == Blocks.CHAIN && !canMoveAdjacentBlock(blockPos3))
|
BlockState chainState = world.getBlockState(blockPos3);
|
||||||
|
if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection) && !canMoveAdjacentBlock(blockPos3))
|
||||||
{
|
{
|
||||||
cir.setReturnValue(false);
|
cir.setReturnValue(false);
|
||||||
}
|
}
|
||||||
@@ -237,6 +240,7 @@ public abstract class PistonHandler_customStickyMixin
|
|||||||
if (blockState.getBlock() == Blocks.CHAIN && isChainOnAxis(blockState, direction))
|
if (blockState.getBlock() == Blocks.CHAIN && isChainOnAxis(blockState, direction))
|
||||||
{
|
{
|
||||||
if ((blockState2.getBlock() == Blocks.CHAIN && (blockState.get(ChainBlock.AXIS) == blockState2.get(ChainBlock.AXIS)))
|
if ((blockState2.getBlock() == Blocks.CHAIN && (blockState.get(ChainBlock.AXIS) == blockState2.get(ChainBlock.AXIS)))
|
||||||
|
|| isEndRodOnAxis(blockState2, blockState.get(ChainBlock.AXIS))
|
||||||
|| Block.sideCoversSmallSquare(world, blockPos, direction.getOpposite()))
|
|| Block.sideCoversSmallSquare(world, blockPos, direction.getOpposite()))
|
||||||
{
|
{
|
||||||
if (!tryMove(blockPos, direction))
|
if (!tryMove(blockPos, direction))
|
||||||
@@ -292,4 +296,14 @@ public abstract class PistonHandler_customStickyMixin
|
|||||||
}catch(IllegalArgumentException e){return false;}
|
}catch(IllegalArgumentException e){return false;}
|
||||||
return stickDirection.getAxis() == axis;
|
return stickDirection.getAxis() == axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isEndRodOnAxis(BlockState state, Direction.Axis stickAxis)
|
||||||
|
{
|
||||||
|
if (state.getBlock() != Blocks.END_ROD) return false;
|
||||||
|
Direction facing;
|
||||||
|
try {
|
||||||
|
facing = state.get(EndRodBlock.FACING);
|
||||||
|
}catch(IllegalArgumentException e){return false;}
|
||||||
|
return stickAxis == facing.getAxis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user