use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class VerticalGearboxItem method updateCustomBlockEntityTag.
@Override
protected boolean updateCustomBlockEntityTag(BlockPos pos, Level world, Player player, ItemStack stack, BlockState state) {
Axis prefferedAxis = null;
for (Direction side : Iterate.horizontalDirections) {
BlockState blockState = world.getBlockState(pos.relative(side));
if (blockState.getBlock() instanceof IRotate) {
if (((IRotate) blockState.getBlock()).hasShaftTowards(world, pos.relative(side), blockState, side.getOpposite()))
if (prefferedAxis != null && prefferedAxis != side.getAxis()) {
prefferedAxis = null;
break;
} else {
prefferedAxis = side.getAxis();
}
}
}
Axis axis = prefferedAxis == null ? player.getDirection().getClockWise().getAxis() : prefferedAxis == Axis.X ? Axis.Z : Axis.X;
world.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.AXIS, axis));
return super.updateCustomBlockEntityTag(pos, world, player, stack, state);
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class BeltTunnelShapes method getShape.
public static VoxelShape getShape(BlockState state) {
BeltTunnelBlock.Shape shape = state.getValue(BeltTunnelBlock.SHAPE);
Direction.Axis axis = state.getValue(BeltTunnelBlock.HORIZONTAL_AXIS);
if (shape == BeltTunnelBlock.Shape.CROSS)
return CROSS;
if (BeltTunnelBlock.isStraight(state))
return STRAIGHT.get(axis);
if (shape == BeltTunnelBlock.Shape.T_LEFT)
return TEE.get(axis == Direction.Axis.Z ? Direction.EAST : Direction.NORTH);
if (shape == BeltTunnelBlock.Shape.T_RIGHT)
return TEE.get(axis == Direction.Axis.Z ? Direction.WEST : Direction.SOUTH);
// something went wrong
return Shapes.block();
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class ItemVaultCTBehaviour method get.
@Override
public CTSpriteShiftEntry get(BlockState state, Direction direction) {
Axis vaultBlockAxis = ItemVaultBlock.getVaultBlockAxis(state);
boolean small = !ItemVaultBlock.isLarge(state);
if (vaultBlockAxis == null)
return null;
if (direction.getAxis() == vaultBlockAxis)
return AllSpriteShifts.VAULT_FRONT.get(small);
if (direction == Direction.UP)
return AllSpriteShifts.VAULT_TOP.get(small);
if (direction == Direction.DOWN)
return AllSpriteShifts.VAULT_BOTTOM.get(small);
return AllSpriteShifts.VAULT_SIDE.get(small);
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class CogWheelBlock method getAxisForPlacement.
protected Axis getAxisForPlacement(BlockPlaceContext context) {
if (context.getPlayer() != null && context.getPlayer().isShiftKeyDown())
return context.getClickedFace().getAxis();
Level world = context.getLevel();
BlockState stateBelow = world.getBlockState(context.getClickedPos().below());
if (AllBlocks.ROTATION_SPEED_CONTROLLER.has(stateBelow) && isLargeCog())
return stateBelow.getValue(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X ? Axis.Z : Axis.X;
BlockPos placedOnPos = context.getClickedPos().relative(context.getClickedFace().getOpposite());
BlockState placedAgainst = world.getBlockState(placedOnPos);
Block block = placedAgainst.getBlock();
if (ICogWheel.isSmallCog(placedAgainst))
return ((IRotate) block).getRotationAxis(placedAgainst);
Axis preferredAxis = getPreferredAxis(context);
return preferredAxis != null ? preferredAxis : context.getClickedFace().getAxis();
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class CogwheelBlockItem method triggerShiftingGearsAdvancement.
protected void triggerShiftingGearsAdvancement(Level world, BlockPos pos, BlockState state, Player player) {
if (world.isClientSide || player == null)
return;
Axis axis = state.getValue(CogWheelBlock.AXIS);
for (Axis perpendicular1 : Iterate.axes) {
if (perpendicular1 == axis)
continue;
Direction d1 = Direction.get(AxisDirection.POSITIVE, perpendicular1);
for (Axis perpendicular2 : Iterate.axes) {
if (perpendicular1 == perpendicular2)
continue;
if (axis == perpendicular2)
continue;
Direction d2 = Direction.get(AxisDirection.POSITIVE, perpendicular2);
for (int offset1 : Iterate.positiveAndNegative) {
for (int offset2 : Iterate.positiveAndNegative) {
BlockPos connectedPos = pos.relative(d1, offset1).relative(d2, offset2);
BlockState blockState = world.getBlockState(connectedPos);
if (!(blockState.getBlock() instanceof CogWheelBlock))
continue;
if (blockState.getValue(CogWheelBlock.AXIS) != axis)
continue;
if (ICogWheel.isLargeCog(blockState) == large)
continue;
AllTriggers.triggerFor(AllTriggers.SHIFTING_GEARS, player);
}
}
}
}
}
Aggregations