--- a/net/minecraft/network/syncher/SynchedEntityData.java +++ b/net/minecraft/network/syncher/SynchedEntityData.java @@ -45,7 +_,7 @@ } } - private SynchedEntityData.DataItem getItem(EntityDataAccessor key) { + public SynchedEntityData.DataItem getItem(EntityDataAccessor key) { // Paper - public return (SynchedEntityData.DataItem)this.itemsById[key.id()]; } @@ -67,6 +_,13 @@ } } + // CraftBukkit start - add method from above + public void markDirty(final EntityDataAccessor entityDataAccessor) { + this.getItem(entityDataAccessor).setDirty(true); + this.isDirty = true; + } + // CraftBukkit end + public boolean isDirty() { return this.isDirty; } @@ -169,6 +_,20 @@ return new SynchedEntityData(this.entity, this.itemsById); } } + + // Paper start + // We need to pack all as we cannot rely on "non default values" or "dirty" ones. + // Because these values can possibly be desynced on the client. + @Nullable + public List> packAll() { + final List> list = new ArrayList<>(); + for (final DataItem dataItem : this.itemsById) { + list.add(dataItem.value()); + } + + return list; + } + // Paper end public static class DataItem { final EntityDataAccessor accessor;