use of com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState in project Create by Creators-of-Create.
the class MechanicalPistonGenerator method getModel.
@Override
public <T extends Block> ModelFile getModel(DataGenContext<Block, T> ctx, RegistrateBlockstateProvider prov, BlockState state) {
Direction facing = state.getValue(PistonBaseBlock.FACING);
boolean axisAlongFirst = state.getValue(MechanicalPistonBlock.AXIS_ALONG_FIRST_COORDINATE);
PistonState pistonState = state.getValue(MechanicalPistonBlock.STATE);
String path = "block/mechanical_piston";
String folder = pistonState == PistonState.RETRACTED ? type.getSerializedName() : pistonState.getSerializedName();
String partial = facing.getAxis() == Axis.X ^ axisAlongFirst ? "block_rotated" : "block";
return prov.models().getExistingFile(prov.modLoc(path + "/" + folder + "/" + partial));
}
use of com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState in project Create by Creators-of-Create.
the class Contraption method moveMechanicalPiston.
private boolean moveMechanicalPiston(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited, BlockState state) throws AssemblyException {
Direction direction = state.getValue(MechanicalPistonBlock.FACING);
PistonState pistonState = state.getValue(MechanicalPistonBlock.STATE);
if (pistonState == PistonState.MOVING)
return false;
BlockPos offset = pos.relative(direction.getOpposite());
if (!visited.contains(offset)) {
BlockState poleState = world.getBlockState(offset);
if (AllBlocks.PISTON_EXTENSION_POLE.has(poleState) && poleState.getValue(PistonExtensionPoleBlock.FACING).getAxis() == direction.getAxis())
frontier.add(offset);
}
if (pistonState == PistonState.EXTENDED || MechanicalPistonBlock.isStickyPiston(state)) {
offset = pos.relative(direction);
if (!visited.contains(offset))
frontier.add(offset);
}
return true;
}
Aggregations