List of usage examples for io.netty.buffer ByteBuf writeFloat
public abstract ByteBuf writeFloat(float value);
From source file:de.sanandrew.mods.turretmod.entity.projectile.EntityTurretProjectile.java
License:Creative Commons License
@Override public void writeSpawnData(ByteBuf buffer) { buffer.writeFloat(this.rotationYaw); buffer.writeFloat(this.rotationPitch); buffer.writeBoolean(this.shooterCache != null); if (this.shooterCache != null) { buffer.writeInt(this.shooterCache.getEntityId()); }/*from w ww . j a v a 2 s.c o m*/ buffer.writeBoolean(this.targetCache != null); if (this.targetCache != null) { buffer.writeInt(this.targetCache.getEntityId()); } }
From source file:de.sanandrew.mods.turretmod.registry.turret.shieldgen.TurretForcefield.java
License:Creative Commons License
@Override public void writeSpawnData(ITurretInst turretInst, ByteBuf buf) { ShieldTurret shield = turretInst.getRAM(() -> new ShieldTurret(turretInst)); buf.writeFloat(shield.value); buf.writeFloat(shield.recovery);//w w w. j a va 2s . c o m }
From source file:de.sanandrew.mods.turretmod.tileentity.electrolytegen.TileEntityElectrolyteGenerator.java
License:Creative Commons License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(this.energyStorage.fluxAmount); buf.writeFloat(this.effectiveness); for (ElectrolyteProcess process : this.processes) { if (process != null) { buf.writeBoolean(true);/*from ww w. j a va 2 s . co m*/ process.writeToByteBuf(buf); } else { buf.writeBoolean(false); } } }
From source file:eu.jangos.realm.network.packet.server.auth.SMSG_LOGIN_VERIFY_WORLD.java
License:Open Source License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - 4b - 4b - 4b - 4b - 4b // Size (Little Endian) - Opcode (Big Endian) - map - posX - posY - posZ - orientation buf.writeShort(this.size); buf.writeShort(this.code.getValue()); buf.writeInt(this.map); buf.writeFloat(this.posX); buf.writeFloat(this.posY); buf.writeFloat(this.posZ); buf.writeFloat(this.orientation); }
From source file:eu.jangos.realm.network.packet.server.character.SMSG_CHAR_ENUM.java
License:Apache License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - 1b // Size (Little Endian) - Opcode (Big Endian) - number of characters // If any character: // 8b - ?b - 1b - 1b - 1b - 1b - 1b - 1b - 1b - 1b - 1b - 4b - 4b - 4b - 4b - 4b - 4b - 1b - 4b - 4b - 4b // GUID (Little Endian) - Name - Race - Class - Gender - Skin - Face - HairStyle - HairColor - FacialHair - level - zone - map - x - y - z - guild // char flags - first login - Pet id - Pet level - Pet Family // Then equipment: (19 pieces) // 4b - 1b//from w w w . ja v a 2s . c om // Item Display ID - Item Inventory Type // Then the bag // 4b - 1b // First bag display ID // First bag inventory type // TODO: // - Guild membership // - Pet ID // - Pet Level // - Pet Family ItemService itemService = ItemServiceFactory.getInstance(); ItemInstanceService iiService = new ItemInstanceService(); buf.writeShort(this.size); buf.writeShort(this.code.getValue()); buf.writeByte(this.numChars); for (Characters c : this.listChars) { buf = buf.order(ByteOrder.LITTLE_ENDIAN); buf.writeLong(c.getGuid()); //buf = buf.order(ByteOrder.BIG_ENDIAN); ByteBufUtil.writeAscii(buf, c.getName()); buf.writeByte((byte) 0); // End of string buf.writeByte(c.getRace()); buf.writeByte(c.getFkDbcClass()); buf.writeByte(c.getGender()); buf.writeByte(c.getSkin()); buf.writeByte(c.getFace()); buf.writeByte(c.getHairstyle()); buf.writeByte(c.getHaircolor()); buf.writeByte(c.getFacialhair()); buf.writeByte((byte) c.getLevel()); buf.writeInt(c.getFkDbcZone()); buf.writeInt(c.getFkDbcMap()); buf.writeFloat((float) c.getPositionX()); // X buf.writeFloat((float) c.getPositionY()); // Y buf.writeFloat((float) c.getPositionZ()); // Z buf.writeInt(0); // Guild ID buf.writeInt(convertPlayersFlagsToInt(c)); // Char Flags buf.writeByte(convertLoginFlagsToByte(c)); // First login buf.writeInt(0); // Pet ID buf.writeInt(0); // Pet Level buf.writeInt(0); // Pet family int count = 0; // We get the list of data for the equipment. for (Object data : iiService.getEquipmentCharEnum(c)) { Object[] itemInstance = (Object[]) data; int displayID = 0; byte inventoryType = 0; // We fill-in the data for the unoccupied slots. for (int i = count; i < Integer.parseInt(itemInstance[0].toString()); i++) { buf.writeInt(displayID); buf.writeByte(inventoryType); count++; } // We add the occupied slot. Object[] item = itemService.getItemByIDCharEnum(Integer.parseInt(itemInstance[1].toString())); displayID = Integer.parseInt(item[0].toString()); inventoryType = Byte.parseByte(item[1].toString()); buf.writeInt(displayID); buf.writeByte(inventoryType); count++; } // We fill in the data for the end of the equipment slot. for (int i = count; i <= EQUIPMENT_SLOT_END; i++) { buf.writeInt(0); buf.writeByte(0); } } }
From source file:eu.jangos.realm.network.packet.server.login.SMSG_LOGIN_SETTIMESPEED.java
License:Apache License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - 4b - 4b // Size (Little Endian) - Opcode (Big Endian) - current time - world time speed buf.writeShort(this.size); buf.writeShort(this.code.getValue()); buf.writeInt(this.time); buf.writeFloat(WORLD_TIME_SPEED); }
From source file:eu.jangos.realm.network.packet.server.misc.SMSG_NEW_WORLD.java
License:Apache License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - 4b - 4b - 4b - 4b - 4b // Size (Little Endian) - Opcode (Big Endian) - mapID - posX - posY - posZ - orientation buf.writeShort(this.size); buf.writeShort(this.code.getValue()); buf.writeInt(this.mapID); buf.writeFloat(this.posX); buf.writeFloat(this.posY); buf.writeFloat(this.posZ); buf.writeFloat(this.orientation); }
From source file:eu.jangos.realm.network.packet.server.query.SMSG_ITEM_QUERY_SINGLE.java
License:Apache License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - // Size (Little Endian) - Opcode (Big Endian) - ItemService itemService = ItemServiceFactory.getInstance(); buf.writeShort(this.size + this.item.getName().length() + this.item.getDescription().length()); buf.writeShort(this.code.getValue()); buf.writeInt(this.item.getEntry()); buf.writeInt(this.item.getItemsubclass().getItemclass().getId()); buf.writeInt(this.item.getItemsubclass().getId().getId()); // 12/* w ww. ja va 2s. co m*/ ByteBufUtil.writeAscii(buf, this.item.getName()); buf.writeByte(0); // End of string buf.writeByte(0); // End of string 2 buf.writeByte(0); // End of string 3 buf.writeByte(0); // End of string 4 // 16 + ? buf.writeInt(this.item.getDisplayid()); buf.writeInt(this.item.getItemquality().getId()); buf.writeInt(this.item.getFlags()); buf.writeInt(this.item.getBuyprice()); buf.writeInt(this.item.getSellprice()); buf.writeInt(this.item.getInventorytype().getId()); buf.writeInt(this.item.getAllowableclass()); buf.writeInt(this.item.getAllowablerace()); buf.writeInt(this.item.getItemlevel()); buf.writeInt(this.item.getRequiredlevel()); buf.writeInt(this.item.getRequiredskill()); buf.writeInt(this.item.getRequiredskillrank()); buf.writeInt(this.item.getRequiredhonorrank()); buf.writeInt(this.item.getRequiredcityrank()); buf.writeInt(this.item.getRequiredreputationfaction()); buf.writeInt((this.item.getRequiredreputationfaction() > 0 ? this.item.getRequiredreputationrank() : 0)); buf.writeInt(this.item.getMaxcount()); buf.writeInt(this.item.getStackable()); buf.writeInt(this.item.getContainerslots()); // 92 buf.writeInt(this.item.getStatType1()); buf.writeInt(this.item.getStatValue1()); buf.writeInt(this.item.getStatType2()); buf.writeInt(this.item.getStatValue2()); buf.writeInt(this.item.getStatType3()); buf.writeInt(this.item.getStatValue3()); buf.writeInt(this.item.getStatType4()); buf.writeInt(this.item.getStatValue4()); buf.writeInt(this.item.getStatType5()); buf.writeInt(this.item.getStatValue5()); buf.writeInt(this.item.getStatType6()); buf.writeInt(this.item.getStatValue6()); buf.writeInt(this.item.getStatType7()); buf.writeInt(this.item.getStatValue7()); buf.writeInt(this.item.getStatType8()); buf.writeInt(this.item.getStatValue8()); buf.writeInt(this.item.getStatType9()); buf.writeInt(this.item.getStatValue9()); buf.writeInt(this.item.getStatType10()); buf.writeInt(this.item.getStatValue10()); // 172 buf.writeFloat(this.item.getDmgMin1()); buf.writeFloat(this.item.getDmgMax1()); buf.writeInt(this.item.getDmgType1()); buf.writeFloat(this.item.getDmgMin2()); buf.writeFloat(this.item.getDmgMax2()); buf.writeInt(this.item.getDmgType2()); buf.writeFloat(this.item.getDmgMin3()); buf.writeFloat(this.item.getDmgMax3()); buf.writeInt(this.item.getDmgType3()); buf.writeFloat(this.item.getDmgMin4()); buf.writeFloat(this.item.getDmgMax4()); buf.writeInt(this.item.getDmgType4()); buf.writeFloat(this.item.getDmgMin5()); buf.writeFloat(this.item.getDmgMax5()); buf.writeInt(this.item.getDmgType5()); // 232 // resistances buf.writeInt(this.item.getArmor()); buf.writeInt(this.item.getHolyRes()); buf.writeInt(this.item.getFireRes()); buf.writeInt(this.item.getNatureRes()); buf.writeInt(this.item.getFrostRes()); buf.writeInt(this.item.getShadowRes()); buf.writeInt(this.item.getArcaneRes()); // 260 buf.writeInt(this.item.getDelay()); buf.writeInt(this.item.getAmmoType()); buf.writeFloat(this.item.getRangedModRange()); // 272 // spells buf.writeInt(this.item.getSpellid1()); buf.writeInt(this.item.getSpelltrigger1()); buf.writeInt(this.item.getSpellcharges1()); buf.writeInt(this.item.getSpellcooldown1()); buf.writeInt(this.item.getSpellcategory1()); buf.writeInt(this.item.getSpellcategorycooldown1()); buf.writeInt(this.item.getSpellid2()); buf.writeInt(this.item.getSpelltrigger2()); buf.writeInt(this.item.getSpellcharges2()); buf.writeInt(this.item.getSpellcooldown2()); buf.writeInt(this.item.getSpellcategory2()); buf.writeInt(this.item.getSpellcategorycooldown2()); buf.writeInt(this.item.getSpellid3()); buf.writeInt(this.item.getSpelltrigger3()); buf.writeInt(this.item.getSpellcharges3()); buf.writeInt(this.item.getSpellcooldown3()); buf.writeInt(this.item.getSpellcategory3()); buf.writeInt(this.item.getSpellcategorycooldown3()); buf.writeInt(this.item.getSpellid4()); buf.writeInt(this.item.getSpelltrigger4()); buf.writeInt(this.item.getSpellcharges4()); buf.writeInt(this.item.getSpellcooldown4()); buf.writeInt(this.item.getSpellcategory4()); buf.writeInt(this.item.getSpellcategorycooldown4()); buf.writeInt(this.item.getSpellid5()); buf.writeInt(this.item.getSpelltrigger5()); buf.writeInt(this.item.getSpellcharges5()); buf.writeInt(this.item.getSpellcooldown5()); buf.writeInt(this.item.getSpellcategory5()); buf.writeInt(this.item.getSpellcategorycooldown5()); // 392 buf.writeInt(this.item.getBonding()); // 396 ByteBufUtil.writeAscii(buf, this.item.getDescription()); buf.writeByte(0); // end of string // 397 + ? buf.writeInt(this.item.getPagetext().getId()); buf.writeInt(this.item.getLanguageid()); buf.writeInt(this.item.getPagematerial()); buf.writeInt(this.item.getStartquest()); buf.writeInt(this.item.getLockid()); buf.writeInt(this.item.getMaterial()); buf.writeInt(this.item.getSheath()); buf.writeInt(this.item.getRandomproperty()); buf.writeInt(this.item.getBlock()); buf.writeInt(this.item.getItemset()); buf.writeInt(this.item.getMaxdurability()); buf.writeInt(this.item.getArea()); buf.writeInt(this.item.getMap()); buf.writeInt(this.item.getBagfamily()); // 453 }
From source file:gedi.remote.codec.NumberEncoder.java
License:Apache License
@Override protected void encode(ChannelHandlerContext ctx, Number msg, ByteBuf out) throws Exception { if (msg instanceof Byte) { out.writeInt(Integer.BYTES + 1 + Byte.BYTES); out.writeInt(1);/*w w w .j a va 2s . c o m*/ out.writeByte('B'); out.writeByte(msg.byteValue()); } else if (msg instanceof Short) { out.writeInt(Integer.BYTES + 1 + Short.BYTES); out.writeInt(1); out.writeByte('S'); out.writeShort(msg.shortValue()); } else if (msg instanceof Integer) { out.writeInt(Integer.BYTES + 1 + Integer.BYTES); out.writeInt(1); out.writeByte('I'); out.writeInt(msg.intValue()); } else if (msg instanceof Long) { out.writeInt(Integer.BYTES + 1 + Long.BYTES); out.writeInt(1); out.writeByte('L'); out.writeLong(msg.longValue()); } else if (msg instanceof Float) { out.writeInt(Integer.BYTES + 1 + Float.BYTES); out.writeInt(1); out.writeByte('F'); out.writeFloat(msg.floatValue()); } else if (msg instanceof Double) { out.writeInt(Integer.BYTES + 1 + Double.BYTES); out.writeInt(1); out.writeByte('D'); out.writeDouble(msg.doubleValue()); } else throw new RuntimeException("Could not encode number " + msg.getClass().getName()); }
From source file:growthcraft.cellar.common.tileentity.component.TileHeatingComponent.java
License:Open Source License
@Override public boolean writeToStream(ByteBuf stream) { stream.writeFloat(heat); return false; }