From 628c3544d91c48eb0fbba18c64dc8377d939748f Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 1 Oct 2013 17:14:16 +1300 Subject: [PATCH] Resend self disguise when it goes below 0 health --- .../disguise/DisguiseTypes/FlagWatcher.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java index 7d91ad8e..a76e04ce 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java @@ -19,6 +19,7 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.reflect.StructureModifier; import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.PacketsManager; import net.minecraft.server.v1_6_R3.ChunkCoordinates; import net.minecraft.server.v1_6_R3.EntityPlayer; import net.minecraft.server.v1_6_R3.ItemStack; @@ -51,6 +52,7 @@ public class FlagWatcher { private Disguise disguise; private HashMap entityValues = new HashMap(); private org.bukkit.inventory.ItemStack[] items = new org.bukkit.inventory.ItemStack[5]; + private boolean hasDied; public FlagWatcher(Disguise disguise) { this.disguise = disguise; @@ -103,6 +105,24 @@ public class FlagWatcher { newList.add(watch); } } + // Here we check for if there is a health packet that says they died. + if (disguise.viewSelfDisguise() && disguise.getEntity() != null && disguise.getEntity() instanceof Player) { + for (WatchableObject watch : newList) { + // Its a health packet + if (watch.a() == 6) { + Object value = watch.b(); + if (value != null && value instanceof Float) { + float newHealth = (Float) value; + if (newHealth > 0 && hasDied) { + hasDied = false; + PacketsManager.sendSelfDisguise((Player) disguise.getEntity()); + } else if (newHealth <= 0 && !hasDied) { + hasDied = true; + } + } + } + } + } return newList; }