List of usage examples for io.netty.buffer ByteBuf readUnsignedByte
public abstract short readUnsignedByte();
From source file:org.spout.vanilla.protocol.codec.entity.spawn.EntityThunderboltCodec.java
License:Open Source License
@Override public EntityThunderboltMessage decode(ByteBuf buffer) throws IOException { int id = buffer.readInt(); int mode = buffer.readUnsignedByte(); int x = buffer.readInt() / 32; int y = buffer.readInt() / 32; int z = buffer.readInt() / 32; return new EntityThunderboltMessage(id, mode, x, y, z, NullRepositionManager.getInstance()); }
From source file:org.spout.vanilla.protocol.codec.player.conn.PlayerLoginRequestCodec.java
License:Open Source License
@Override public PlayerLoginRequestMessage decodeFromServer(ByteBuf buffer) { int id = buffer.readInt(); String worldType = VanillaByteBufUtils.readString(buffer); byte mode = buffer.readByte(); byte dimension = buffer.readByte(); byte difficulty = buffer.readByte(); buffer.readUnsignedByte(); //not used? short maxPlayers = buffer.readUnsignedByte(); return new PlayerLoginRequestMessage(id, worldType, mode, dimension, difficulty, maxPlayers); }
From source file:org.spout.vanilla.protocol.codec.player.conn.PlayerLoginRequestCodec.java
License:Open Source License
@Override public PlayerLoginRequestMessage decodeFromClient(ByteBuf buffer) { int id = buffer.readInt(); String worldType = VanillaByteBufUtils.readString(buffer); byte mode = buffer.readByte(); byte dimension = buffer.readByte(); byte difficulty = buffer.readByte(); buffer.readUnsignedByte(); //not used? short maxPlayers = buffer.readUnsignedByte(); return new PlayerLoginRequestMessage(id, worldType, mode, dimension, difficulty, maxPlayers); }
From source file:org.spout.vanilla.protocol.codec.player.PlayerBedCodec.java
License:Open Source License
@Override public PlayerBedMessage decode(ByteBuf buffer) throws IOException { int id = buffer.readInt(); int used = buffer.readUnsignedByte(); int x = buffer.readInt(); int y = buffer.readUnsignedByte(); int z = buffer.readInt(); return new PlayerBedMessage(id, used, x, y, z, NullRepositionManager.getInstance()); }
From source file:org.spout.vanilla.protocol.codec.player.PlayerBlockPlacementCodec.java
License:Open Source License
@Override public PlayerBlockPlacementMessage decode(ByteBuf buffer) throws IOException { int x = buffer.readInt(); int y = buffer.readUnsignedByte(); int z = buffer.readInt(); BlockFace direction = BlockFaces.BTEWNS.get(buffer.readUnsignedByte(), BlockFace.THIS); ItemStack heldItem = VanillaByteBufUtils.readItemStack(buffer); float dx = ((float) (buffer.readByte() & 0xFF)) / 16.0F; float dy = ((float) (buffer.readByte() & 0xFF)) / 16.0F; float dz = ((float) (buffer.readByte() & 0xFF)) / 16.0F; return new PlayerBlockPlacementMessage(x, y, z, direction, new Vector3f(dx, dy, dz), heldItem, NullRepositionManager.getInstance()); }
From source file:org.spout.vanilla.protocol.codec.player.PlayerDiggingCodec.java
License:Open Source License
@Override public PlayerDiggingMessage decode(ByteBuf buffer) throws IOException { int state = buffer.readUnsignedByte(); int x = buffer.readInt(); int y = buffer.readUnsignedByte(); int z = buffer.readInt(); BlockFace face = BlockFaces.BTEWNS.get(buffer.readUnsignedByte(), BlockFace.THIS); return new PlayerDiggingMessage(state, x, y, z, face, NullRepositionManager.getInstance()); }
From source file:org.spout.vanilla.protocol.codec.player.pos.PlayerSpawnCodec.java
License:Open Source License
@Override public PlayerSpawnMessage decode(ByteBuf buffer) throws IOException { int id = buffer.readInt(); String name = VanillaByteBufUtils.readString(buffer); int x = buffer.readInt(); int y = buffer.readInt(); int z = buffer.readInt(); int rotation = buffer.readUnsignedByte(); int pitch = buffer.readUnsignedByte(); int item = buffer.readUnsignedShort(); List<Parameter<?>> parameters = VanillaByteBufUtils.readParameters(buffer); return new PlayerSpawnMessage(id, name, x, y, z, rotation, pitch, item, parameters); }
From source file:org.spout.vanilla.protocol.codec.window.WindowClickCodec.java
License:Open Source License
@Override public WindowClickMessage decode(ByteBuf buffer) throws IOException { int id = buffer.readUnsignedByte(); int slot = buffer.readUnsignedShort(); byte button = buffer.readByte(); int transaction = buffer.readUnsignedShort(); byte mode = buffer.readByte(); ItemStack item = VanillaByteBufUtils.readItemStack(buffer); return new WindowClickMessage(id, slot, button, transaction, mode, item); }
From source file:org.spout.vanilla.protocol.codec.window.WindowCloseCodec.java
License:Open Source License
@Override public WindowCloseMessage decode(ByteBuf buffer) throws IOException { int id = buffer.readUnsignedByte(); return new WindowCloseMessage(id); }
From source file:org.spout.vanilla.protocol.codec.window.WindowOpenCodec.java
License:Open Source License
@Override public WindowOpenMessage decode(ByteBuf buffer) throws IOException { int id = buffer.readUnsignedByte(); WindowType type = WindowType.get(buffer.readUnsignedByte()); if (type == null) { throw new IOException("Read Window Type is invalid"); }/*from w w w . j a v a 2 s.c o m*/ String title = VanillaByteBufUtils.readString(buffer); int slots = buffer.readUnsignedByte(); boolean useTitle = buffer.readUnsignedByte() != 0; return new WindowOpenMessage(id, type, title, slots, useTitle); }