use of net.minecraft.network.PacketBuffer 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();
}
}
use of net.minecraft.network.PacketBuffer in project minecolonies by Minecolonies.
the class SaveScanMessage method toBytes.
@Override
public void toBytes(@NotNull final ByteBuf buf) {
final NBTTagCompound wrapperCompound = new NBTTagCompound();
wrapperCompound.setString(TAG_MILLIS, fileName);
wrapperCompound.setTag(TAG_SCHEMATIC, nbttagcompound);
final PacketBuffer buffer = new PacketBuffer(buf);
try (ByteBufOutputStream stream = new ByteBufOutputStream(buffer)) {
CompressedStreamTools.writeCompressed(wrapperCompound, stream);
} catch (final IOException e) {
Log.getLogger().info("Problem at retrieving structure on server.", e);
}
}
use of net.minecraft.network.PacketBuffer in project Bewitchment by Um-Mitternacht.
the class ParticleMessage method fromBytes.
@Override
public void fromBytes(ByteBuf byteBuf) {
PacketBuffer buf = new PacketBuffer(byteBuf);
particleF = buf.readEnumValue(ParticleF.class);
x = buf.readDouble();
y = buf.readDouble();
z = buf.readDouble();
amount = buf.readInt();
xSpeed = buf.readDouble();
ySpeed = buf.readDouble();
zSpeed = buf.readDouble();
int argCount = buf.readInt();
args = new int[argCount];
for (int i = 0; i < argCount; i++) {
args[i] = buf.readInt();
}
}
use of net.minecraft.network.PacketBuffer in project Solar by ArekkuusuJerii.
the class ServerToClientPacket method fromBytes.
@Override
public void fromBytes(ByteBuf buf) {
PacketBuffer beef = new PacketBuffer(buf);
try {
handler = PacketHandler.HANDLERS.get(buf.readInt());
data = beef.readCompoundTag();
} catch (Exception e) {
Solar.LOG.error("[Packet] Failed to receive packet");
e.printStackTrace();
}
}
use of net.minecraft.network.PacketBuffer in project Solar by ArekkuusuJerii.
the class ClientToServerPacket method fromBytes.
@Override
public void fromBytes(ByteBuf buf) {
PacketBuffer beef = new PacketBuffer(buf);
try {
handler = PacketHandler.HANDLERS.get(buf.readInt());
data = beef.readCompoundTag();
} catch (Exception e) {
Solar.LOG.error("[Packet] Failed to receive packet");
e.printStackTrace();
}
}
Aggregations