@Nullable public List<EntityDataManager.DataEntry<?>> getDirty() { List<EntityDataManager.DataEntry<?>> list = null; if (this.dirty) { this.lock.readLock().lock(); for (EntityDataManager.DataEntry<?> dataentry : this.entries.values()) { if (dataentry.isDirty()) { dataentry.setDirty(false); if (list == null) { list = Lists.<EntityDataManager.DataEntry<?>>newArrayList(); } list.add(dataentry); } } this.lock.readLock().unlock(); } this.dirty = false; return list; }
public <T> void set(DataParameter<T> key, T value) { EntityDataManager.DataEntry<T> dataentry = this.<T>getEntry(key); if (ObjectUtils.notEqual(value, dataentry.getValue())) { dataentry.setValue(value); this.entity.notifyDataManagerChange(key); dataentry.setDirty(true); this.dirty = true; } }
private static <T> void writeEntry(PacketBuffer buf, EntityDataManager.DataEntry<T> entry) throws IOException { DataParameter<T> dataparameter = entry.getKey(); int i = DataSerializers.getSerializerId(dataparameter.getSerializer()); if (i < 0) { throw new EncoderException("Unknown serializer type " + dataparameter.getSerializer()); } else { buf.writeByte(dataparameter.getId()); buf.writeVarIntToBuffer(i); dataparameter.getSerializer().write(buf, entry.getValue()); } }
@SideOnly(Side.CLIENT) public void setEntryValues(List<EntityDataManager.DataEntry<?>> entriesIn) { this.lock.writeLock().lock(); for (EntityDataManager.DataEntry<?> dataentry : entriesIn) { EntityDataManager.DataEntry<?> dataentry1 = (EntityDataManager.DataEntry) this.entries.get(Integer.valueOf(dataentry.getKey().getId())); if (dataentry1 != null) { this.setEntryValue(dataentry1, dataentry); this.entity.notifyDataManagerChange(dataentry.getKey()); } } this.lock.writeLock().unlock(); this.dirty = true; }
@SideOnly(Side.CLIENT) protected <T> void setEntryValue( EntityDataManager.DataEntry<T> target, EntityDataManager.DataEntry<?> source) { target.setValue((T) source.getValue()); }