mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-22 21:09:44 +00:00
135 lines
4.6 KiB
Java
135 lines
4.6 KiB
Java
package WayofTime.alchemicalWizardry.common.items.sigil;
|
|
|
|
import java.util.List;
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.item.EntityItem;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.util.StatCollector;
|
|
import net.minecraft.world.World;
|
|
|
|
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
|
import WayofTime.alchemicalWizardry.api.compress.CompressionRegistry;
|
|
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
|
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
|
import WayofTime.alchemicalWizardry.api.items.interfaces.IHolding;
|
|
import WayofTime.alchemicalWizardry.api.items.interfaces.ISigil;
|
|
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
public class SigilPackRat extends EnergyItems implements IHolding, ArmourUpgrade, ISigil {
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
private IIcon activeIcon;
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
private IIcon passiveIcon;
|
|
|
|
public SigilPackRat() {
|
|
super();
|
|
this.maxStackSize = 1;
|
|
setEnergyUsed(AlchemicalWizardry.sigilCompressCost);
|
|
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
|
}
|
|
|
|
@Override
|
|
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
|
par3List.add(StatCollector.translateToLocal("tooltip.packratsigil.desc"));
|
|
addBindingInformation(par1ItemStack, par3List);
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public void registerIcons(IIconRegister iconRegister) {
|
|
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:CompressionSigil_deactivated");
|
|
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:CompressionSigil_activated");
|
|
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:CompressionSigil_deactivated");
|
|
}
|
|
|
|
@Override
|
|
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
|
|
if (IBindable.isActive(stack)) {
|
|
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) {
|
|
if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) {
|
|
return par1ItemStack;
|
|
}
|
|
|
|
toggleSigil(par1ItemStack, par2World, par3EntityPlayer);
|
|
|
|
return par1ItemStack;
|
|
}
|
|
|
|
@Override
|
|
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
|
|
if (!(par3Entity instanceof EntityPlayer) || par2World.isRemote) {
|
|
return;
|
|
}
|
|
|
|
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
|
|
|
if (par1ItemStack.getTagCompound() == null) {
|
|
par1ItemStack.setTagCompound(new NBTTagCompound());
|
|
}
|
|
|
|
if (IBindable.isActive(par1ItemStack)) {
|
|
ItemStack stack = CompressionRegistry
|
|
.compressInventory(par3EntityPlayer.inventory.mainInventory, par2World);
|
|
if (stack != null) {
|
|
EntityItem entityItem = new EntityItem(
|
|
par2World,
|
|
par3EntityPlayer.posX,
|
|
par3EntityPlayer.posY,
|
|
par3EntityPlayer.posZ,
|
|
stack);
|
|
par2World.spawnEntityInWorld(entityItem);
|
|
}
|
|
}
|
|
|
|
checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer);
|
|
}
|
|
|
|
@Override
|
|
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack) {
|
|
if (world.isRemote) {
|
|
return;
|
|
}
|
|
ItemStack stack = CompressionRegistry.compressInventory(player.inventory.mainInventory, world);
|
|
if (stack != null) {
|
|
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, stack);
|
|
world.spawnEntityInWorld(entityItem);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean isUpgrade() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public int getEnergyForTenSeconds() {
|
|
return 200;
|
|
}
|
|
}
|