mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 11:59:14 +00:00
Fix the extended armor inventory being lost sometimes...
And maybe a little cleanup in ArmorExtended...
This commit is contained in:
1 parent
801a514ae3
commit
07c339c001
3 files changed
+23
-6
No files matched your search
@@ -148,9 +148,9 @@ public class ArmorExtended implements IInventory
|
||||
if (inventory[4] != null || inventory[5] != null || inventory[6] != null)
|
||||
{
|
||||
int bonusHP = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 4; i < 7; i++)
|
||||
{
|
||||
ItemStack stack = inventory[i + 4];
|
||||
ItemStack stack = inventory[i];
|
||||
if (stack != null && stack.getItem() instanceof IHealthAccessory)
|
||||
{
|
||||
bonusHP += ((IHealthAccessory) stack.getItem()).getHealthBoost(stack);
|
||||
@@ -267,7 +267,7 @@ public class ArmorExtended implements IInventory
|
||||
public void dropItems (ArrayList<EntityItem> drops)
|
||||
{
|
||||
EntityPlayer player = parent.get();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < this.inventory.length; ++i)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
@@ -290,13 +290,13 @@ public class ArmorExtended implements IInventory
|
||||
|
||||
public void writeInventoryToStream (ByteBuf os) throws IOException
|
||||
{
|
||||
for (int i = 0; i < 7; i++)
|
||||
for (int i = 0; i < inventory.length; i++)
|
||||
ByteBufUtils.writeItemStack(os, inventory[i]);
|
||||
}
|
||||
|
||||
public void readInventoryFromStream (ByteBuf is) throws IOException
|
||||
{
|
||||
for (int i = 0; i < 7; i++)
|
||||
for (int i = 0; i < inventory.length; i++)
|
||||
inventory[i] = ByteBufUtils.readItemStack(is);
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class TPlayerHandler
|
||||
TPlayerStats stats = TPlayerStats.get(entityplayer);
|
||||
if (playerData != null)
|
||||
{
|
||||
stats = playerData;
|
||||
stats.copyFrom(playerData, true);
|
||||
}
|
||||
|
||||
stats.player = new WeakReference<EntityPlayer>(entityplayer);
|
||||
|
||||
@@ -70,6 +70,23 @@ public class TPlayerStats implements IExtendedEntityProperties
|
||||
{
|
||||
}
|
||||
|
||||
public void copyFrom(TPlayerStats stats, boolean copyCalc)
|
||||
{
|
||||
this.armor = stats.armor;
|
||||
this.knapsack = stats.knapsack;
|
||||
this.beginnerManual = stats.beginnerManual;
|
||||
this.materialManual = stats.materialManual;
|
||||
this.smelteryManual = stats.smelteryManual;
|
||||
this.battlesignBonus = stats.battlesignBonus;
|
||||
|
||||
if (copyCalc) {
|
||||
this.bonusHealth = stats.bonusHealth;
|
||||
this.bonusHealthClient = stats.bonusHealthClient;
|
||||
this.hunger = stats.hunger;
|
||||
this.level = stats.level;
|
||||
}
|
||||
}
|
||||
|
||||
public static final void register (EntityPlayer player)
|
||||
{
|
||||
player.registerExtendedProperties(TPlayerStats.PROP_NAME, new TPlayerStats(player));
|
||||
|
||||
Reference in new issue
Block a user