@Override public String toString() { return "DataWatcherItem[index=" + getIndex() + ", value=" + getValue() + ", dirty=" + getDirtyState() + "]"; }
/** * Sets the value of this item. * @param value New value */ public void setValue(Object value) { setValue(value, false); }
@Override protected WrappedWatchableObject toOuter(Object inner) { return inner != null ? new WrappedWatchableObject(inner) : null; }
/** * Gets the wrapped value of this data watcher item. * @return The wrapped value */ public Object getValue() { return getWrapped(getRawValue()); }
@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; }
int id = watch.getIndex(); sentValues.add(id); value = addEntityAnimations((byte) value, (byte) watch.getValue()); boolean isDirty = watch.getDirtyState(); watch.setDirtyState(false); boolean isDirty = watch.getDirtyState(); watch = ReflectionManager.createWatchable(id, watch.getValue()); watch.setDirtyState(false); for (WrappedWatchableObject watch : newList) { if (watch.getIndex() == 6) { Object value = watch.getValue();
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()); continue; Object nmsValue = ReflectionManager.convertInvalidMeta(watch.getValue()); getLogger().severe("Index: " + watch.getIndex() + " | " + flagType.getFlagWatcher().getSimpleName() + " | " + MetaIndex.getName(flagType)); Object flagDefault = flagType.getDefault(); getLogger().severe("Minecraft: " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ")"); getLogger().severe("Minecraft Converted: " + nmsValue + " (" + nmsValue.getClass() + ")");
/** * 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; }
/** * 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); } } }
return getWrapped(new WrappedWatchableObject(value).getRawValue()); Optional<?> optional = (Optional<?>) value; if (optional.isPresent()) { return Optional.of(getWrapped(optional.get())); } else { return Optional.absent();
/** * Sets the value of this item. * @param value New value * @param updateClient Whether or not to update the client */ public void setValue(Object value, boolean updateClient) { if (VALUE_INDEX == null) { VALUE_INDEX = MinecraftReflection.watcherObjectExists() ? 1 : 2; } modifier.write(VALUE_INDEX, getUnwrapped(value)); if (updateClient) { setDirtyState(true); } }
WrappedWatchableObject watchableObject = dataWatcherValues.get(i); if (watchableObject.getIndex() == customNameWatcherIndex) { if (replaceRelativePlaceholders(watchableObject, player, relativePlaceholders)) { event.setPacket(entityMetadataPacket.getHandle());
/** * Alias for {@link #setObject(int, WrappedWatchableObject, boolean)} */ public void setObject(int index, WrappedWatchableObject value) { setObject(index, value.getRawValue(), 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; }
/** * 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; }