Backported life shard fixes.
This commit is contained in:
parent
6b4f4d809c
commit
bb7fe747f2
|
@ -33,7 +33,7 @@ public class ItemLifeShard extends Item {
|
|||
}
|
||||
|
||||
if (playerAether.getShardsUsed() < playerAether.getMaxShardCount()) {
|
||||
playerAether.updateShardCount(playerAether.getShardsUsed() + 1);
|
||||
playerAether.updateShardCount(1);
|
||||
|
||||
--heldItem.stackSize;
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@ public class AetherNetwork {
|
|||
INSTANCE.registerMessage(PacketCheckKey.class, PacketCheckKey.class, discriminant++, Side.SERVER);
|
||||
|
||||
INSTANCE.registerMessage(PacketSwetJump.class, PacketSwetJump.class, discriminant++, Side.CLIENT);
|
||||
|
||||
INSTANCE.registerMessage(PacketUpdateLifeShardCount.class, PacketUpdateLifeShardCount.class, discriminant++, Side.CLIENT);
|
||||
}
|
||||
|
||||
public static void sendToAll(IMessage message) {
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package com.gildedgames.the_aether.network.packets;
|
||||
|
||||
import com.gildedgames.the_aether.api.AetherAPI;
|
||||
import com.gildedgames.the_aether.api.player.IPlayerAether;
|
||||
import com.gildedgames.the_aether.player.PlayerAether;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class PacketUpdateLifeShardCount extends AetherPacket<PacketUpdateLifeShardCount>
|
||||
{
|
||||
private int entityID;
|
||||
|
||||
private int count;
|
||||
|
||||
public PacketUpdateLifeShardCount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PacketUpdateLifeShardCount(EntityPlayer thePlayer, int count)
|
||||
{
|
||||
this.entityID = thePlayer.getEntityId();
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
this.entityID = buf.readInt();
|
||||
this.count = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt(this.entityID);
|
||||
buf.writeInt(this.count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClient(PacketUpdateLifeShardCount message, EntityPlayer player)
|
||||
{
|
||||
if (player != null && player.worldObj != null)
|
||||
{
|
||||
Entity entity = player.worldObj.getEntityByID(message.entityID);
|
||||
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer parent = (EntityPlayer) entity;
|
||||
|
||||
IPlayerAether iPlayerAether = AetherAPI.get(parent);
|
||||
|
||||
if (iPlayerAether != null)
|
||||
{
|
||||
PlayerAether playerAether = (PlayerAether) iPlayerAether;
|
||||
|
||||
playerAether.shardCount = message.count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServer(PacketUpdateLifeShardCount message, EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ public class PlayerAether implements IPlayerAether {
|
|||
|
||||
public final ArrayList<Entity> clouds = new ArrayList<Entity>(2);
|
||||
|
||||
private int shardCount;
|
||||
public int shardCount;
|
||||
|
||||
public DonatorMoaSkin donatorMoaSkin = new DonatorMoaSkin();
|
||||
|
||||
|
@ -99,6 +99,10 @@ public class PlayerAether implements IPlayerAether {
|
|||
|
||||
public int poisonTime = 0, cureTime = 0;
|
||||
|
||||
private UUID uuid = UUID.fromString("df6eabe7-6947-4a56-9099-002f90370706");
|
||||
|
||||
private AttributeModifier healthModifier;
|
||||
|
||||
public PlayerAether() {
|
||||
this.shouldRenderHalo = true;
|
||||
this.shouldRenderGlow = false;
|
||||
|
@ -118,6 +122,8 @@ public class PlayerAether implements IPlayerAether {
|
|||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
System.out.println("s " + this.shardCount);
|
||||
|
||||
if (!this.player.worldObj.isRemote)
|
||||
{
|
||||
AetherNetwork.sendToAll(new PacketPerkChanged(this.getEntity().getEntityId(), EnumAetherPerkType.Halo, this.shouldRenderHalo));
|
||||
|
@ -502,7 +508,11 @@ public class PlayerAether implements IPlayerAether {
|
|||
this.shouldGetPortal = aetherTag.getBoolean("get_portal");
|
||||
}
|
||||
|
||||
this.updateShardCount(aetherTag.getInteger("shardCount"));
|
||||
if (aetherTag.hasKey("shardCount"))
|
||||
{
|
||||
this. shardCount = aetherTag.getInteger("shardCount");
|
||||
}
|
||||
|
||||
this.getAccessoryInventory().readFromNBT(aetherTag.getTagList("accessories", 10));
|
||||
this.setBedLocation(new ChunkCoordinates(aetherTag.getInteger("bedX"), aetherTag.getInteger("bedY"), aetherTag.getInteger("bedZ")));
|
||||
}
|
||||
|
@ -539,16 +549,24 @@ public class PlayerAether implements IPlayerAether {
|
|||
|
||||
@Override
|
||||
public void updateShardCount(int amount) {
|
||||
UUID uuid = UUID.fromString("df6eabe7-6947-4a56-9099-002f90370706");
|
||||
AttributeModifier healthModifier = new AttributeModifier(uuid, "Aether Health Modifier", amount * 2.0D, 0);
|
||||
|
||||
this.shardCount = amount;
|
||||
if (!this.getEntity().worldObj.isRemote)
|
||||
{
|
||||
if (this.getShardsUsed() < this.getMaxShardCount())
|
||||
{
|
||||
this.shardCount += amount;
|
||||
AetherNetwork.sendToAll(new PacketUpdateLifeShardCount(this.player, this.shardCount));
|
||||
|
||||
if (this.getEntity().getEntityAttribute(SharedMonsterAttributes.maxHealth).getModifier(uuid) != null) {
|
||||
this.getEntity().getEntityAttribute(SharedMonsterAttributes.maxHealth).removeModifier(healthModifier);
|
||||
this.healthModifier = new AttributeModifier(uuid, "Aether Health Modifier", (this.shardCount * 2.0D), 0);
|
||||
|
||||
if (this.player.getEntityAttribute(SharedMonsterAttributes.maxHealth).getModifier(this.uuid) != null)
|
||||
{
|
||||
this.player.getEntityAttribute(SharedMonsterAttributes.maxHealth).removeModifier(this.healthModifier);
|
||||
}
|
||||
|
||||
this.player.getEntityAttribute(SharedMonsterAttributes.maxHealth).applyModifier(this.healthModifier);
|
||||
}
|
||||
}
|
||||
|
||||
this.getEntity().getEntityAttribute(SharedMonsterAttributes.maxHealth).applyModifier(healthModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public class PlayerAetherEvents {
|
|||
PlayerAether playerAether = PlayerAether.get(event.player);
|
||||
|
||||
AetherNetwork.sendTo(new PacketAccessory(playerAether), (EntityPlayerMP) event.player);
|
||||
playerAether.updateShardCount(playerAether.getShardsUsed());
|
||||
playerAether.updateShardCount(0);
|
||||
|
||||
if (!AetherConfig.shouldAetherStart())
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public class PlayerAetherEvents {
|
|||
PlayerAether original = PlayerAether.get(event.original);
|
||||
PlayerAether playerAether = PlayerAether.get(event.entityPlayer);
|
||||
|
||||
playerAether.updateShardCount(original.getShardsUsed());
|
||||
playerAether.shardCount = original.shardCount;
|
||||
|
||||
if (!event.wasDeath || event.entityPlayer.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
|
||||
playerAether.setAccessoryInventory(original.getAccessoryInventory());
|
||||
|
@ -85,7 +85,9 @@ public class PlayerAetherEvents {
|
|||
PlayerAether playerAether = PlayerAether.get(event.player);
|
||||
|
||||
AetherNetwork.sendTo(new PacketAccessory(playerAether), (EntityPlayerMP) event.player);
|
||||
playerAether.updateShardCount(playerAether.getShardsUsed());
|
||||
|
||||
playerAether.updateShardCount(0);
|
||||
event.player.setHealth(event.player.getMaxHealth());
|
||||
|
||||
playerAether.isPoisoned = false;
|
||||
playerAether.poisonTime = 0;
|
||||
|
@ -100,7 +102,7 @@ public class PlayerAetherEvents {
|
|||
PlayerAether playerAether = PlayerAether.get(event.player);
|
||||
|
||||
AetherNetwork.sendTo(new PacketAccessory(playerAether), (EntityPlayerMP) event.player);
|
||||
playerAether.updateShardCount(playerAether.getShardsUsed());
|
||||
playerAether.updateShardCount(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue