@Override public String getFullSlabName(int metadata) { String woodType; switch (metadata & 7) { case 1: woodType = BlockType.FIR.toString(); break; case 2: woodType = BlockType.ACACIA.toString(); break; default: woodType = BlockType.REDWOOD.toString(); } return super.getUnlocalizedName() + "." + woodType; }
public void growTree(World world, int x, int y, int z, Random rand) { final int metadata = unmarkedMetadata(world.getBlockMetadata(x, y, z)); WorldGenerator tree = null; int x1 = 0; int z1 = 0; boolean isHuge = false; final boolean isForestryFarmed = world.getBlockId(x, y - 1, z) == forestrySoilID; if (metadata == BlockType.BROWN.metadata()) { if (rand.nextInt(20) == 0) tree = new WorldGenBigAutumnTree(true, AutumnTreeType.BROWN); else tree = new WorldGenAutumnTree(true, AutumnTreeType.BROWN); } else if (metadata == BlockType.ORANGE.metadata()) { if (rand.nextInt(20) == 0) tree = new WorldGenBigAutumnTree(true, AutumnTreeType.ORANGE); else tree = new WorldGenAutumnTree(true, AutumnTreeType.ORANGE); } else if (metadata == BlockType.PURPLE.metadata()) { if (rand.nextInt(20) == 0) tree = new WorldGenBigAutumnTree(true, AutumnTreeType.PURPLE); else tree = new WorldGenAutumnTree(true, AutumnTreeType.PURPLE); } else if (metadata == BlockType.YELLOW.metadata()) { if (rand.nextInt(20) == 0) tree = new WorldGenBigAutumnTree(true, AutumnTreeType.YELLOW); else tree = new WorldGenAutumnTree(true, AutumnTreeType.YELLOW); } else if (metadata == BlockType.ACACIA.metadata()) tree = new WorldGenAcacia(true); else { // Check for 2x2 firs and redwoods for (x1 = 0; x1 >= -1; --x1) { for (z1 = 0; z1 >= -1; --z1) if (isSameSapling(world, x + x1, y, z + z1, metadata) && isSameSapling(world, x + x1 + 1, y, z + z1, metadata) && isSameSapling(world, x + x1, y, z + z1 + 1, metadata) && isSameSapling(world, x + x1 + 1, y, z + z1 + 1, metadata)) { if (metadata == BlockType.FIR.metadata()) tree = new WorldGenFirTreeHuge(true); else tree = new WorldGenRedwood(true); isHuge = true; break; } if (tree != null) break; } if (tree == null && metadata == BlockType.FIR.metadata()) { // Single fir sapling generates 1x1 tree z1 = 0; x1 = 0; tree = new WorldGenFirTree(true); } } if (tree != null) { if (isHuge) { world.setBlock(x + x1, y, z + z1, 0); world.setBlock(x + x1 + 1, y, z + z1, 0); world.setBlock(x + x1, y, z + z1 + 1, 0); world.setBlock(x + x1 + 1, y, z + z1 + 1, 0); } else world.setBlock(x, y, z, 0); final int offset = isHuge ? 1 : 0; if (!tree.generate(world, rand, x + x1 + offset, y, z + z1 + offset)) { if (isHuge) { world.setBlockAndMetadata(x + x1, y, z + z1, blockID, metadata); world.setBlockAndMetadata(x + x1 + 1, y, z + z1, blockID, metadata); world.setBlockAndMetadata(x + x1, y, z + z1 + 1, blockID, metadata); world.setBlockAndMetadata(x + x1 + 1, y, z + z1 + 1, blockID, metadata); } else world.setBlockAndMetadata(x, y, z, blockID, metadata); } else if (isForestryFarmed) if (isHuge) { world.setBlock(x + x1, y - 1, z + z1, Block.sand.blockID); world.setBlock(x + x1 + 1, y - 1, z + z1, Block.sand.blockID); world.setBlock(x + x1, y - 1, z + z1 + 1, Block.sand.blockID); world.setBlock(x + x1 + 1, y - 1, z + z1 + 1, Block.sand.blockID); } else world.setBlock(x, y - 1, z, Block.sand.blockID); } }