List of usage examples for io.netty.buffer ByteBuf readUnsignedByte
public abstract short readUnsignedByte();
From source file:buildcraft.core.lib.network.command.PacketCommand.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf data) { command = NetworkUtils.readUTF(data); handler = targets.get(data.readUnsignedByte()); stream = data; // for further reading }
From source file:buildcraft.core.list.ContainerListNew.java
License:Minecraft Mod Public
@Override public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) { if (side.isServer()) { if ("setLabel".equals(command)) { setLabel(NetworkUtils.readUTF(stream)); } else if ("switchButton".equals(command)) { switchButton(stream.readUnsignedByte(), stream.readUnsignedByte()); } else if ("setStack".equals(command)) { setStack(stream.readUnsignedByte(), stream.readUnsignedByte(), NetworkUtils.readStack(stream)); }//from ww w. j ava 2 s .c o m } }
From source file:buildcraft.core.network.PacketCommand.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf data) { command = Utils.readUTF(data);// w w w .j av a 2s.c om handler = targets.get(data.readUnsignedByte()); stream = data; // for further reading }
From source file:buildcraft.energy.TileEngineCreative.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf stream) { super.readData(stream); powerMode = PowerMode.fromId(stream.readUnsignedByte()); }
From source file:buildcraft.factory.TileMiningWell.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf stream) { super.readData(stream); int newLedState = stream.readUnsignedByte(); if (newLedState != ledState) { ledState = newLedState;//from ww w. j a v a2 s .co m worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); } }
From source file:buildcraft.factory.TileQuarry.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf stream) { super.readData(stream); box.readData(stream);/*from w ww .j a v a 2s. c o m*/ targetX = stream.readInt(); targetY = stream.readUnsignedShort(); targetZ = stream.readInt(); headPosX = stream.readDouble(); headPosY = stream.readDouble(); headPosZ = stream.readDouble(); speed = stream.readFloat(); headTrajectory = stream.readFloat(); int flags = stream.readUnsignedByte(); stage = Stage.values()[flags & 0x07]; movingHorizontally = (flags & 0x10) != 0; movingVertically = (flags & 0x20) != 0; createUtilsIfNeeded(); if (arm != null) { arm.setHead(headPosX, headPosY, headPosZ); arm.updatePosition(); } }
From source file:buildcraft.robotics.EntityRobot.java
License:Minecraft Mod Public
@Override public void readSpawnData(ByteBuf data) { int amount = data.readUnsignedByte(); while (amount > 0) { wearables.add(NetworkUtils.readStack(data)); amount--;/*from w w w . j av a 2 s .com*/ } init(); }
From source file:buildcraft.robotics.EntityRobot.java
License:Minecraft Mod Public
@Override public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) { if (side.isClient()) { if ("clientSetItemInUse".equals(command)) { itemInUse = NetworkUtils.readStack(stream); } else if ("clientSetInventory".equals(command)) { int slot = stream.readUnsignedShort(); inv[slot] = NetworkUtils.readStack(stream); } else if ("initialize".equals(command)) { itemInUse = NetworkUtils.readStack(stream); itemActive = stream.readBoolean(); } else if ("setItemActive".equals(command)) { itemActive = stream.readBoolean(); itemActiveStage = 0;/*from w ww . j av a 2 s . c om*/ lastUpdateTime = new Date().getTime(); if (!itemActive) { setSteamDirection(0, -1, 0); } } else if ("setSteamDirection".equals(command)) { setSteamDirection(stream.readInt(), stream.readShort(), stream.readInt()); } else if ("syncWearables".equals(command)) { wearables.clear(); int amount = stream.readUnsignedByte(); while (amount > 0) { wearables.add(NetworkUtils.readStack(stream)); amount--; } } } else if (side.isServer()) { EntityPlayer p = (EntityPlayer) sender; if ("requestInitialization".equals(command)) { BuildCraftCore.instance.sendToPlayer(p, new PacketCommand(this, "initialize", new CommandWriter() { public void write(ByteBuf data) { NetworkUtils.writeStack(data, itemInUse); data.writeBoolean(itemActive); } })); for (int i = 0; i < inv.length; ++i) { final int j = i; BuildCraftCore.instance.sendToPlayer(p, new PacketCommand(this, "clientSetInventory", new CommandWriter() { public void write(ByteBuf data) { data.writeShort(j); NetworkUtils.writeStack(data, inv[j]); } })); } if (currentDockingStation != null) { setSteamDirection(currentDockingStation.side.offsetX, currentDockingStation.side.offsetY, currentDockingStation.side.offsetZ); } else { setSteamDirection(0, -1, 0); } } } }
From source file:buildcraft.robotics.gui.ContainerZonePlan.java
License:Minecraft Mod Public
@Override public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) { if (side.isClient()) { if ("areaLoaded".equals(command)) { currentAreaSelection = new ZonePlan(); currentAreaSelection.readData(stream); gui.refreshSelectedArea();/* w w w. j a v a 2 s. com*/ } else if ("receiveImage".equals(command)) { int size = stream.readUnsignedMedium(); int pos = stream.readUnsignedMedium(); for (int i = 0; i < Math.min(size - pos, MAX_PACKET_LENGTH); ++i) { mapTexture.colorMap[pos + i] = 0xFF000000 | MapColor.mapColorArray[stream.readUnsignedByte()].colorValue; } } } else if (side.isServer()) { if ("loadArea".equals(command)) { final int index = stream.readUnsignedByte(); BuildCraftCore.instance.sendToPlayer((EntityPlayer) sender, new PacketCommand(this, "areaLoaded", new CommandWriter() { public void write(ByteBuf data) { map.selectArea(index).writeData(data); } })); } else if ("saveArea".equals(command)) { final int index = stream.readUnsignedByte(); ZonePlan plan = new ZonePlan(); plan.readData(stream); map.setArea(index, plan); } else if ("computeMap".equals(command)) { computeMap(stream.readInt(), stream.readInt(), stream.readUnsignedShort(), stream.readUnsignedShort(), stream.readFloat(), (EntityPlayer) sender); } else if ("setName".equals(command)) { map.mapName = NetworkUtils.readUTF(stream); } } }
From source file:buildcraft.robotics.TileRequester.java
License:Minecraft Mod Public
@Override public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) { if (side.isServer() && "setRequest".equals(command)) { setRequest(stream.readUnsignedByte(), NetworkUtils.readStack(stream)); }/*from w w w . ja v a 2 s.co m*/ }