Record Class EnchantmentMenuSyncPayload
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.network.EnchantmentMenuSyncPayload
- Record Components:
containerId- The ID of the container menu receiving the sync.contexts- The list of calculated enchantment contexts to display in the UI.
- All Implemented Interfaces:
net.minecraft.network.protocol.common.custom.CustomPacketPayload
public record EnchantmentMenuSyncPayload(int containerId, List<EnchantContext> contexts)
extends Record
implements net.minecraft.network.protocol.common.custom.CustomPacketPayload
A custom network payload responsible for synchronizing the complex, dynamically generated
list of
EnchantContexts from the server to the client's enchanting menu.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.network.protocol.common.custom.CustomPacketPayload
net.minecraft.network.protocol.common.custom.CustomPacketPayload.FallbackProvider<B extends net.minecraft.network.FriendlyByteBuf>, net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>, net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<B extends net.minecraft.network.FriendlyByteBuf,T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, EnchantContext> A stream codec for serializing and deserializing fullEnchantContextobjects.static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, net.minecraft.world.item.enchantment.EnchantmentInstance> A stream codec for serializing and deserializingEnchantmentInstanceobjects.static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, PendingEnchantment> A stream codec for serializing and deserializingPendingEnchantmentobjects.static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, EnchantmentMenuSyncPayload> The primary stream codec for the entireEnchantmentMenuSyncPayload.static final net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<EnchantmentMenuSyncPayload> The unique identifier type for this custom payload. -
Constructor Summary
ConstructorsConstructorDescriptionEnchantmentMenuSyncPayload(int containerId, List<EnchantContext> contexts) Creates an instance of aEnchantmentMenuSyncPayloadrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecontainerIdrecord component.contexts()Returns the value of thecontextsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type()
-
Field Details
-
TYPE
public static final net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<EnchantmentMenuSyncPayload> TYPEThe unique identifier type for this custom payload. -
ENCHANTMENT_INSTANCE_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,net.minecraft.world.item.enchantment.EnchantmentInstance> ENCHANTMENT_INSTANCE_CODECA stream codec for serializing and deserializingEnchantmentInstanceobjects.Safely unwraps the
Holderinto aIdentifierfor network transit to prevent crashes associated with transmitting unbound direct holders. -
PENDING_ENCHANTMENT_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,PendingEnchantment> PENDING_ENCHANTMENT_CODECA stream codec for serializing and deserializingPendingEnchantmentobjects. -
CONTEXT_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,EnchantContext> CONTEXT_CODECA stream codec for serializing and deserializing fullEnchantContextobjects. -
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,EnchantmentMenuSyncPayload> STREAM_CODECThe primary stream codec for the entireEnchantmentMenuSyncPayload.
-
-
Constructor Details
-
EnchantmentMenuSyncPayload
Creates an instance of aEnchantmentMenuSyncPayloadrecord class.- Parameters:
containerId- the value for thecontainerIdrecord componentcontexts- the value for thecontextsrecord component
-
-
Method Details
-
type
public net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type()- Specified by:
typein interfacenet.minecraft.network.protocol.common.custom.CustomPacketPayload
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
containerId
public int containerId()Returns the value of thecontainerIdrecord component.- Returns:
- the value of the
containerIdrecord component
-
contexts
Returns the value of thecontextsrecord component.- Returns:
- the value of the
contextsrecord component
-