@Override public void explosion(int power, boolean flag) { int radius = getPowered() ? (int) (ECVars.darkCreeperRadius * power) : ECVars.darkCreeperRadius; for (int x = -radius; x <= radius; x++) for (int y = -radius; y <= radius; y++) for (int z = -radius; z <= radius; z++) { Block id = worldObj.getBlock((int) posX + x, (int) posY + y, (int) posZ + z); if (id != null && id.getLightValue() > 0.5F) { id.dropBlockAsItem( worldObj, (int) posX + x, (int) posY + y, (int) posZ + z, worldObj.getBlockMetadata((int) posX + x, (int) posY + y, (int) posZ + z), 0); worldObj.setBlockToAir((int) posX + x, (int) posY + y, (int) posZ + z); id.onBlockDestroyedByExplosion( worldObj, (int) posX + x, (int) posY + y, (int) posZ + z, new Explosion(worldObj, this, 0.0D, 0.0D, 0.0D, 0.0F)); } } }
@Override public boolean onBlockDestroyed( ItemStack is, World world, int blockID, int x, int y, int z, EntityLivingBase e) { if (is.getItemDamage() > 0 && e instanceof EntityPlayer) { EntityPlayer ep = (EntityPlayer) e; Block b = Block.blocksList[blockID]; if (b.blockMaterial == Material.leaves) { is.setItemDamage(is.getItemDamage() - 1); int r = 3; for (int i = -r; i <= r; i++) { for (int j = -r; j <= r; j++) { for (int k = -r; k <= r; k++) { int dx = x + i; int dy = y + j; int dz = z + k; Block b2 = Block.blocksList[world.getBlockId(dx, dy, dz)]; if (b2 != null && b2.blockMaterial == Material.leaves) { b2.dropBlockAsItem(world, dx, dy, dz, world.getBlockMetadata(dx, dy, dz), 0); b2.removeBlockByPlayer(world, ep, dx, dy, dz); is.setItemDamage(is.getItemDamage() - 1); } } } } e.setCurrentItemOrArmor(0, is); return true; } } return false; }
@Override public boolean onBlockDestroyed( ItemStack itemStack, World world, Block destroyedBlock, int x, int y, int z, EntityLivingBase player) { // System.out.println("Test (" + x + "," + y + "," + z + ")"); // player.getLookVec(); int numBlocks = 0; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { Block block = world.getBlock(x + i, y + j, z + k); if (block != null) { System.out.println("block: " + block.getUnlocalizedName()); System.out.println("can: " + itemStack.getItem().canHarvestBlock(block, itemStack)); if (this.canHarvestBlock(block, itemStack)) { int fortuneLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemStack); block.dropBlockAsItem( world, x, y, z, world.getBlockMetadata(x + i, y + j, z + k), fortuneLevel); world.setBlockToAir(x + i, y + j, z + k); numBlocks++; } } } } } itemStack.damageItem(numBlocks / 3, player); // Block block = Block.blocksList[l] return false; }
@Override public double injectEnergy(ForgeDirection directionFrom, double realAmount, double voltage) { double amount = (int) Math.floor(realAmount); if (amount > getSinkTier()) { Block block = worldObj.getBlock(xCoord, yCoord, zCoord); int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); worldObj.setBlockToAir(xCoord, yCoord, zCoord); block.dropBlockAsItem(worldObj, xCoord, yCoord, zCoord, meta, 0); return amount; } double pcuNotStored = storeEnergy(amount * PowerSystems.powerSystemIndustrialCraft.getScaleAmmount(), false); double euNotStored = pcuNotStored / PowerSystems.powerSystemIndustrialCraft.getScaleAmmount(); double euThisInjection = (amount - euNotStored); if (_lastTickInjected == worldObj.getWorldTime()) { _euLastTick += euThisInjection; } else { _euLastTick = euThisInjection; _lastTickInjected = worldObj.getWorldTime(); } return euNotStored; }
private void emulateBlockHarvest( ItemStack stack, World world, int x, int y, int z, Block block, int meta, EntityPlayer player) { world.playAuxSFXAtEntity(player, 2001, x, y, z, Block.getIdFromBlock(block) | meta << 12); stack.func_150999_a(world, block, x, y, z, player); if (stack.stackSize == 0) player.destroyCurrentEquippedItem(); if (block.removedByPlayer(world, player, x, y, z, false)) { block.dropBlockAsItem(world, x, y, z, meta, EnchantmentHelper.getFortuneModifier(player)); } }
@SubscribeEvent public void handleCropRightClick(PlayerInteractEvent event) { int x = event.x, y = event.y, z = event.z; Block block = event.world.getBlock(x, y, z); int meta = event.world.getBlockMetadata(x, y, z); if (ConfigHandler.allowCropRC && event.action == Action.RIGHT_CLICK_BLOCK && (event.entityPlayer.getHeldItem() == null || !event.entityPlayer.isSneaking())) { for (PlantInfo info : plants) { if (info.blockInst == block && meta == info.meta) { if (event.world.isRemote) { event.entityPlayer.swingItem(); } else { currentPlant = info; block.dropBlockAsItem(event.world, x, y, z, meta, 0); currentPlant = null; event.world.setBlockMetadataWithNotify(x, y, z, info.resetMeta, 3); event.setCanceled(true); } break; } } } }