@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof WrappedWatchableObject) { WrappedWatchableObject that = (WrappedWatchableObject) obj; return this.getIndex() == that.getIndex() && this.getRawValue().equals(that.getRawValue()) && this.getDirtyState() == that.getDirtyState(); } return false; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + getIndex(); result = prime * result + getRawValue().hashCode(); result = prime * result + (getDirtyState() ? 1231 : 1237); return result; }
@Override public String toString() { return "DataWatcherItem[index=" + getIndex() + ", value=" + getValue() + ", dirty=" + getDirtyState() + "]"; }
/** * Constructs a new DataWatcher using a fake egg entity and a given * list of watchable objects. * * @param objects The list of objects */ public WrappedDataWatcher(List<WrappedWatchableObject> objects) { this(); if (MinecraftReflection.watcherObjectExists()) { for (WrappedWatchableObject object : objects) { setObject(object.getWatcherObject(), object); } } else { for (WrappedWatchableObject object : objects) { setObject(object.getIndex(), object); } } }
/** * Clone the content of the current DataWatcher. * * @return A cloned data watcher. */ public WrappedDataWatcher deepClone() { WrappedDataWatcher clone = new WrappedDataWatcher(getEntity()); if (MinecraftReflection.watcherObjectExists()) { for (WrappedWatchableObject wrapper : this) { clone.setObject(wrapper.getWatcherObject(), wrapper); } } else { for (WrappedWatchableObject wrapper : this) { clone.setObject(wrapper.getIndex(), wrapper); } } return clone; }
/** * Create a new datawatcher but with the 'correct' values */ public static WrappedDataWatcher createSanitizedDataWatcher(WrappedDataWatcher entityWatcher, FlagWatcher disguiseWatcher) { WrappedDataWatcher newWatcher = new WrappedDataWatcher(); try { List<WrappedWatchableObject> list = DisguiseConfig.isMetadataPacketsEnabled() ? disguiseWatcher.convert(entityWatcher.getWatchableObjects()) : disguiseWatcher.getWatchableObjects(); for (WrappedWatchableObject watchableObject : list) { if (watchableObject == null) continue; if (watchableObject.getValue() == null) continue; WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager .createDataWatcherObject(watchableObject.getIndex(), watchableObject.getValue()); newWatcher.setObject(obj, watchableObject.getValue()); } } catch (Exception ex) { ex.printStackTrace(); } return newWatcher; }
MetaIndex flagType = MetaIndex.getMetaIndex(watcherClass, watch.getIndex()); getLogger().severe("MetaIndex not found for " + disguiseType + "! Index: " + watch.getIndex()); getLogger().severe("Value: " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName()); getLogger().severe("Index: " + watch.getIndex() + " | " + flagType.getFlagWatcher().getSimpleName() + " | " + MetaIndex.getName(flagType)); Object flagDefault = flagType.getDefault();
} else { for (WrappedWatchableObject obj : disguise.getWatcher().getWatchableObjects()) { if (obj.getIndex() == 0) { list.add(obj); break;
WrappedWatchableObject watchableObject = dataWatcherValues.get(i); if (watchableObject.getIndex() == customNameWatcherIndex) { if (replaceRelativePlaceholders(watchableObject, player, relativePlaceholders)) { event.setPacket(entityMetadataPacket.getHandle());
if (watch.getIndex() == 0) { byte b = (byte) watch.getValue();