mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-23 21:49:45 +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
@@ -1048,6 +1048,11 @@ public class TProxyClient extends TProxyCommon
|
||||
// new RenderArmorCast());
|
||||
}
|
||||
|
||||
public void recalculateHealth ()
|
||||
{
|
||||
armorExtended.recalculateHealth(mc.thePlayer, TConstruct.playerTracker.getPlayerStats(mc.thePlayer.getDisplayName()));
|
||||
}
|
||||
|
||||
private static IIcon getIcon (IIcon icon)
|
||||
{
|
||||
if (icon != null)
|
||||
|
||||
@@ -109,11 +109,11 @@ public class ArmorExtendedGui extends InventoryEffectRenderer
|
||||
if (!stats.isStackInSlot(3))
|
||||
drawTexturedModalRect(cornerX + 115, cornerY + 34, 212, 27, 18, 18);
|
||||
if (!stats.isStackInSlot(4))
|
||||
drawTexturedModalRect(cornerX + 151, cornerY + 16, 230, 0, 18, 18);
|
||||
drawTexturedModalRect(cornerX + 151, cornerY + 52, 230, 0, 18, 18);
|
||||
if (!stats.isStackInSlot(5))
|
||||
drawTexturedModalRect(cornerX + 151, cornerY + 34, 230, 18, 18, 18);
|
||||
if (!stats.isStackInSlot(6))
|
||||
drawTexturedModalRect(cornerX + 151, cornerY + 52, 230, 36, 18, 18);
|
||||
drawTexturedModalRect(cornerX + 151, cornerY + 16, 230, 36, 18, 18);
|
||||
|
||||
cornerX = this.guiLeft;
|
||||
cornerY = this.guiTop;
|
||||
|
||||
@@ -124,4 +124,9 @@ public class TProxyCommon implements IGuiHandler
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void recalculateHealth ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -794,6 +794,10 @@ public class TRecipes
|
||||
GameRegistry.addRecipe(new ItemStack(TRepo.diamondApple), " d ", "d#d", " d ", 'd', new ItemStack(Items.diamond), '#', new ItemStack(Items.apple));
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TRepo.heartCanister, 1, 2), new ItemStack(TRepo.diamondApple), new ItemStack(TRepo.materials, 1, 8), new ItemStack(TRepo.heartCanister, 1, 0),
|
||||
new ItemStack(TRepo.heartCanister, 1, 1));
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TRepo.heartCanister, 1, 4), new ItemStack(TRepo.heartCanister, 1, 2), new ItemStack(TRepo.heartCanister, 1, 3), new ItemStack(Items.golden_apple,
|
||||
1, 1));
|
||||
//GameRegistry.addShapelessRecipe(new ItemStack(heartCanister, 1, 6), new ItemStack(heartCanister, 1, 0), new ItemStack(heartCanister, 1, 4), new ItemStack(heartCanister, 1, 5));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TRepo.knapsack, 1, 0), "###", "rmr", "###", '#', new ItemStack(Items.leather), 'r', new ItemStack(TRepo.toughRod, 1, 2), 'm',
|
||||
"ingotGold"));
|
||||
GameRegistry.addRecipe(new ItemStack(TRepo.knapsack, 1, 0), "###", "rmr", "###", '#', new ItemStack(Items.leather), 'r', new ItemStack(TRepo.toughRod, 1, 2), 'm', aluBrass);
|
||||
|
||||
@@ -20,10 +20,9 @@ public class ArmorExtendedContainer extends ActiveContainer
|
||||
this.addSlotToContainer(new SlotUnused(armor, 1, 80, 35));
|
||||
this.addSlotToContainer(new SlotKnapsack(armor, 2, 116, 17));
|
||||
this.addSlotToContainer(new SlotUnused(armor, 3, 116, 35));
|
||||
this.addSlotToContainer(new SlotUnused(armor, 4, 152, 17));
|
||||
this.addSlotToContainer(new SlotUnused(armor, 5, 152, 35));
|
||||
this.addSlotToContainer(new SlotCanister(armor, 6, 152, 53));
|
||||
/* Player inventory */
|
||||
this.addSlotToContainer(new SlotCanister(armor, 4, 152, 53));
|
||||
this.addSlotToContainer(new SlotCanister(armor, 5, 152, 35));
|
||||
this.addSlotToContainer(new SlotCanister(armor, 6, 152, 17)); /* Player inventory */
|
||||
for (int playerArmor = 0; playerArmor < 4; ++playerArmor)
|
||||
{
|
||||
this.addSlotToContainer(new SlotArmorCopy(this, inventoryplayer, inventoryplayer.getSizeInventory() - 1 - playerArmor, 98, 8 + playerArmor * 18, playerArmor));
|
||||
|
||||
@@ -4,13 +4,16 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.items.armor.HeartCanister;
|
||||
import tconstruct.library.armor.IHealthAccessory;
|
||||
|
||||
public class SlotCanister extends Slot
|
||||
{
|
||||
private final int slotID;
|
||||
|
||||
public SlotCanister(IInventory par2IInventory, int par3, int par4, int par5)
|
||||
{
|
||||
super(par2IInventory, par3, par4, par5);
|
||||
this.slotID = par3;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,6 +34,7 @@ public class SlotCanister extends Slot
|
||||
public boolean isItemValid (ItemStack par1ItemStack)
|
||||
{
|
||||
Item item = (par1ItemStack == null ? null : par1ItemStack.getItem());
|
||||
return item != null && (item instanceof HeartCanister);
|
||||
return item != null && (item instanceof IHealthAccessory) && ((IHealthAccessory) item).canEquipItem(par1ItemStack, this.slotID);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,29 +4,37 @@ import java.util.List;
|
||||
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.armor.IHealthAccessory;
|
||||
import tconstruct.util.player.ArmorExtended;
|
||||
import tconstruct.util.player.TPlayerStats;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class HeartCanister extends CraftingItem
|
||||
public class HeartCanister extends CraftingItem implements IHealthAccessory
|
||||
{
|
||||
|
||||
public HeartCanister()
|
||||
{
|
||||
super(new String[] { "empty", "miniheart.red", "heart" }, new String[] { "canister_empty", "miniheart_red", "canister_heart" }, "", "tinker", TConstructRegistry.materialTab);
|
||||
super(new String[] { "empty", "miniheart.red", "red", "miniheart.yellow", "yellow", "miniheart.green", "green" }, new String[] { "canister_empty", "miniheart_red", "canister_red",
|
||||
"miniheart_yellow", "canister_yellow", "miniheart_green", "canister_green" }, "", "tinker", TConstructRegistry.materialTab);
|
||||
this.setMaxStackSize(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote && stack.getItemDamage() == 2)
|
||||
int meta = stack.getItemDamage();
|
||||
if (meta == 1 || meta == 3 || meta == 5)
|
||||
{
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
}
|
||||
if (!world.isRemote && meta == 2)
|
||||
{
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.getDisplayName());
|
||||
if (stats != null)
|
||||
@@ -49,24 +57,64 @@ public class HeartCanister extends CraftingItem
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onEaten (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
int meta = stack.getItemDamage();
|
||||
--stack.stackSize;
|
||||
player.heal((meta + 1) * 5);
|
||||
world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction (ItemStack par1ItemStack)
|
||||
{
|
||||
return EnumAction.eat;
|
||||
}
|
||||
|
||||
public int getMaxItemUseDuration (ItemStack par1ItemStack)
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
switch (stack.getItemDamage())
|
||||
int meta = stack.getItemDamage();
|
||||
if (meta == 0 || meta % 2 == 1)
|
||||
list.add(StatCollector.translateToLocal("item.crafting.tooltip"));
|
||||
else
|
||||
{
|
||||
list.add(StatCollector.translateToLocal("item.accessory.tooltip"));
|
||||
list.add(StatCollector.translateToLocal("canister.tooltip"));
|
||||
}
|
||||
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
list.add(StatCollector.translateToLocal("hearthcanister1.tooltip"));
|
||||
break;
|
||||
case 1:
|
||||
list.add(StatCollector.translateToLocal("hearthcanister2.tooltip"));
|
||||
list.add(StatCollector.translateToLocal("hearthcanister3.tooltip"));
|
||||
list.add(StatCollector.translateToLocal("canister.red.tooltip1"));
|
||||
list.add(StatCollector.translateToLocal("canister.red.tooltip2"));
|
||||
break;
|
||||
case 2:
|
||||
list.add(StatCollector.translateToLocal("hearthcanister4.tooltip"));
|
||||
list.add(StatCollector.translateToLocal("hearthcanister5.tooltip"));
|
||||
list.add(StatCollector.translateToLocal("canister.green.tooltip1"));
|
||||
list.add(StatCollector.translateToLocal("canister.green.tooltip2"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquipItem (ItemStack item, int slot)
|
||||
{
|
||||
int type = item.getItemDamage();
|
||||
return ((type == 2 && slot == 6) || (type == 4 && slot == 5) || (type == 6 && slot == 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHealthBoost (ItemStack item)
|
||||
{
|
||||
return item.stackSize * 2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IHealthAccessory
|
||||
{
|
||||
public boolean canEquipItem (ItemStack item, int slot);
|
||||
|
||||
public int getHealthBoost (ItemStack item);
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.IEntityLivingData;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
@@ -47,6 +49,7 @@ import tconstruct.achievements.TAchievements;
|
||||
import tconstruct.blocks.LiquidMetalFinite;
|
||||
import tconstruct.blocks.TankAirBlock;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.entity.BlueSlime;
|
||||
import tconstruct.items.tools.FryingPan;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.event.PartBuilderEvent;
|
||||
@@ -275,15 +278,25 @@ public class TEventHandler
|
||||
}
|
||||
}
|
||||
|
||||
if (random.nextInt(500) == 0 && event.entityLiving instanceof IMob)
|
||||
if (random.nextInt(200) == 0 && event.entityLiving instanceof IMob && event.source.damageType.equals("player"))
|
||||
{
|
||||
ItemStack dropStack = new ItemStack(TRepo.heartCanister, 1, 1);
|
||||
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
event.drops.add(entityitem);
|
||||
if (event.entityLiving instanceof BlueSlime)
|
||||
{
|
||||
BlueSlime slime = (BlueSlime) event.entityLiving;
|
||||
if (slime.getSlimeSize() < 8)
|
||||
return;
|
||||
}
|
||||
int count = event.entityLiving instanceof EntityDragon ? 5 : 1;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
ItemStack dropStack = new ItemStack(TRepo.heartCanister, 1, 3);
|
||||
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.entityLiving instanceof EntityWither && random.nextInt(5) == 0)
|
||||
if (event.entityLiving instanceof IBossDisplayData)
|
||||
{
|
||||
ItemStack dropStack = new ItemStack(TRepo.heartCanister, 1, 1);
|
||||
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
|
||||
@@ -293,19 +306,16 @@ public class TEventHandler
|
||||
|
||||
if (!event.entityLiving.isChild() && event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot"))
|
||||
{
|
||||
|
||||
if (event.entityLiving.getClass() == EntityCow.class)
|
||||
{
|
||||
int amount = random.nextInt(3) + random.nextInt(1 +
|
||||
event.lootingLevel) + random.nextInt(3) + random.nextInt(1 +
|
||||
event.lootingLevel) + 1;
|
||||
|
||||
for (int iter = 0; iter < amount; ++iter)
|
||||
{
|
||||
addDrops(event, new ItemStack(Items.leather, 1));
|
||||
}
|
||||
|
||||
if (event.entityLiving.getClass() == EntityCow.class)
|
||||
{
|
||||
int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1;
|
||||
|
||||
for (int iter = 0; iter < amount; ++iter)
|
||||
{
|
||||
addDrops(event, new ItemStack(Items.leather, 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (event.entityLiving.getClass() == EntityChicken.class)
|
||||
{
|
||||
@@ -364,13 +374,12 @@ public class TEventHandler
|
||||
addDrops(event, new ItemStack(Items.skull, 1, 2));
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getItem() == TRepo.cleaver &&
|
||||
random.nextInt(100) < 10) //Swap out for real beheading
|
||||
{
|
||||
addDrops(event, new ItemStack(Items.skull, 1, 2));
|
||||
}
|
||||
|
||||
|
||||
if (stack.getItem() == TRepo.cleaver && random.nextInt(100) < 10) //Swap out for real beheading
|
||||
{
|
||||
addDrops(event, new ItemStack(Items.skull, 1, 2));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,31 +622,29 @@ public class TEventHandler
|
||||
}
|
||||
|
||||
// TODO 1.7 Fix this -- for ticking stuffs in extra armor slots
|
||||
|
||||
@SubscribeEvent
|
||||
public void livingUpdate (LivingUpdateEvent event)
|
||||
{ if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.getDisplayName());
|
||||
|
||||
if (stats != null && stats.armor != null)
|
||||
{
|
||||
ArmorExtended armor = stats.armor;
|
||||
for (int i = 0; i < armor.getSizeInventory(); i++)
|
||||
{
|
||||
if (armor.getStackInSlot(i) != null)
|
||||
{
|
||||
armor.getStackInSlot(i).getItem().onUpdate(armor.getStackInSlot(i),
|
||||
player.worldObj, player, i, false);
|
||||
armor.getStackInSlot(i).getItem().onArmorTick(player.worldObj, player,
|
||||
armor.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void livingUpdate (LivingUpdateEvent event)
|
||||
{
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.getDisplayName());
|
||||
|
||||
if (stats != null && stats.armor != null)
|
||||
{
|
||||
ArmorExtended armor = stats.armor;
|
||||
for (int i = 0; i < armor.getSizeInventory(); i++)
|
||||
{
|
||||
if (armor.getStackInSlot(i) != null)
|
||||
{
|
||||
armor.getStackInSlot(i).getItem().onUpdate(armor.getStackInSlot(i), player.worldObj, player, i, false);
|
||||
armor.getStackInSlot(i).getItem().onArmorTick(player.worldObj, player, armor.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Player interact event - prevent breaking of tank air blocks in creative
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package tconstruct.util.network.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class PacketArmorSync extends AbstractPacket
|
||||
{
|
||||
ByteBuf b;
|
||||
|
||||
@Override
|
||||
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte packetID = buffer.readByte();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TConstruct.logger.warn("Failed at reading server packet for TConstruct.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
try
|
||||
{
|
||||
TProxyClient.armorExtended.readInventoryFromStream(buffer);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide (EntityPlayer player)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
TProxyClient.armorExtended.recalculateHealth(player, TConstruct.playerTracker.getPlayerStats(player.getDisplayName()));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -141,6 +141,7 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
|
||||
registerPacket(PacketSmeltery.class);
|
||||
registerPacket(PacketStencilTable.class);
|
||||
registerPacket(PacketToolStation.class);
|
||||
registerPacket(PacketArmorSync.class);
|
||||
}
|
||||
|
||||
// Method to call from FMLPostInitializationEvent
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package tconstruct.util.player;
|
||||
|
||||
import static io.netty.buffer.Unpooled.*;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Random;
|
||||
@@ -54,6 +57,7 @@ public class TPlayerHandler
|
||||
public void onPlayerChangedDimension (PlayerChangedDimensionEvent event)
|
||||
{
|
||||
savePlayerStats(event.player, false);
|
||||
updatePlayerInventory(event.player, getPlayerStats(event.player.getDisplayName()));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -150,26 +154,32 @@ public class TPlayerHandler
|
||||
updatePlayerInventory(entityplayer, stats);
|
||||
}
|
||||
|
||||
void updatePlayerInventory (EntityPlayer entityplayer, TPlayerStats stats)
|
||||
void updatePlayerInventory (EntityPlayer player, TPlayerStats stats)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void updateClientPlayer (ByteArrayOutputStream bos, EntityPlayer player)
|
||||
{
|
||||
/*
|
||||
* Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
* packet.channel = "TConstruct"; packet.data = bos.toByteArray();
|
||||
* packet.length = bos.size();
|
||||
*
|
||||
* PacketDispatcher.sendPacketToPlayer(packet, (Player) player);
|
||||
*/
|
||||
// TODO find out what packet needs to be used here (and make sure that
|
||||
// player actually is a playerMP and this gets called)
|
||||
ByteBuf outputStream = buffer(8);
|
||||
try
|
||||
{
|
||||
outputStream.writeByte(4);
|
||||
stats.armor.writeInventoryToStream(outputStream);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
TConstruct.packetPipeline.sendTo(new PacketDoubleJump(), (EntityPlayerMP) player);
|
||||
}
|
||||
/*
|
||||
* Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
* packet.channel = "TConstruct"; packet.data = bos.toByteArray();
|
||||
* packet.length = bos.size();
|
||||
*
|
||||
* PacketDispatcher.sendPacketToPlayer(packet, (Player) player);
|
||||
*/
|
||||
// TODO find out what packet needs to be used here (and make sure that
|
||||
// player actually is a playerMP and this gets called)
|
||||
|
||||
}
|
||||
|
||||
void savePlayerStats (EntityPlayer player, boolean clean)
|
||||
@@ -221,6 +231,7 @@ public class TPlayerHandler
|
||||
if (PHConstruct.keepHunger)
|
||||
entityplayer.getFoodStats().setFoodLevel(stats.hunger);
|
||||
}
|
||||
updatePlayerInventory(entityplayer, getPlayerStats(entityplayer.getDisplayName()));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
Reference in new issue
Block a user