List of usage examples for io.netty.buffer ByteBuf writeByte
public abstract ByteBuf writeByte(int value);
From source file:buildcraft.core.list.ContainerListNew.java
License:Minecraft Mod Public
public void setStack(final int lineIndex, final int slotIndex, final ItemStack stack) { lines[lineIndex].setStack(slotIndex, stack); ListHandlerNew.saveLines(player.getCurrentEquippedItem(), lines); if (player.worldObj.isRemote) { BuildCraftCore.instance.sendToServer(new PacketCommand(this, "setStack", new CommandWriter() { public void write(ByteBuf data) { data.writeByte(lineIndex); data.writeByte(slotIndex); NetworkUtils.writeStack(data, stack); }/* w w w . j a v a 2s .c om*/ })); } }
From source file:buildcraft.core.list.ContainerListNew.java
License:Minecraft Mod Public
public void switchButton(final int lineIndex, final int button) { lines[lineIndex].toggleOption(button); ListHandlerNew.saveLines(player.getCurrentEquippedItem(), lines); if (player.worldObj.isRemote) { BuildCraftCore.instance.sendToServer(new PacketCommand(this, "switchButton", new CommandWriter() { public void write(ByteBuf data) { data.writeByte(lineIndex); data.writeByte(button);//from w w w. j a v a2 s . co m } })); } }
From source file:buildcraft.core.list.ContainerListOld.java
License:Minecraft Mod Public
public void setStack(final int lineIndex, final int slotIndex, final ItemStack stack) { lines[lineIndex].setStack(slotIndex, stack); ListHandlerOld.saveLine(player.getCurrentEquippedItem(), lines[lineIndex], lineIndex); if (player.worldObj.isRemote) { BuildCraftCore.instance.sendToServer(new PacketCommand(this, "setStack", new CommandWriter() { public void write(ByteBuf data) { data.writeByte(lineIndex); data.writeByte(slotIndex); NetworkUtils.writeStack(data, stack); }/*from w w w . ja v a 2 s . com*/ })); } }
From source file:buildcraft.core.list.ContainerListOld.java
License:Minecraft Mod Public
public void switchButton(final int lineIndex, final int button) { if (button == 0) { lines[lineIndex].oreWildcard = false; lines[lineIndex].subitemsWildcard = !lines[lineIndex].subitemsWildcard; } else if (button == 1 && lines[lineIndex].isOre) { lines[lineIndex].subitemsWildcard = false; lines[lineIndex].oreWildcard = !lines[lineIndex].oreWildcard; }/*from w w w.j av a 2 s . c o m*/ ListHandlerOld.saveLine(player.getCurrentEquippedItem(), lines[lineIndex], lineIndex); if (player.worldObj.isRemote) { BuildCraftCore.instance.sendToServer(new PacketCommand(this, "switchButton", new CommandWriter() { public void write(ByteBuf data) { data.writeByte(lineIndex); data.writeByte(button); } })); } }
From source file:buildcraft.core.network.PacketCommand.java
License:Minecraft Mod Public
@Override public void writeData(ByteBuf data) { Utils.writeUTF(data, command);/*from w w w .j av a 2 s .co m*/ data.writeByte(targets.indexOf(handler)); handler.write(data, target); if (writer != null) { writer.write(data); } }
From source file:buildcraft.core.network.PacketCoordinates.java
License:Minecraft Mod Public
@Override public void writeData(ByteBuf data) { data.writeByte(id); data.writeInt(posX); data.writeInt(posY); data.writeInt(posZ); }
From source file:buildcraft.core.network.PacketTileState.java
License:Minecraft Mod Public
@Override public void writeData(ByteBuf data) { super.writeData(data); ByteBuf tmpState = Unpooled.buffer(); tmpState.writeByte(stateList.size()); for (StateWithId stateWithId : stateList) { tmpState.writeByte(stateWithId.stateId); stateWithId.state.writeData(tmpState); }/*from w w w . j a v a 2s.c o m*/ data.writeInt(tmpState.readableBytes()); data.writeBytes(tmpState.readBytes(tmpState.readableBytes())); }
From source file:buildcraft.core.network.PacketUpdate.java
License:Minecraft Mod Public
@Override public void writeData(ByteBuf data) { data.writeByte(packetId); data.writeInt(posX);/*from w w w. j a va 2 s . com*/ data.writeInt(posY); data.writeInt(posZ); if (payload != null) { payload.writeData(data); } else { data.writeByte(0); } }
From source file:buildcraft.core.network.serializers.ClassMapping.java
License:Minecraft Mod Public
@SuppressWarnings("rawtypes") void writeClass(Object obj, ByteBuf data, SerializationContext context) throws IllegalArgumentException, IllegalAccessException { Class realClass = obj.getClass(); if (realClass.equals(this.mappedClass)) { data.writeByte(0); } else {//from w w w .ja v a2 s.c o m ClassMapping delegateMapping; if (context.classToId.containsKey(realClass.getCanonicalName())) { int index = context.classToId.get(realClass.getCanonicalName()) + 1; data.writeByte(index); delegateMapping = (ClassMapping) context.idToClass.get(index - 1); } else { int index = context.classToId.size() + 1; delegateMapping = (ClassMapping) get(realClass); data.writeByte(index); Utils.writeUTF(data, realClass.getCanonicalName()); context.classToId.put(realClass.getCanonicalName(), context.classToId.size()); context.idToClass.add(delegateMapping); } delegateMapping.writeClass(obj, data, context); return; } for (Field f : shortFields) { data.writeShort(f.getShort(obj)); } for (Field f : intFields) { data.writeInt(f.getInt(obj)); } for (Field f : booleanFields) { data.writeBoolean(f.getBoolean(obj)); } for (Field f : enumFields) { data.writeByte(((Enum) f.get(obj)).ordinal()); } for (Field f : floatFields) { data.writeFloat(f.getFloat(obj)); } for (Field f : doubleFields) { data.writeDouble(f.getDouble(obj)); } for (FieldObject f : objectFields) { Object cpt = f.field.get(obj); f.mapping.write(data, cpt, context); } }
From source file:buildcraft.core.network.serializers.SerializerObject.java
License:Minecraft Mod Public
@Override public void write(ByteBuf data, Object o, SerializationContext context) throws IllegalArgumentException, IllegalAccessException { if (o == null) { data.writeBoolean(false);/* ww w. j ava 2 s . c o m*/ } else { data.writeBoolean(true); Class realClass = o.getClass(); ClassSerializer delegateMapping; if (context.classToId.containsKey(realClass.getCanonicalName())) { int index = context.classToId.get(realClass.getCanonicalName()) + 1; data.writeByte(index); delegateMapping = context.idToClass.get(index - 1); } else { int index = context.classToId.size() + 1; delegateMapping = ClassMapping.get(realClass); data.writeByte(index); Utils.writeUTF(data, realClass.getCanonicalName()); context.classToId.put(realClass.getCanonicalName(), context.classToId.size()); context.idToClass.add(delegateMapping); } if (delegateMapping instanceof ClassMapping) { ((ClassMapping) delegateMapping).writeClass(o, data, context); } else { delegateMapping.write(data, o, context); } } }