net.minecraft.util.io.netty.buffer.Unpooled Java Examples
The following examples show how to use
net.minecraft.util.io.netty.buffer.Unpooled.
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: PacketConverter7.java From Hawk with GNU General Public License v3.0 | 6 votes |
private static HawkAsyncPlayerMetadataEvent packetToPlayerMetadataEvent(PacketPlayOutEntityMetadata packet, Player p) { PacketDataSerializer serializer = new PacketDataSerializer(Unpooled.buffer(0)); packet.b(serializer); int id = serializer.readInt(); List metaData = DataWatcher.b(serializer); if(id != p.getEntityId() || metaData == null) return null; List<WrappedWatchableObject> wrappedMetaData = new ArrayList<>(); for(Object object : metaData) { if(object instanceof WatchableObject) { WatchableObject wO = (WatchableObject) object; WrappedWatchableObject wwO = new WrappedWatchableObject(wO.c(), wO.a(), wO.b()); wwO.setWatched(wO.d()); wrappedMetaData.add(wwO); } } return new HawkAsyncPlayerMetadataEvent(p, wrappedMetaData); }
Example #2
Source File: WrappedPacket7.java From Hawk with GNU General Public License v3.0 | 5 votes |
public void setByte(int index, int value) { PacketDataSerializer serializer = new PacketDataSerializer(Unpooled.buffer(0)); try { ((Packet) packet).b(serializer); //"b" method writes to PacketDataSerializer (reads from packet) serializer.setByte(index, value); ((Packet) packet).a(serializer); //"a" method interprets PacketDataSerializer (writes to packet) } catch (IOException e) { e.printStackTrace(); } }
Example #3
Source File: WrappedPacket7.java From Hawk with GNU General Public License v3.0 | 5 votes |
public byte[] getBytes() { PacketDataSerializer serializer = new PacketDataSerializer(Unpooled.buffer(0)); try { ((Packet) packet).b(serializer); //"b" method writes to PacketDataSerializer (reads from packet) } catch (IOException e) { e.printStackTrace(); } return serializer.array(); }
Example #4
Source File: WrappedPacket7.java From Hawk with GNU General Public License v3.0 | 5 votes |
public PacketDataSerializer readPacket() { PacketDataSerializer serializer = new PacketDataSerializer(Unpooled.buffer(0)); try { ((Packet) packet).b(serializer); //"b" method writes to PacketDataSerializer (reads from packet) } catch (IOException e) { e.printStackTrace(); } return serializer; }
Example #5
Source File: BungeeProvider.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
private void requestPlayerCount(String serverName) { if (ServerUtil.getOnlinePlayers().size() == 0) { return; // No players online; we can't send this request yet. } ByteBuf buf = Unpooled.buffer(); MiscUtil.writePrefixedString(buf, "PlayerCount"); MiscUtil.writePrefixedString(buf, serverName); byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes); ServerUtil.getOnlinePlayer(0).sendPluginMessage(plugin, "BungeeCord", bytes); buf.release(); }
Example #6
Source File: BungeeProvider.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@Override public void run() { if (ServerUtil.getOnlinePlayers().size() == 0) { return; } ByteBuf buf = Unpooled.buffer(); MiscUtil.writePrefixedString(buf, "GetServers"); byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes); ServerUtil.getOnlinePlayer(0).sendPluginMessage(plugin, "BungeeCord", bytes); buf.release(); }