diff --git a/src/main/java/com/gildedgames/the_aether/player/PlayerAether.java b/src/main/java/com/gildedgames/the_aether/player/PlayerAether.java index 8712c98..8d9c811 100644 --- a/src/main/java/com/gildedgames/the_aether/player/PlayerAether.java +++ b/src/main/java/com/gildedgames/the_aether/player/PlayerAether.java @@ -9,16 +9,25 @@ import com.gildedgames.the_aether.api.player.IPlayerAether; import com.gildedgames.the_aether.api.player.util.IAccessoryInventory; import com.gildedgames.the_aether.api.player.util.IAetherAbility; import com.gildedgames.the_aether.api.player.util.IAetherBoss; +import com.gildedgames.the_aether.blocks.BlocksAether; import com.gildedgames.the_aether.entities.passive.mountable.EntityParachute; import com.gildedgames.the_aether.inventory.InventoryAccessories; -import com.gildedgames.the_aether.network.packets.*; -import com.gildedgames.the_aether.registry.achievements.AchievementsAether; import com.gildedgames.the_aether.items.ItemsAether; +import com.gildedgames.the_aether.items.tools.ItemValkyrieTool; import com.gildedgames.the_aether.network.AetherNetwork; +import com.gildedgames.the_aether.network.packets.*; +import com.gildedgames.the_aether.player.abilities.AbilityAccessories; +import com.gildedgames.the_aether.player.abilities.AbilityArmor; +import com.gildedgames.the_aether.player.abilities.AbilityFlight; +import com.gildedgames.the_aether.player.abilities.AbilityRepulsion; import com.gildedgames.the_aether.player.perks.AetherRankings; +import com.gildedgames.the_aether.player.perks.util.DonatorMoaSkin; import com.gildedgames.the_aether.player.perks.util.EnumAetherPerkType; +import com.gildedgames.the_aether.registry.achievements.AchievementsAether; +import com.gildedgames.the_aether.world.TeleporterAether; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.block.Block; -import net.minecraft.client.resources.I18n; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; @@ -33,55 +42,44 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.*; import net.minecraft.world.World; -import com.gildedgames.the_aether.blocks.BlocksAether; -import com.gildedgames.the_aether.items.tools.ItemValkyrieTool; -import com.gildedgames.the_aether.player.abilities.AbilityAccessories; -import com.gildedgames.the_aether.player.abilities.AbilityArmor; -import com.gildedgames.the_aether.player.abilities.AbilityFlight; -import com.gildedgames.the_aether.player.abilities.AbilityRepulsion; -import com.gildedgames.the_aether.player.perks.util.DonatorMoaSkin; -import com.gildedgames.the_aether.world.TeleporterAether; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.ReflectionHelper; - public class PlayerAether implements IPlayerAether { + private EntityPlayer player; - private EntityPlayer player; + private IAetherBoss focusedBoss; - private IAetherBoss focusedBoss; + private IAccessoryInventory accessories = new InventoryAccessories(this); - private IAccessoryInventory accessories = new InventoryAccessories(this); + private final ArrayList abilities = new ArrayList(); - private final ArrayList abilities = new ArrayList(); + public final ArrayList clouds = new ArrayList(2); - public final ArrayList clouds = new ArrayList(2); + public int shardCount; - public int shardCount; + public DonatorMoaSkin donatorMoaSkin = new DonatorMoaSkin(); - public DonatorMoaSkin donatorMoaSkin = new DonatorMoaSkin(); + public boolean shouldRenderHalo, shouldRenderGlow, shouldRenderCape; + public boolean shouldRenderHaloPrev, shouldRenderGlowPrev, shouldRenderCapePrev; - public boolean shouldRenderHalo, shouldRenderGlow, shouldRenderCape; + public boolean seenSpiritDialog = false; + public boolean seenSpiritDialogPrev = true; - public boolean seenSpiritDialog = false; + private boolean isJumping; - private boolean isJumping; + private boolean isMountSneaking; - private boolean isMountSneaking; + private boolean inPortal; - private boolean inPortal; + private int portalCounter; - private int portalCounter; + public int teleportDirection; - public int teleportDirection; + private String hammerName = StatCollector.translateToLocal("item.notch_hammer.name"); - private String hammerName = StatCollector.translateToLocal("item.notch_hammer.name"); + private int cooldown; - private int cooldown; + private int cooldownMax; - private int cooldownMax; - - public float wingSinage; + public float wingSinage; public float timeInPortal; @@ -91,198 +89,206 @@ public class PlayerAether implements IPlayerAether { private ChunkCoordinates bedLocation; - public boolean isPoisoned = false, isCured = false; + public boolean isPoisoned = false, isCured = false; - public boolean shouldGetPortal; + public boolean shouldGetPortal; + public boolean shouldGetPortalPrev; - public int poisonTime = 0, cureTime = 0; + public int poisonTime = 0, cureTime = 0; + public int poisonTimePrev = -1; - private UUID uuid = UUID.fromString("df6eabe7-6947-4a56-9099-002f90370706"); + private UUID uuid = UUID.fromString("df6eabe7-6947-4a56-9099-002f90370706"); - private AttributeModifier healthModifier; + private AttributeModifier healthModifier; - public PlayerAether() { - this.shouldRenderHalo = true; - this.shouldRenderGlow = false; - this.shouldRenderCape = true; - this.shouldGetPortal = true; - this.abilities.addAll(Arrays.asList(new AbilityAccessories(this), new AbilityArmor(this), new AbilityFlight(this), new AbilityRepulsion(this))); - } + public PlayerAether() { + this.shouldRenderHalo = true; + this.shouldRenderHaloPrev = !this.shouldRenderHalo; - public static PlayerAether get(EntityPlayer player) { - return (PlayerAether) player.getExtendedProperties("aether_legacy:player_aether"); - } + this.shouldRenderGlow = false; + this.shouldRenderGlowPrev = !this.shouldRenderGlow; - @Override - public void init(Entity entity, World world) { - this.player = (EntityPlayer) entity; - } + this.shouldRenderCape = true; + this.shouldRenderCapePrev = !this.shouldRenderCape; - @Override - public void onUpdate() { - if (!this.player.worldObj.isRemote) - { - AetherNetwork.sendToAll(new PacketPerkChanged(this.getEntity().getEntityId(), EnumAetherPerkType.Halo, this.shouldRenderHalo)); - AetherNetwork.sendToAll(new PacketPerkChanged(this.getEntity().getEntityId(), EnumAetherPerkType.Glow, this.shouldRenderGlow)); - AetherNetwork.sendToAll(new PacketCapeChanged(this.getEntity().getEntityId(), this.shouldRenderCape)); - AetherNetwork.sendToAll(new PacketSendPoisonTime(this.getEntity(), this.poisonTime)); - AetherNetwork.sendToAll(new PacketSendSeenDialogue(this.getEntity(), this.seenSpiritDialog)); - AetherNetwork.sendToAll(new PacketPortalItem(this.getEntity(), this.shouldGetPortal)); - } + this.shouldGetPortal = true; + this.shouldGetPortalPrev = !this.shouldGetPortal; - if (this.isPoisoned) - { - if (poisonTime > 0) - { - this.poisonTime--; - } - else - { - this.poisonTime = 0; - this.isPoisoned = false; - } - } + this.abilities.addAll(Arrays.asList( + new AbilityAccessories(this), + new AbilityArmor(this), + new AbilityFlight(this), + new AbilityRepulsion(this) + )); + } - if (this.isCured) - { - if (cureTime > 0) - { - this.cureTime--; - } - else - { - this.cureTime = 0; - this.isCured = false; - } - } + public static PlayerAether get(EntityPlayer player) { + return (PlayerAether) player.getExtendedProperties("aether_legacy:player_aether"); + } - for (int i = 0; i < this.getAbilities().size(); ++i) { - IAetherAbility ability = this.getAbilities().get(i); + @Override + public void init(Entity entity, World world) { + this.player = (EntityPlayer) entity; + } - if (ability.shouldExecute()) { - ability.onUpdate(); - } - } + @Override + public void onUpdate() { + if (!this.player.worldObj.isRemote) { + sendPackets(); + } - for (int i = 0; i < this.clouds.size(); ++i) { - Entity entity = this.clouds.get(i); + if (this.isPoisoned) { + if (poisonTime > 0) { + this.poisonTime--; + } else { + this.poisonTime = 0; + this.isPoisoned = false; + } + } - if (entity.isDead) { - this.clouds.remove(i); - } - } + if (this.isCured) { + if (cureTime > 0) { + this.cureTime--; + } else { + this.cureTime = 0; + this.isCured = false; + } + } - if (this.cooldown > 0) { - this.cooldown -= 2; - } + for (int i = 0; i < this.getAbilities().size(); ++i) { + IAetherAbility ability = this.getAbilities().get(i); - if (this.isInsideBlock(BlocksAether.aercloud)) { - this.getEntity().fallDistance = 0.0F; - } + if (ability.shouldExecute()) { + ability.onUpdate(); + } + } - if (this.getEntity().motionY < -2F) - { - this.activateParachute(); - } + for (int i = 0; i < this.clouds.size(); ++i) { + Entity entity = this.clouds.get(i); - if (!this.getEntity().onGround) { - this.wingSinage += 0.75F; - } else { - this.wingSinage += 0.15F; - } + if (entity.isDead) { + this.clouds.remove(i); + } + } - if (this.wingSinage > 3.141593F * 2F) { - this.wingSinage -= 3.141593F * 2F; - } else { - this.wingSinage += 0.1F; - } + if (this.cooldown > 0) { + this.cooldown -= 2; + } - boolean hasJumped = ReflectionHelper.getPrivateValue(EntityLivingBase.class, this.getEntity(), "isJumping", "field_70703_bu"); + if (this.isInsideBlock(BlocksAether.aercloud)) { + this.getEntity().fallDistance = 0.0F; + } - this.setJumping(hasJumped); + if (this.getEntity().motionY < -2F) { + this.activateParachute(); + } - this.getEntity().worldObj.theProfiler.startSection("portal"); + if (!this.getEntity().onGround) { + this.wingSinage += 0.75F; + } else { + this.wingSinage += 0.15F; + } - if (this.getEntity().dimension == AetherConfig.getAetherDimensionID()) { - if (this.getEntity().posY < -2) { - this.teleportPlayer(false); + if (this.wingSinage > 3.141593F * 2F) { + this.wingSinage -= 3.141593F * 2F; + } else { + this.wingSinage += 0.1F; + } - if (this.riddenEntity != null) - { - this.getEntity().mountEntity(this.riddenEntity); - this.riddenEntity = null; - } - } - } + boolean hasJumped = ReflectionHelper.getPrivateValue( + EntityLivingBase.class, this.getEntity(), "isJumping", "field_70703_bu" + ); - if (this.inPortal) { - if (this.getEntity().timeUntilPortal <= 0) { - int limit = this.getEntity().getMaxInPortalTime(); + this.setJumping(hasJumped); - if (this.getEntity().ridingEntity == null) { - if (this.portalCounter >= limit) - { - this.portalCounter = 0; - this.getEntity().timeUntilPortal = this.getEntity().getPortalCooldown(); + this.getEntity().worldObj.theProfiler.startSection("portal"); - if (!this.getEntity().worldObj.isRemote) { - this.teleportPlayer(true); - this.getEntity().triggerAchievement(AchievementsAether.enter_aether); - } - } - else - { - this.portalCounter++; - } - } - } - else - { - this.getEntity().timeUntilPortal = this.getEntity().getPortalCooldown(); - } + if (this.getEntity().dimension == AetherConfig.getAetherDimensionID()) { + if (this.getEntity().posY < -2) { + this.teleportPlayer(false); - if (this.getEntity().worldObj.getBlock((int) this.getEntity().posX, (int) this.getEntity().posY - 1, (int) this.getEntity().posZ) != Blocks.air) - { - AxisAlignedBB playerBounding = this.getEntity().boundingBox; + if (this.riddenEntity != null) { + this.getEntity().mountEntity(this.riddenEntity); + this.riddenEntity = null; + } + } + } - if (this.getEntity().worldObj.getBlock((int) playerBounding.minX, (int) playerBounding.minY, (int) playerBounding.minZ) != BlocksAether.aether_portal - && this.getEntity().worldObj.getBlock((int) playerBounding.minX, (int) playerBounding.minY, (int) playerBounding.minZ) != BlocksAether.aether_portal) - { - this.inPortal = false; - } - } - } else { - if (this.portalCounter > 0) { - this.portalCounter -= 4; - } + if (this.inPortal) { + if (this.getEntity().timeUntilPortal <= 0) { + int limit = this.getEntity().getMaxInPortalTime(); - if (this.portalCounter < 0) { - this.portalCounter = 0; - } - } + if (this.getEntity().ridingEntity == null) { + if (this.portalCounter >= limit) { + this.portalCounter = 0; + this.getEntity().timeUntilPortal + = this.getEntity().getPortalCooldown(); - this.getEntity().worldObj.theProfiler.endSection(); + if (!this.getEntity().worldObj.isRemote) { + this.teleportPlayer(true); + this.getEntity().triggerAchievement( + AchievementsAether.enter_aether + ); + } + } else { + this.portalCounter++; + } + } + } else { + this.getEntity().timeUntilPortal = this.getEntity().getPortalCooldown(); + } - if (!this.getEntity().worldObj.isRemote) { - ItemStack stack = this.getEntity().getCurrentEquippedItem(); + if (this.getEntity().worldObj.getBlock( + (int) this.getEntity().posX, + (int) this.getEntity().posY - 1, + (int) this.getEntity().posZ + ) + != Blocks.air) { + AxisAlignedBB playerBounding = this.getEntity().boundingBox; - double distance = this.getEntity().capabilities.isCreativeMode ? 5.0D : 4.5D; + if (this.getEntity().worldObj.getBlock( + (int) playerBounding.minX, + (int) playerBounding.minY, + (int) playerBounding.minZ + ) != BlocksAether.aether_portal + && this.getEntity().worldObj.getBlock( + (int) playerBounding.minX, + (int) playerBounding.minY, + (int) playerBounding.minZ + ) != BlocksAether.aether_portal) { + this.inPortal = false; + } + } + } else { + if (this.portalCounter > 0) { + this.portalCounter -= 4; + } - if (stack != null && stack.getItem() instanceof ItemValkyrieTool) { - distance = 8.0D; - } + if (this.portalCounter < 0) { + this.portalCounter = 0; + } + } - ((EntityPlayerMP) this.getEntity()).theItemInWorldManager.setBlockReachDistance(distance); - } - else { + this.getEntity().worldObj.theProfiler.endSection(); + + if (!this.getEntity().worldObj.isRemote) { + ItemStack stack = this.getEntity().getCurrentEquippedItem(); + + double distance = this.getEntity().capabilities.isCreativeMode ? 5.0D : 4.5D; + + if (stack != null && stack.getItem() instanceof ItemValkyrieTool) { + distance = 8.0D; + } + + ((EntityPlayerMP) this.getEntity()) + .theItemInWorldManager.setBlockReachDistance(distance); + } else { this.prevTimeInPortal = this.timeInPortal; - if (this.isInsideBlock(BlocksAether.aether_portal)) - { + if (this.isInsideBlock(BlocksAether.aether_portal)) { this.timeInPortal += 0.0125F; - if (this.timeInPortal >= 1.0F) - { + if (this.timeInPortal >= 1.0F) { this.timeInPortal = 1.0F; } } @@ -290,388 +296,440 @@ public class PlayerAether implements IPlayerAether { { this.timeInPortal += 0.006666667F; - if (this.timeInPortal > 1.0F) - { + if (this.timeInPortal > 1.0F) { this.timeInPortal = 1.0F; } - } - else - { - if (this.timeInPortal > 0.0F) - { + } else { + if (this.timeInPortal > 0.0F) { this.timeInPortal -= 0.05F; } - if (this.timeInPortal < 0.0F) - { + if (this.timeInPortal < 0.0F) { this.timeInPortal = 0.0F; } } - } + } - if (!player.worldObj.isRemote) - { - if (this.bedLocation != null) - { - if (player.dimension == AetherConfig.getAetherDimensionID()) - { - if (player.worldObj.getBlock(this.bedLocation.posX, this.bedLocation.posY, this.bedLocation.posZ) != BlocksAether.skyroot_bed) - { - this.setBedLocation(null); - } - } - } - } - } + if (!player.worldObj.isRemote) { + if (this.bedLocation != null) { + if (player.dimension == AetherConfig.getAetherDimensionID()) { + if (player.worldObj.getBlock( + this.bedLocation.posX, + this.bedLocation.posY, + this.bedLocation.posZ + ) + != BlocksAether.skyroot_bed) { + this.setBedLocation(null); + } + } + } + } + } - @Override - public void setInPortal() { - double d0 = this.getEntity().prevPosX - this.getEntity().posX; - double d1 = this.getEntity().prevPosZ - this.getEntity().posZ; + @Override + public void setInPortal() { + double d0 = this.getEntity().prevPosX - this.getEntity().posX; + double d1 = this.getEntity().prevPosZ - this.getEntity().posZ; - if (!this.getEntity().worldObj.isRemote && !this.inPortal) { - this.teleportDirection = Direction.getMovementDirection(d0, d1); - } + if (!this.getEntity().worldObj.isRemote && !this.inPortal) { + this.teleportDirection = Direction.getMovementDirection(d0, d1); + } - this.inPortal = true; - } + this.inPortal = true; + } - private void activateParachute() - { - if (!this.player.capabilities.isCreativeMode) - { - EntityParachute parachute = null; + private void activateParachute() { + if (!this.player.capabilities.isCreativeMode) { + EntityParachute parachute = null; - ItemStack itemstack = null; + ItemStack itemstack = null; - for (int i = 0; i < this.getEntity().inventory.getSizeInventory(); i++) - { - ItemStack stackInSlot = this.getEntity().inventory.getStackInSlot(i); + for (int i = 0; i < this.getEntity().inventory.getSizeInventory(); i++) { + ItemStack stackInSlot = this.getEntity().inventory.getStackInSlot(i); - if(stackInSlot != null && stackInSlot.getItem() == ItemsAether.cloud_parachute) - { - itemstack = stackInSlot; - break; - } - else - { - if (stackInSlot != null && stackInSlot.getItem() == ItemsAether.golden_parachute) - { - itemstack = stackInSlot; - break; - } - } - } + if (stackInSlot != null + && stackInSlot.getItem() == ItemsAether.cloud_parachute) { + itemstack = stackInSlot; + break; + } else { + if (stackInSlot != null + && stackInSlot.getItem() == ItemsAether.golden_parachute) { + itemstack = stackInSlot; + break; + } + } + } - if (itemstack != null) - { - if (itemstack.getItem() == ItemsAether.cloud_parachute) - { - parachute = new EntityParachute(this.getEntity().worldObj, this.getEntity(), false); - parachute.setPosition(this.getEntity().posX, this.getEntity().posY, this.getEntity().posZ); - this.getEntity().worldObj.spawnEntityInWorld(parachute); - this.getEntity().inventory.consumeInventoryItem(itemstack.getItem()); - } - else - { - if (itemstack.getItem() == ItemsAether.golden_parachute) - { - itemstack.damageItem(1, this.getEntity()); - parachute = new EntityParachute(this.getEntity().worldObj, this.getEntity(), true); - parachute.setPosition(this.getEntity().posX, this.getEntity().posY, this.getEntity().posZ); - this.getEntity().worldObj.spawnEntityInWorld(parachute); - } - } - } - } - } + if (itemstack != null) { + if (itemstack.getItem() == ItemsAether.cloud_parachute) { + parachute = new EntityParachute( + this.getEntity().worldObj, this.getEntity(), false + ); + parachute.setPosition( + this.getEntity().posX, + this.getEntity().posY, + this.getEntity().posZ + ); + this.getEntity().worldObj.spawnEntityInWorld(parachute); + this.getEntity().inventory.consumeInventoryItem(itemstack.getItem()); + } else { + if (itemstack.getItem() == ItemsAether.golden_parachute) { + itemstack.damageItem(1, this.getEntity()); + parachute = new EntityParachute( + this.getEntity().worldObj, this.getEntity(), true + ); + parachute.setPosition( + this.getEntity().posX, + this.getEntity().posY, + this.getEntity().posZ + ); + this.getEntity().worldObj.spawnEntityInWorld(parachute); + } + } + } + } + } - public boolean isInsideBlock(Block block) { - AxisAlignedBB boundingBox = this.getEntity().boundingBox; - int i = MathHelper.floor_double(boundingBox.minX); - int j = MathHelper.floor_double(boundingBox.maxX + 1.0D); - int k = MathHelper.floor_double(boundingBox.minY); - int l = MathHelper.floor_double(boundingBox.maxY + 1.0D); - int i1 = MathHelper.floor_double(boundingBox.minZ); - int j1 = MathHelper.floor_double(boundingBox.maxZ + 1.0D); + public boolean isInsideBlock(Block block) { + AxisAlignedBB boundingBox = this.getEntity().boundingBox; + int i = MathHelper.floor_double(boundingBox.minX); + int j = MathHelper.floor_double(boundingBox.maxX + 1.0D); + int k = MathHelper.floor_double(boundingBox.minY); + int l = MathHelper.floor_double(boundingBox.maxY + 1.0D); + int i1 = MathHelper.floor_double(boundingBox.minZ); + int j1 = MathHelper.floor_double(boundingBox.maxZ + 1.0D); - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = k; l1 < l; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { - if (this.getEntity().worldObj.getBlock(k1, l1, i2) == block) { - return true; - } - } - } - } + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = k; l1 < l; ++l1) { + for (int i2 = i1; i2 < j1; ++i2) { + if (this.getEntity().worldObj.getBlock(k1, l1, i2) == block) { + return true; + } + } + } + } - return false; - } + return false; + } - /* - * The teleporter which sends the player to the Aether/Overworld - */ - private void teleportPlayer(boolean shouldSpawnPortal) { - if (this.getEntity() instanceof EntityPlayerMP) { - int previousDimension = this.getEntity().dimension; - int transferDimension = previousDimension == AetherConfig.getAetherDimensionID() ? AetherConfig.getTravelDimensionID() : AetherConfig.getAetherDimensionID(); - MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - TeleporterAether teleporter = new TeleporterAether(shouldSpawnPortal, server.worldServerForDimension(transferDimension)); + /* + * The teleporter which sends the player to the Aether/Overworld + */ + private void teleportPlayer(boolean shouldSpawnPortal) { + if (this.getEntity() instanceof EntityPlayerMP) { + int previousDimension = this.getEntity().dimension; + int transferDimension + = previousDimension == AetherConfig.getAetherDimensionID() + ? AetherConfig.getTravelDimensionID() + : AetherConfig.getAetherDimensionID(); + MinecraftServer server + = FMLCommonHandler.instance().getMinecraftServerInstance(); + TeleporterAether teleporter = new TeleporterAether( + shouldSpawnPortal, server.worldServerForDimension(transferDimension) + ); - if (this.getEntity().ridingEntity != null) { - this.getEntity().ridingEntity.mountEntity(null); - } + if (this.getEntity().ridingEntity != null) { + this.getEntity().ridingEntity.mountEntity(null); + } - if (this.getEntity().riddenByEntity != null) { - this.getEntity().riddenByEntity.mountEntity(null); - } + if (this.getEntity().riddenByEntity != null) { + this.getEntity().riddenByEntity.mountEntity(null); + } - if (server != null && server.getConfigurationManager() != null) - { - server.getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) this.getEntity(), transferDimension, teleporter); - } - } - } + if (server != null && server.getConfigurationManager() != null) { + server.getConfigurationManager().transferPlayerToDimension( + (EntityPlayerMP) this.getEntity(), transferDimension, teleporter + ); + } + } + } - @Override - public void saveNBTData(NBTTagCompound compound) { - NBTTagCompound aetherTag = new NBTTagCompound(); + @Override + public void saveNBTData(NBTTagCompound compound) { + NBTTagCompound aetherTag = new NBTTagCompound(); - if (AetherRankings.isRankedPlayer(this.player.getUniqueID())) - { - aetherTag.setBoolean("halo", this.shouldRenderHalo); - } + if (AetherRankings.isRankedPlayer(this.player.getUniqueID())) { + aetherTag.setBoolean("halo", this.shouldRenderHalo); + } - if (AetherRankings.isDeveloper(this.player.getUniqueID())) - { - aetherTag.setBoolean("glow", this.shouldRenderGlow); - } + if (AetherRankings.isDeveloper(this.player.getUniqueID())) { + aetherTag.setBoolean("glow", this.shouldRenderGlow); + } - aetherTag.setBoolean("poisoned", this.isPoisoned); - aetherTag.setInteger("poison_time", this.poisonTime); - aetherTag.setBoolean("cape", this.shouldRenderCape); - aetherTag.setInteger("shardCount", this.shardCount); - aetherTag.setTag("accessories", this.getAccessoryInventory().writeToNBT(aetherTag)); - aetherTag.setBoolean("seen_spirit_dialog", this.seenSpiritDialog); - aetherTag.setBoolean("get_portal", this.shouldGetPortal); + aetherTag.setBoolean("poisoned", this.isPoisoned); + aetherTag.setInteger("poison_time", this.poisonTime); + aetherTag.setBoolean("cape", this.shouldRenderCape); + aetherTag.setInteger("shardCount", this.shardCount); + aetherTag.setTag( + "accessories", this.getAccessoryInventory().writeToNBT(aetherTag) + ); + aetherTag.setBoolean("seen_spirit_dialog", this.seenSpiritDialog); + aetherTag.setBoolean("get_portal", this.shouldGetPortal); - if (this.bedLocation != null) - { - aetherTag.setInteger("bedX", this.bedLocation.posX); - aetherTag.setInteger("bedY", this.bedLocation.posY); - aetherTag.setInteger("bedZ", this.bedLocation.posZ); - } + if (this.bedLocation != null) { + aetherTag.setInteger("bedX", this.bedLocation.posX); + aetherTag.setInteger("bedY", this.bedLocation.posY); + aetherTag.setInteger("bedZ", this.bedLocation.posZ); + } - compound.setTag("aetherI", aetherTag); - } + compound.setTag("aetherI", aetherTag); + } - @Override - public void loadNBTData(NBTTagCompound compound) { - NBTTagCompound aetherTag = compound.getCompoundTag("aetherI"); + @Override + public void loadNBTData(NBTTagCompound compound) { + NBTTagCompound aetherTag = compound.getCompoundTag("aetherI"); - if (aetherTag.hasKey("halo")) - { - this.shouldRenderHalo = aetherTag.getBoolean("halo"); - } + if (aetherTag.hasKey("halo")) { + this.shouldRenderHalo = aetherTag.getBoolean("halo"); + } - if (aetherTag.hasKey("glow")) - { - this.shouldRenderGlow = aetherTag.getBoolean("glow"); - } + if (aetherTag.hasKey("glow")) { + this.shouldRenderGlow = aetherTag.getBoolean("glow"); + } - if (aetherTag.hasKey("cape")) - { - this.shouldRenderCape = aetherTag.getBoolean("cape"); - } + if (aetherTag.hasKey("cape")) { + this.shouldRenderCape = aetherTag.getBoolean("cape"); + } - if (aetherTag.hasKey("poisoned")) - { - this.isPoisoned = aetherTag.getBoolean("poisoned"); - } + if (aetherTag.hasKey("poisoned")) { + this.isPoisoned = aetherTag.getBoolean("poisoned"); + } - if (aetherTag.hasKey("poison_time")) - { - this.poisonTime = aetherTag.getInteger("poison_time"); - } + if (aetherTag.hasKey("poison_time")) { + this.poisonTime = aetherTag.getInteger("poison_time"); + } - if (aetherTag.hasKey("seen_spirit_dialog")) - { - this.seenSpiritDialog = aetherTag.getBoolean("seen_spirit_dialog"); - } + if (aetherTag.hasKey("seen_spirit_dialog")) { + this.seenSpiritDialog = aetherTag.getBoolean("seen_spirit_dialog"); + } - if (aetherTag.hasKey("get_portal")) - { - this.shouldGetPortal = aetherTag.getBoolean("get_portal"); - } + if (aetherTag.hasKey("get_portal")) { + this.shouldGetPortal = aetherTag.getBoolean("get_portal"); + } - if (aetherTag.hasKey("shardCount")) - { - this. shardCount = 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"))); - } + this.getAccessoryInventory().readFromNBT(aetherTag.getTagList("accessories", 10)); + this.setBedLocation(new ChunkCoordinates( + aetherTag.getInteger("bedX"), + aetherTag.getInteger("bedY"), + aetherTag.getInteger("bedZ") + )); + } - @Override - public void setFocusedBoss(IAetherBoss boss) { - this.focusedBoss = boss; - } + @Override + public void setFocusedBoss(IAetherBoss boss) { + this.focusedBoss = boss; + } - @Override - public IAetherBoss getFocusedBoss() { - return this.focusedBoss; - } + @Override + public IAetherBoss getFocusedBoss() { + return this.focusedBoss; + } - @Override - public void setAccessoryInventory(IAccessoryInventory inventory) { - this.accessories = inventory; - } + @Override + public void setAccessoryInventory(IAccessoryInventory inventory) { + this.accessories = inventory; + } - @Override - public IAccessoryInventory getAccessoryInventory() { - return this.accessories; - } + @Override + public IAccessoryInventory getAccessoryInventory() { + return this.accessories; + } - @Override - public ArrayList getAbilities() { - return this.abilities; - } + @Override + public ArrayList getAbilities() { + return this.abilities; + } - @Override - public EntityPlayer getEntity() { - return this.player; - } + @Override + public EntityPlayer getEntity() { + return this.player; + } - @Override - public void updateShardCount(int amount) { + @Override + public void updateShardCount(int 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().worldObj.isRemote) - { - if (this.getShardsUsed() < this.getMaxShardCount()) - { - this.shardCount += amount; - AetherNetwork.sendToAll(new PacketUpdateLifeShardCount(this.player, this.shardCount)); + this.healthModifier = new AttributeModifier( + uuid, "Aether Health Modifier", (this.shardCount * 2.0D), 0 + ); - 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); + } - 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); + } else { + AetherNetwork.sendToAll( + new PacketUpdateLifeShardCount(this.player, this.shardCount) + ); + } + } + } - this.player.getEntityAttribute(SharedMonsterAttributes.maxHealth).applyModifier(this.healthModifier); - } - else - { - AetherNetwork.sendToAll(new PacketUpdateLifeShardCount(this.player, this.shardCount)); - } - } - } + @Override + public int getShardsUsed() { + return this.shardCount; + } - @Override - public int getShardsUsed() { - return this.shardCount; - } + @Override + public int getMaxShardCount() { + return AetherConfig.getMaxLifeShards(); + } - @Override - public int getMaxShardCount() { - return AetherConfig.getMaxLifeShards(); - } + @Override + public void setJumping(boolean isJumping) { + this.isJumping = isJumping; + } - @Override - public void setJumping(boolean isJumping) { - this.isJumping = isJumping; - } + @Override + public boolean isJumping() { + return this.isJumping; + } - @Override - public boolean isJumping() { - return this.isJumping; - } + @Override + public void setMountSneaking(boolean isSneaking) { + this.isMountSneaking = isSneaking; + } - @Override - public void setMountSneaking(boolean isSneaking) { - this.isMountSneaking = isSneaking; - } + @Override + public boolean isMountSneaking() { + return this.isMountSneaking; + } - @Override - public boolean isMountSneaking() { - return this.isMountSneaking; - } + @Override + public boolean isDonator() { + return true; + } - @Override - public boolean isDonator() { - return true; - } + public boolean setHammerCooldown(int cooldown, String hammerName) { + if (this.cooldown <= 0) { + this.cooldown = cooldown; + this.cooldownMax = cooldown; + this.hammerName = hammerName; - public boolean setHammerCooldown(int cooldown, String hammerName) { - if (this.cooldown <= 0) { - this.cooldown = cooldown; - this.cooldownMax = cooldown; - this.hammerName = hammerName; + return true; + } - return true; - } + return false; + } - return false; - } + @Override + public String getHammerName() { + return this.hammerName; + } - @Override - public String getHammerName() { - return this.hammerName; - } + @Override + public int getHammerCooldown() { + return this.cooldown; + } - @Override - public int getHammerCooldown() { - return this.cooldown; - } + @Override + public int getHammerMaxCooldown() { + return this.cooldownMax; + } - @Override - public int getHammerMaxCooldown() { - return this.cooldownMax; - } + public void setBedLocation(ChunkCoordinates bedLocation) { + this.bedLocation = bedLocation; + } - public void setBedLocation(ChunkCoordinates bedLocation) - { - this.bedLocation = bedLocation; - } + public ChunkCoordinates getBedLocation() { + return bedLocation; + } - public ChunkCoordinates getBedLocation() - { - return bedLocation; - } + public boolean isPoisoned() { + return this.isPoisoned; + } - public boolean isPoisoned() - { - return this.isPoisoned; - } + public void setPoisoned() { + this.isPoisoned = true; + this.poisonTime = 500; + } - public void setPoisoned() - { - this.isPoisoned = true; - this.poisonTime = 500; - } + public boolean isCured() { + return this.isCured; + } - public boolean isCured() - { - return this.isCured; - } + public void setCured(int time) { + this.isCured = true; + this.cureTime = time; - public void setCured(int time) - { - this.isCured = true; - this.cureTime = time; + this.isPoisoned = false; + this.poisonTime = 0; + } - this.isPoisoned = false; - this.poisonTime = 0; - } + public void givePortalFrame() { + if (this.shouldGetPortal) { + this.player.inventory.addItemStackToInventory( + new ItemStack(ItemsAether.aether_portal_frame) + ); + this.shouldGetPortal = false; + } + } - public void givePortalFrame() - { - if (this.shouldGetPortal) - { - this.player.inventory.addItemStackToInventory(new ItemStack(ItemsAether.aether_portal_frame)); - this.shouldGetPortal = false; - } - } -} \ No newline at end of file + public void sendPackets() { + if (this.shouldRenderHalo != this.shouldRenderHaloPrev) { + AetherNetwork.sendToAll(new PacketPerkChanged( + this.getEntity().getEntityId(), + EnumAetherPerkType.Halo, + this.shouldRenderHalo + )); + + this.shouldRenderHaloPrev = this.shouldRenderHalo; + } + + if (this.shouldRenderGlow != this.shouldRenderGlowPrev) { + AetherNetwork.sendToAll(new PacketPerkChanged( + this.getEntity().getEntityId(), + EnumAetherPerkType.Glow, + this.shouldRenderGlow + )); + + this.shouldRenderGlowPrev = this.shouldRenderGlow; + } + + if (this.shouldRenderCape != this.shouldRenderCapePrev) { + AetherNetwork.sendToAll(new PacketCapeChanged( + this.getEntity().getEntityId(), this.shouldRenderCape + )); + + this.shouldRenderCapePrev = this.shouldRenderCape; + } + + if (this.poisonTime != this.poisonTimePrev) { + AetherNetwork.sendToAll( + new PacketSendPoisonTime(this.getEntity(), this.poisonTime) + ); + + this.poisonTimePrev = this.poisonTime; + } + + if (this.seenSpiritDialog != this.seenSpiritDialogPrev) { + AetherNetwork.sendToAll( + new PacketSendSeenDialogue(this.getEntity(), this.seenSpiritDialog) + ); + + this.seenSpiritDialogPrev = this.seenSpiritDialog; + } + + if (this.shouldGetPortal != this.shouldGetPortalPrev) { + AetherNetwork.sendToAll( + new PacketPortalItem(this.getEntity(), this.shouldGetPortal) + ); + + this.shouldGetPortalPrev = this.shouldGetPortal; + } + } +}