summaryrefslogtreecommitdiff
path: root/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-02-21 21:31:16 +0000
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-02-21 21:31:16 +0000
commit420faddca46e70e3a70def168fb4e452ef193b0d (patch)
tree247e334012e4bf9e4fa6d42718bf601ce6bd42d9 /java/darkknight/jewelrycraft/entities/EntityHalfHeart.java
parent3f4c717de5ebc9b942d65ae45ac87c43bdf8a31b (diff)
Added just a butt ton of stuff, also thanks to pau101 for helping me with the Hand Pedestal animation :)
Diffstat (limited to 'java/darkknight/jewelrycraft/entities/EntityHalfHeart.java')
-rw-r--r--java/darkknight/jewelrycraft/entities/EntityHalfHeart.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java b/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java
new file mode 100644
index 0000000..4fc1e39
--- /dev/null
+++ b/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());
+ }
+}