From 005e28fe8b5081915d1a32bf33fe58d16ccf8a60 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 20 May 2013 12:51:49 +1200 Subject: [PATCH] Fixed 2 bugs with entity location and metadata. Released 2,2 --- pom.xml | 2 +- .../disguise/DisguiseTypes/Disguise.java | 4 ++- .../disguise/DisguiseTypes/FlagWatcher.java | 27 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d17e6f05..90feea57 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 LibsDisguises LibsDisguises - v2.1 + v2.2 src clean package diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java index 04e24b1c..68f7a346 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java @@ -65,8 +65,10 @@ public class Disguise { } public Entity getEntity(World world, Location loc, int entityId) { - if (entity != null) + if (entity != null) { + entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); return entity; + } try { String name = toReadable(disguiseType.name()); if (disguiseType == DisguiseType.WITHER_SKELETON) { diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java index fc251ea5..7e895f08 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java @@ -27,13 +27,17 @@ public abstract class FlagWatcher { protected FlagWatcher(int entityId) { this.entityId = entityId; + setValue(6, (byte) 0); + setValue(5, ""); } public List convert(List list) { Iterator itel = list.iterator(); List newList = new ArrayList(); + List sentValues = new ArrayList(); while (itel.hasNext()) { WatchableObject watch = itel.next(); + sentValues.add(watch.a()); if (entityValues.containsKey(watch.a())) { boolean doD = watch.d(); watch = new WatchableObject(watch.c(), watch.a(), watch.b()); @@ -59,6 +63,18 @@ public abstract class FlagWatcher { } newList.add(watch); } + if (list.size() == 10) { + // Its sending the entire meta data. Better add the custom meta + for (int value : entityValues.keySet()) { + if (sentValues.contains(value)) + continue; + Object obj = entityValues.get(value); + if (obj == null) + continue; + WatchableObject watch = new WatchableObject(classTypes.get(obj.getClass()), value, obj); + newList.add(watch); + } + } return newList; } @@ -84,6 +100,17 @@ public abstract class FlagWatcher { } } + public void setName(String name) { + setValue(5, name); + } + + public void displayName(boolean display) { + if ((Byte) getValue(6) != (display ? 1 : 0)) { + setValue(6, (byte) (display ? 1 : 0)); + sendData(6); + } + } + protected void setValue(int no, Object value) { entityValues.put(no, value); }