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_TYPES
with a sync handler. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
onChunkSent
(ChunkWatchEvent.Sent event) Handles initial syncing of block entity and chunk attachments.static void
receiveSyncedDataAttachments
(AttachmentHolder holder, RegistryAccess registryAccess, List<AttachmentType<?>> types, byte[] bytes) static void
syncBlockEntityUpdate
(BlockEntity blockEntity, AttachmentType<?> type) static void
syncChunkUpdate
(LevelChunk chunk, AttachmentHolder.AsField holder, AttachmentType<?> type) static void
syncEntityUpdate
(Entity entity, AttachmentType<?> type) private static @Nullable SyncAttachmentsPayload
syncInitialAttachments
(AttachmentHolder holder, ServerPlayer to) Constructs a payload to sync all syncable attachments to a player, if any.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.static void
syncInitialLevelAttachments
(ServerLevel level, ServerPlayer to) Handles initial syncing of level attachments.static void
Handles initial syncing of a player's own attachments.static void
syncLevelUpdate
(ServerLevel level, AttachmentType<?> type) private static SyncAttachmentsPayload.Target
syncTarget
(AttachmentHolder holder) 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.
-
Field Details
-
SYNCED_ATTACHMENT_TYPES
Contains all entries added toNeoForgeRegistries.ATTACHMENT_TYPES
with 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)
-