private void writeItem(IAEItemStack slotItem, ByteBuf data) throws IOException { if (slotItem == null) { data.writeBoolean(false); } else { data.writeBoolean(true); slotItem.writeToPacket(data); } }
@Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { if (protocolVersion < ProtocolConstants.MINECRAFT_SNAPSHOT) { Item item = items[0]; // Only one at a time writeString(item.displayName, buf); // TODO: Server unique only! buf.writeBoolean(action != Action.REMOVE_PLAYER); buf.writeShort(item.ping); } else { DefinedPacket.writeVarInt(action.ordinal(), buf); DefinedPacket.writeVarInt(items.length, buf); for (Item item : items) { DefinedPacket.writeUUID(item.uuid, buf); switch (action) { case ADD_PLAYER: DefinedPacket.writeString(item.username, buf); DefinedPacket.writeVarInt(item.properties.length, buf); for (String[] prop : item.properties) { DefinedPacket.writeString(prop[0], buf); DefinedPacket.writeString(prop[1], buf); if (prop.length >= 3) { buf.writeBoolean(true); DefinedPacket.writeString(prop[2], buf); } else { buf.writeBoolean(false); } } DefinedPacket.writeVarInt(item.gamemode, buf); DefinedPacket.writeVarInt(item.ping, buf); buf.writeBoolean(item.displayName != null); if (item.displayName != null) { DefinedPacket.writeString(item.displayName, buf); } break; case UPDATE_GAMEMODE: DefinedPacket.writeVarInt(item.gamemode, buf); break; case UPDATE_LATENCY: DefinedPacket.writeVarInt(item.ping, buf); break; case UPDATE_DISPLAY_NAME: buf.writeBoolean(item.displayName != null); if (item.displayName != null) { DefinedPacket.writeString(item.displayName, buf); } break; } } } }
@Override public void writeToByteBuff(ByteBuf buf) { super.writeToByteBuff(buf); buf.writeBoolean(fill); tank.writeToByteBuff(buf); inventory.writeToByteBuff(buf); }
/** * Writes boolean <code>value</code> if not null, otherwise writes zero to the <code>output</code> * ByteBuf. ByteBuf's writerIndex is increased by 1. * * @param value Boolean value to be written to the output. * @param output ByteBuf, where value or zero is written. */ public static void writeBoolean(final Boolean value, final ByteBuf output) { if (value != null) { output.writeBoolean(value); } else { output.writeZero(ONE_BYTE_LENGTH); } }
/* * ID 0: client changed xcoord in interface * ID 1: client changed ycoord in interface * ID 2: sync whether the machine is running * ID 3: sync Mode * ID 4: jam reset */ @Override public void writeDataToNetwork(ByteBuf out, byte id) { if (id == 0) out.writeInt(this.laserX); else if (id == 1) out.writeInt(this.laserZ); else if (id == 2) out.writeBoolean(isRunning); else if (id == 3) out.writeInt(mode.ordinal()); }
public void write(ByteBuf buf) { buf.writeLong(this.id.getMostSignificantBits()); buf.writeLong(this.id.getLeastSignificantBits()); // rip in organize for (Object o : this.values) { switch (o.getClass().getSimpleName()) { case "String": Codec.writeString(buf, (String) o); break; case "Integer": Codec.writeVarInt32(buf, (Integer) o); break; case "Boolean": buf.writeBoolean((Boolean) o); break; default: // ignore bad developers break; } } }
@Override public void toBytes(ByteBuf buf) { buf.writeInt(entityID); buf.writeInt(componentID); buf.writeBoolean(ident != null); if (ident != null) ident.serializeBuf(buf); buf.writeFloat(progress); }
@Override public void toBytes(ByteBuf buf) { buf.writeDouble(this.posX); buf.writeDouble(this.posY); buf.writeDouble(this.posZ); buf.writeFloat(this.strength); buf.writeBoolean(this.showParticles); }
/** * Called when a packet to sync client and server is being created. * * @throws IOException */ @Override public void writeToStream(final ByteBuf stream) throws IOException { // Call super super.writeToStream(stream); // Write the activity state stream.writeBoolean(this.isEmitting); }
@Override public void write(ByteBuf data, Object o, SerializationContext context) throws IllegalArgumentException, IllegalAccessException { LinkedList list = (LinkedList) o; if (o == null) { data.writeBoolean(false); } else { data.writeBoolean(true); data.writeShort(list.size()); for (Object val : list) { anonymousSerializer.write(data, val, context); } } }
public ByteBuf encode(ByteBuf buf, PositionRotationMessage message) throws IOException { buf.writeDouble(message.getX()); buf.writeDouble(message.getY()); buf.writeDouble(message.getZ()); buf.writeFloat(message.getRotation()); buf.writeFloat(message.getPitch()); buf.writeBoolean(message.isOnGround()); return buf; }
@Override public void toBytes(ByteBuf buf) { buf.writeInt(x); buf.writeInt(y); buf.writeInt(z); buf.writeInt(_freq); buf.writeBoolean(_isPublic); buf.writeByte(_state); }
@Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { writeString(cursor, buf); if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8) { buf.writeBoolean(hasPositon); if (hasPositon) { buf.writeLong(position); } } }
@Override public void write(ByteBuf data, Object o, SerializationContext context) throws IllegalArgumentException, IllegalAccessException { HashMap map = (HashMap<?, ?>) o; if (o == null) { data.writeBoolean(false); } else { data.writeBoolean(true); data.writeShort(map.size()); Set<Map.Entry> s = map.entrySet(); for (Map.Entry e : s) { anonymousSerializer.write(data, e.getKey(), context); anonymousSerializer.write(data, e.getValue(), context); } } }
@Override public void toBytes(ByteBuf buffer) { buffer.writeInt(packetType.ordinal()); if (packetType == PortableTeleporterPacketType.DATA_REQUEST) { if (frequency != null) { buffer.writeBoolean(true); PacketHandler.writeString(buffer, frequency.name); buffer.writeBoolean(frequency.publicFreq); } else { buffer.writeBoolean(false); } } else if (packetType == PortableTeleporterPacketType.DATA_RESPONSE) { if (frequency != null) { buffer.writeBoolean(true); PacketHandler.writeString(buffer, frequency.name); buffer.writeBoolean(frequency.publicFreq); } else { buffer.writeBoolean(false); } buffer.writeByte(status); ArrayList data = new ArrayList(); data.add(publicCache.size()); for (Frequency freq : publicCache) { freq.write(data); } data.add(privateCache.size()); for (Frequency freq : privateCache) { freq.write(data); } PacketHandler.encode(data.toArray(), buffer); } else if (packetType == PortableTeleporterPacketType.SET_FREQ) { PacketHandler.writeString(buffer, frequency.name); buffer.writeBoolean(frequency.publicFreq); } else if (packetType == PortableTeleporterPacketType.DEL_FREQ) { PacketHandler.writeString(buffer, frequency.name); buffer.writeBoolean(frequency.publicFreq); } else if (packetType == PortableTeleporterPacketType.TELEPORT) { PacketHandler.writeString(buffer, frequency.name); buffer.writeBoolean(frequency.publicFreq); } }
public ByteBuf encode(ByteBuf buf, PlayerPositionLookMessage message) throws IOException { buf.writeDouble(message.getX()); buf.writeDouble(message.getY()); buf.writeDouble(message.getHeadY()); buf.writeDouble(message.getZ()); buf.writeFloat(message.getYaw()); buf.writeFloat(message.getPitch()); buf.writeBoolean(message.getOnGround()); return buf; }
@Override public void writeData(ByteBuf data) { super.writeData(data); data.writeBoolean(overload); for (short element : displayPower) { data.writeByte( Math.min( PipeRendererTESR.POWER_STAGES, (int) Math.ceil(element * PipeRendererTESR.DISPLAY_MULTIPLIER))); } }
public void writeToStream(ByteBuf stream) { stream.writeBoolean(initialized); stream.writeInt(xMin); stream.writeInt(yMin); stream.writeInt(zMin); stream.writeInt(xMax); stream.writeInt(yMax); stream.writeInt(zMax); }
@Override public void toBytes(ByteBuf buffer) { buffer.writeInt(this.x); buffer.writeInt(this.y); buffer.writeInt(this.z); for (int i = 0; i < 6; ++i) buffer.writeBoolean(this.closedSides[i]); buffer.writeInt(this.lasers.size()); for (int i = 0; i < this.lasers.size(); ++i) this.lasers.get(i).writeToPacket(buffer); }
@Override public void writeSpawnData(ByteBuf buffer) { buffer.writeBoolean(ex != null); if (ex != null) { ByteBufUtils.writeUTF8String(buffer, ex.getID()); if (ex_data != null) { ByteBufUtils.writeTag(buffer, ex_data); } else { ByteBufUtils.writeTag(buffer, new NBTTagCompound()); } } }
@Override public void encode(ByteBuf buf) { buf.writeInt(this.particleId); buf.writeBoolean(this.distance); buf.writeFloat((float) this.loc.getX()); buf.writeFloat((float) this.loc.getY()); buf.writeFloat((float) this.loc.getZ()); buf.writeFloat((float) this.offset.getX()); buf.writeFloat((float) this.offset.getY()); buf.writeFloat((float) this.offset.getZ()); buf.writeFloat(this.particleData); buf.writeInt(this.data.length); for (int i : this.data) { Codec.writeVarInt32(buf, i); } }
// api public PacketPatternSlot(IInventory pat, IAEItemStack slotItem, boolean shift) throws IOException { this.slotItem = slotItem; this.shift = shift; ByteBuf data = Unpooled.buffer(); data.writeInt(this.getPacketID()); data.writeBoolean(shift); this.writeItem(slotItem, data); for (int x = 0; x < 9; x++) { this.pattern[x] = AEApi.instance().storage().createItemStack(pat.getStackInSlot(x)); this.writeItem(this.pattern[x], data); } this.configureWrite(data); }
@Override public void toBytes(ByteBuf buf) { buf.writeInt(x); buf.writeInt(y); buf.writeInt(z); buf.writeInt(coinSum); buf.writeInt(itemPrice); ByteBufUtils.writeUTF8String(buf, customName); ByteBufUtils.writeUTF8String(buf, playerName); buf.writeBoolean(buyButtonActive); buf.writeBoolean(sellButtonActive); buf.writeBoolean(autoModeButtonActive); buf.writeBoolean(coinButtonActive); buf.writeBoolean(isSStackButtonActive); buf.writeBoolean(isLStackButtonActive); buf.writeBoolean(isSBagButtonActive); buf.writeBoolean(isLBagButtonActive); buf.writeBoolean(inUse); }
@Override public void encodeInto(ChannelHandlerContext ctx, ByteBuf data) { data.writeInt(playerEntityId); data.writeInt(mgEntityId); data.writeBoolean(mounting); }
@Override protected void writeData(final ByteBuf stream) { stream.writeInt(this.saveState.ordinal()); stream.writeBoolean(this.justSaved); }
public void toBytes(ByteBuf buf) { NetworkTools.writeEnum(buf, terrainType, TerrainType.TERRAIN_VOID); NetworkTools.writeEnumCollection(buf, featureTypes); NetworkTools.writeEnumCollection(buf, structureTypes); NetworkTools.writeEnumCollection(buf, effectTypes); buf.writeInt(biomes.size()); for (BiomeGenBase entry : biomes) { if (entry != null) { buf.writeInt(entry.biomeID); } else { buf.writeInt(BiomeGenBase.plains.biomeID); } } NetworkTools.writeEnum(buf, controllerType, ControllerType.CONTROLLER_DEFAULT); NetworkTools.writeString(buf, digitString); buf.writeLong(forcedDimensionSeed); buf.writeLong(baseSeed); buf.writeInt(worldVersion); buf.writeInt(Block.blockRegistry.getIDForObject(baseBlockForTerrain.getBlock())); buf.writeInt(baseBlockForTerrain.getMeta()); buf.writeInt(Block.blockRegistry.getIDForObject(tendrilBlock.getBlock())); buf.writeInt(tendrilBlock.getMeta()); writeBlockArrayToBuf(buf, pyramidBlocks); writeBlockArrayToBuf(buf, sphereBlocks); writeBlockArrayToBuf(buf, hugeSphereBlocks); writeBlockArrayToBuf(buf, liquidSphereBlocks); writeFluidArrayToBuf(buf, liquidSphereFluids); writeBlockArrayToBuf(buf, hugeLiquidSphereBlocks); writeFluidArrayToBuf(buf, hugeLiquidSphereFluids); buf.writeInt(Block.blockRegistry.getIDForObject(canyonBlock.getBlock())); buf.writeInt(canyonBlock.getMeta()); buf.writeInt(Block.blockRegistry.getIDForObject(fluidForTerrain)); writeBlockArrayToBuf(buf, extraOregen); writeFluidArrayToBuf(buf, fluidsForLakes); buf.writeBoolean(peaceful); buf.writeBoolean(noanimals); buf.writeBoolean(shelter); buf.writeBoolean(respawnHere); NetworkTools.writeFloat(buf, celestialAngle); NetworkTools.writeFloat(buf, timeSpeed); buf.writeInt(probeCounter); buf.writeInt(actualRfCost); skyDescriptor.toBytes(buf); weatherDescriptor.toBytes(buf); buf.writeLong(patreon1); buf.writeInt(extraMobs.size()); for (MobDescriptor mob : extraMobs) { if (mob != null) { if (mob.getEntityClass() != null) { NetworkTools.writeString(buf, mob.getEntityClass().getName()); buf.writeInt(mob.getSpawnChance()); buf.writeInt(mob.getMinGroup()); buf.writeInt(mob.getMaxGroup()); buf.writeInt(mob.getMaxLoaded()); } } } buf.writeInt(dimensionTypes.length); for (String type : dimensionTypes) { NetworkTools.writeString(buf, type); } }
@TileEvent(TileEventType.NETWORK_WRITE) public void writeToStream_TileMolecularAssembler(final ByteBuf data) { data.writeBoolean(this.isPowered); }
@Override public void writeSpawnData(ByteBuf buffer) { buffer.writeInt(this.mID); buffer.writeBoolean(this.isRandom); }
public void writeBuf(ByteBuf data) { data.writeBoolean(red); data.writeBoolean(green); data.writeBoolean(blue); }
@Override public ByteBuf writeBoolean(boolean value) { return buf.writeBoolean(value); }