use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class EncasedBeltBlock method areBlocksConnected.
public static boolean areBlocksConnected(BlockState state, BlockState other, Direction facing) {
Part part = state.getValue(PART);
Axis connectionAxis = getConnectionAxis(state);
Axis otherConnectionAxis = getConnectionAxis(other);
if (otherConnectionAxis != connectionAxis)
return false;
if (facing.getAxis() != connectionAxis)
return false;
if (facing.getAxisDirection() == AxisDirection.POSITIVE && (part == Part.MIDDLE || part == Part.START))
return true;
if (facing.getAxisDirection() == AxisDirection.NEGATIVE && (part == Part.MIDDLE || part == Part.END))
return true;
return false;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class EncasedBeltBlock method getConnectionAxis.
protected static Axis getConnectionAxis(BlockState state) {
Axis axis = state.getValue(AXIS);
boolean connectionAlongFirst = state.getValue(CONNECTED_ALONG_FIRST_COORDINATE);
Axis connectionAxis = connectionAlongFirst ? (axis == Axis.X ? Axis.Y : Axis.X) : (axis == Axis.Z ? Axis.Y : Axis.Z);
return connectionAxis;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class EncasedBeltGenerator method getYRotation.
@Override
protected int getYRotation(BlockState state) {
EncasedBeltBlock.Part part = state.getValue(EncasedBeltBlock.PART);
boolean connectedAlongFirst = state.getValue(EncasedBeltBlock.CONNECTED_ALONG_FIRST_COORDINATE);
Axis axis = state.getValue(EncasedBeltBlock.AXIS);
if (part == Part.NONE)
return axis == Axis.X ? 90 : 0;
if (axis == Axis.Z)
return (connectedAlongFirst && part == Part.END ? 270 : 90);
boolean flip = part == Part.END && !connectedAlongFirst || part == Part.START && connectedAlongFirst;
if (axis == Axis.Y)
return (connectedAlongFirst ? 90 : 0) + (flip ? 180 : 0);
return 0;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class IWrenchableWithBracket method tryRemoveBracket.
default boolean tryRemoveBracket(UseOnContext context) {
Level world = context.getLevel();
BlockPos pos = context.getClickedPos();
Optional<ItemStack> bracket = removeBracket(world, pos, false);
BlockState blockState = world.getBlockState(pos);
if (bracket.isPresent()) {
Player player = context.getPlayer();
if (!world.isClientSide && !player.isCreative())
player.getInventory().placeItemBackInInventory(bracket.get());
if (!world.isClientSide && AllBlocks.FLUID_PIPE.has(blockState)) {
Axis preferred = FluidPropagator.getStraightPipeAxis(blockState);
Direction preferredDirection = preferred == null ? Direction.UP : Direction.get(AxisDirection.POSITIVE, preferred);
BlockState updated = AllBlocks.FLUID_PIPE.get().updateBlockState(blockState, preferredDirection, null, world, pos);
if (updated != blockState)
world.setBlockAndUpdate(pos, updated);
}
return true;
}
return false;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class ItemVaultCTBehaviour method getUpDirection.
@Override
protected Direction getUpDirection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) {
Axis vaultBlockAxis = ItemVaultBlock.getVaultBlockAxis(state);
boolean alongX = vaultBlockAxis == Axis.X;
if (face.getAxis().isVertical() && alongX)
return super.getUpDirection(reader, pos, state, face).getClockWise();
if (face.getAxis() == vaultBlockAxis || face.getAxis().isVertical())
return super.getUpDirection(reader, pos, state, face);
return Direction.fromAxisAndDirection(vaultBlockAxis, alongX ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE);
}
Aggregations