use of net.minecraft.network.play.client.C17PacketCustomPayload in project Hyperium by HyperiumClient.
the class MixinNetHandlerPlayClient method handleCustomPayload.
@Inject(method = "handleCustomPayload", at = @At("RETURN"))
private void handleCustomPayload(S3FPacketCustomPayload packetIn, CallbackInfo ci) {
PacketBuffer packetBuffer = packetIn.getBufferData();
try {
int readableBytes = packetBuffer.readableBytes();
if (readableBytes > 0) {
byte[] payload = new byte[readableBytes - 1];
packetBuffer.readBytes(payload);
String message = new String(payload, Charsets.UTF_8);
if (LoginReplyHandler.SHOW_MESSAGES) {
GeneralChatHandler.instance().sendMessage("Packet message on channel " + packetIn.getChannelName() + " -> " + message);
}
if ("REGISTER".equalsIgnoreCase(packetIn.getChannelName())) {
if (message.contains("Hyperium")) {
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
buffer.writeString("Hyperium;" + Metadata.getVersion() + ";" + Metadata.getVersionID());
addToSendQueue(new C17PacketCustomPayload("REGISTER", buffer));
PacketBuffer addonbuffer = new PacketBuffer(Unpooled.buffer());
List<AddonManifest> addons = AddonBootstrap.INSTANCE.getAddonManifests();
addonbuffer.writeInt(addons.size());
for (AddonManifest addonmanifest : addons) {
String addonName = addonmanifest.getName();
String version = addonmanifest.getVersion();
if (addonName == null)
addonName = addonmanifest.getMainClass();
if (version == null)
version = "unknown";
addonbuffer.writeString(addonName);
addonbuffer.writeString(version);
}
addToSendQueue(new C17PacketCustomPayload("hyperium|Addons", addonbuffer));
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations