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

154 lines
4.4 KiB
Java
Raw Normal View History

package WayofTime.alchemicalWizardry.common.items;
2014-10-13 22:33:20 +02:00
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
2014-10-13 22:33:20 +02:00
import java.util.List;
public class ArmourInhibitor extends EnergyItems
{
private static IIcon activeIcon;
private static IIcon passiveIcon;
private int tickDelay = 200;
public ArmourInhibitor()
{
super();
this.maxStackSize = 1;
setEnergyUsed(0);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Used to suppress a soul's");
par3List.add("unnatural abilities.");
2015-01-16 10:00:50 -05:00
if (!(par1ItemStack.getTagCompound() == null))
{
2015-01-16 10:00:50 -05:00
if (par1ItemStack.getTagCompound().getBoolean("isActive"))
{
par3List.add("Activated");
} else
{
par3List.add("Deactivated");
}
2015-01-16 10:00:50 -05:00
par3List.add("Current owner: " + par1ItemStack.getTagCompound().getString("ownerName"));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ArmourInhibitor_deactivated");
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:ArmourInhibitor_activated");
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:ArmourInhibitor_deactivated");
}
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
2015-01-16 10:00:50 -05:00
if (stack.getTagCompound() == null)
{
stack.setTagCompound(new NBTTagCompound());
}
2015-01-16 10:00:50 -05:00
NBTTagCompound tag = stack.getTagCompound();
if (tag.getBoolean("isActive"))
{
return this.activeIcon;
} else
{
return this.passiveIcon;
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1)
{
if (par1 == 1)
{
return this.activeIcon;
} else
{
return this.passiveIcon;
}
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
if (par3EntityPlayer.isSneaking())
{
return par1ItemStack;
}
2015-01-16 10:00:50 -05:00
if (par1ItemStack.getTagCompound() == null)
{
par1ItemStack.setTagCompound(new NBTTagCompound());
}
2015-01-16 10:00:50 -05:00
NBTTagCompound tag = par1ItemStack.getTagCompound();
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
if (tag.getBoolean("isActive"))
{
par1ItemStack.setItemDamage(1);
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % tickDelay);
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
}
} else
{
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
}
return par1ItemStack;
}
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
{
if (!(par3Entity instanceof EntityPlayer))
{
return;
}
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
2015-01-16 10:00:50 -05:00
if (par1ItemStack.getTagCompound() == null)
{
par1ItemStack.setTagCompound(new NBTTagCompound());
}
2015-01-16 10:00:50 -05:00
if (par1ItemStack.getTagCompound().getBoolean("isActive"))
{
2015-01-16 10:00:50 -05:00
if (par2World.getWorldTime() % tickDelay == par1ItemStack.getTagCompound().getInteger("worldTimeDelay") && par3Entity instanceof EntityPlayer)
{
}
//TODO Do stuff
par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 2, 0));
}
return;
}
}