List of usage examples for io.netty.buffer ByteBuf readInt
public abstract int readInt();
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 w w. j a v a2 s . 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 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 www .java 2s .c o m*/ 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();//from w w w . j ava 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.robots.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 = Utils.readStack(stream); } else if ("clientSetInventory".equals(command)) { int slot = stream.readUnsignedShort(); inv[slot] = Utils.readStack(stream); } else if ("initialize".equals(command)) { itemInUse = Utils.readStack(stream); itemActive = stream.readBoolean(); } else if ("setItemActive".equals(command)) { itemActive = stream.readBoolean(); itemActiveStage = 0;// w w w .j av a2 s .c o m lastUpdateTime = new Date().getTime(); if (!itemActive) { setSteamDirection(0, -1, 0); } } else if ("setSteamDirection".equals(command)) { setSteamDirection(stream.readInt(), stream.readShort(), stream.readInt()); } } 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) { Utils.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); Utils.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.transport.gui.ContainerGateInterface.java
License:Minecraft Mod Public
/** * Sets the currently selected actions and triggers according to packet. * * @param packet// w w w.jav a2s. co m */ public void setSelection(PacketUpdate packet, boolean notify) { PacketPayload payload = packet.payload; ByteBuf data = payload.stream; int position = data.readInt(); setTrigger(position, ActionManager.triggers.get(Utils.readUTF(data)), notify); setAction(position, ActionManager.actions.get(Utils.readUTF(data)), notify); ItemStack parameter = Utils.readStack(data); if (parameter != null) { ITriggerParameter param = new TriggerParameter(); param.set(parameter); setTriggerParameter(position, param, notify); } else { setTriggerParameter(position, null, notify); } }
From source file:buildcraft.transport.network.PacketFluidUpdate.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf data) { super.readData(data); World world = CoreProxy.proxy.getClientWorld(); if (!world.blockExists(posX, posY, posZ)) { return;/* w w w . java2s. com*/ } TileEntity entity = world.getTileEntity(posX, posY, posZ); if (!(entity instanceof TileGenericPipe)) { return; } TileGenericPipe pipe = (TileGenericPipe) entity; if (pipe.pipe == null) { return; } if (!(pipe.pipe.transport instanceof PipeTransportFluids)) { return; } PipeTransportFluids transLiq = (PipeTransportFluids) pipe.pipe.transport; renderCache = transLiq.renderCache; colorRenderCache = transLiq.colorRenderCache; byte[] dBytes = new byte[2]; data.readBytes(dBytes); delta = fromByteArray(dBytes); // System.out.printf("read %d, %d, %d = %s, %s%n", posX, posY, posZ, Arrays.toString(dBytes), delta); for (ForgeDirection dir : ForgeDirection.values()) { if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) { int amt = renderCache[dir.ordinal()] != null ? renderCache[dir.ordinal()].amount : 0; renderCache[dir.ordinal()] = new FluidStack(data.readShort(), amt); colorRenderCache[dir.ordinal()] = data.readInt(); } if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) { if (renderCache[dir.ordinal()] == null) { renderCache[dir.ordinal()] = new FluidStack(0, 0); } renderCache[dir.ordinal()].amount = Math.min(transLiq.getCapacity(), data.readInt()); } } }
From source file:buildcraft.transport.network.PacketPipeTransportItemStack.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf data) { this.entityId = data.readInt(); stack = Utils.readStack(data);//from w w w. j ava 2 s.com TravelingItem item = TravelingItem.clientCache.get(entityId); if (item != null) { item.setItemStack(stack); } }
From source file:buildcraft.transport.PipeRenderState.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf data) { isGateLit = data.readBoolean();/*from ww w . ja v a 2s .c o m*/ isGatePulsing = data.readBoolean(); gateIconIndex = data.readInt(); pipeConnectionMatrix.readData(data); textureMatrix.readData(data); wireMatrix.readData(data); facadeMatrix.readData(data); plugMatrix.readData(data); robotStationMatrix.readData(data); }
From source file:buildcraft.transport.pipes.PipeFluidsWood.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf data) { liquidToExtract = data.readInt(); }
From source file:buildcraft.transport.utils.GateMatrix.java
License:Minecraft Mod Public
public void readData(ByteBuf data) { for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { isGateLit[i] = data.readBoolean(); isGatePulsing[i] = data.readBoolean(); isGateExists[i] = data.readBoolean(); gateIconIndex[i] = data.readInt(); }/*from w w w . j av a 2 s . co m*/ }