C1
- old clientbound packet typesC2
- new clientbound packet typesS1
- old serverbound packet typesS2
- new serverbound packet typespublic interface Protocol<C1 extends ClientboundPacketType,C2 extends ClientboundPacketType,S1 extends ServerboundPacketType,S2 extends ServerboundPacketType>
Modifier and Type | Method and Description |
---|---|
void |
cancelClientbound(C1 packetType)
Cancels any clientbound packets from the given type.
|
void |
cancelClientbound(State state,
int oldPacketID) |
void |
cancelClientbound(State state,
int oldPacketID,
int newPacketID)
Deprecated.
|
void |
cancelServerbound(S2 packetType)
Cancels any serverbound packets from the given type.
|
void |
cancelServerbound(State state,
int newPacketID) |
void |
cancelServerbound(State state,
int oldPacketID,
int newPacketID)
Deprecated.
|
<T> T |
get(java.lang.Class<T> objectClass)
Returns a cached object by the given type if present.
|
default @Nullable EntityRewriter |
getEntityRewriter()
Returns the protocol's entity rewriter if present.
|
default @Nullable ItemRewriter |
getItemRewriter()
Returns the protocol's item rewriter if present.
|
default @Nullable MappingData |
getMappingData()
Returns the protocol's mapping data if present.
|
boolean |
hasMappingDataToLoad()
Returns true if this Protocol's
loadMappingData() method should be called. |
boolean |
hasRegisteredClientbound(C1 packetType)
Checks if a clientbound packet has already been registered.
|
boolean |
hasRegisteredClientbound(State state,
int oldPacketId)
Checks if a clientbound packet has already been registered.
|
boolean |
hasRegisteredServerbound(S2 packetType)
Checks if a serverbound packet has already been registered.
|
boolean |
hasRegisteredServerbound(State state,
int unmappedPacketId)
Checks if a serverbound packet has already been registered.
|
default void |
init(UserConnection userConnection)
Initialise a user for this protocol setting up objects.
|
void |
initialize()
Called with
ProtocolManager.registerProtocol(com.viaversion.viaversion.api.protocol.Protocol, com.viaversion.viaversion.api.protocol.version.ProtocolVersion, com.viaversion.viaversion.api.protocol.version.ProtocolVersion) to register packet handlers and automatic packet id remapping. |
default boolean |
isBaseProtocol()
Returns whether this protocol is a base protocol.
|
void |
loadMappingData()
Loads the protocol's mapping data.
|
void |
put(java.lang.Object object)
Caches an object, retrievable by using
get(Class) . |
default void |
register(ViaProviders providers)
Handle protocol registration phase, use this to register providers / tasks.
|
default void |
registerClientbound(C1 packetType,
C2 mappedPacketType)
Maps a packet type to another packet type without a packet handler.
|
default void |
registerClientbound(C1 packetType,
C2 mappedPacketType,
@Nullable PacketRemapper packetRemapper)
Registers a clientbound packet mapping.
|
void |
registerClientbound(C1 packetType,
C2 mappedPacketType,
@Nullable PacketRemapper packetRemapper,
boolean override)
Registers a clientbound packet mapping.
|
void |
registerClientbound(C1 packetType,
@Nullable PacketRemapper packetRemapper)
Registers a clientbound protocol and automatically maps it to the new id.
|
default void |
registerClientbound(State state,
int oldPacketID,
int newPacketID) |
default void |
registerClientbound(State state,
int oldPacketID,
int newPacketID,
PacketRemapper packetRemapper) |
void |
registerClientbound(State state,
int oldPacketID,
int newPacketID,
PacketRemapper packetRemapper,
boolean override)
Registers a clientbound packet, with id transformation and remapper.
|
void |
registerServerbound(S2 packetType,
@Nullable PacketRemapper packetRemapper)
Registers a serverbound protocol and automatically maps it to the server's id.
|
default void |
registerServerbound(S2 packetType,
S1 mappedPacketType)
Maps a packet type to another packet type without a packet handler.
|
default void |
registerServerbound(S2 packetType,
S1 mappedPacketType,
@Nullable PacketRemapper packetRemapper)
Registers a serverbound protocol.
|
void |
registerServerbound(S2 packetType,
S1 mappedPacketType,
@Nullable PacketRemapper packetRemapper,
boolean override)
Registers a serverbound packet mapping.
|
default void |
registerServerbound(State state,
int oldPacketID,
int newPacketID) |
default void |
registerServerbound(State state,
int oldPacketID,
int newPacketID,
PacketRemapper packetRemapper) |
void |
registerServerbound(State state,
int oldPacketID,
int newPacketID,
PacketRemapper packetRemapper,
boolean override)
Registers a serverbound packet, with id transformation and remapper.
|
void |
transform(Direction direction,
State state,
PacketWrapper packetWrapper)
Transform a packet using this protocol
|
default void registerServerbound(State state, int oldPacketID, int newPacketID)
default void registerServerbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper)
void registerServerbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override)
state
- state which the packet is sent in.oldPacketID
- old packet IDnewPacketID
- new packet IDpacketRemapper
- remapper to use for the packetoverride
- whether an existing mapper should be overriddenregisterServerbound(ServerboundPacketType, ServerboundPacketType, PacketRemapper, boolean)
@Deprecated void cancelServerbound(State state, int oldPacketID, int newPacketID)
cancelServerbound(State, int)
void cancelServerbound(State state, int newPacketID)
default void registerClientbound(State state, int oldPacketID, int newPacketID)
default void registerClientbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper)
@Deprecated void cancelClientbound(State state, int oldPacketID, int newPacketID)
cancelClientbound(State, int)
void cancelClientbound(State state, int oldPacketID)
void registerClientbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override)
state
- state which the packet is sent in.oldPacketID
- old packet IDnewPacketID
- new packet IDpacketRemapper
- remapper to use for the packetoverride
- whether an existing mapper should be overriddenregisterClientbound(ClientboundPacketType, ClientboundPacketType, PacketRemapper, boolean)
void registerClientbound(C1 packetType, @Nullable PacketRemapper packetRemapper)
packetType
- clientbound packet type the server sendspacketRemapper
- remapperdefault void registerClientbound(C1 packetType, C2 mappedPacketType)
packetType
- clientbound packet type the server initially sendsmappedPacketType
- clientbound packet type after transforming for the clientdefault void registerClientbound(C1 packetType, C2 mappedPacketType, @Nullable PacketRemapper packetRemapper)
packetType
- clientbound packet type the server initially sendsmappedPacketType
- clientbound packet type after transforming for the clientpacketRemapper
- remappervoid registerClientbound(C1 packetType, C2 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override)
packetType
- clientbound packet type the server initially sendsmappedPacketType
- clientbound packet type after transforming for the clientpacketRemapper
- remapperoverride
- whether an existing mapping should be overridden if presentvoid cancelClientbound(C1 packetType)
packetType
- clientbound packet type to canceldefault void registerServerbound(S2 packetType, S1 mappedPacketType)
packetType
- serverbound packet type the client initially sendsmappedPacketType
- serverbound packet type after transforming for the clientvoid registerServerbound(S2 packetType, @Nullable PacketRemapper packetRemapper)
packetType
- serverbound packet type the client sendspacketRemapper
- remapperdefault void registerServerbound(S2 packetType, S1 mappedPacketType, @Nullable PacketRemapper packetRemapper)
packetType
- serverbound packet type initially sent by the clientmappedPacketType
- serverbound packet type after transforming for the serverpacketRemapper
- remappervoid registerServerbound(S2 packetType, S1 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override)
packetType
- serverbound packet type initially sent by the clientmappedPacketType
- serverbound packet type after transforming for the serverpacketRemapper
- remapperoverride
- whether an existing mapping should be overridden if presentvoid cancelServerbound(S2 packetType)
packetType
- serverbound packet type to cancelboolean hasRegisteredClientbound(C1 packetType)
packetType
- clientbound packet typeboolean hasRegisteredServerbound(S2 packetType)
packetType
- serverbound packet typeboolean hasRegisteredClientbound(State state, int oldPacketId)
state
- state which the packet is sent inoldPacketId
- old packet idboolean hasRegisteredServerbound(State state, int unmappedPacketId)
state
- state which the packet is sent inunmappedPacketId
- new packet idvoid transform(Direction direction, State state, PacketWrapper packetWrapper) throws java.lang.Exception
direction
- The direction the packet is going instate
- The current protocol statepacketWrapper
- The packet wrapper to transformjava.lang.Exception
- Throws exception if it fails to transform<T> T get(java.lang.Class<T> objectClass)
T
- typeobjectClass
- class of the object to getvoid put(java.lang.Object object)
get(Class)
.object
- object to cachevoid initialize()
ProtocolManager.registerProtocol(com.viaversion.viaversion.api.protocol.Protocol, com.viaversion.viaversion.api.protocol.version.ProtocolVersion, com.viaversion.viaversion.api.protocol.version.ProtocolVersion)
to register packet handlers and automatic packet id remapping.java.lang.IllegalArgumentException
- if this method has already been calledboolean hasMappingDataToLoad()
loadMappingData()
method should be called.
This does *not* necessarily mean that getMappingData()
is non-null, since this may be
overriden, depending on special cases.
loadMappingData()
method should be calledvoid loadMappingData()
java.lang.NullPointerException
- if this protocol has no mapping datadefault void register(ViaProviders providers)
To be overridden if needed.
providers
- The current providersdefault void init(UserConnection userConnection)
UserConnection
To be overridden if needed.
userConnection
- The user to initialisedefault @Nullable MappingData getMappingData()
default @Nullable EntityRewriter getEntityRewriter()
default @Nullable ItemRewriter getItemRewriter()
default boolean isBaseProtocol()