From 6312636fd9a4d0f56dc7c9ff474a99d879bcb4e9 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Mon, 23 Mar 2015 14:51:06 +0000 Subject: Reworked the whole repo. --- .../jewelrycraft/entities/EntityHalfHeart.java | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java (limited to 'src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java') diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java b/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java new file mode 100644 index 0000000..4fc1e39 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java @@ -0,0 +1,45 @@ +/** + * + */ +package darkknight.jewelrycraft.entities; + +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.network.PacketRequestPlayerInfo; +import darkknight.jewelrycraft.util.PlayerUtils; + +/** + * @author Sorin + */ +public class EntityHalfHeart extends EntityHeart +{ + public EntityHalfHeart(World world) + { + super(world); + } + + @Override + public void onCollideWithPlayer(EntityPlayer player) + { + if (!player.worldObj.isRemote){ + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + if (getType().equals("Red") && player.getHealth() < player.getMaxHealth()){ + player.heal(1f); + this.setDead(); + }else if (getType().equals("White") && playerInfo.getFloat("WhiteHeart") > 0.1F){ + playerInfo.setFloat(getType() + "Heart", 0F); + player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + 2f); + this.setDead(); + }else if (!getType().equals("Red") && playerInfo.getFloat(getType() + "Heart") < 20f){ + playerInfo.setFloat(getType() + "Heart", playerInfo.getFloat(getType() + "Heart") + 1.0F <= 20f ? playerInfo.getFloat(getType() + "Heart") + 1.0F : 20f); + this.setDead(); + } + } + else JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + } +} -- cgit v1.2.3