Package net.minecraft.network.syncher
Class SynchedEntityData
java.lang.Object
net.minecraft.network.syncher.SynchedEntityData
Keeps data in sync from server to client for an entity.
A maximum of 254 parameters per entity class can be registered. The system then ensures that these values are updated on the client whenever they change on the server.
Use
during
to set the default value for a given parameter.
defineId(java.lang.Class<? extends net.minecraft.network.syncher.SyncedDataHolder>, net.minecraft.network.syncher.EntityDataSerializer<T>)
to register a piece of data for your entity class.
Use
invalid reference
#define
invalid reference
Entity#defineSynchedData
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static final record
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SyncedDataHolder
(package private) static final ClassTreeIdRegistry
private boolean
private final SynchedEntityData.DataItem<?>[]
private static final org.slf4j.Logger
private static final int
-
Constructor Summary
ConstructorsConstructorDescriptionSynchedEntityData
(SyncedDataHolder pEntity, SynchedEntityData.DataItem<?>[] pItemsById) -
Method Summary
Modifier and TypeMethodDescriptionprivate <T> void
assignValue
(SynchedEntityData.DataItem<T> pTarget, SynchedEntityData.DataValue<?> pEntry) void
assignValues
(List<SynchedEntityData.DataValue<?>> pEntries) Updates the data using the given entries.static <T> EntityDataAccessor
<T> defineId
(Class<? extends SyncedDataHolder> pClazz, EntityDataSerializer<T> pSerializer) Register a piece of data to be kept in sync for an entity class.<T> T
get
(EntityDataAccessor<T> pKey) Get the value of the given key for this entity.private <T> SynchedEntityData.DataItem
<T> getItem
(EntityDataAccessor<T> pKey) boolean
isDirty()
<T> void
set
(EntityDataAccessor<T> pKey, T pValue) Set the value of the given key for this entity.<T> void
set
(EntityDataAccessor<T> pKey, T pValue, boolean pForce)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
MAX_ID_VALUE
private static final int MAX_ID_VALUE- See Also:
-
ID_REGISTRY
-
entity
-
itemsById
-
isDirty
private boolean isDirty
-
-
Constructor Details
-
SynchedEntityData
SynchedEntityData(SyncedDataHolder pEntity, SynchedEntityData.DataItem<?>[] pItemsById)
-
-
Method Details
-
defineId
public static <T> EntityDataAccessor<T> defineId(Class<? extends SyncedDataHolder> pClazz, EntityDataSerializer<T> pSerializer) Register a piece of data to be kept in sync for an entity class. This method must be called during a static initializer of an entity class and the first parameter of this method must be that entity class. -
getItem
-
get
Get the value of the given key for this entity. -
set
Set the value of the given key for this entity. -
set
-
isDirty
public boolean isDirty() -
packDirty
-
getNonDefaultValues
-
assignValues
Updates the data using the given entries. Used on the client when the update packet is received. -
assignValue
private <T> void assignValue(SynchedEntityData.DataItem<T> pTarget, SynchedEntityData.DataValue<?> pEntry)
-