Package io.github.kosmx.emotes.api.proxy
Class AbstractNetworkInstance
java.lang.Object
io.github.kosmx.emotes.api.proxy.AbstractNetworkInstance
- All Implemented Interfaces:
INetworkInstance
Implement this if you want to act as a proxy for EmoteX
This has most of the functions implemented as you might want, but you can override any.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidWhen the network instance disconnects...seeINetworkInstance.getRemoteVersions()it is just a default implementationbooleanDoes the track the emote play state of every player -> true The client has to resend the emote if a new player get close -> falsevoidreceiveMessage(EmotePacket packet) Receive message, but you don't know who sent this The bytes data has to contain the identity of the senderINetworkInstance.trustReceivedPlayer()should return true as you don't have your own identifier system as alternativevoidsendC2SConfig(Consumer<EmotePacket.Builder> consumer) Client is sending config message to server.voidsendMessage(EmotePacket.Builder builder, @Nullable UUID target) Send not prepared message, if you want to modify the message before sending, override this.voidsendMessage(EmotePacket packet, @Nullable UUID target) If you want to send byte arrayvoidsetVersions(Map<Byte, Byte> map) Default client-side version config, Please call super if you override it.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.kosmx.emotes.api.proxy.INetworkInstance
isActive, maxDataSize, presenceResponse, receiveMessage, sendPlayerID, trustReceivedPlayer
-
Constructor Details
-
AbstractNetworkInstance
public AbstractNetworkInstance()
-
-
Method Details
-
sendMessage
If you want to send byte arrayYou can wrap bytes to Netty
Unpooled.wrappedBuffer(bytes)or to Minecraft's PacketByteBuf (yarn mappings) / FriendlyByteBuf (official mappings)new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes))- Parameters:
packet- bytes to sendtarget- target to send message, if null, everyone in the view distance
-
sendMessage
public void sendMessage(EmotePacket.Builder builder, @Nullable @Nullable UUID target) throws IOException Send not prepared message, if you want to modify the message before sending, override this. You can call the super, but if you do, you'll need to override another.For example, you want to manipulate the data, before sending, override this, edit the builder, call its super then override
sendMessage(EmotePacket, UUID)to send the bytes data- Specified by:
sendMessagein interfaceINetworkInstance- Parameters:
builder- EmotePacket buildertarget- target to send message, if null, everyone in the view distance- Throws:
IOException- throws IOException if packet writing has failed
-
receiveMessage
Receive message, but you don't know who sent this The bytes data has to contain the identity of the senderINetworkInstance.trustReceivedPlayer()should return true as you don't have your own identifier system as alternative- Parameters:
packet- message
-
disconnect
protected void disconnect()When the network instance disconnects... -
setVersions
Default client-side version config, Please call super if you override it.- Specified by:
setVersionsin interfaceINetworkInstance- Parameters:
map- version/config map
-
getRemoteVersions
seeINetworkInstance.getRemoteVersions()it is just a default implementation- Specified by:
getRemoteVersionsin interfaceINetworkInstance- Returns:
- maybe null
-
isServerTrackingPlayState
public boolean isServerTrackingPlayState()Description copied from interface:INetworkInstanceDoes the track the emote play state of every player -> true The client has to resend the emote if a new player get close -> false- Specified by:
isServerTrackingPlayStatein interfaceINetworkInstance
-
sendC2SConfig
Description copied from interface:INetworkInstanceClient is sending config message to server. Vanilla clients will answer to the server configuration phase message. This might get invoked multiple times on the same network instance.- Specified by:
sendC2SConfigin interfaceINetworkInstance
-