mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 18:12:09 +01:00
46 lines
1.4 KiB
Diff
46 lines
1.4 KiB
Diff
--- a/net/minecraft/network/syncher/SynchedEntityData.java
|
|
+++ b/net/minecraft/network/syncher/SynchedEntityData.java
|
|
@@ -45,7 +_,7 @@
|
|
}
|
|
}
|
|
|
|
- private <T> SynchedEntityData.DataItem<T> getItem(EntityDataAccessor<T> key) {
|
|
+ public <T> SynchedEntityData.DataItem<T> getItem(EntityDataAccessor<T> key) { // Paper - public
|
|
return (SynchedEntityData.DataItem<T>)this.itemsById[key.id()];
|
|
}
|
|
|
|
@@ -67,6 +_,13 @@
|
|
}
|
|
}
|
|
|
|
+ // CraftBukkit start - add method from above
|
|
+ public <T> void markDirty(final EntityDataAccessor<T> 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<SynchedEntityData.DataValue<?>> packAll() {
|
|
+ final List<SynchedEntityData.DataValue<?>> list = new ArrayList<>();
|
|
+ for (final DataItem<?> dataItem : this.itemsById) {
|
|
+ list.add(dataItem.value());
|
|
+ }
|
|
+
|
|
+ return list;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public static class DataItem<T> {
|
|
final EntityDataAccessor<T> accessor;
|