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-06-14 10:33:01 -04:00
|
|
|
import WayofTime.alchemicalWizardry.common.tileEntity.TESocket;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.block.Block;
|
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.init.Blocks;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.item.ItemBucket;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.potion.Potion;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
|
|
|
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.FluidRegistry;
|
|
|
|
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.EnergyBattery;
|
|
|
|
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
|
|
|
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 SigilLava extends ItemBucket implements ArmourUpgrade, ISigil
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* field for checking if the bucket has been filled.
|
|
|
|
*/
|
|
|
|
private Block isFull = Blocks.lava;
|
|
|
|
private int energyUsed;
|
|
|
|
|
2015-05-18 18:33:23 -04:00
|
|
|
public SigilLava()
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
super(Blocks.lava);
|
2015-07-31 12:09:09 -04:00
|
|
|
this.maxStackSize = 1;
|
2014-06-27 19:43:09 -04:00
|
|
|
setEnergyUsed(1000);
|
2015-07-31 12:09:09 -04:00
|
|
|
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerIcons(IIconRegister iconRegister)
|
|
|
|
{
|
|
|
|
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:LavaSigil");
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
|
|
|
{
|
2015-01-22 20:13:57 +03:00
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.lavasigil.desc1"));
|
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.lavasigil.desc2"));
|
2014-06-27 19:43:09 -04:00
|
|
|
|
2015-01-16 10:00:50 -05:00
|
|
|
if (!(par1ItemStack.getTagCompound() == null))
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-01-22 20:13:57 +03:00
|
|
|
par3List.add(StatCollector.translateToLocal("tooltip.owner.currentowner") + " " + par1ItemStack.getTagCompound().getString("ownerName"));
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
|
|
|
*/
|
2015-04-24 07:41:08 -04:00
|
|
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-04-24 07:41:08 -04:00
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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)
|
2015-04-24 07:41:08 -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;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (!world.canMineBlock(player, x, y, z))
|
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
|
|
|
TileEntity tile = world.getTileEntity(x, y, z);
|
2015-04-24 07:41:08 -04:00
|
|
|
if (tile instanceof IFluidHandler)
|
|
|
|
{
|
|
|
|
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
|
2015-07-31 12:09:09 -04:00
|
|
|
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(side), fluid, false);
|
2014-10-13 22:33:20 +02:00
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (amount > 0 && EnergyItems.syphonBatteries(stack, player, getEnergyUsed()))
|
2015-04-24 07:41:08 -04:00
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
((IFluidHandler) tile).fill(ForgeDirection.getOrientation(side), fluid, true);
|
2015-04-24 07:41:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-14 10:33:01 -04:00
|
|
|
else if (tile instanceof TESocket)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-06-27 19:43:09 -04:00
|
|
|
|
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 0)
|
2015-04-24 07:41:08 -04:00
|
|
|
{
|
|
|
|
--y;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 1)
|
2015-04-24 07:41:08 -04:00
|
|
|
{
|
|
|
|
++y;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 2)
|
2015-04-24 07:41:08 -04:00
|
|
|
{
|
|
|
|
--z;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 3)
|
2015-04-24 07:41:08 -04:00
|
|
|
{
|
|
|
|
++z;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 4)
|
2015-04-24 07:41:08 -04:00
|
|
|
{
|
|
|
|
--x;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (side == 5)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-04-24 07:41:08 -04:00
|
|
|
++x;
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if (!player.canPlayerEdit(x, y, z, side, stack))
|
2015-04-24 07:41:08 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
if(this.canPlaceContainedLiquid(world, x, y, z, x, y, z) && EnergyItems.syphonBatteries(stack, player, getEnergyUsed()))
|
2015-04-24 07:41:08 -04:00
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
return this.tryPlaceContainedLiquid(world, x, y, z, x, y, z);
|
2015-04-24 07:41:08 -04:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid())
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
return false;
|
2015-07-31 12:09:09 -04:00
|
|
|
} else if ((par1World.getBlock(par8, par9, par10) == Blocks.lava || par1World.getBlock(par8, par9, par10) == Blocks.flowing_lava) && par1World.getBlockMetadata(par8, par9, par10) == 0)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
} else
|
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
par1World.setBlock(par8, par9, par10, this.isFull, 0, 3);
|
2014-06-27 19:43:09 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2014-11-07 13:45:02 -05:00
|
|
|
|
2015-07-31 12:09:09 -04:00
|
|
|
public boolean canPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, int par10)
|
2014-11-07 13:45:02 -05:00
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid())
|
2014-11-07 13:45:02 -05:00
|
|
|
{
|
|
|
|
return false;
|
2015-07-31 12:09:09 -04:00
|
|
|
} else if ((par1World.getBlock(par8, par9, par10) == Blocks.lava || par1World.getBlock(par8, par9, par10) == Blocks.flowing_lava) && par1World.getBlockMetadata(par8, par9, par10) == 0)
|
2014-11-07 13:45:02 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2014-06-27 19:43:09 -04:00
|
|
|
|
|
|
|
protected void setEnergyUsed(int par1int)
|
|
|
|
{
|
|
|
|
this.energyUsed = par1int;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int getEnergyUsed()
|
|
|
|
{
|
|
|
|
return this.energyUsed;
|
|
|
|
}
|
2014-10-13 22:33:20 +02:00
|
|
|
|
2014-06-27 19:43:09 -04:00
|
|
|
protected boolean syphonBatteries(ItemStack ist, EntityPlayer player, int damageToBeDone)
|
|
|
|
{
|
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
|
|
{
|
|
|
|
boolean usedBattery = false;
|
|
|
|
IInventory inventory = player.inventory;
|
|
|
|
|
|
|
|
for (int slot = 0; slot < inventory.getSizeInventory(); slot++)
|
|
|
|
{
|
|
|
|
ItemStack stack = inventory.getStackInSlot(slot);
|
|
|
|
|
|
|
|
if (stack == null)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2015-07-31 12:09:09 -04:00
|
|
|
if (stack.getItem() instanceof EnergyBattery && !usedBattery)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
if (stack.getItemDamage() <= stack.getMaxDamage() - damageToBeDone)
|
|
|
|
{
|
|
|
|
stack.setItemDamage(stack.getItemDamage() + damageToBeDone);
|
|
|
|
usedBattery = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-02 11:05:07 -04:00
|
|
|
return usedBattery;
|
2014-06-27 19:43:09 -04:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-10-13 22:33:20 +02:00
|
|
|
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-31 12:09:09 -04:00
|
|
|
player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 9, true));
|
2014-06-27 19:43:09 -04:00
|
|
|
player.extinguish();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isUpgrade()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getEnergyForTenSeconds()
|
|
|
|
{
|
|
|
|
return 100;
|
|
|
|
}
|
|
|
|
}
|