2014-06-27 19:43:09 -04:00
|
|
|
package WayofTime.alchemicalWizardry.common.items.sigil;
|
|
|
|
|
2015-04-24 07:41:08 -04:00
|
|
|
import java.util.List;
|
|
|
|
|
2015-05-18 18:33:23 -04:00
|
|
|
import WayofTime.alchemicalWizardry.api.items.interfaces.ISigil;
|
2015-07-31 12:09:09 -04:00
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemBucket;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2015-01-22 20:13:57 +03:00
|
|
|
import net.minecraft.util.StatCollector;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.world.World;
|
2015-07-31 12:09:09 -04:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
import net.minecraftforge.fluids.IFluidHandler;
|
2015-07-31 12:09:09 -04:00
|
|
|
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
2015-04-24 07:41:08 -04:00
|
|
|
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
2015-07-31 12:09:09 -04:00
|
|
|
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
2015-04-24 07:47:30 -04:00
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
2015-07-31 12:09:09 -04:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-06-27 19:43:09 -04:00
|
|
|
|
2015-05-18 18:33:23 -04:00
|
|
|
public class SigilVoid extends ItemBucket implements ArmourUpgrade, ISigil
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
private int isFull;
|
2014-06-27 19:43:09 -04:00
|
|
|
private int energyUsed;
|
|
|
|
|
2015-05-18 18:33:23 -04:00
|
|
|
public SigilVoid()
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
super(null);
|
2015-07-31 12:09:09 -04:00
|
|
|
this.maxStackSize = 1;
|
2014-06-27 19:43:09 -04:00
|
|
|
setEnergyUsed(50);
|
2015-07-31 12:09:09 -04:00
|
|
|
isFull = 0;
|
|
|
|
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerIcons(IIconRegister iconRegister)
|
|
|
|
{
|
|
|
|
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:VoidSigil");
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-24 07:41:08 -04:00
|
|
|
public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-01-22 20:13:57 +03:00
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.voidsigil.desc"));
|
2014-06-27 19:43:09 -04:00
|
|
|
|
2015-04-24 07:41:08 -04:00
|
|
|
if (!(stack.getTagCompound() == null))
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-04-24 07:41:08 -04:00
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.owner.currentowner") + " " + stack.getTagCompound().getString("ownerName"));
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getContainerItem(ItemStack itemStack)
|
|
|
|
{
|
|
|
|
ItemStack copiedStack = itemStack.copy();
|
|
|
|
copiedStack.setItemDamage(copiedStack.getItemDamage() + getEnergyUsed());
|
|
|
|
copiedStack.stackSize = 1;
|
|
|
|
return copiedStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void setEnergyUsed(int par1int)
|
|
|
|
{
|
|
|
|
this.energyUsed = par1int;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int getEnergyUsed()
|
|
|
|
{
|
|
|
|
return this.energyUsed;
|
|
|
|
}
|
|
|
|
|
2015-04-24 07:41:08 -04:00
|
|
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
|
|
|
{
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
2014-06-27 19:43:09 -04:00
|
|
|
@Override
|
2015-07-31 12:09:09 -04:00
|
|
|
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
if (world.isRemote || !EnergyItems.checkAndSetItemOwner(stack, player) || player.isSneaking())
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-04-24 07:41:08 -04:00
|
|
|
return false;
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
float f = 1.0F;
|
|
|
|
|
|
|
|
if (!world.canMineBlock(player, x, y, z))
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-04-24 07:41:08 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
TileEntity tile = world.getTileEntity(x, y, z);
|
2015-04-24 07:41:08 -04:00
|
|
|
if (tile instanceof IFluidHandler)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
FluidStack amount = ((IFluidHandler) tile).drain(ForgeDirection.getOrientation(side), 1000, false);
|
2014-06-27 19:43:09 -04:00
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (amount != null && amount.amount > 0 && EnergyItems.syphonBatteries(stack, player, getEnergyUsed()))
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
((IFluidHandler) tile).drain(ForgeDirection.getOrientation(side), 1000, true);
|
2015-04-24 07:41:08 -04:00
|
|
|
return true;
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
|
2015-04-24 07:41:08 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 0)
|
2015-04-24 07:41:08 -04:00
|
|
|
{
|
2015-04-24 07:47:30 -04:00
|
|
|
--y;
|
|
|
|
}
|
2014-06-27 19:43:09 -04:00
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 1)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
++y;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 2)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
--z;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 3)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
++z;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 4)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
--x;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 5)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
++x;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (!player.canPlayerEdit(x, y, z, side, stack))
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (SpellHelper.isBlockFluid(world.getBlock(x, y, z)) && EnergyItems.syphonBatteries(stack, player, getEnergyUsed()))
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
world.setBlockToAir(x, y, z);
|
2015-04-24 07:47:30 -04:00
|
|
|
return true;
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
2015-04-24 07:47:30 -04:00
|
|
|
|
2015-04-24 07:41:08 -04:00
|
|
|
|
|
|
|
return false;
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to place the liquid contained inside the bucket.
|
|
|
|
*/
|
2015-07-31 12:09:09 -04:00
|
|
|
public boolean tryPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, int par10)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-31 12:09:09 -04:00
|
|
|
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
|
|
|
{
|
|
|
|
}
|
2014-06-27 19:43:09 -04:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isUpgrade()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getEnergyForTenSeconds()
|
|
|
|
{
|
|
|
|
return 25;
|
|
|
|
}
|
|
|
|
}
|