Improved the API and internal workings
Update things Fix some more things Update once more Refactoring and removing unnecessary null checks Woops Fix Nother fix Moar fix Fix imports Update ItemBindable.java
This commit is contained in:
parent
0a2dfb4fd4
commit
3e50dd4117
28 changed files with 389 additions and 340 deletions
|
@ -3,10 +3,12 @@ package WayofTime.bloodmagic.item.gear;
|
|||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.iface.IItemLPContainer;
|
||||
import WayofTime.bloodmagic.api.util.helper.ItemHelper.LPContainer;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
|
@ -24,15 +26,23 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator, IVariantProvider
|
||||
public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider
|
||||
{
|
||||
/** How much LP per half heart */
|
||||
/**
|
||||
* How much LP per half heart
|
||||
*/
|
||||
public final int CONVERSION = 100;
|
||||
/** Max LP storage */
|
||||
/**
|
||||
* Max LP storage
|
||||
*/
|
||||
public final int CAPACITY = 10000;
|
||||
/** How often the pack syphons */
|
||||
/**
|
||||
* How often the pack syphons
|
||||
*/
|
||||
public final int INTERVAL = 20;
|
||||
/** How much health is required for the pack to syphon (0 - 1) */
|
||||
/**
|
||||
* How much health is required for the pack to syphon (0 - 1)
|
||||
*/
|
||||
public final float HEALTHREQ = 0.5f;
|
||||
|
||||
public ItemPackSelfSacrifice()
|
||||
|
@ -54,29 +64,17 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
if (position == null)
|
||||
{
|
||||
return super.onItemRightClick(stack, world, player, EnumHand.MAIN_HAND);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (position.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
||||
|
||||
if (!(tile instanceof TileAltar))
|
||||
if (!(tile instanceof IBloodAltar))
|
||||
return super.onItemRightClick(stack, world, player, EnumHand.MAIN_HAND);
|
||||
|
||||
TileAltar altar = (TileAltar) tile;
|
||||
|
||||
if (!altar.isActive())
|
||||
{
|
||||
int amount = this.getStoredLP(stack);
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
int filledAmount = altar.fillMainTank(amount);
|
||||
amount -= filledAmount;
|
||||
setStoredLP(stack, amount);
|
||||
world.notifyBlockUpdate(position.getBlockPos(), world.getBlockState(position.getBlockPos()), world.getBlockState(position.getBlockPos()), 3);
|
||||
}
|
||||
}
|
||||
LPContainer.tryAndFillAltar((IBloodAltar) tile, stack, world, position.getBlockPos());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +92,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0)
|
||||
{
|
||||
NetworkHelper.getSoulNetwork(player).hurtPlayer(player, 1.0F);
|
||||
addLP(stack, CONVERSION);
|
||||
LPContainer.addLPToItem(stack, CONVERSION, CAPACITY);
|
||||
}
|
||||
|
||||
if (getStoredLP(stack) > CAPACITY)
|
||||
|
@ -117,28 +115,26 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
return ret;
|
||||
}
|
||||
|
||||
public void addLP(ItemStack stack, int toAdd)
|
||||
// IFillable
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (toAdd < 0)
|
||||
toAdd = 0;
|
||||
|
||||
if (toAdd > CAPACITY)
|
||||
toAdd = CAPACITY;
|
||||
|
||||
setStoredLP(stack, Math.min(getStoredLP(stack) + toAdd, CAPACITY));
|
||||
}
|
||||
|
||||
public void setStoredLP(ItemStack stack, int lp)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
stack.getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
|
||||
return this.CAPACITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredLP(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
return stack.getTagCompound().getInteger(Constants.NBT.STORED_LP);
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.STORED_LP) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredLP(ItemStack stack, int lp)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue