Search in sources :

Example 1 with BlockStairs

use of net.minecraft.block.BlockStairs in project NetherEx by LogicTechCorp.

the class PigtificateVillageCollection method getOutside.

private EnumFacing getOutside(BlockPos fenceGatePos) {
    IBlockState fenceGateState = world.getBlockState(fenceGatePos);
    IBlockState stairState = world.getBlockState(fenceGatePos.up(2));
    if (fenceGateState.getBlock() instanceof BlockFenceGate && stairState.getBlock() instanceof BlockStairs) {
        EnumFacing fenceGateFacing = fenceGateState.getValue(BlockFenceGate.FACING);
        EnumFacing stairFacing = stairState.getValue(BlockStairs.FACING);
        if (stairFacing == fenceGateFacing || stairFacing == fenceGateFacing.getOpposite()) {
            return stairFacing;
        }
        return null;
    } else {
        return null;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) EnumFacing(net.minecraft.util.EnumFacing) BlockStairs(net.minecraft.block.BlockStairs)

Example 2 with BlockStairs

use of net.minecraft.block.BlockStairs in project minecolonies by Minecolonies.

the class StructureWrapper method isStructureBlockEqualWorldBlock.

/**
     * Checks if the block in the world is the same as what is in the structure.
     *
     * @return true if the structure block equals the world block.
     */
public boolean isStructureBlockEqualWorldBlock() {
    final IBlockState structureBlockState = structure.getBlockState(this.getLocalPosition());
    final Block structureBlock = structureBlockState.getBlock();
    //All worldBlocks are equal the substitution block
    if (structureBlock == ModBlocks.blockSubstitution) {
        return true;
    }
    final BlockPos worldPos = this.getBlockPosition();
    final IBlockState worldBlockState = world.getBlockState(worldPos);
    if (structureBlock == ModBlocks.blockSolidSubstitution && worldBlockState.getMaterial().isSolid()) {
        return true;
    }
    //For the time being any flower pot is equal to each other.
    if (structureBlock instanceof BlockDoor || structureBlock == Blocks.FLOWER_POT) {
        return structureBlock == worldBlockState.getBlock();
    } else if ((structureBlock instanceof BlockStairs && structureBlockState == worldBlockState) || BlockUtils.isGrassOrDirt(structureBlock, worldBlockState.getBlock(), structureBlockState, worldBlockState)) {
        return true;
    }
    final Template.EntityInfo entityInfo = structure.getEntityinfo(this.getLocalPosition());
    if (entityInfo != null) {
        return false;
    //todo get entity at position.
    }
    //had this problem in a super flat world, causes builder to sit doing nothing because placement failed
    return worldPos.getY() <= 0 || structureBlockState == worldBlockState;
}
Also used : BlockDoor(net.minecraft.block.BlockDoor) IBlockState(net.minecraft.block.state.IBlockState) BlockStairs(net.minecraft.block.BlockStairs) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) Template(net.minecraft.world.gen.structure.template.Template)

Aggregations

BlockStairs (net.minecraft.block.BlockStairs)2 IBlockState (net.minecraft.block.state.IBlockState)2 Block (net.minecraft.block.Block)1 BlockDoor (net.minecraft.block.BlockDoor)1 BlockFenceGate (net.minecraft.block.BlockFenceGate)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1 Template (net.minecraft.world.gen.structure.template.Template)1