Search in sources :

Example 1 with PistonState

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));
}
Also used : PistonState(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState) Direction(net.minecraft.core.Direction)

Example 2 with PistonState

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;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) PistonState(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState) BlockPos(net.minecraft.core.BlockPos) Direction(net.minecraft.core.Direction)

Aggregations

PistonState (com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState)2 Direction (net.minecraft.core.Direction)2 BlockPos (net.minecraft.core.BlockPos)1 BlockState (net.minecraft.world.level.block.state.BlockState)1