BloodMagic/1.7.2/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectWater.java
2014-02-14 15:20:20 -05:00

65 lines
2.2 KiB
Java

package WayofTime.alchemicalWizardry.common.rituals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.LifeEssenceNetwork;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
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.getWorldObj();
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++)
{
SpellHelper.sendIndexedParticleToAllAround(world, x, y, z, 20, world.provider.dimensionId, 3, x, y, z);
}
world.setBlock(x, y + 1, z, Blocks.water, 0, 3);
data.currentEssence = currentEssence - this.getCostPerRefresh();
data.markDirty();
}
}
}
public int getCostPerRefresh()
{
return 25;
}
}