Beispiel #1
0
 @Override
 public void receivedFrom(GPlayer ply) {
   Glydar.getServer().getLogger().info("Packet 8!");
 }
Beispiel #2
0
  /**
   * Updates this EntityData with another EntityData via bitmask
   *
   * @param changes Bitmasked EntityData with changes.
   */
  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;
    }

    BitSet changesBitSet = changes.getBitSet();

    if (changesBitSet.get(0)) {
      this.position = changes.getPosition();
    }
    if (changesBitSet.get(1)) {
      this.orientation = changes.getOrientation();
    }
    if (changesBitSet.get(2)) {
      this.velocity = changes.getVelocity();
    }
    if (changesBitSet.get(3)) {
      this.accel = changes.getAccel();
    }
    if (changesBitSet.get(4)) {
      this.extraVel = changes.getExtraVel();
    }
    if (changesBitSet.get(5)) {
      this.lookPitch = changes.getLookPitch();
    }
    if (changesBitSet.get(6)) {
      this.physicsFlags = changes.getPhysicsFlags();
    }
    if (changesBitSet.get(7)) {
      this.hostileType = changes.getHostileType();
    }
    if (changesBitSet.get(8)) {
      this.entityType = changes.getEntityType();
    }
    if (changesBitSet.get(9)) {
      this.currentMode = changes.getCurrentMode();
    }
    if (changesBitSet.get(10)) {
      this.lastShootTime = changes.getLastShootTime();
    }
    if (changesBitSet.get(11)) {
      this.hitCounter = changes.getHitCounter();
    }
    if (changesBitSet.get(12)) {
      this.lastHitTime = changes.getLastHitTime();
    }
    if (changesBitSet.get(13)) {
      this.app = (GAppearance) changes.getApp();
    }
    if (changesBitSet.get(14)) {
      // TODO: A bit messy?
      if (entity.getWorld().isPVPAllowed()) {
        this.flags1 = (byte) 32;
      } else {
        this.flags1 = changes.getFlags1();
      }
      this.flags2 = changes.getFlags2();
    }
    if (changesBitSet.get(15)) {
      this.rollTime = changes.getRollTime();
    }
    if (changesBitSet.get(16)) {
      this.stunTime = changes.getStunTime();
    }
    if (changesBitSet.get(17)) {
      this.slowedTime = changes.getSlowedTime();
    }
    if (changesBitSet.get(18)) {
      this.makeBlueTime = changes.getMakeBlueTime();
    }
    if (changesBitSet.get(19)) {
      this.speedUpTime = changes.getSpeedUpTime();
    }
    if (changesBitSet.get(20)) {
      this.slowPatchTime = changes.getSlowPatchTime();
    }
    if (changesBitSet.get(21)) {
      this.classType = changes.getClassType();
    }
    if (changesBitSet.get(22)) {
      this.specialization = changes.getSpecialization();
    }
    if (changesBitSet.get(23)) {
      this.chargedMP = changes.getChargedMP();
    }
    if (changesBitSet.get(24)) {
      this.nu1 = changes.getNu1();
      this.nu2 = changes.getNu2();
      this.nu3 = changes.getNu3();
    }
    if (changesBitSet.get(25)) {
      this.nu4 = changes.getNu4();
      this.nu5 = changes.getNu5();
      this.nu6 = changes.getNu6();
    }
    if (changesBitSet.get(26)) {
      this.rayHit = changes.getRayHit();
    }
    if (changesBitSet.get(27)) {
      this.HP = changes.getHP();
    }
    if (changesBitSet.get(28)) {
      this.MP = changes.getMP();
    }
    if (changesBitSet.get(29)) {
      this.blockPower = changes.getBlockPower();
    }
    if (changesBitSet.get(30)) {
      this.maxHPMultiplier = changes.getMaxHPMultiplier();
      this.shootSpeed = changes.getShootSpeed();
      this.damageMultiplier = changes.getDamageMultiplier();
      this.armorMultiplier = changes.getArmorMultiplier();
      this.resistanceMultiplier = changes.getResistanceMultiplier();
    }
    if (changesBitSet.get(31)) {
      this.nu7 = changes.getNu7();
    }
    if (changesBitSet.get(32)) {
      this.nu8 = changes.getNu8();
    }
    if (changesBitSet.get(33)) {
      this.level = changes.getLevel();
    }
    if (changesBitSet.get(34)) {
      this.currentXP = changes.getCurrentXP();
    }
    if (changesBitSet.get(35)) {
      this.parentOwner = changes.getParentOwner();
    }
    if (changesBitSet.get(36)) {
      this.na1 = changes.getNa1();
      this.na2 = changes.getNa2();
    }
    if (changesBitSet.get(37)) {
      this.na3 = changes.getNa3();
    }
    if (changesBitSet.get(38)) {
      this.na4 = changes.getNa4();
    }
    if (changesBitSet.get(39)) {
      this.na5 = changes.getNa5();
      this.nu11 = changes.getNu11();
      this.nu12 = changes.getNu12();
    }
    if (changesBitSet.get(40)) {
      this.spawnPosition = changes.getSpawnPosition();
    }
    if (changesBitSet.get(41)) {
      this.nu20 = changes.getNu20();
      this.nu21 = changes.getNu21();
      this.nu22 = changes.getNu22();
    }
    if (changesBitSet.get(42)) {
      this.nu19 = changes.getNu19();
    }
    if (changesBitSet.get(43)) {
      this.itemData = (GItem) changes.getItemData();
    }
    if (changesBitSet.get(44)) {
      this.equipment = (GItem[]) changes.getEquipment();
    }
    if (changesBitSet.get(45)) {
      this.name = changes.getName();
    }
    if (changesBitSet.get(46)) {
      this.skills = changes.getSkills();
    }
    if (changesBitSet.get(47)) {
      this.iceBlockFour = changes.getIceBlockFour();
    }
  }
