Class AttachmentSync
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentSync
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AddCallback<AttachmentType<?>> static final Registry<AttachmentType<?>> Contains all entries added toNeoForgeRegistries.ATTACHMENT_TYPESwith a sync handler. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidonChunkSent(ChunkWatchEvent.Sent event) Handles initial syncing of block entity and chunk attachments.static voidreceiveSyncedDataAttachments(AttachmentHolder holder, RegistryAccess registryAccess, List<AttachmentType<?>> types, byte[] bytes) static voidsyncBlockEntityUpdate(BlockEntity blockEntity, AttachmentType<?> type) static voidsyncChunkUpdate(LevelChunk chunk, AttachmentHolder.AsField holder, AttachmentType<?> type) static voidsyncEntityUpdate(Entity entity, AttachmentType<?> type) private static @Nullable SyncAttachmentsPayloadsyncInitialAttachments(AttachmentHolder holder, ServerPlayer to) Constructs a payload to sync all syncable attachments to a player, if any.static voidsyncInitialEntityAttachments(Entity entity, ServerPlayer to, Consumer<Packet<? super ClientGamePacketListener>> packetConsumer) Handles initial syncing of entity attachments, except for a player's own attachments.static voidsyncInitialLevelAttachments(ServerLevel level, ServerPlayer to) Handles initial syncing of level attachments.static voidHandles initial syncing of a player's own attachments.static voidsyncLevelUpdate(ServerLevel level, AttachmentType<?> type) private static SyncAttachmentsPayload.TargetsyncTarget(AttachmentHolder holder) private static <T> voidsyncUpdate(AttachmentHolder holder, AttachmentType<T> type, List<ServerPlayer> players) Syncs the update (possibly removal) of a single attachment type to a list of players.
-
Field Details
-
SYNCED_ATTACHMENT_TYPES
Contains all entries added toNeoForgeRegistries.ATTACHMENT_TYPESwith a sync handler. This ensures that non-synced attachments can be used freely on either side, but synced attachments must match across client and server. This also ensures that we can use the raw ids for network syncing.Should never be registered against directly. Entries are automatically added with
ATTACHMENT_TYPE_ADD_CALLBACK. -
ATTACHMENT_TYPE_ADD_CALLBACK
-
-
Constructor Details
-
AttachmentSync
private AttachmentSync()
-
-
Method Details
-
syncTarget
-
syncUpdate
private static <T> void syncUpdate(AttachmentHolder holder, AttachmentType<T> type, List<ServerPlayer> players) Syncs the update (possibly removal) of a single attachment type to a list of players. -
syncBlockEntityUpdate
-
syncChunkUpdate
public static void syncChunkUpdate(LevelChunk chunk, AttachmentHolder.AsField holder, AttachmentType<?> type) -
syncEntityUpdate
-
syncLevelUpdate
-
syncInitialAttachments
@Nullable private static @Nullable SyncAttachmentsPayload syncInitialAttachments(AttachmentHolder holder, ServerPlayer to) Constructs a payload to sync all syncable attachments to a player, if any. -
onChunkSent
Handles initial syncing of block entity and chunk attachments. -
syncInitialEntityAttachments
public static void syncInitialEntityAttachments(Entity entity, ServerPlayer to, Consumer<Packet<? super ClientGamePacketListener>> packetConsumer) Handles initial syncing of entity attachments, except for a player's own attachments. -
syncInitialPlayerAttachments
Handles initial syncing of a player's own attachments. -
syncInitialLevelAttachments
Handles initial syncing of level attachments. Needs to be called for login, respawn and teleports. -
receiveSyncedDataAttachments
public static void receiveSyncedDataAttachments(AttachmentHolder holder, RegistryAccess registryAccess, List<AttachmentType<?>> types, byte[] bytes)
-