List of usage examples for io.netty.buffer ByteBuf writeInt
public abstract ByteBuf writeInt(int value);
From source file:buildcraft.factory.TilePump.java
License:Minecraft Mod Public
@Override public PacketPayload getPacketPayload() { PacketPayload payload = new PacketPayload(new PacketPayload.StreamWriter() { @Override/*from ww w. j av a2 s. co m*/ public void writeData(ByteBuf buf) { buf.writeInt(aimY); buf.writeFloat((float) tubeY); buf.writeBoolean(powered); } }); return payload; }
From source file:buildcraft.factory.TileQuarry.java
License:Minecraft Mod Public
@Override public void writeData(ByteBuf stream) { super.writeData(stream); box.writeData(stream);/* w ww . j a v a 2 s. co m*/ stream.writeInt(targetX); stream.writeShort(targetY); stream.writeInt(targetZ); stream.writeDouble(headPosX); stream.writeDouble(headPosY); stream.writeDouble(headPosZ); stream.writeFloat((float) speed); stream.writeFloat((float) headTrajectory); int flags = stage.ordinal(); flags |= movingHorizontally ? 0x10 : 0; flags |= movingVertically ? 0x20 : 0; stream.writeByte(flags); }
From source file:buildcraft.robotics.EntityRobot.java
License:Minecraft Mod Public
private void setSteamDirection(final int x, final int y, final int z) { if (!worldObj.isRemote) { BuildCraftCore.instance.sendToEntity(new PacketCommand(this, "setSteamDirection", new CommandWriter() { public void write(ByteBuf data) { data.writeInt(x); data.writeShort(y);//from ww w . j av a2 s.c om data.writeInt(z); } }), this); } else { Vec3 v = Vec3.createVectorHelper(x, y, z); v = v.normalize(); steamDx = (int) v.xCoord; steamDy = (int) v.yCoord; steamDz = (int) v.zCoord; } }
From source file:buildcraft.robotics.gui.GuiZonePlan.java
License:Minecraft Mod Public
private void uploadMap() { BuildCraftCore.instance.sendToServer(new PacketCommand(getContainer(), "computeMap", new CommandWriter() { public void write(ByteBuf data) { data.writeInt(cx); data.writeInt(cz);// ww w . java2 s.c o m data.writeShort(getContainer().mapTexture.width); data.writeShort(getContainer().mapTexture.height); data.writeFloat(blocksPerPixel); } })); }
From source file:buildcraft.robots.EntityRobot.java
License:Minecraft Mod Public
private void setSteamDirection(final int x, final int y, final int z) { if (!worldObj.isRemote) { BuildCraftCore.instance.sendToWorld(new PacketCommand(this, "setSteamDirection", new CommandWriter() { public void write(ByteBuf data) { data.writeInt(x); data.writeShort(y);//from www. j av a2 s. c o m data.writeInt(z); } }), worldObj); } else { Vec3 v = Vec3.createVectorHelper(x, y, z); v = v.normalize(); steamDx = (int) v.xCoord; steamDy = (int) v.yCoord; steamDz = (int) v.zCoord; } }
From source file:buildcraft.transport.gui.ContainerGateInterface.java
License:Minecraft Mod Public
private PacketPayload getSelectionPayload(final int position) { PacketPayload payload = new PacketPayload(new PacketPayload.StreamWriter() { @Override/* w ww .ja v a 2 s . c om*/ public void writeData(ByteBuf data) { data.writeInt(position); if (pipe.gate.triggers[position] != null) { Utils.writeUTF(data, pipe.gate.triggers[position].getUniqueTag()); } else { Utils.writeUTF(data, ""); } if (pipe.gate.actions[position] != null) { Utils.writeUTF(data, pipe.gate.actions[position].getUniqueTag()); } else { Utils.writeUTF(data, ""); } if (pipe.gate.triggerParameters[position] != null && pipe.gate.triggerParameters[position].getItemStack() != null) { Utils.writeStack(data, pipe.gate.triggerParameters[position].getItemStack()); } else { Utils.writeStack(data, null); } } }); return payload; }
From source file:buildcraft.transport.gui.ContainerGateInterface.java
License:Minecraft Mod Public
/** * Sends the list of potential actions to the client * * @param player// w w w . ja v a 2s . c om */ private void sendActions(EntityPlayer player) { // Compose update packet PacketPayload payload = new PacketPayload(new PacketPayload.StreamWriter() { @Override public void writeData(ByteBuf data) { int length = potentialActions.size(); data.writeInt(length); for (IAction action : potentialActions) { Utils.writeUTF(data, action.getUniqueTag()); } } }); PacketUpdate packet = new PacketUpdate(PacketIds.GATE_ACTIONS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload); // Send to player BuildCraftTransport.instance.sendToPlayer(player, packet); }
From source file:buildcraft.transport.gui.ContainerGateInterface.java
License:Minecraft Mod Public
/** * Sends the list of potential triggers to the client * * @param player/*www.j a va 2 s . com*/ */ private void sendTriggers(EntityPlayer player) { PacketPayload payload = new PacketPayload(new PacketPayload.StreamWriter() { @Override public void writeData(ByteBuf data) { int length = potentialTriggers.size(); data.writeInt(length); for (ITrigger trigger : potentialTriggers) { Utils.writeUTF(data, trigger.getUniqueTag()); } } }); PacketUpdate packet = new PacketUpdate(PacketIds.GATE_TRIGGERS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload); // Send to player BuildCraftTransport.instance.sendToPlayer(player, packet); }
From source file:buildcraft.transport.network.PacketFluidUpdate.java
License:Minecraft Mod Public
@Override public void writeData(ByteBuf data) { super.writeData(data); byte[] dBytes = toByteArray(delta); // System.out.printf("write %d, %d, %d = %s, %s%n", posX, posY, posZ, Arrays.toString(dBytes), delta); data.writeBytes(dBytes);/*from ww w . ja v a 2 s.c o m*/ for (ForgeDirection dir : ForgeDirection.values()) { FluidStack liquid = renderCache[dir.ordinal()]; if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) { if (liquid != null) { data.writeShort(liquid.fluidID); data.writeInt(colorRenderCache[dir.ordinal()]); } else { data.writeShort(0); data.writeInt(0xFFFFFF); } } if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) { if (liquid != null) { data.writeInt(liquid.amount); } else { data.writeInt(0); } } } }
From source file:buildcraft.transport.network.PacketPipeTransportItemStack.java
License:Minecraft Mod Public
@Override public void writeData(ByteBuf data) { data.writeInt(entityId); Utils.writeStack(data, stack); }