Search in sources :

Example 1 with BlockLever

use of net.minecraft.block.BlockLever in project AgriCraft by AgriCraft.

the class TileEntityChannelValve method classifyConnection.

@Override
protected byte classifyConnection(@Nonnull EnumFacing side) {
    final Block b = WorldHelper.getBlock(world, pos.offset(side), Block.class).orElse(null);
    final IAgriFluidComponent component = WorldHelper.getTile(world, pos.offset(side), IAgriFluidComponent.class).orElse(null);
    if (b instanceof BlockLever) {
        return -1;
    } else if (component == null) {
        return 0;
    } else if (side.getAxis().isHorizontal()) {
        return 1;
    } else if (component instanceof TileEntitySprinkler) {
        return 2;
    } else {
        return 0;
    }
}
Also used : BlockLever(net.minecraft.block.BlockLever) Block(net.minecraft.block.Block) IAgriFluidComponent(com.infinityraider.agricraft.api.v1.misc.IAgriFluidComponent)

Example 2 with BlockLever

use of net.minecraft.block.BlockLever in project MC-Prefab by Brian-Wuest.

the class BuildBlock method setComparable.

private static Comparable setComparable(Comparable<?> comparable, Block foundBlock, IProperty<?> property, StructureConfiguration configuration, BuildBlock block, EnumFacing assumedNorth, Optional<?> propertyValue, EnumFacing vineFacing, EnumAxis logFacing, Axis boneFacing, BlockQuartz.EnumType quartzFacing, EnumOrientation leverOrientation, Structure structure) {
    if (property.getName().equals("facing") && !(foundBlock instanceof BlockLever)) {
        // Facing properties should be relative to the configuration facing.
        EnumFacing facing = EnumFacing.byName(propertyValue.get().toString());
        // Cannot rotate verticals.
        if (facing != null && facing != EnumFacing.UP && facing != EnumFacing.DOWN) {
            if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateY()) {
                facing = facing.rotateY();
            } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().getOpposite()) {
                facing = facing.getOpposite();
            } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateYCCW()) {
                facing = facing.rotateYCCW();
            }
        }
        comparable = facing;
        block.setHasFacing(true);
    } else if (property.getName().equals("facing") && foundBlock instanceof BlockLever) {
        comparable = leverOrientation;
        block.setHasFacing(true);
    } else if (property.getName().equals("rotation")) {
        // 0 = South
        // 4 = West
        // 8 = North
        // 12 = East
        int rotation = (Integer) propertyValue.get();
        EnumFacing facing = rotation == 0 ? EnumFacing.SOUTH : rotation == 4 ? EnumFacing.WEST : rotation == 8 ? EnumFacing.NORTH : EnumFacing.EAST;
        if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateY()) {
            facing = facing.rotateY();
        } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().getOpposite()) {
            facing = facing.getOpposite();
        } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateYCCW()) {
            facing = facing.rotateYCCW();
        }
        rotation = facing == EnumFacing.SOUTH ? 0 : facing == EnumFacing.WEST ? 4 : facing == EnumFacing.NORTH ? 8 : 12;
        comparable = rotation;
        block.setHasFacing(true);
    } else if (foundBlock instanceof BlockVine) {
        // Vines have a special state. There is 1 property for each "facing".
        if (property.getName().equals(vineFacing.getName2())) {
            comparable = true;
            block.setHasFacing(true);
        } else {
            comparable = false;
        }
    } else if (foundBlock instanceof BlockWall) {
        if (!property.getName().equals("variant")) {
            if (property.getName().equals(vineFacing.getName2()) || property.getName().equals(vineFacing.getOpposite().getName2())) {
                comparable = true;
                block.setHasFacing(true);
            } else {
                comparable = false;
            }
        }
    } else if (foundBlock instanceof BlockLog) {
        // logs have a special state. There is a property called axis and it only has 3 directions.
        if (property.getName().equals("axis")) {
            comparable = logFacing;
        }
    } else if (foundBlock instanceof BlockBone) {
        // bones have a special state. There is a property called axis and it only has 3 directions.
        if (property.getName().equals("axis")) {
            comparable = boneFacing;
        }
    } else if (foundBlock instanceof BlockQuartz) {
        if (property.getName().equals("variant") && quartzFacing != BlockQuartz.EnumType.DEFAULT) {
            comparable = quartzFacing;
        }
    }
    return comparable;
}
Also used : BlockLever(net.minecraft.block.BlockLever) BlockVine(net.minecraft.block.BlockVine) BlockWall(net.minecraft.block.BlockWall) EnumFacing(net.minecraft.util.EnumFacing) BlockLog(net.minecraft.block.BlockLog) BlockBone(net.minecraft.block.BlockBone) BlockQuartz(net.minecraft.block.BlockQuartz)

Example 3 with BlockLever

use of net.minecraft.block.BlockLever in project Ceramics by KnightMiner.

the class BlockChannel method addExtra.

private IBlockState addExtra(IBlockState state, IBlockAccess world, BlockPos pos, PropertyEnum<ChannelConnectionState> prop, EnumFacing side) {
    ChannelConnectionState connection = state.getValue(prop);
    IBlockState offsetState = world.getBlockState(pos.offset(side));
    Block block = offsetState.getBlock();
    if (connection == ChannelConnectionState.OUT && block instanceof BlockBarrel) {
        state = state.withProperty(prop, ChannelConnectionState.BARREL);
    } else if (connection == ChannelConnectionState.NONE && (block instanceof BlockLever && offsetState.getValue(BlockLever.FACING).getFacing() == side || block instanceof BlockButton && offsetState.getValue(BlockButton.FACING) == side)) {
        state = state.withProperty(prop, ChannelConnectionState.LEVER);
    }
    return state;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLever(net.minecraft.block.BlockLever) Block(net.minecraft.block.Block) BlockButton(net.minecraft.block.BlockButton)

Aggregations

BlockLever (net.minecraft.block.BlockLever)3 Block (net.minecraft.block.Block)2 IAgriFluidComponent (com.infinityraider.agricraft.api.v1.misc.IAgriFluidComponent)1 BlockBone (net.minecraft.block.BlockBone)1 BlockButton (net.minecraft.block.BlockButton)1 BlockLog (net.minecraft.block.BlockLog)1 BlockQuartz (net.minecraft.block.BlockQuartz)1 BlockVine (net.minecraft.block.BlockVine)1 BlockWall (net.minecraft.block.BlockWall)1 IBlockState (net.minecraft.block.state.IBlockState)1 EnumFacing (net.minecraft.util.EnumFacing)1