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;
|
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-07-31 11:35:05 -04:00
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
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;
|
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
import net.minecraftforge.fluids.IFluidHandler;
|
2015-04-24 07:41:08 -04:00
|
|
|
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
2015-07-30 17:24:20 -04:00
|
|
|
import WayofTime.alchemicalWizardry.common.items.BindableItems;
|
2015-04-24 07:47:30 -04:00
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
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
|
|
|
{
|
|
|
|
private int energyUsed;
|
|
|
|
|
2015-05-18 18:33:23 -04:00
|
|
|
public SigilVoid()
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
super(null);
|
|
|
|
setEnergyUsed(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 11:35:05 -04:00
|
|
|
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-30 17:24:20 -04:00
|
|
|
if (world.isRemote || !BindableItems.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 11:35:05 -04:00
|
|
|
if (!world.canMineBlockBody(player, blockPos))
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-04-24 07:41:08 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-31 11:35:05 -04:00
|
|
|
TileEntity tile = world.getTileEntity(blockPos);
|
2015-04-24 07:41:08 -04:00
|
|
|
if (tile instanceof IFluidHandler)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-31 11:35:05 -04:00
|
|
|
FluidStack amount = ((IFluidHandler) tile).drain(side, 1000, false);
|
2014-06-27 19:43:09 -04:00
|
|
|
|
2015-07-30 17:24:20 -04:00
|
|
|
if (amount != null && amount.amount > 0 && BindableItems.syphonBatteries(stack, player, getEnergyUsed()))
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-31 11:35:05 -04:00
|
|
|
((IFluidHandler) tile).drain(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 11:35:05 -04:00
|
|
|
int x = blockPos.getX();
|
|
|
|
int y = blockPos.getY();
|
|
|
|
int z = blockPos.getZ();
|
|
|
|
|
|
|
|
if (side.getIndex() == 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 11:35:05 -04:00
|
|
|
if (side.getIndex() == 1)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
++y;
|
|
|
|
}
|
|
|
|
|
2015-07-31 11:35:05 -04:00
|
|
|
if (side.getIndex() == 2)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
--z;
|
|
|
|
}
|
|
|
|
|
2015-07-31 11:35:05 -04:00
|
|
|
if (side.getIndex() == 3)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
++z;
|
|
|
|
}
|
|
|
|
|
2015-07-31 11:35:05 -04:00
|
|
|
if (side.getIndex() == 4)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
--x;
|
|
|
|
}
|
|
|
|
|
2015-07-31 11:35:05 -04:00
|
|
|
if (side.getIndex() == 5)
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
++x;
|
|
|
|
}
|
|
|
|
|
2015-07-31 11:35:05 -04:00
|
|
|
if (!player.func_175151_a(new BlockPos(x, y, z), side, stack)) //was canPlayerEdit
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-31 11:35:05 -04:00
|
|
|
if (SpellHelper.isBlockFluid(world.getBlockState(new BlockPos(x, y, z)).getBlock()) && BindableItems.syphonBatteries(stack, player, getEnergyUsed()))
|
2015-04-24 07:47:30 -04:00
|
|
|
{
|
2015-07-31 11:35:05 -04:00
|
|
|
world.setBlockToAir(new BlockPos(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
|
|
|
}
|
|
|
|
|
2015-07-31 11:35:05 -04:00
|
|
|
@Override
|
2014-06-27 19:43:09 -04:00
|
|
|
/**
|
|
|
|
* Attempts to place the liquid contained inside the bucket.
|
|
|
|
*/
|
2015-07-31 11:35:05 -04:00
|
|
|
public boolean func_180616_a(World world, BlockPos blockPos) //was tryPlaceContainedLiquid
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-31 11:35:05 -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;
|
|
|
|
}
|
|
|
|
}
|