@Override public boolean onItemUse( ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { if (!ReikaWorldHelper.softBlocks(world.getBlock(x, y, z))) { if (side == 0) --y; if (side == 1) ++y; if (side == 2) --z; if (side == 3) ++z; if (side == 4) --x; if (side == 5) ++x; } Block idbelow = world.getBlock(x, y - 1, z); if ((!ReikaWorldHelper.softBlocks(world.getBlock(x, y, z))) || !ReikaPlantHelper.SAPLING.canPlantAt(world, x, y, z)) return false; if (!player.canPlayerEdit(x, y, z, 0, item)) return false; else { if (!player.capabilities.isCreativeMode) --item.stackSize; world.setBlock(x, y, z, ChromaBlocks.PLANT.getBlockInstance(), item.getItemDamage() % 16, 3); ReikaSoundHelper.playPlaceSound(world, x, y, z, Blocks.grass); return true; } }
@Override public void updateEntity(World world, int x, int y, int z, int meta) { super.updateTileEntity(); tickcount++; tree.setWorld(world); treeCopy.setWorld(world); this.getIOSides(world, x, y, z, meta); this.getPower(false); if (power < MINPOWER || torque < MINTORQUE) { return; } if (this.isJammed()) return; if (world.isRemote) return; if (tree.isEmpty() && this.hasWood()) { tree.reset(); ModWoodList wood = ModWoodList.getModWood( world.getBlock(editx, edity, editz), world.getBlockMetadata(editx, edity, editz)); ReikaTreeHelper vanilla = ReikaTreeHelper.getTree( world.getBlock(editx, edity, editz), world.getBlockMetadata(editx, edity, editz)); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { tree.checkAndAddDyeTree(world, editx + i, edity, editz + j); if (tree.isEmpty() || !tree.isValidTree()) tree.clear(); } } if (tree.isEmpty()) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { tree.checkAndAddRainbowTree(world, editx + i, edity, editz + j); if (tree.isEmpty() || !tree.isValidTree()) tree.clear(); } } } if (tree.isEmpty()) { if (wood == ModWoodList.SEQUOIA) { for (int i = -32; i < 255; i += 16) tree.addSequoia(world, editx, edity + i, editz, RotaryCraft.logger.shouldDebug()); } else if (wood == ModWoodList.DARKWOOD) { tree.addDarkForest( world, editx, edity, editz, editx - 8, editx + 8, editz - 8, editz + 8, RotaryCraft.logger.shouldDebug()); } else if (wood == ModWoodList.IRONWOOD) { for (int i = -2; i < 128; i += 16) tree.addIronwood(world, editx, edity + i, editz, RotaryCraft.logger.shouldDebug()); } else if (wood != null) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { // tree.addGenerousTree(world, editx+i, edity, editz+j, 16); tree.setTree(wood); tree.addModTree(world, editx + i, edity, editz + j); } // ReikaJavaLibrary.pConsole(tree, Side.SERVER); } } else if (vanilla != null) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { // tree.addGenerousTree(world, editx+i, edity, editz+j, 16); tree.setTree(vanilla); tree.addTree(world, editx + i, edity, editz + j); } } } } this.checkAndMatchInventory(); tree.sortBlocksByHeight(); tree.reverseBlockOrder(); tree.sort(inwardsComparator); tree.sort(leafPriority); treeCopy = (TreeReader) tree.copy(); } Block b = world.getBlock(x, y + 1, z); if (b != Blocks.air) { if (b.getMaterial() == Material.wood || b.getMaterial() == Material.leaves) { ReikaItemHelper.dropItems( world, dropx, y - 0.25, dropz, this.getDrops(world, x, y + 1, z, b, world.getBlockMetadata(x, y, z))); world.setBlockToAir(x, y + 1, z); } } // RotaryCraft.logger.debug(tree); if (tree.isEmpty()) return; if (tickcount < this.getOperationTime()) return; tickcount = 0; if (!tree.isValidTree()) { tree.reset(); tree.clear(); return; } for (int i = 0; i < this.getNumberConsecutiveOperations(); i++) { Coordinate c = tree.getNextAndMoveOn(); Block drop = c.getBlock(world); int dropmeta = c.getBlockMetadata(world); if (drop != Blocks.air) { Material mat = ReikaWorldHelper.getMaterial(world, c.xCoord, c.yCoord, c.zCoord); if (ConfigRegistry.INSTACUT.getState()) { // ReikaItemHelper.dropItems(world, dropx, y-0.25, dropz, dropBlocks.getDrops(world, // c.xCoord, c.yCoord, c.zCoord, dropmeta, 0)); this.cutBlock(world, x, y, z, c, mat); if (c.yCoord == edity) { Block idbelow = world.getBlock(c.xCoord, c.yCoord - 1, c.zCoord); Block root = TwilightForestHandler.BlockEntry.ROOT.getBlock(); if (ReikaPlantHelper.SAPLING.canPlantAt(world, c.xCoord, c.yCoord, c.zCoord)) { ItemStack plant = this.getPlantedSapling(); if (plant != null) { if (inv[0] != null && !this.hasEnchantment(Enchantment.infinity)) ReikaInventoryHelper.decrStack(0, inv); ReikaWorldHelper.setBlock(world, c.xCoord, c.yCoord, c.zCoord, plant); } } else if (tree.getTreeType() == ModWoodList.TIMEWOOD && (idbelow == root || idbelow == Blocks.air)) { ItemStack plant = this.getPlantedSapling(); if (plant != null) { if (inv[0] != null && !this.hasEnchantment(Enchantment.infinity)) ReikaInventoryHelper.decrStack(0, inv); world.setBlock(c.xCoord, c.yCoord - 1, c.zCoord, Blocks.dirt); ReikaWorldHelper.setBlock(world, c.xCoord, c.yCoord, c.zCoord, plant); } } } } else { boolean fall = BlockSand.func_149831_e(world, c.xCoord, c.yCoord - 1, c.zCoord); if (fall) { EntityFallingBlock e = new EntityFallingBlock( world, c.xCoord + 0.5, c.yCoord + 0.65, c.zCoord + 0.5, drop, dropmeta); e.field_145812_b = -5000; if (!world.isRemote) { world.spawnEntityInWorld(e); } c.setBlock(world, Blocks.air); } else { this.cutBlock(world, x, y, z, c, mat); if (c.yCoord == edity) { Block idbelow = world.getBlock(c.xCoord, c.yCoord - 1, c.zCoord); Block root = TwilightForestHandler.BlockEntry.ROOT.getBlock(); if (ReikaPlantHelper.SAPLING.canPlantAt(world, c.xCoord, c.yCoord, c.zCoord)) { ItemStack plant = this.getPlantedSapling(); if (plant != null) { if (inv[0] != null && !this.hasEnchantment(Enchantment.infinity)) ReikaInventoryHelper.decrStack(0, inv); ReikaWorldHelper.setBlock(world, c.xCoord, c.yCoord, c.zCoord, plant); } } else if (tree.getTreeType() == ModWoodList.TIMEWOOD && (idbelow == root || idbelow == Blocks.air)) { ItemStack plant = this.getPlantedSapling(); if (plant != null) { if (inv[0] != null && !this.hasEnchantment(Enchantment.infinity)) ReikaInventoryHelper.decrStack(0, inv); world.setBlock(c.xCoord, c.yCoord - 1, c.zCoord, Blocks.dirt); ReikaWorldHelper.setBlock(world, c.xCoord, c.yCoord, c.zCoord, plant); } } } } } } if (tree.isEmpty()) break; } }