use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class KineticTileEntityRenderer method standardKineticRotationTransform.
public static SuperByteBuffer standardKineticRotationTransform(SuperByteBuffer buffer, KineticTileEntity te, int light) {
final BlockPos pos = te.getBlockPos();
Axis axis = ((IRotate) te.getBlockState().getBlock()).getRotationAxis(te.getBlockState());
return kineticRotationTransform(buffer, te, axis, getAngleForTe(te, pos, axis), light);
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class FluidTankConnectivityHandler method formTanks.
private static void formTanks(BlockEntityType<?> type, BlockGetter world, TankSearchCache cache, List<FluidTankTileEntity> frontier) {
PriorityQueue<Pair<Integer, FluidTankTileEntity>> creationQueue = makeCreationQueue();
Set<BlockPos> visited = new HashSet<>();
int minX = Integer.MAX_VALUE;
int minZ = Integer.MAX_VALUE;
for (FluidTankTileEntity fluidTankTileEntity : frontier) {
BlockPos pos = fluidTankTileEntity.getBlockPos();
minX = Math.min(pos.getX(), minX);
minZ = Math.min(pos.getZ(), minZ);
}
minX -= FluidTankTileEntity.getMaxSize();
minZ -= FluidTankTileEntity.getMaxSize();
while (!frontier.isEmpty()) {
FluidTankTileEntity tank = frontier.remove(0);
BlockPos tankPos = tank.getBlockPos();
if (visited.contains(tankPos))
continue;
visited.add(tankPos);
int amount = tryToFormNewTank(tank, cache, true);
if (amount > 1)
creationQueue.add(Pair.of(amount, tank));
for (Axis axis : Iterate.axes) {
Direction d = Direction.get(AxisDirection.NEGATIVE, axis);
BlockPos next = tankPos.relative(d);
if (next.getX() <= minX || next.getZ() <= minZ)
continue;
if (visited.contains(next))
continue;
FluidTankTileEntity nextTank = tankAt(type, world, next);
if (nextTank == null)
continue;
if (nextTank.isRemoved())
continue;
frontier.add(nextTank);
}
}
visited.clear();
while (!creationQueue.isEmpty()) {
Pair<Integer, FluidTankTileEntity> next = creationQueue.poll();
FluidTankTileEntity toCreate = next.getValue();
if (visited.contains(toCreate.getBlockPos()))
continue;
visited.add(toCreate.getBlockPos());
tryToFormNewTank(toCreate, cache, false);
}
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class FluidPipeBlock method onWrenched.
@Override
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
if (tryRemoveBracket(context))
return InteractionResult.SUCCESS;
Level world = context.getLevel();
BlockPos pos = context.getClickedPos();
Direction clickedFace = context.getClickedFace();
Axis axis = getAxis(world, pos, state);
if (axis == null) {
Vec3 clickLocation = context.getClickLocation().subtract(pos.getX(), pos.getY(), pos.getZ());
double closest = Float.MAX_VALUE;
Direction argClosest = Direction.UP;
for (Direction direction : Iterate.directions) {
if (clickedFace.getAxis() == direction.getAxis())
continue;
Vec3 centerOf = Vec3.atCenterOf(direction.getNormal());
double distance = centerOf.distanceToSqr(clickLocation);
if (distance < closest) {
closest = distance;
argClosest = direction;
}
}
axis = argClosest.getAxis();
}
if (clickedFace.getAxis() == axis)
return InteractionResult.PASS;
if (!world.isClientSide) {
FluidTransportBehaviour.cacheFlows(world, pos);
world.setBlockAndUpdate(pos, AllBlocks.GLASS_FLUID_PIPE.getDefaultState().setValue(GlassFluidPipeBlock.AXIS, axis).setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED)));
FluidTransportBehaviour.loadFlows(world, pos);
}
return InteractionResult.SUCCESS;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class FluidPropagator method getStraightPipeAxis.
@Nullable
public static Axis getStraightPipeAxis(BlockState state) {
if (state.getBlock() instanceof PumpBlock)
return state.getValue(PumpBlock.FACING).getAxis();
if (state.getBlock() instanceof AxisPipeBlock)
return state.getValue(AxisPipeBlock.AXIS);
if (!FluidPipeBlock.isPipe(state))
return null;
Axis axisFound = null;
int connections = 0;
for (Axis axis : Iterate.axes) {
Direction d1 = Direction.get(AxisDirection.NEGATIVE, axis);
Direction d2 = Direction.get(AxisDirection.POSITIVE, axis);
boolean openAt1 = FluidPipeBlock.isOpenAt(state, d1);
boolean openAt2 = FluidPipeBlock.isOpenAt(state, d2);
if (openAt1)
connections++;
if (openAt2)
connections++;
if (openAt1 && openAt2)
if (axisFound != null)
return null;
else
axisFound = axis;
}
return connections == 2 ? axisFound : null;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class BrassTunnelTileEntity method hasDistributionBehaviour.
public boolean hasDistributionBehaviour() {
if (flaps.isEmpty())
return false;
if (connectedLeft || connectedRight)
return true;
BlockState blockState = getBlockState();
if (!AllBlocks.BRASS_TUNNEL.has(blockState))
return false;
Axis axis = blockState.getValue(BrassTunnelBlock.HORIZONTAL_AXIS);
for (Direction direction : flaps.keySet()) if (direction.getAxis() != axis)
return true;
return false;
}
Aggregations