@SubscribeEvent public void onEntityDamaged(LivingHurtEvent event) { if (event.source.getEntity() instanceof EntityPlayer && event.entityLiving instanceof EntityLiving && Math.random() < 0.3333F) { EntityPlayer player = (EntityPlayer) event.source.getEntity(); ItemStack amulet = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); if (amulet != null && amulet.getItem() == this) { final int cost = 250; if (ManaItemHandler.requestManaExact(amulet, player, cost, false)) { final int range = 20; List<IMob> mobs = player.worldObj.getEntitiesWithinAABB( IMob.class, AxisAlignedBB.getBoundingBox( event.entity.posX - range, event.entity.posY - range, event.entity.posZ - range, event.entity.posX + range, event.entity.posY + range, event.entity.posZ + range)); if (mobs.size() > 1) { SubTileHeiseiDream.brainwashEntity((EntityLiving) event.entityLiving, mobs); event.entityLiving.heal(event.entityLiving.getMaxHealth()); ManaItemHandler.requestManaExact(amulet, player, cost, true); player.worldObj.playSoundAtEntity(player, "random.levelup", 1F, 1F); double x = event.entityLiving.posX; double y = event.entityLiving.posY; double z = event.entityLiving.posZ; for (int i = 0; i < 50; i++) Botania.proxy.sparkleFX( event.entityLiving.worldObj, x + Math.random() * event.entityLiving.width, y + Math.random() * event.entityLiving.height, z + Math.random() * event.entityLiving.width, 1F, 1F, 0.25F, 1F, 3); } } } } }
@Override public boolean onBlockActivated( World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4); if (par5EntityPlayer.isSneaking()) { for (int i = tile.getSizeInventory() - 1; i >= 0; i--) { ItemStack stackAt = tile.getStackInSlot(i); if (stackAt != null) { ItemStack copy = stackAt.copy(); if (!par5EntityPlayer.inventory.addItemStackToInventory(copy)) par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); tile.setInventorySlotContents(i, null); par1World.func_147453_f(par2, par3, par4, this); break; } } } else if (tile.isEmpty() && tile.hasWater && stack == null) tile.trySetLastRecipe(par5EntityPlayer); else { if (stack != null && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.requestManaExact( stack, par5EntityPlayer, ItemWaterRod.COST, false))) { if (!tile.hasWater) { if (stack.getItem() == ModItems.waterRod) ManaItemHandler.requestManaExact(stack, par5EntityPlayer, ItemWaterRod.COST, true); else if (!par5EntityPlayer.capabilities.isCreativeMode) par5EntityPlayer.inventory.setInventorySlotContents( par5EntityPlayer.inventory.currentItem, getContainer(stack)); tile.setWater(true); par1World.func_147453_f(par2, par3, par4, this); } return true; } else if (stack != null && stack.getItem() == Items.lava_bucket) { if (!par5EntityPlayer.capabilities.isCreativeMode) par5EntityPlayer.inventory.setInventorySlotContents( par5EntityPlayer.inventory.currentItem, getContainer(stack)); tile.setLava(true); tile.setWater(false); par1World.func_147453_f(par2, par3, par4, this); return true; } else if (stack != null && stack.getItem() == Items.bucket && (tile.hasWater || tile.hasLava) && !Botania.gardenOfGlassLoaded) { ItemStack bucket = tile.hasLava ? new ItemStack(Items.lava_bucket) : new ItemStack(Items.water_bucket); if (stack.stackSize == 1) par5EntityPlayer.inventory.setInventorySlotContents( par5EntityPlayer.inventory.currentItem, bucket); else { if (!par5EntityPlayer.inventory.addItemStackToInventory(bucket)) par5EntityPlayer.dropPlayerItemWithRandomChoice(bucket, false); stack.stackSize--; } if (tile.hasLava) tile.setLava(false); else tile.setWater(false); par1World.func_147453_f(par2, par3, par4, this); return true; } } return false; }