Java Code Examples for net.minecraft.network.PacketBuffer#readBytes()
The following examples show how to use
net.minecraft.network.PacketBuffer#readBytes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyncedTileEntity.java From OpenModsLib with MIT License | 5 votes |
private NBTTagCompound serializeInitializationData(NBTTagCompound tag) { final PacketBuffer tmp = new PacketBuffer(Unpooled.buffer()); try { getSyncMap().writeInitializationData(tmp); } catch (IOException e) { throw new RuntimeException(e); } byte[] data = new byte[tmp.readableBytes()]; tmp.readBytes(data); tag.setByteArray(TAG_SYNC_INIT, data); return tag; }
Example 2
Source File: MixinNetHandlerPlayClient.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
@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(); } }
Example 3
Source File: StreamUtils.java From OpenModsLib with MIT License | 4 votes |
public static byte[] readBytes(PacketBuffer stream, int count) { byte[] buffer = new byte[count]; stream.readBytes(buffer); return buffer; }
Example 4
Source File: Command.java From OpenModsLib with MIT License | 4 votes |
protected static PacketBuffer readChunk(PacketBuffer input) { final int size = input.readVarInt(); return new PacketBuffer(input.readBytes(size)); }