BloodMagic/src/main/java/WayofTime/alchemicalWizardry/common/items/LavaCrystal.java

77 lines
2.3 KiB
Java
Raw Normal View History

package WayofTime.alchemicalWizardry.common.items;
2015-02-13 14:48:22 -05:00
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
2015-07-30 08:44:01 -04:00
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
2015-07-30 17:24:20 -04:00
public class LavaCrystal extends BindableItems
{
public LavaCrystal()
{
super();
setMaxStackSize(1);
setEnergyUsed(25);
}
/*
* Used to have the item contain itself.
*/
@Override
public ItemStack getContainerItem(ItemStack itemStack)
{
2015-07-30 17:24:20 -04:00
SoulNetworkHandler.syphonFromNetwork(itemStack, this.getEnergyUsed());
ItemStack copiedStack = itemStack.copy();
copiedStack.setItemDamage(copiedStack.getItemDamage());
copiedStack.stackSize = 1;
return copiedStack;
}
@Override
2015-07-30 17:24:20 -04:00
public boolean hasContainerItem(ItemStack itemStack)
{
return true;
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
2015-07-30 17:24:20 -04:00
BindableItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
return par1ItemStack;
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add(StatCollector.translateToLocal("tooltip.lavacrystal.desc1"));
par3List.add(StatCollector.translateToLocal("tooltip.lavacrystal.desc2"));
2015-01-16 10:00:50 -05:00
if (!(par1ItemStack.getTagCompound() == null))
{
par3List.add(StatCollector.translateToLocal("tooltip.owner.currentowner") + " " + par1ItemStack.getTagCompound().getString("ownerName"));
}
}
public boolean hasEnoughEssence(ItemStack itemStack)
{
if (itemStack.getTagCompound() != null && !(itemStack.getTagCompound().getString("ownerName").equals("")))
{
String ownerName = itemStack.getTagCompound().getString("ownerName");
if (MinecraftServer.getServer() == null)
{
return false;
}
2015-07-30 08:44:01 -04:00
if (SoulNetworkHandler.getCurrentEssence(ownerName) >= this.getEnergyUsed())
{
return true;
}
}
return false;
}
}