mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 11:59:14 +00:00
pull in extra heart stuffs from 1.6 warning: probably will fail serverside
This commit is contained in:
1 parent
58bf2934be
commit
d6372a79ae
13 files changed
+284
-113
No files matched your search
@@ -1,5 +1,8 @@
|
||||
package tconstruct.util.player;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -12,8 +15,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.armor.IHealthAccessory;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ArmorExtended implements IInventory
|
||||
@@ -139,40 +143,39 @@ public class ArmorExtended implements IInventory
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
if (inventory[6] != null && inventory[6].getItem() == TRepo.heartCanister)
|
||||
{
|
||||
ItemStack stack = inventory[6];
|
||||
int meta = stack.getItemDamage();
|
||||
// TConstruct.logger.info("Calculating HP on side " +
|
||||
// FMLCommonHandler.instance().getEffectiveSide());
|
||||
if (meta == 2)
|
||||
if (inventory[4] != null || inventory[5] != null || inventory[6] != null) {
|
||||
int bonusHP = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
int prevHealth = stats.bonusHealth;
|
||||
if (side == Side.CLIENT)
|
||||
prevHealth = stats.bonusHealthClient;
|
||||
|
||||
int bonusHP = stack.stackSize * 2;
|
||||
if (side == Side.CLIENT)
|
||||
stats.bonusHealthClient = bonusHP;
|
||||
else
|
||||
stats.bonusHealth = bonusHP;
|
||||
|
||||
int healthChange = bonusHP - prevHealth;
|
||||
// TConstruct.logger.info("healthChange: "+healthChange+" on side "+FMLCommonHandler.instance().getEffectiveSide());
|
||||
if (healthChange != 0)
|
||||
ItemStack stack = inventory[i + 4];
|
||||
if (stack != null && stack.getItem() instanceof IHealthAccessory)
|
||||
{
|
||||
IAttributeInstance attributeinstance = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
|
||||
try
|
||||
{
|
||||
attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
attributeinstance.applyModifier(new AttributeModifier(globalID, "tconstruct.heartCanister", bonusHP, 0));
|
||||
bonusHP += ((IHealthAccessory) stack.getItem()).getHealthBoost(stack);
|
||||
}
|
||||
}
|
||||
int prevHealth = stats.bonusHealth;
|
||||
if (side == Side.CLIENT)
|
||||
prevHealth = stats.bonusHealthClient;
|
||||
|
||||
if (side == Side.CLIENT)
|
||||
stats.bonusHealthClient = bonusHP;
|
||||
else
|
||||
stats.bonusHealth = bonusHP;
|
||||
|
||||
int healthChange = bonusHP - prevHealth;
|
||||
if (healthChange != 0)
|
||||
{
|
||||
IAttributeInstance attributeinstance = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
|
||||
try
|
||||
{
|
||||
attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
attributeinstance.applyModifier(new AttributeModifier(globalID, "tconstruct.heartCanister", bonusHP, 0));
|
||||
|
||||
}
|
||||
}
|
||||
else if (parent != null && parent.get() != null)
|
||||
{
|
||||
@@ -279,4 +282,16 @@ public class ArmorExtended implements IInventory
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
public void writeInventoryToStream (ByteBuf os) throws IOException
|
||||
{
|
||||
for (int i = 0; i < 7; i++)
|
||||
ByteBufUtils.writeItemStack(os,inventory[i]);
|
||||
}
|
||||
|
||||
public void readInventoryFromStream (ByteBuf is) throws IOException
|
||||
{
|
||||
for (int i = 0; i < 7; i++)
|
||||
inventory[i] = ByteBufUtils.readItemStack(is);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user