@Override public void updateEntity(World world, int x, int y, int z, int meta) { super.updateEntity(world, x, y, z, meta); if (!world.isRemote && this.getEnergy(CrystalElement.GREEN) >= 200) { int n = this.getNumberAttempts(); for (int i = 0; i < n; i++) { Coordinate c = this.getRandomPosition(world, x, y, z); CropType crop = this.getCropAt(world, c); if (crop != null && crop.isRipe(world, c.xCoord, c.yCoord, c.zCoord)) { int fortune = this.getFortune(); ArrayList<ItemStack> li = crop.getDrops(world, c.xCoord, c.yCoord, c.zCoord, fortune); if (fortune < 3) { CropMethods.removeOneSeed(crop, li); } ReikaItemHelper.dropItems(world, c.xCoord + 0.5, c.yCoord + 0.5, c.zCoord + 0.5, li); crop.setHarvested(world, c.xCoord, c.yCoord, c.zCoord); ReikaSoundHelper.playBreakSound(world, x, y, z, c.getBlock(world)); this.drainEnergy(CrystalElement.GREEN, 200); this.drainEnergy(CrystalElement.PURPLE, 50); this.sendParticles(c); break; } } } }
@Override public void harvestBlock(World world, EntityPlayer ep, int x, int y, int z, int meta) { ChromaTiles c = ChromaTiles.getTile(world, x, y, z); if (c == null) return; if (c == ChromaTiles.PYLON) { } else { boolean silk = EnchantmentHelper.getSilkTouchModifier(ep); TileEntity tile = world.getTileEntity(x, y, z); if (silk) { ItemStack is = c.getCraftedProduct(); if (tile instanceof TileEntityAccelerator) { TileEntityAccelerator te = (TileEntityAccelerator) tile; if (is.stackTagCompound == null) is.stackTagCompound = new NBTTagCompound(); is.stackTagCompound.setInteger("tier", te.getTier()); } ReikaItemHelper.dropItem(world, x + 0.5, y + 0.5, z + 0.5, is); } else { ReikaItemHelper.dropItems(world, x + 0.5, y + 0.5, z + 0.5, this.getPieces(world, x, y, z)); } } }
@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; } }
public void dropCache() { ReikaItemHelper.dropItems(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, overflow); overflow.clear(); }