/** * Updates this EntityData with another EntityData via bitmask * * @param changes Bitmasked EntityData with changes. */ @SuppressWarnings("restriction") public void updateFrom(EntityData changes) { if (changes.getId() != this.id) { Glydar.getServer() .getLogger() .warning( "Tried to update entity ID " + this.id + " with changes from ID " + changes.getId() + "!"); return; } BitArray bitArray = new BitArray( 8 * changes.getBitmask().length, Bitops.flipBits(changes.getBitmask())); // Size in bits, byte[] if (bitArray.get(0)) { this.posX = changes.getPosX(); this.posY = changes.getPosY(); this.posZ = changes.getPosZ(); } if (bitArray.get(1)) { this.pitch = changes.getPitch(); this.roll = changes.getRoll(); this.yaw = changes.getYaw(); } if (bitArray.get(2)) { this.velocity = (GVector3) changes.getVelocity(); } if (bitArray.get(3)) { this.accel = (GVector3) changes.getAccel(); } if (bitArray.get(4)) { this.extraVel = (GVector3) changes.getExtraVel(); } if (bitArray.get(5)) { this.lookPitch = changes.getLookPitch(); } if (bitArray.get(6)) { this.physicsFlags = changes.getPhysicsFlags(); } if (bitArray.get(7)) { this.speedFlags = changes.getSpeedFlags(); } if (bitArray.get(8)) { this.entityType = changes.getEntityType(); } if (bitArray.get(9)) { this.currentMode = changes.getCurrentMode(); } if (bitArray.get(10)) { this.lastShootTime = changes.getLastShootTime(); } if (bitArray.get(11)) { this.hitCounter = changes.getHitCounter(); } if (bitArray.get(12)) { this.lastHitTime = changes.getLastHitTime(); } if (bitArray.get(13)) { this.app = (GAppearance) changes.getApp(); } if (bitArray.get(14)) { this.flags1 = changes.getFlags1(); this.flags2 = changes.getFlags2(); } if (bitArray.get(15)) { this.rollTime = changes.getRollTime(); } if (bitArray.get(16)) { this.stunTime = changes.getStunTime(); } if (bitArray.get(17)) { this.slowedTime = changes.getSlowedTime(); } if (bitArray.get(18)) { this.makeBlueTime = changes.getMakeBlueTime(); } if (bitArray.get(19)) { this.speedUpTime = changes.getSpeedUpTime(); } if (bitArray.get(20)) { this.slowPatchTime = changes.getSlowPatchTime(); } if (bitArray.get(21)) { this.classType = changes.getClassType(); } if (bitArray.get(22)) { this.specialization = changes.getSpecialization(); } if (bitArray.get(23)) { this.chargedMP = changes.getChargedMP(); } if (bitArray.get(24)) { this.nu1 = changes.getNu1(); this.nu2 = changes.getNu2(); this.nu3 = changes.getNu3(); } if (bitArray.get(25)) { this.nu4 = changes.getNu4(); this.nu5 = changes.getNu5(); this.nu6 = changes.getNu6(); } if (bitArray.get(26)) { this.rayHit = (GVector3) changes.getRayHit(); } if (bitArray.get(27)) { this.HP = changes.getHP(); } if (bitArray.get(28)) { this.MP = changes.getMP(); } if (bitArray.get(29)) { this.blockPower = changes.getBlockPower(); } if (bitArray.get(30)) { this.maxHPMultiplier = changes.getMaxHPMultiplier(); this.shootSpeed = changes.getShootSpeed(); this.damageMultiplier = changes.getDamageMultiplier(); this.armorMultiplier = changes.getArmorMultiplier(); this.resistanceMultiplier = changes.getResistanceMultiplier(); } if (bitArray.get(31)) { this.nu7 = changes.getNu7(); } if (bitArray.get(32)) { this.nu8 = changes.getNu8(); } if (bitArray.get(33)) { this.level = changes.getLevel(); } if (bitArray.get(34)) { this.currentXP = changes.getCurrentXP(); } if (bitArray.get(35)) { this.parentOwner = changes.getParentOwner(); } if (bitArray.get(36)) { this.na1 = changes.getNa1(); this.na2 = changes.getNa2(); } if (bitArray.get(37)) { this.na3 = changes.getNa3(); } if (bitArray.get(38)) { this.na4 = changes.getNa4(); } if (bitArray.get(39)) { this.na5 = changes.getNa5(); this.nu11 = changes.getNu11(); this.nu12 = changes.getNu12(); } if (bitArray.get(40)) { this.nu13 = changes.getNu13(); this.nu14 = changes.getNu14(); this.nu15 = changes.getNu15(); this.nu16 = changes.getNu16(); this.nu17 = changes.getNu17(); this.nu18 = changes.getNu18(); } if (bitArray.get(41)) { this.nu20 = changes.getNu20(); this.nu21 = changes.getNu21(); this.nu22 = changes.getNu22(); } if (bitArray.get(42)) { this.nu19 = changes.getNu19(); } if (bitArray.get(43)) { this.itemData = (GItem) changes.getItemData(); } if (bitArray.get(44)) { this.equipment = (GItem[]) changes.getEquipment(); } if (bitArray.get(45)) { this.name = changes.getName(); } if (bitArray.get(46)) { this.skills = changes.getSkills(); } if (bitArray.get(47)) { this.iceBlockFour = changes.getIceBlockFour(); } }
@Override @SuppressWarnings("restriction") public void decode(ByteBuf buf) { id = buf.readLong(); buf.readBytes(bitmask); BitArray bitArray = new BitArray(8 * bitmask.length, Bitops.flipBits(bitmask)); // Size in bits, byte[] // BitArray bitArray = new BitArray(bitmask); if (bitArray.get(0)) { posX = buf.readLong(); posY = buf.readLong(); posZ = buf.readLong(); } if (bitArray.get(1)) { pitch = buf.readFloat(); roll = buf.readFloat(); yaw = buf.readFloat(); } if (bitArray.get(2)) { velocity.decode(buf); } if (bitArray.get(3)) { accel.decode(buf); } if (bitArray.get(4)) { extraVel.decode(buf); } if (bitArray.get(5)) { lookPitch = buf.readFloat(); } if (bitArray.get(6)) { physicsFlags = buf.readUnsignedInt(); } if (bitArray.get(7)) { speedFlags = buf.readByte(); } if (bitArray.get(8)) { entityType = buf.readUnsignedInt(); } if (bitArray.get(9)) { currentMode = buf.readByte(); } if (bitArray.get(10)) { lastShootTime = buf.readUnsignedInt(); } if (bitArray.get(11)) { hitCounter = buf.readUnsignedInt(); } if (bitArray.get(12)) { lastHitTime = buf.readUnsignedInt(); } if (bitArray.get(13)) { app.decode(buf); } if (bitArray.get(14)) { flags1 = buf.readByte(); flags2 = buf.readByte(); } if (bitArray.get(15)) { rollTime = buf.readUnsignedInt(); } if (bitArray.get(16)) { stunTime = buf.readInt(); } if (bitArray.get(17)) { slowedTime = buf.readUnsignedInt(); } if (bitArray.get(18)) { makeBlueTime = buf.readUnsignedInt(); } if (bitArray.get(19)) { speedUpTime = buf.readUnsignedInt(); } if (bitArray.get(20)) { slowPatchTime = buf.readFloat(); } if (bitArray.get(21)) { classType = buf.readByte(); } if (bitArray.get(22)) { specialization = buf.readByte(); } if (bitArray.get(23)) { chargedMP = buf.readFloat(); } if (bitArray.get(24)) { nu1 = buf.readUnsignedInt(); nu2 = buf.readUnsignedInt(); nu3 = buf.readUnsignedInt(); } if (bitArray.get(25)) { nu4 = buf.readUnsignedInt(); nu5 = buf.readUnsignedInt(); nu6 = buf.readUnsignedInt(); } if (bitArray.get(26)) { rayHit.decode(buf); } if (bitArray.get(27)) { HP = buf.readFloat(); } if (bitArray.get(28)) { MP = buf.readFloat(); } if (bitArray.get(29)) { blockPower = buf.readFloat(); } if (bitArray.get(30)) { maxHPMultiplier = buf.readFloat(); shootSpeed = buf.readFloat(); damageMultiplier = buf.readFloat(); armorMultiplier = buf.readFloat(); resistanceMultiplier = buf.readFloat(); } if (bitArray.get(31)) { nu7 = buf.readByte(); } if (bitArray.get(32)) { nu8 = buf.readByte(); } if (bitArray.get(33)) { level = buf.readUnsignedInt(); } if (bitArray.get(34)) { currentXP = buf.readUnsignedInt(); } if (bitArray.get(35)) { parentOwner = buf.readLong(); } if (bitArray.get(36)) { na1 = buf.readUnsignedInt(); na2 = buf.readUnsignedInt(); } if (bitArray.get(37)) { na3 = buf.readByte(); } if (bitArray.get(38)) { na4 = buf.readUnsignedInt(); } if (bitArray.get(39)) { na5 = buf.readUnsignedInt(); nu11 = buf.readUnsignedInt(); nu12 = buf.readUnsignedInt(); } if (bitArray.get(40)) { nu13 = buf.readUnsignedInt(); nu14 = buf.readUnsignedInt(); nu15 = buf.readUnsignedInt(); nu16 = buf.readUnsignedInt(); nu17 = buf.readUnsignedInt(); nu18 = buf.readUnsignedInt(); } if (bitArray.get(41)) { nu20 = buf.readUnsignedInt(); nu21 = buf.readUnsignedInt(); nu22 = buf.readUnsignedInt(); } if (bitArray.get(42)) { nu19 = buf.readByte(); } if (bitArray.get(43)) { itemData.decode(buf); } if (bitArray.get(44)) { for (int i = 0; i < 13; i++) { GItem item = new GItem(); item.decode(buf); equipment[i] = item; } } if (bitArray.get(45)) { name = new String(buf.readBytes(16).array(), Charsets.US_ASCII).trim(); } if (bitArray.get(46)) { for (int i = 0; i < 11; i++) { skills[i] = buf.readUnsignedInt(); } } if (bitArray.get(47)) { iceBlockFour = buf.readUnsignedInt(); } debugCap = buf.capacity(); buf.resetReaderIndex(); buf.resetWriterIndex(); }