diff --git a/src/main/java/com/legacy/aether/AetherConfig.java b/src/main/java/com/legacy/aether/AetherConfig.java index bf5f752..6dd94ae 100644 --- a/src/main/java/com/legacy/aether/AetherConfig.java +++ b/src/main/java/com/legacy/aether/AetherConfig.java @@ -27,6 +27,8 @@ public class AetherConfig { private static boolean legacy_altar_name; + private static int inebriation_id; + public static void init(File location) { File newFile = new File(location + "/aether" + "/AetherI.cfg"); @@ -64,6 +66,8 @@ public class AetherConfig { legacy_altar_name = config.get("Misc", "Changes whether the Altar should be named Enchanter or not.", false).getBoolean(false); + inebriation_id = config.get("Misc", "Sets the id for the Inebriation effect.", 31).getInt(31); + config.save(); } @@ -130,4 +134,9 @@ public class AetherConfig { public static boolean legacyAltarName() { return AetherConfig.legacy_altar_name; } + + public static int getInebriationId() + { + return AetherConfig.inebriation_id; + } } \ No newline at end of file diff --git a/src/main/java/com/legacy/aether/api/player/IPlayerAether.java b/src/main/java/com/legacy/aether/api/player/IPlayerAether.java index e57e8d1..4588adc 100644 --- a/src/main/java/com/legacy/aether/api/player/IPlayerAether.java +++ b/src/main/java/com/legacy/aether/api/player/IPlayerAether.java @@ -27,14 +27,6 @@ public interface IPlayerAether extends IExtendedEntityProperties { public EntityLivingBase getEntity(); - public void inflictPoison(int ticks); - - public boolean isPoisoned(); - - public void inflictCure(int ticks); - - public boolean isCured(); - public boolean setHammerCooldown(int cooldown, String hammerName); public String getHammerName(); diff --git a/src/main/java/com/legacy/aether/client/overlay/AetherOverlay.java b/src/main/java/com/legacy/aether/client/overlay/AetherOverlay.java index f95fff1..c89b25b 100644 --- a/src/main/java/com/legacy/aether/client/overlay/AetherOverlay.java +++ b/src/main/java/com/legacy/aether/client/overlay/AetherOverlay.java @@ -38,11 +38,11 @@ public class AetherOverlay { public static void renderPoison(Minecraft mc) { PlayerAether playerAether = PlayerAether.get(mc.thePlayer); - if (playerAether.isPoisoned()) { + if (playerAether.poisonTime > 0) { ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); Tessellator tessellator = Tessellator.instance; - float alpha = getPoisonAlpha((float) (playerAether.poisonMovement.ticks % 50) / 50); + float alpha = getPoisonAlpha((float) (playerAether.poisonTime % 50) / 50); int width = scaledresolution.getScaledWidth(); int height = scaledresolution.getScaledHeight(); diff --git a/src/main/java/com/legacy/aether/client/renders/entity/DartBaseRenderer.java b/src/main/java/com/legacy/aether/client/renders/entity/DartBaseRenderer.java index 9a84998..7fdb182 100644 --- a/src/main/java/com/legacy/aether/client/renders/entity/DartBaseRenderer.java +++ b/src/main/java/com/legacy/aether/client/renders/entity/DartBaseRenderer.java @@ -29,10 +29,6 @@ public class DartBaseRenderer extends Render { return; } - if (dart instanceof EntityDartPoison && ((EntityDartPoison) dart).victim != null) { - return; - } - this.bindEntityTexture(dart); GL11.glPushMatrix(); GL11.glTranslatef((float) d, (float) d1, (float) d2); diff --git a/src/main/java/com/legacy/aether/entities/effects/EffectInebriation.java b/src/main/java/com/legacy/aether/entities/effects/EffectInebriation.java new file mode 100644 index 0000000..4b57aa2 --- /dev/null +++ b/src/main/java/com/legacy/aether/entities/effects/EffectInebriation.java @@ -0,0 +1,54 @@ +package com.legacy.aether.entities.effects; + +import com.legacy.aether.items.ItemsAether; +import com.legacy.aether.items.util.EnumSkyrootBucketType; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; + +import java.util.ArrayList; +import java.util.List; + +public class EffectInebriation extends PotionEffect +{ + private List curativeItems; + + public EffectInebriation(int potionID, int duration, int amplifier) + { + this(potionID, duration, amplifier, false); + } + + public EffectInebriation(int potionID, int duration, int amplifier, boolean isAmbient) + { + super(potionID, duration, amplifier, isAmbient); + this.curativeItems = new ArrayList<>(); + this.curativeItems.add(new ItemStack(ItemsAether.skyroot_bucket, EnumSkyrootBucketType.Remedy.meta)); + this.curativeItems.add(new ItemStack(ItemsAether.white_apple)); + } + + @Override + public List getCurativeItems() + { + return this.curativeItems; + } + + @Override + public boolean isCurativeItem(ItemStack stack) + { + boolean found = false; + for (ItemStack curativeItem : this.curativeItems) + { + if (curativeItem.isItemEqual(stack)) + { + found = true; + } + } + + return found; + } + + @Override + public void setCurativeItems(List curativeItems) + { + this.curativeItems = curativeItems; + } +} diff --git a/src/main/java/com/legacy/aether/entities/effects/PotionInebriation.java b/src/main/java/com/legacy/aether/entities/effects/PotionInebriation.java new file mode 100644 index 0000000..f301a44 --- /dev/null +++ b/src/main/java/com/legacy/aether/entities/effects/PotionInebriation.java @@ -0,0 +1,91 @@ +package com.legacy.aether.entities.effects; + +import com.legacy.aether.Aether; +import com.legacy.aether.AetherConfig; +import com.legacy.aether.api.AetherAPI; +import com.legacy.aether.network.AetherNetwork; +import com.legacy.aether.network.packets.PacketSendPoison; +import com.legacy.aether.player.PlayerAether; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.potion.Potion; +import net.minecraft.util.DamageSource; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.WorldServer; + +public class PotionInebriation extends Potion +{ + public static Potion inebriation = new PotionInebriation(); + + private int duration; + + public double rotD, motD; + + public PotionInebriation() + { + super(AetherConfig.getInebriationId(), true, 0x51297B); + this.duration = 0; + this.setPotionName("Inebriation"); + this.setIconIndex(0, 0); + } + + public boolean isReady(int duration, int amplifier) + { + this.duration = duration; + return true; + } + + @Override + public void performEffect(EntityLivingBase entityLivingBaseIn, int amplifier) + { + this.distractEntity(entityLivingBaseIn); + + if (this.duration % 50 == 0) + { + entityLivingBaseIn.attackEntityFrom(new DamageSource("inebriation"), 1.0F); + } + + if (entityLivingBaseIn instanceof EntityPlayer) + { + if (this.duration >= 500) + { + ((PlayerAether) AetherAPI.get((EntityPlayer) entityLivingBaseIn)).setPoisoned(); + AetherNetwork.sendToAll(new PacketSendPoison((EntityPlayer) entityLivingBaseIn)); + } + } + + } + + public void distractEntity(EntityLivingBase entityLivingBaseIn) + { + double gaussian = entityLivingBaseIn.worldObj.rand.nextGaussian(); + double newMotD = 0.1D * gaussian; + double newRotD = (Math.PI / 4D) * gaussian; + + this.motD = 0.2D * newMotD + (0.8D) * this.motD; + entityLivingBaseIn.motionX += this.motD; + entityLivingBaseIn.motionZ += this.motD; + this.rotD = 0.125D * newRotD + (1.0D - 0.125D) * this.rotD; + + entityLivingBaseIn.rotationYaw = (float)((double)entityLivingBaseIn.rotationYaw + rotD); + entityLivingBaseIn.rotationPitch = (float)((double)entityLivingBaseIn.rotationPitch + rotD); + + if (entityLivingBaseIn.worldObj instanceof WorldServer) + { + ((WorldServer) entityLivingBaseIn.worldObj).func_147487_a("iconcrack_" + Item.getIdFromItem(Items.dye) + "_" + 1, entityLivingBaseIn.posX, entityLivingBaseIn.boundingBox.minY + entityLivingBaseIn.height * 0.8D, entityLivingBaseIn.posZ, 2, 0.0D, 0.0D, 0.0D, 0.0D); + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getStatusIconIndex() + { + Minecraft.getMinecraft().renderEngine.bindTexture(Aether.locate("textures/gui/inventory/inebriation.png")); + return super.getStatusIconIndex(); + } +} diff --git a/src/main/java/com/legacy/aether/entities/movement/AetherPoisonMovement.java b/src/main/java/com/legacy/aether/entities/movement/AetherPoisonMovement.java deleted file mode 100644 index 60918b5..0000000 --- a/src/main/java/com/legacy/aether/entities/movement/AetherPoisonMovement.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.legacy.aether.entities.movement; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; - -public class AetherPoisonMovement { - - public int ticks = 0; - - public double rotD, motD; - - private EntityLivingBase entity; - - public AetherPoisonMovement(EntityLivingBase entity) { - this.entity = entity; - } - - public void onUpdate() { - int timeUntilHit = this.ticks % 50; - - if (this.entity.isDead) { - this.ticks = 0; - } else if (this.ticks < 0) { - this.ticks++; - } else if (this.ticks > 0) { - this.ticks--; - - if (timeUntilHit == 0) { - this.entity.attackEntityFrom(causePoisonDamage(), 1.0F); - } - - this.distractEntity(); - } - } - - public void inflictPoison(int ticks) { - if (this.ticks >= 0) { - this.ticks = ticks; - } - } - - public void inflictCure(int ticks) { - this.ticks = -ticks; - } - - public void distractEntity() { - double gaussian = this.entity.worldObj.rand.nextGaussian(); - double newMotD = 0.1D * gaussian; - double newRotD = (Math.PI / 4D) * gaussian; - - this.motD = 0.2D * newMotD + (0.8D) * this.motD; - this.entity.motionX += this.motD; - this.entity.motionZ += this.motD; - this.rotD = 0.125D * newRotD + (1.0D - 0.125D) * this.rotD; - - this.entity.rotationYaw = (float) ((double) this.entity.rotationYaw + rotD); - this.entity.rotationPitch = (float) ((double) this.entity.rotationPitch + rotD); - } - - public static DamageSource causePoisonDamage() { - return new DamageSource("aether_legacy.poison").setDamageBypassesArmor(); - } - -} \ No newline at end of file diff --git a/src/main/java/com/legacy/aether/entities/projectile/darts/EntityDartPoison.java b/src/main/java/com/legacy/aether/entities/projectile/darts/EntityDartPoison.java index d6a9618..ac6cd16 100644 --- a/src/main/java/com/legacy/aether/entities/projectile/darts/EntityDartPoison.java +++ b/src/main/java/com/legacy/aether/entities/projectile/darts/EntityDartPoison.java @@ -1,31 +1,17 @@ package com.legacy.aether.entities.projectile.darts; -import net.minecraft.entity.Entity; +import com.legacy.aether.entities.effects.EffectInebriation; +import com.legacy.aether.entities.effects.PotionInebriation; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -import com.legacy.aether.api.player.util.IAetherBoss; -import com.legacy.aether.entities.hostile.EntityAechorPlant; -import com.legacy.aether.entities.hostile.EntityCockatrice; -import com.legacy.aether.entities.movement.AetherPoisonMovement; import com.legacy.aether.items.ItemsAether; -import com.legacy.aether.network.AetherNetwork; -import com.legacy.aether.network.packets.PacketSendPoison; -import com.legacy.aether.player.PlayerAether; public class EntityDartPoison extends EntityDartBase { - public EntityLivingBase victim; - - public AetherPoisonMovement poison; - public EntityDartPoison(World worldIn) { super(worldIn); } @@ -39,58 +25,22 @@ public class EntityDartPoison extends EntityDartBase { this.setDamage(0); } - public void onUpdate() { - super.onUpdate(); - - if (this.victim != null) { - if (this.victim.isDead || this.poison.ticks == 0) { - this.setDead(); - - return; - } - - if (this.getThrower() != null) { - if (this.getThrower().worldObj instanceof WorldServer) { - ((WorldServer) this.getThrower().worldObj).func_147487_a("iconcrack_" + Item.getIdFromItem(Items.dye) + "_" + 1, this.victim.posX, this.victim.boundingBox.minY + this.victim.height * 0.8D, this.victim.posZ, 2, 0.0D, 0.0D, 0.0D, 0.0D); - } - } - - this.isDead = false; - this.poison.onUpdate(); - this.setInvisible(true); - this.setPosition(this.victim.posX, this.victim.posY, this.victim.posZ); - } - } - - @Override - public void onCollideWithPlayer(EntityPlayer entity) { - if (this.victim == null) { - super.onCollideWithPlayer(entity); - } - } - @Override public void onDartHit(MovingObjectPosition movingobjectposition) { super.onDartHit(movingobjectposition); - if (movingobjectposition.entityHit instanceof EntityLivingBase) { - Entity entity = movingobjectposition.entityHit; - - if (entity instanceof EntityPlayer) { - EntityPlayer ent = (EntityPlayer) entity; - - if (!this.worldObj.isRemote) { - PlayerAether.get(ent).inflictPoison(500); - AetherNetwork.sendTo(new PacketSendPoison(), (EntityPlayerMP) ent); + if (!worldObj.isRemote) + { + if (movingobjectposition.entityHit != null) + { + if (movingobjectposition.entityHit instanceof EntityLivingBase) + { + ((EntityLivingBase) movingobjectposition.entityHit).addPotionEffect(new EffectInebriation(PotionInebriation.inebriation.id, 500, 0)); } - } else if (!(entity instanceof IAetherBoss) && !(entity instanceof EntityCockatrice) && !(entity instanceof EntityAechorPlant)) { - this.victim = (EntityLivingBase) entity; - this.poison = new AetherPoisonMovement(this.victim); - this.poison.inflictPoison(500); } - - this.isDead = false; } + + this.isDead = false; } @Override diff --git a/src/main/java/com/legacy/aether/items/food/ItemWhiteApple.java b/src/main/java/com/legacy/aether/items/food/ItemWhiteApple.java index e3c65dc..abed0ae 100644 --- a/src/main/java/com/legacy/aether/items/food/ItemWhiteApple.java +++ b/src/main/java/com/legacy/aether/items/food/ItemWhiteApple.java @@ -1,5 +1,6 @@ package com.legacy.aether.items.food; +import com.legacy.aether.items.ItemsAether; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -16,7 +17,12 @@ public class ItemWhiteApple extends ItemAetherFood { @Override protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) { - PlayerAether.get(player).inflictCure(300); - } + PlayerAether.get(player).setCured(300); + + if (!world.isRemote) + { + player.curePotionEffects(new ItemStack(ItemsAether.white_apple)); + } + } } \ No newline at end of file diff --git a/src/main/java/com/legacy/aether/items/tools/ItemSkyrootBucket.java b/src/main/java/com/legacy/aether/items/tools/ItemSkyrootBucket.java index c5427ed..12ddc39 100644 --- a/src/main/java/com/legacy/aether/items/tools/ItemSkyrootBucket.java +++ b/src/main/java/com/legacy/aether/items/tools/ItemSkyrootBucket.java @@ -2,12 +2,15 @@ package com.legacy.aether.items.tools; import java.util.List; +import com.legacy.aether.entities.effects.EffectInebriation; +import com.legacy.aether.entities.effects.PotionInebriation; import javafx.print.PageLayout; import net.minecraft.block.Block; import net.minecraft.block.BlockCauldron; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -15,6 +18,7 @@ import net.minecraft.item.EnumAction; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; import net.minecraft.stats.StatList; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; @@ -316,9 +320,13 @@ public class ItemSkyrootBucket extends Item { } if (EnumSkyrootBucketType.getType(meta) == EnumSkyrootBucketType.Poison) { - player.inflictPoison(200); + entityplayer.addPotionEffect(new EffectInebriation(PotionInebriation.inebriation.id, 500, 0)); } else if (EnumSkyrootBucketType.getType(meta) == EnumSkyrootBucketType.Remedy) { - player.inflictCure(200); + player.setCured(200); + if (!world.isRemote) + { + entityplayer.curePotionEffects(new ItemStack(ItemsAether.skyroot_bucket, EnumSkyrootBucketType.Remedy.meta)); + } } else if (EnumSkyrootBucketType.getType(meta) == EnumSkyrootBucketType.Milk) { if (!world.isRemote) { entityplayer.curePotionEffects(new ItemStack(Items.milk_bucket)); diff --git a/src/main/java/com/legacy/aether/network/AetherNetwork.java b/src/main/java/com/legacy/aether/network/AetherNetwork.java index c1200bb..5dcb83f 100644 --- a/src/main/java/com/legacy/aether/network/AetherNetwork.java +++ b/src/main/java/com/legacy/aether/network/AetherNetwork.java @@ -27,6 +27,7 @@ public class AetherNetwork { INSTANCE.registerMessage(PacketAchievement.class, PacketAchievement.class, discriminant++, Side.CLIENT); INSTANCE.registerMessage(PacketSendPoison.class, PacketSendPoison.class, discriminant++, Side.CLIENT); + INSTANCE.registerMessage(PacketSendPoisonTime.class, PacketSendPoisonTime.class, discriminant++, Side.CLIENT); INSTANCE.registerMessage(PacketInitiateValkyrieFight.class, PacketInitiateValkyrieFight.class, discriminant++, Side.SERVER); diff --git a/src/main/java/com/legacy/aether/network/packets/PacketSendPoison.java b/src/main/java/com/legacy/aether/network/packets/PacketSendPoison.java index 09cf9ee..73d6c44 100644 --- a/src/main/java/com/legacy/aether/network/packets/PacketSendPoison.java +++ b/src/main/java/com/legacy/aether/network/packets/PacketSendPoison.java @@ -1,5 +1,6 @@ package com.legacy.aether.network.packets; +import com.legacy.aether.api.AetherAPI; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; @@ -7,33 +8,47 @@ import com.legacy.aether.player.PlayerAether; public class PacketSendPoison extends AetherPacket { - public PacketSendPoison() { + private int entityID; + + public PacketSendPoison() + { } - public PacketSendPoison(EntityPlayer thePlayer) { - + public PacketSendPoison(EntityPlayer thePlayer) + { + this.entityID = thePlayer.getEntityId(); } @Override - public void fromBytes(ByteBuf buf) { - + public void fromBytes(ByteBuf buf) + { + this.entityID = buf.readInt(); } @Override - public void toBytes(ByteBuf buf) { - + public void toBytes(ByteBuf buf) + { + buf.writeInt(this.entityID); } @Override - public void handleClient(PacketSendPoison message, EntityPlayer player) { - if (player != null && player.worldObj != null) { - PlayerAether.get(player).inflictPoison(500); + public void handleClient(PacketSendPoison message, EntityPlayer player) + { + if (player != null && player.worldObj != null) + { + EntityPlayer parent = (EntityPlayer) player.worldObj.getEntityByID(message.entityID); + + if (parent != null) + { + ((PlayerAether) AetherAPI.get(parent)).setPoisoned(); + } } } @Override - public void handleServer(PacketSendPoison message, EntityPlayer player) { + public void handleServer(PacketSendPoison message, EntityPlayer player) + { } diff --git a/src/main/java/com/legacy/aether/network/packets/PacketSendPoisonTime.java b/src/main/java/com/legacy/aether/network/packets/PacketSendPoisonTime.java new file mode 100644 index 0000000..8568af1 --- /dev/null +++ b/src/main/java/com/legacy/aether/network/packets/PacketSendPoisonTime.java @@ -0,0 +1,57 @@ +package com.legacy.aether.network.packets; + +import com.legacy.aether.api.AetherAPI; +import com.legacy.aether.player.PlayerAether; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; + +public class PacketSendPoisonTime extends AetherPacket +{ + private int entityID; + private int time; + + public PacketSendPoisonTime() + { + + } + + public PacketSendPoisonTime(EntityPlayer thePlayer, int time) + { + this.entityID = thePlayer.getEntityId(); + this.time = time; + } + + @Override + public void fromBytes(ByteBuf buf) + { + this.entityID = buf.readInt(); + this.time = buf.readInt(); + } + + @Override + public void toBytes(ByteBuf buf) + { + buf.writeInt(this.entityID); + buf.writeInt(this.time); + } + + @Override + public void handleClient(PacketSendPoisonTime message, EntityPlayer player) + { + if (player != null && player.worldObj != null) + { + EntityPlayer parent = (EntityPlayer) player.worldObj.getEntityByID(message.entityID); + + if (parent != null) + { + ((PlayerAether) AetherAPI.get(parent)).poisonTime = message.time; + } + } + } + + @Override + public void handleServer(PacketSendPoisonTime message, EntityPlayer player) + { + + } +} \ No newline at end of file diff --git a/src/main/java/com/legacy/aether/player/PlayerAether.java b/src/main/java/com/legacy/aether/player/PlayerAether.java index 209c5e9..479748b 100644 --- a/src/main/java/com/legacy/aether/player/PlayerAether.java +++ b/src/main/java/com/legacy/aether/player/PlayerAether.java @@ -4,12 +4,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.UUID; -import com.legacy.aether.Aether; import com.legacy.aether.entities.passive.mountable.EntityParachute; import com.legacy.aether.items.ItemsAether; import com.legacy.aether.network.AetherNetwork; import com.legacy.aether.network.packets.PacketCapeChanged; import com.legacy.aether.network.packets.PacketPerkChanged; +import com.legacy.aether.network.packets.PacketSendPoisonTime; import com.legacy.aether.player.perks.AetherRankings; import com.legacy.aether.player.perks.util.EnumAetherPerkType; import net.minecraft.block.Block; @@ -35,7 +35,6 @@ import com.legacy.aether.api.player.util.IAccessoryInventory; import com.legacy.aether.api.player.util.IAetherAbility; import com.legacy.aether.api.player.util.IAetherBoss; import com.legacy.aether.blocks.BlocksAether; -import com.legacy.aether.entities.movement.AetherPoisonMovement; import com.legacy.aether.inventory.InventoryAccessories; import com.legacy.aether.items.tools.ItemValkyrieTool; import com.legacy.aether.player.abilities.AbilityAccessories; @@ -53,8 +52,6 @@ public class PlayerAether implements IPlayerAether { private EntityPlayer player; - public AetherPoisonMovement poisonMovement; - private IAetherBoss focusedBoss; private IAccessoryInventory accessories = new InventoryAccessories(this); @@ -95,6 +92,10 @@ public class PlayerAether implements IPlayerAether { private ChunkCoordinates bedLocation; + public boolean isPoisoned = false, isCured = false; + + public int poisonTime = 0, cureTime = 0; + public PlayerAether() { this.shouldRenderHalo = true; this.shouldRenderGlow = false; @@ -109,7 +110,6 @@ public class PlayerAether implements IPlayerAether { @Override public void init(Entity entity, World world) { this.player = (EntityPlayer) entity; - this.poisonMovement = new AetherPoisonMovement(this.player); } @Override @@ -119,6 +119,33 @@ public class PlayerAether implements IPlayerAether { 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)); + } + + if (this.isPoisoned) + { + if (poisonTime > 0) + { + this.poisonTime--; + } + else + { + this.poisonTime = 0; + this.isPoisoned = false; + } + } + + if (this.isCured) + { + if (cureTime > 0) + { + this.cureTime--; + } + else + { + this.cureTime = 0; + this.isCured = false; + } } for (int i = 0; i < this.getAbilities().size(); ++i) { @@ -162,8 +189,6 @@ public class PlayerAether implements IPlayerAether { this.wingSinage += 0.1F; } - this.poisonMovement.onUpdate(); - boolean hasJumped = ReflectionHelper.getPrivateValue(EntityLivingBase.class, this.getEntity(), "isJumping", "field_70703_bu"); this.setJumping(hasJumped); @@ -400,6 +425,8 @@ public class PlayerAether implements IPlayerAether { 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)); @@ -433,6 +460,16 @@ public class PlayerAether implements IPlayerAether { this.shouldRenderCape = aetherTag.getBoolean("cape"); } + if (aetherTag.hasKey("poisoned")) + { + this.isPoisoned = aetherTag.getBoolean("poisoned"); + } + + if (aetherTag.hasKey("poison_time")) + { + this.poisonTime = aetherTag.getInteger("poison_time"); + } + this.updateShardCount(aetherTag.getInteger("shardCount")); this.getAccessoryInventory().readFromNBT(aetherTag.getTagList("accessories", 10)); this.setBedLocation(new ChunkCoordinates(aetherTag.getInteger("bedX"), aetherTag.getInteger("bedY"), aetherTag.getInteger("bedZ"))); @@ -468,26 +505,6 @@ public class PlayerAether implements IPlayerAether { return this.player; } - @Override - public void inflictPoison(int ticks) { - this.poisonMovement.inflictPoison(ticks); - } - - @Override - public boolean isPoisoned() { - return this.poisonMovement.ticks > 0; - } - - @Override - public void inflictCure(int ticks) { - this.poisonMovement.inflictCure(ticks); - } - - @Override - public boolean isCured() { - return this.poisonMovement.ticks < 0; - } - @Override public void updateShardCount(int amount) { UUID uuid = UUID.fromString("df6eabe7-6947-4a56-9099-002f90370706"); @@ -573,4 +590,29 @@ public class PlayerAether implements IPlayerAether { { return bedLocation; } + + public boolean isPoisoned() + { + return this.isPoisoned; + } + + public void setPoisoned() + { + this.isPoisoned = true; + this.poisonTime = 500; + } + + public boolean isCured() + { + return this.isCured; + } + + public void setCured(int time) + { + this.isCured = true; + this.cureTime = time; + + this.isPoisoned = false; + this.poisonTime = 0; + } } \ No newline at end of file diff --git a/src/main/java/com/legacy/aether/player/PlayerAetherEvents.java b/src/main/java/com/legacy/aether/player/PlayerAetherEvents.java index dff5fba..9dbf46d 100644 --- a/src/main/java/com/legacy/aether/player/PlayerAetherEvents.java +++ b/src/main/java/com/legacy/aether/player/PlayerAetherEvents.java @@ -75,6 +75,11 @@ public class PlayerAetherEvents { AetherNetwork.sendTo(new PacketAccessory(playerAether), (EntityPlayerMP) event.player); playerAether.updateShardCount(playerAether.getShardsUsed()); + + playerAether.isPoisoned = false; + playerAether.poisonTime = 0; + playerAether.isCured = false; + playerAether.cureTime = 0; } } diff --git a/src/main/resources/assets/aether_legacy/textures/gui/inventory/inebriation.png b/src/main/resources/assets/aether_legacy/textures/gui/inventory/inebriation.png new file mode 100644 index 0000000..a30825d Binary files /dev/null and b/src/main/resources/assets/aether_legacy/textures/gui/inventory/inebriation.png differ