Beispiel #3
0
  /**
   * 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();
    }
  }
Beispiel #4
0
  @Override
  public void encode(ByteBuf buf) {
    // For testing purposes using default dummy entity :)
    /*boolean dummy = false;
    if (name.contains("dummy")) dummy = true;*/

    buf.writeLong(id); // Ulong but whatever
    buf.writeBytes(bitSet.toByteArray());
    buf.writeBytes(
        new byte
            [8 - bitSet.toByteArray().length]); // BitSet/BitArray are the stupidest classes ever :(
    if (bitSet.get(0)) {
      writeLongVector3(buf, position);
    }
    if (bitSet.get(1)) {
      writeOrientation(buf, orientation);
    }
    if (bitSet.get(2)) {
      writeFloatVector3(buf, velocity);
    }
    if (bitSet.get(3)) {
      writeFloatVector3(buf, accel);
    }
    if (bitSet.get(4)) {
      writeFloatVector3(buf, extraVel);
    }
    if (bitSet.get(5)) {
      buf.writeFloat(lookPitch);
    }
    if (bitSet.get(6)) {
      buf.writeInt((int) physicsFlags);
    }
    if (bitSet.get(7)) {
      buf.writeByte(hostileType);
    }
    if (bitSet.get(8)) {
      buf.writeInt((int) entityType);
    }
    if (bitSet.get(9)) {
      buf.writeByte(currentMode);
    }
    if (bitSet.get(10)) {
      buf.writeInt((int) lastShootTime);
    }
    if (bitSet.get(11)) {
      buf.writeInt((int) hitCounter);
    }
    if (bitSet.get(12)) {
      buf.writeInt((int) lastHitTime);
    }
    if (bitSet.get(13)) {
      app.encode(buf);
    }
    if (bitSet.get(14)) {
      buf.writeByte(flags1);
      buf.writeByte(flags2);
    }
    if (bitSet.get(15)) {
      buf.writeInt((int) rollTime);
    }
    if (bitSet.get(16)) {
      buf.writeInt(stunTime);
    }
    if (bitSet.get(17)) {
      buf.writeInt((int) slowedTime);
    }
    if (bitSet.get(18)) {
      buf.writeInt((int) makeBlueTime);
    }
    if (bitSet.get(19)) {
      buf.writeInt((int) speedUpTime);
    }
    if (bitSet.get(20)) {
      buf.writeFloat(slowPatchTime);
    }
    if (bitSet.get(21)) {
      buf.writeByte(classType);
    }
    if (bitSet.get(22)) {
      buf.writeByte(specialization);
    }
    if (bitSet.get(23)) {
      buf.writeFloat(chargedMP);
    }
    if (bitSet.get(24)) {
      buf.writeInt((int) nu1);
      buf.writeInt((int) nu2);
      buf.writeInt((int) nu3);
    }
    if (bitSet.get(25)) {
      buf.writeInt((int) nu4);
      buf.writeInt((int) nu5);
      buf.writeInt((int) nu6);
    }
    if (bitSet.get(26)) {
      writeFloatVector3(buf, rayHit);
    }
    if (bitSet.get(27)) {
      buf.writeFloat(HP);
    }
    if (bitSet.get(28)) {
      buf.writeFloat(MP);
    }
    if (bitSet.get(29)) {
      buf.writeFloat(blockPower);
    }
    if (bitSet.get(30)) {
      buf.writeFloat(maxHPMultiplier);
      buf.writeFloat(shootSpeed);
      buf.writeFloat(damageMultiplier);
      buf.writeFloat(armorMultiplier);
      buf.writeFloat(resistanceMultiplier);
    }
    if (bitSet.get(31)) {
      buf.writeByte(nu7);
    }
    if (bitSet.get(32)) {
      buf.writeByte(nu8);
    }
    if (bitSet.get(33)) {
      buf.writeInt((int) level);
    }
    if (bitSet.get(34)) {
      buf.writeInt((int) currentXP);
    }
    if (bitSet.get(35)) {
      buf.writeLong(parentOwner);
    }
    if (bitSet.get(36)) {
      buf.writeInt((int) na1);
      buf.writeInt((int) na2);
    }
    if (bitSet.get(37)) {
      buf.writeByte(na3);
    }
    if (bitSet.get(38)) {
      buf.writeInt((int) na4);
    }
    if (bitSet.get(39)) {
      buf.writeInt((int) na5);
      buf.writeInt((int) nu11);
      buf.writeInt((int) nu12);
    }
    if (bitSet.get(40)) {
      writeLongVector3(buf, spawnPosition);
    }
    if (bitSet.get(41)) {
      buf.writeInt((int) nu20);
      buf.writeInt((int) nu21);
      buf.writeInt((int) nu22);
    }
    if (bitSet.get(42)) {
      buf.writeByte(nu19);
    }
    if (bitSet.get(43)) {
      itemData.encode(buf);
    }
    if (bitSet.get(44)) {
      for (int i = 0; i < 13; i++) {
        GItem item = equipment[i];
        item.encode(buf);
      }
    }
    if (bitSet.get(45)) {
      byte[] ascii = name.getBytes(Charsets.US_ASCII);
      buf.writeBytes(ascii);
      buf.writeBytes(new byte[16 - name.length()]);
    }
    if (bitSet.get(46)) {
      for (int i = 0; i < 11; i++) {
        buf.writeInt((int) skills[i]);
      }
    }
    if (bitSet.get(47)) {
      buf.writeInt((int) iceBlockFour);
    }

    buf.capacity(buf.writerIndex() + 1);
    if (buf.readerIndex() > 0) {
      Glydar.getServer().getLogger().warning("Data read during encode.");
    }
  }