Java 类net.minecraft.block.BlockRotatedPillar 实例源码

项目:carpentersblocks    文件:BlockProperties.java   
/**
 * Returns whether block rotates based on placement conditions.
 * The blocks that utilize this property are mostly atypical, and
 * must be added manually.
 */
public static boolean blockRotates(ItemStack itemStack)
{
    Block block = toBlock(itemStack);

    return block instanceof BlockQuartz ||
           block instanceof BlockRotatedPillar;
}
项目:ThermionicsWorld    文件:GeneratorBoneTree.java   
@Override
public boolean generate(World world, Random rand, BlockPos position) {
    BlockPos pos = NeoHellGenerators.findSurface(world, position);
    if (pos==null) {
        //System.out.println("Failed to generate at "+position);
        return false;
    } else {
        //System.out.println("Generating at "+pos);
    }

    int height = rand.nextInt(4) + 7;

    IBlockState trunkState = Blocks.BONE_BLOCK.getDefaultState().withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y);
    //EnumFacing.Axis axis = rand.nextBoolean() ? EnumFacing.Axis.X : EnumFacing.Axis.Z;
    EnumAxis axis = rand.nextBoolean() ? EnumAxis.X : EnumAxis.Z;
    BlockPos section = pos;

    for(int y=0; y<height; y++) {

        world.setBlockState(section, trunkState);

        if (y>3 && y%2==0) {
            axis = rand.nextBoolean() ? EnumAxis.X : EnumAxis.Z;
            BlockPos arm = section;
            int width = (height-y) / 2;

            for(int i=0; i<width; i++) {
                arm = arm.add(axis.xofs, axis.yofs, axis.zofs);
                world.setBlockState(arm, axis==EnumAxis.X ?
                        trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X) :
                        trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z));
            }
            arm = section;
            for(int i=0; i<width; i++) {
                arm = arm.add(-axis.xofs, -axis.yofs, -axis.zofs);
                world.setBlockState(arm, axis==EnumAxis.X ?
                        trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X) :
                        trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z));
            }
        }
        section = section.up();
    }

    return true;
}