use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class MountedContraption method capture.
@Override
protected Pair<StructureBlockInfo, BlockEntity> capture(Level world, BlockPos pos) {
Pair<StructureBlockInfo, BlockEntity> pair = super.capture(world, pos);
StructureBlockInfo capture = pair.getKey();
if (!AllBlocks.CART_ASSEMBLER.has(capture.state))
return pair;
Pair<StructureBlockInfo, BlockEntity> anchorSwap = Pair.of(new StructureBlockInfo(pos, CartAssemblerBlock.createAnchor(capture.state), null), pair.getValue());
if (pos.equals(anchor) || connectedCart != null)
return anchorSwap;
for (Axis axis : Iterate.axes) {
if (axis.isVertical() || !VecHelper.onSameAxis(anchor, pos, axis))
continue;
for (AbstractMinecart abstractMinecartEntity : world.getEntitiesOfClass(AbstractMinecart.class, new AABB(pos))) {
if (!CartAssemblerBlock.canAssembleTo(abstractMinecartEntity))
break;
connectedCart = abstractMinecartEntity;
connectedCart.setPos(pos.getX() + .5, pos.getY(), pos.getZ() + .5f);
}
}
return anchorSwap;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class MountedContraption method assemble.
@Override
public boolean assemble(Level world, BlockPos pos) throws AssemblyException {
BlockState state = world.getBlockState(pos);
if (!state.hasProperty(RAIL_SHAPE))
return false;
if (!searchMovedStructure(world, pos, null))
return false;
Axis axis = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.X : Axis.Z;
addBlock(pos, Pair.of(new StructureBlockInfo(pos, AllBlocks.MINECART_ANCHOR.getDefaultState().setValue(BlockStateProperties.HORIZONTAL_AXIS, axis), null), null));
if (blocks.size() == 1)
return false;
return true;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class MechanicalPistonTileEntity method getMovementModeSlot.
@Override
protected ValueBoxTransform getMovementModeSlot() {
return new DirectionalExtenderScrollOptionSlot((state, d) -> {
Axis axis = d.getAxis();
Axis extensionAxis = state.getValue(MechanicalPistonBlock.FACING).getAxis();
Axis shaftAxis = ((IRotate) state.getBlock()).getRotationAxis(state);
return extensionAxis != axis && shaftAxis != axis;
});
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class SuperGlueRenderer method initQuads.
private void initQuads() {
Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal());
Vec3 extension = diff.normalize().scale(1 / 32f - 1 / 128f);
Vec3 plane = VecHelper.axisAlingedPlaneOf(diff);
Axis axis = Direction.getNearest(diff.x, diff.y, diff.z).getAxis();
Vec3 start = Vec3.ZERO.subtract(extension);
Vec3 end = Vec3.ZERO.add(extension);
plane = plane.scale(1 / 2f);
Vec3 a1 = plane.add(start);
Vec3 b1 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis);
Vec3 a2 = plane.add(start);
Vec3 b2 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis);
Vec3 a3 = plane.add(start);
Vec3 b3 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis);
Vec3 a4 = plane.add(start);
Vec3 b4 = plane.add(end);
insideQuad = new float[] { (float) a1.x, (float) a1.y, (float) a1.z, 1, 0, (float) a2.x, (float) a2.y, (float) a2.z, 1, 1, (float) a3.x, (float) a3.y, (float) a3.z, 0, 1, (float) a4.x, (float) a4.y, (float) a4.z, 0, 0 };
outsideQuad = new float[] { (float) b4.x, (float) b4.y, (float) b4.z, 0, 0, (float) b3.x, (float) b3.y, (float) b3.z, 0, 1, (float) b2.x, (float) b2.y, (float) b2.z, 1, 1, (float) b1.x, (float) b1.y, (float) b1.z, 1, 0 };
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class PistonExtensionPoleBlock method playerWillDestroy.
@Override
public void playerWillDestroy(Level worldIn, BlockPos pos, BlockState state, Player player) {
Axis axis = state.getValue(FACING).getAxis();
Direction direction = Direction.get(AxisDirection.POSITIVE, axis);
BlockPos pistonHead = null;
BlockPos pistonBase = null;
for (int modifier : new int[] { 1, -1 }) {
for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset += modifier) {
BlockPos currentPos = pos.relative(direction, offset);
BlockState block = worldIn.getBlockState(currentPos);
if (isExtensionPole(block) && axis == block.getValue(FACING).getAxis())
continue;
if (isPiston(block) && block.getValue(BlockStateProperties.FACING).getAxis() == axis)
pistonBase = currentPos;
if (isPistonHead(block) && block.getValue(BlockStateProperties.FACING).getAxis() == axis)
pistonHead = currentPos;
break;
}
}
if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead).getValue(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase).getValue(BlockStateProperties.FACING)) {
final BlockPos basePos = pistonBase;
BlockPos.betweenClosedStream(pistonBase, pistonHead).filter(p -> !p.equals(pos) && !p.equals(basePos)).forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
worldIn.setBlockAndUpdate(basePos, worldIn.getBlockState(basePos).setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
BlockEntity te = worldIn.getBlockEntity(basePos);
if (te instanceof MechanicalPistonTileEntity) {
MechanicalPistonTileEntity baseTE = (MechanicalPistonTileEntity) te;
baseTE.offset = 0;
baseTE.onLengthBroken();
}
}
super.playerWillDestroy(worldIn, pos, state, player);
}
Aggregations