More work on the implementation of events
This commit is contained in:
parent
dd3a093825
commit
39b4243a82
27 changed files with 217 additions and 259 deletions
|
@ -50,7 +50,10 @@ public class ItemBloodLightSigil extends EnergyItems implements IHolding
|
|||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par2EntityPlayer);
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed());
|
||||
if(!EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (par3World.isRemote)
|
||||
{
|
||||
|
@ -105,7 +108,10 @@ public class ItemBloodLightSigil extends EnergyItems implements IHolding
|
|||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed() * 5);
|
||||
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed() * 5))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
|
@ -114,30 +120,4 @@ public class ItemBloodLightSigil extends EnergyItems implements IHolding
|
|||
|
||||
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;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (par2World.getWorldTime() % tickDelay == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par3Entity instanceof EntityPlayer)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par3Entity, getEnergyUsed());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ public class ItemSigilOfEnderSeverance extends EnergyItems implements IHolding
|
|||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
tag.setBoolean("isActive", false);
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
@ -160,7 +161,10 @@ public class ItemSigilOfEnderSeverance extends EnergyItems implements IHolding
|
|||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
par1ItemStack.stackTagCompound.setBoolean("isActive", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,10 @@ public class ItemSigilOfSupression extends EnergyItems implements ArmourUpgrade
|
|||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
tag.setBoolean("isActive", false);
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
@ -201,8 +204,10 @@ public class ItemSigilOfSupression extends EnergyItems implements ArmourUpgrade
|
|||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
|
||||
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
par1ItemStack.stackTagCompound.setBoolean("isActive", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,15 +110,9 @@ public class LavaSigil extends ItemBucket implements ArmourUpgrade
|
|||
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
|
||||
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, false);
|
||||
|
||||
if (amount > 0)
|
||||
if (amount > 0 && EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, true);
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
|
@ -158,17 +152,9 @@ public class LavaSigil extends ItemBucket implements ArmourUpgrade
|
|||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !par3EntityPlayer.capabilities.isCreativeMode)
|
||||
if(this.canPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,6 +179,20 @@ public class LavaSigil extends ItemBucket implements ArmourUpgrade
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, int par10)
|
||||
{
|
||||
if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid())
|
||||
{
|
||||
return false;
|
||||
} else if ((par1World.getBlock(par8, par9, par10) == Blocks.lava || par1World.getBlock(par8, par9, par10) == Blocks.flowing_lava) && par1World.getBlockMetadata(par8, par9, par10) == 0)
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setEnergyUsed(int par1int)
|
||||
{
|
||||
|
|
|
@ -117,15 +117,9 @@ public class VoidSigil extends ItemBucket implements ArmourUpgrade
|
|||
{
|
||||
FluidStack amount = ((IFluidHandler) tile).drain(ForgeDirection.getOrientation(movingobjectposition.sideHit), 1000, false);
|
||||
|
||||
if (amount != null && amount.amount > 0)
|
||||
if (amount != null && amount.amount > 0 && EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
((IFluidHandler) tile).drain(ForgeDirection.getOrientation(movingobjectposition.sideHit), 1000, true);
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
|
@ -138,19 +132,9 @@ public class VoidSigil extends ItemBucket implements ArmourUpgrade
|
|||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par2World.getBlock(i, j, k).getMaterial() instanceof MaterialLiquid)
|
||||
if (par2World.getBlock(i, j, k).getMaterial() instanceof MaterialLiquid && EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
par2World.setBlockToAir(i, j, k);
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,15 +113,9 @@ public class WaterSigil extends ItemBucket implements ArmourUpgrade
|
|||
FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000);
|
||||
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, false);
|
||||
|
||||
if (amount > 0)
|
||||
if (amount > 0 && EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, true);
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
|
@ -163,17 +157,9 @@ public class WaterSigil extends ItemBucket implements ArmourUpgrade
|
|||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !par3EntityPlayer.capabilities.isCreativeMode)
|
||||
if(this.canPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,6 +197,20 @@ public class WaterSigil extends ItemBucket implements ArmourUpgrade
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, int par10)
|
||||
{
|
||||
if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid())
|
||||
{
|
||||
return false;
|
||||
} else if ((par1World.getBlock(par8, par9, par10) == Blocks.water || par1World.getBlock(par8, par9, par10) == Blocks.flowing_water) && par1World.getBlockMetadata(par8, par9, par10) == 0)
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setEnergyUsed(int par1int)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue