package WayofTime.alchemicalWizardry.common.rituals; import WayofTime.alchemicalWizardry.common.LifeEssenceNetwork; import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar; import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone; import cpw.mods.fml.common.network.PacketDispatcher; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; public class RitualEffectWater extends RitualEffect { public void performEffect(TEMasterStone ritualStone) { String owner = ritualStone.getOwner(); World worldSave = MinecraftServer.getServer().worldServers[0]; LifeEssenceNetwork data = (LifeEssenceNetwork) worldSave.loadItemData(LifeEssenceNetwork.class, owner); if (data == null) { data = new LifeEssenceNetwork(owner); worldSave.setItemData(owner, data); } int currentEssence = data.currentEssence; World world = ritualStone.worldObj; int x = ritualStone.xCoord; int y = ritualStone.yCoord; int z = ritualStone.zCoord; if (world.isAirBlock(x, y + 1, z)) { if (currentEssence < this.getCostPerRefresh()) { EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner); if (entityOwner == null) { return; } entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); } else { for (int i = 0; i < 10; i++) { PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(x, y, z, (short) 3)); } world.setBlock(x, y + 1, z, Block.waterMoving.blockID, 0, 3); data.currentEssence = currentEssence - this.getCostPerRefresh(); data.markDirty(); } } } public int getCostPerRefresh() { return 25; } }