Exemple #1
0
  public void spawnExcrement(int value) {
    Entity entity = null;

    Vector<Entity> fats = getBodyParts();
    Entity last = fats.get(fats.size() - 1);

    switch (value) {
      case 50:
        entity = new FoodEntityLevel1();
        break;
      case 100:
        entity = new FoodEntityLevel2();
        break;
      case 150:
        entity = new FoodEntityLevel3();
        break;
      case 200:
        entity = new FoodEntityLevel4();
        break;
      case 250:
        entity = new FoodEntityLevel5();
        break;
    }

    if (entity != null) {
      entity.setX(last.getRearX());
      entity.setY(last.getRearY());
      NonHostileAIController controller = new NonHostileAIController(entity);
      entity.setController(controller);
      entity.setWorld(getWorld());
      getWorld().addEntity(entity);
    }
  }
Exemple #2
0
  /** Initialise the Camera variables to the player position. */
  private void initToPlayerPosition() {
    // Cycle through all of the map objects
    // initialise the player when the player object is found
    for (int i = 0; i < map.getObjectGroupCount(); i++) {
      for (int j = 0; j < map.getObjectCount(i); j++) {
        if (map.getObjectName(i, j).equalsIgnoreCase("Player")) {
          player.setX(map.getObjectX(i, j) + (player.getWidth() / 2));
          player.setY(map.getObjectY(i, j));
          this.setPlayerStartXY(player.getX(), player.getY());
        }
      }
    }
    vPlayerX = player.getX();
    vPlayerY = player.getY();

    lastPlayerX = (int) vPlayerX / tileWidth;
    lastPlayerY = (int) vPlayerY / tileHeight;
    curPlayerX = lastPlayerX;
    curPlayerY = lastPlayerY;
  }
 @Override
 public void setX(double x) {
   super.setX((int) x);
 }
Exemple #4
0
  public void drawBuffer() {
    Graphics2D b = buffer.createGraphics(); // DrawPanel
    Graphics2D pl_b = buffer.createGraphics();
    Graphics2D pl_c = buffer.createGraphics();
    rkt = buffer.createGraphics();
    AffineTransform rkt_aff = new AffineTransform();
    Graphics2D envi[] = new Graphics2D[amountEnv];
    AffineTransform enviTrans[] = new AffineTransform[amountEnv];

    b.setColor(Color.BLACK);
    b.fillRect(0, 0, w, h);

    // #if (Default)
    // @
    // #elif (Blue_White)
    // @        	ii_bg = new ImageIcon("imgs/Hintergrund/HgBlauWeiss1.gif");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Blue_White_Green)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/HgBlauWeissGruen.gif");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Purple_White)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/HgLilaWeiss.gif");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Glass)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundglass05.gif");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Lava)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundlava01.gif");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Limba)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundlimba.gif");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Old)
    ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundoldpnt01.gif");
    img_bg = ii_bg.getImage();
    b.drawImage(img_bg, w, w, this);
    // #elif (Ov_Paper)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundov_paper.gif");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Paper)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundpaper05.gif");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Univ)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrunduniv01.jpg");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Water)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundwater01.jpg");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #elif (Water_2)
    // @            ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundwater05.jpg");
    // @            img_bg = ii_bg.getImage();
    // @            b.drawImage(img_bg, w, w, this);
    // #endif

    b.setColor(Color.gray);
    b.fillRect(0, 0, w, 25); // oben
    b.fillRect(0, h - 50, w, 25); // unten
    b.fillRect(0, 0, 25, h); // links
    b.fillRect(w - 35, 0, 30, h); // rechts
    b.setColor(Color.WHITE);

    // rocket
    // #if (tar)
    // #if (Rectangle)
    // @               if (current_Player.isRocket()){
    // @                   rkt_aff.rotate(current_Player.getDegree(), sch.getX(), sch.getY());
    // @                   rkt.setTransform(rkt_aff);
    // @                   System.out.println("Rok X:"+sch.getX()+" Rok Y:"+sch.getY());
    // @                   rkt.drawRect(sch.getX()+ current_Player.getWidth()/2, sch.getY() +
    // current_Player.getHeight()/2, kaliber, kaliber);} // Rocket 4Eck
    // #endif
    // #if (Oval)
    // @               if (current_Player.isRocket()){
    // @                   b.drawOval(sch.getX()+ current_Player.getWidth()/2, sch.getY() +
    // current_Player.getHeight()/2, kaliber, kaliber);} // Rocket Oval
    // #endif
    // #if (aa31)
    // @                 if (current_Player.isRocket()){
    // @                     try {
    // @                        rocketFire = ImageIO.read(new File("imgs/aa31.gif"));
    // @                        rkt_aff.rotate(current_Player.getDegree(), sch.getX(), sch.getY());
    // @                        rkt.setTransform(rkt_aff);
    // @                        rkt.drawImage(rocketFire, null, (int)sch.getX(), (int)sch.getY());
    // @                        //rkt.drawImage(rocketFire, null, (int)current_Player.getX(),
    // (int)current_Player.getY());
    // @                    } catch (IOException e) {
    // @                    }
    // @                 }
    // #endif
    // #if (Portal)
    // @                 if (current_Player.isRocket()){
    // @                     try {
    // @                        rocketFire = ImageIO.read(new File("imgs/portal.gif"));
    // @                        rkt_aff.rotate(current_Player.getDegree(), sch.getX(), sch.getY());
    // @                        rkt.setTransform(rkt_aff);
    // @                        rkt.drawImage(rocketFire, null,
    // sch.getX()+current_Player.getWidth()/2, sch.getY()+current_Player.getHeight()/2);
    // @                     } catch (IOException e) {
    // @                     }
    // @                 }
    // #endif
    // #if (Nino)
    // @                 if (current_Player.isRocket()){
    // @                     try {
    // @                        rocketFire = ImageIO.read(new File("imgs/nino.gif"));
    // @                        rkt_aff.rotate(current_Player.getDegree(), sch.getX(), sch.getY());
    // @                        rkt.setTransform(rkt_aff);
    // @                        rkt.drawImage(rocketFire, null,
    // sch.getX()+current_Player.getWidth()/2, sch.getY()+current_Player.getHeight()/2);
    // @                     } catch (IOException e) {
    // @                     }
    // @                 }
    // #endif
    // #endif

    for (int i = 0; i <= amountEnv - 1; i++) {
      envi[i] = buffer.createGraphics();
      enviTrans[i] = new AffineTransform();
      envi[i].setTransform(enviTrans[i]);
      envi[i].drawImage(env[i].getImg(), env[i].getX(), env[i].getY(), this);
    }

    for (int i = 0; i < 8; i++) {
      if (powerUps[i].isAktiv()) {
        b.setColor(powerUps[i].getCol());
        b.drawImage(powerUps[i].getImg(), powerUps[i].getX(), powerUps[i].getY(), this);
      }
    }

    b.setColor(Color.WHITE);
    b.drawString("BP: " + current_Player.getBp(), 10, 20);
    b.drawString("TP P1/P2: " + player_1.getTp() + " / " + player_2.getTp(), 100, 20);

    if (current_Player.getSch().getEnd_X() != 0 && current_Player.getSch().getEnd_Y() != 0) {
      b.setColor(Color.YELLOW);
      b.drawLine(
          (int) current_Player.getSch().getStart_X(),
          (int) current_Player.getSch().getStart_Y(),
          (int) current_Player.getSch().getEnd_X(),
          (int) current_Player.getSch().getEnd_Y());
      b.setColor(Color.WHITE);
      for (int i = 0; i < current_Player.getSch().getArImg().length; i++) {
        if (current_Player.getSch().getArImg()[i] != null && current_Player.getSch().isIsActive()) {
          b.drawImage(
              current_Player.getSch().getArImg()[i],
              (int) current_Player.getSch().getEnd_X()
                  - current_Player.getSch().getArImg()[i].getWidth(this) / 2,
              (int) current_Player.getSch().getEnd_Y()
                  - current_Player.getSch().getArImg()[i].getHeight(this) / 2,
              (int)
                  (current_Player.getSch().getArImg()[i].getWidth(this)
                      * (current_Player.getSch().getSpeed() / 150)),
              (int)
                  (current_Player.getSch().getArImg()[i].getHeight(this)
                      * (current_Player.getSch().getSpeed() / 150)),
              this);
          if (timeCounter == 75) {
            System.out.println("----------------------><---------------------");
            if (player_1
                .getBounds()
                .intersects(
                    (int) current_Player.getSch().getEnd_X()
                        - current_Player.getSch().getArImg()[i].getWidth(this) / 2,
                    (int) current_Player.getSch().getEnd_Y()
                        - current_Player.getSch().getArImg()[i].getHeight(this) / 2,
                    (int)
                        (current_Player.getSch().getArImg()[i].getWidth(this)
                            * (current_Player.getSch().getSpeed() / 150)),
                    (int)
                        (current_Player.getSch().getArImg()[i].getHeight(this)
                            * (current_Player.getSch().getSpeed() / 150)))) {
              player_1.setTp(player_1.getTp() - (int) current_Player.getSch().getSpeed() / 4);
              System.out.println("----------------------> P1 <---------------------");
            }
            if (player_2
                .getBounds()
                .intersects(
                    (int) current_Player.getSch().getEnd_X()
                        - current_Player.getSch().getArImg()[i].getWidth(this) / 2,
                    (int) current_Player.getSch().getEnd_Y()
                        - current_Player.getSch().getArImg()[i].getHeight(this) / 2,
                    (int)
                        (current_Player.getSch().getArImg()[i].getWidth(this)
                            * (current_Player.getSch().getSpeed() / 150)),
                    (int)
                        (current_Player.getSch().getArImg()[i].getHeight(this)
                            * (current_Player.getSch().getSpeed() / 150)))) {
              player_2.setTp(player_2.getTp() - (int) current_Player.getSch().getSpeed() / 4);
              System.out.println("----------------------> P2 <---------------------");
            }
          }
        }
        if (timeCounter >= 150) {
          timeCounter = 0;
          current_Player.getSch().setIsActive(false);
          current_Player.getSch().setEnd_X(0);
          current_Player.getSch().setEnd_Y(0);
        }
        if (current_Player.getSch().isIsActive()) timeCounter += 1;
        System.out.println("timecounter: " + timeCounter);
      }
    }

    if (player_1.getTp() <= 0) b.drawString("SPIELER 2 HAT GEWONNEN !", w / 2, h / 2);
    if (player_2.getTp() <= 0) b.drawString("SPIELER 1 HAT GEWONNEN !", w / 2, h / 2);

    current_Player.setStop(false);
    b.setColor(Color.red);

    AffineTransform a = new AffineTransform();
    a.rotate(
        current_Player.getDegree(),
        current_Player.getX() + current_Player.getWidth() / 2,
        current_Player.getY() + current_Player.getHeight() / 2);
    ((Graphics2D) pl_b).setTransform(a);
    pl_b.drawImage(
        current_Player.getImg(), (int) current_Player.getX(), (int) current_Player.getY(), this);
    System.out.println(
        "P1 X:" + (int) current_Player.getX() + " P1 Y:" + (int) current_Player.getY());
    System.out.println("P1 W:" + current_Player.getWidth() + " P1 H:" + current_Player.getHeight());
    AffineTransform a2 = new AffineTransform();
    a2.rotate(
        other_Player.getDegree(),
        other_Player.getX() + other_Player.getWidth() / 2,
        other_Player.getY() + other_Player.getHeight() / 2);
    ((Graphics2D) pl_c).setTransform(a2);
    pl_c.drawImage(
        other_Player.getImg(), (int) other_Player.getX(), (int) other_Player.getY(), this);

    if (current_Player.isCollision() == true) {
      current_Player.setStop(true);
      if (timecount > 10) {
        b.setColor(Color.WHITE);
        b.drawString("C O L L I S I O N !", (int) w / 2 - 50, (int) h / 2);
        timecount--;
      } else {
        timecount = 0;
        current_Player.setBp(0);
        current_Player.setX(300);
        current_Player.setY(100);
        current_Player.getSch().setEnd_X(1);
        current_Player.getSch().setEnd_Y(1);
        current_Player.getSch().setStart_X(1);
        current_Player.getSch().setStart_Y(1);
      }
      b.dispose();
    }
  }
  /** Updates the enitities position depending on nearest food and attacking */
  public void update() {
    radarEntity.setX(entity.getX());
    radarEntity.setY(entity.getY());
    Entity target = entity.getWorld().getNearbyFood(radarEntity, entity);

    if (entity.getSizeValue() * entity.getBodyParts().size()
        < prevEntityValue * entity.getBodyParts().size()) runAway = true;

    if (!runAway) {
      if (target != null) {

        int xTarget = target.getX();
        int yTarget = target.getY();
        if (target.getType() < 3) {
          entity.setColor(Color.orange);
          entity.setVelocity(MAX_ATTACK_VELOCITY);
          entity.setAcceleration(MAX_ATTACK_ACCELERATION);
          entity.setDeceleration(MAX_ATTACK_ACCELERATION / 2);
          entity.setTarget(xTarget, yTarget);
        } else {
          entity.setColor(Color.white);
          entity.setVelocity(MAX_VELOCITY);
          entity.setAcceleration(MAX_ACCELERATION);
          entity.setDeceleration(MAX_ACCELERATION / 2);
          entity.setTarget(xTarget, yTarget);
        }
      } else {
        entity.setColor(Color.white);
        entity.setVelocity(MAX_VELOCITY);
        entity.setAcceleration(MAX_ACCELERATION);
        entity.setDeceleration(MAX_ACCELERATION / 2);
        currTime = timer.milliTime(); // get the time we are at
        accumulator += currTime - prevTime; // add time taken since last loop to accumulator

        prevTime = currTime; // set new previous time

        if (accumulator >= TIMESTEP_MILLIS) { // while there is an update rate in the accumulator

          boolean bx = rbooleanx.nextBoolean();
          boolean by = rbooleany.nextBoolean();

          int xTarget = entity.getX();
          int yTarget = entity.getY();

          if (bx == true) xTarget += rx.nextInt(RANGE);
          else xTarget += (rx.nextInt(RANGE)) * -1;

          if (by == true) yTarget += ry.nextInt(RANGE);
          else yTarget += (ry.nextInt(RANGE)) * -1;

          entity.setTarget(xTarget, yTarget);
          accumulator = 0;
        }
      }
      prevEntityValue = entity.getSizeValue();
    } else // we're running away
    {
      entity.setColor(Color.blue);
      entity.setVelocity(MAX_ATTACK_VELOCITY);
      entity.setAcceleration(MAX_ATTACK_ACCELERATION);
      currTime = timer.milliTime(); // get the time we are at
      accumulator += currTime - prevTime; // add time taken since last loop to accumulator
      runningTime += currTime - prevTime;
      prevTime = currTime; // set new previous time

      if (accumulator >= TIMESTEP_MILLIS) { // while there is an update rate in the accumulator

        int xTarget = entity.getX();
        int yTarget = entity.getY();

        if (xTarget < 0) xTarget -= FLEE_RANGE;
        else xTarget += FLEE_RANGE;

        if (yTarget < 0) yTarget -= FLEE_RANGE;
        else yTarget += FLEE_RANGE;

        entity.setTarget(xTarget, yTarget);
        accumulator = 0;
      }

      if (runningTime > 10000) {
        runAway = false;
        runningTime = 0;
        prevEntityValue = entity.getSizeValue();
        accumulator = TIMESTEP_MILLIS;
      }
    }
  }
  @EventHandler
  public void onPacketProcess(PacketProcessEvent event) {
    Packet packet = event.getPacket();
    if (packet instanceof Packet5PlayerInventory) {
      Packet5PlayerInventory inventoryPacket = (Packet5PlayerInventory) packet;
      Entity entity = getEntityById(inventoryPacket.entityID);
      if (entity == null || !(entity instanceof LivingEntity)) return;
      LivingEntity livingEntity = (LivingEntity) entity;
      livingEntity.setWornItemAt(inventoryPacket.slot, inventoryPacket.item);
    } else if (packet instanceof Packet8UpdateHealth) {
      Packet8UpdateHealth updateHealthPacket = (Packet8UpdateHealth) packet;
      MainPlayerEntity player = bot.getPlayer();
      player.setHealth(updateHealthPacket.healthMP);
      player.setHunger(updateHealthPacket.food);
    } else if (packet instanceof Packet9Respawn) {
      synchronized (chunks) {
        chunks.clear();
      }
    } else if (packet instanceof Packet20NamedEntitySpawn) {
      Packet20NamedEntitySpawn spawnPacket = (Packet20NamedEntitySpawn) packet;
      PlayerEntity entity = new PlayerEntity(this, spawnPacket.entityId, spawnPacket.name);
      entity.setX(spawnPacket.xPosition / 32D);
      entity.setY(spawnPacket.yPosition / 32D);
      entity.setZ(spawnPacket.zPosition / 32D);
      entity.setYaw(spawnPacket.rotation);
      entity.setPitch(spawnPacket.pitch);
      entity.setWornItemAt(0, new BasicItemStack(spawnPacket.currentItem, 1, 0));
      spawnEntity(entity);
    } else if (packet instanceof Packet21PickupSpawn) {
      Packet21PickupSpawn spawnPacket = (Packet21PickupSpawn) packet;
      ItemEntity entity = new ItemEntity(this, spawnPacket.entityId, spawnPacket.item);
      entity.setX(spawnPacket.xPosition / 32D);
      entity.setY(spawnPacket.yPosition / 32D);
      entity.setZ(spawnPacket.zPosition / 32D);
      spawnEntity(entity);
    } else if (packet instanceof Packet22Collect) {
      Entity entity = getEntityById(((Packet22Collect) packet).collectedEntityId);
      if (entity != null) despawnEntity(entity);
    } else if (packet instanceof Packet23VehicleSpawn) {
      Packet23VehicleSpawn spawnPacket = (Packet23VehicleSpawn) packet;
      Entity entity = null;
      Class<? extends Entity> entityClass = EntityList.getObjectEntityClass(spawnPacket.type);
      if (entityClass == null) return;
      try {
        Constructor<? extends Entity> constructor =
            entityClass.getConstructor(World.class, Integer.TYPE);
        entity = constructor.newInstance(this, spawnPacket.entityId);
      } catch (Exception exception) {
        exception.printStackTrace();
        return;
      }
      entity.setX(spawnPacket.xPosition / 32D);
      entity.setY(spawnPacket.yPosition / 32D);
      entity.setZ(spawnPacket.zPosition / 32D);
      entity.setYaw(0);
      entity.setPitch(0);
      spawnEntity(entity);
    } else if (packet instanceof Packet24MobSpawn) {
      Packet24MobSpawn mobSpawnPacket = (Packet24MobSpawn) packet;
      LivingEntity entity = null;
      Class<? extends LivingEntity> entityClass =
          EntityList.getLivingEntityClass(mobSpawnPacket.type);
      if (entityClass == null) return;
      try {
        Constructor<? extends LivingEntity> constructor =
            entityClass.getConstructor(World.class, Integer.TYPE);
        entity = constructor.newInstance(this, mobSpawnPacket.entityId);
      } catch (Exception exception) {
        exception.printStackTrace();
        return;
      }
      entity.setX(mobSpawnPacket.xPosition / 32D);
      entity.setY(mobSpawnPacket.yPosition / 32D);
      entity.setZ(mobSpawnPacket.zPosition / 32D);
      entity.setYaw((mobSpawnPacket.yaw * 360) / 256F);
      entity.setPitch((mobSpawnPacket.pitch * 360) / 256F);
      entity.setHeadYaw((mobSpawnPacket.headYaw * 360) / 256F);

      if (mobSpawnPacket.getMetadata() != null) entity.updateMetadata(mobSpawnPacket.getMetadata());
      spawnEntity(entity);
    } else if (packet instanceof Packet25EntityPainting) {
      Packet25EntityPainting paintingPacket = (Packet25EntityPainting) packet;
      PaintingEntity entity =
          new PaintingEntity(
              this, paintingPacket.entityId, ArtType.getArtTypeByName(paintingPacket.title));
      entity.setX(paintingPacket.xPosition);
      entity.setY(paintingPacket.yPosition);
      entity.setZ(paintingPacket.zPosition);
      entity.setDirection(paintingPacket.direction);
      spawnEntity(entity);
    } else if (packet instanceof Packet26EntityExpOrb) {

    } else if (packet instanceof Packet29DestroyEntity) {
      Packet29DestroyEntity destroyEntityPacket = (Packet29DestroyEntity) packet;
      for (int id : destroyEntityPacket.entityIds) {
        Entity entity = getEntityById(id);
        if (entity != null) {
          despawnEntity(entity);
          entity.setDead(true);
        }
      }
    } else if (packet instanceof Packet30Entity) {
      Packet30Entity entityPacket = (Packet30Entity) packet;
      Entity entity = getEntityById(entityPacket.entityId);
      if (entity == null) return;
      entity.setX(entity.getX() + (entityPacket.xPosition / 32D));
      entity.setY(entity.getY() + (entityPacket.yPosition / 32D));
      entity.setZ(entity.getZ() + (entityPacket.zPosition / 32D));
      if (packet instanceof Packet31RelEntityMove || packet instanceof Packet33RelEntityMoveLook) {
        entity.setYaw((entityPacket.yaw * 360) / 256F);
        entity.setPitch((entityPacket.pitch * 360) / 256F);
      }
    } else if (packet instanceof Packet34EntityTeleport) {
      Packet34EntityTeleport teleportPacket = (Packet34EntityTeleport) packet;
      Entity entity = getEntityById(teleportPacket.entityId);
      if (entity == null) return;
      entity.setX(teleportPacket.xPosition / 32D);
      entity.setY(teleportPacket.yPosition / 32D);
      entity.setZ(teleportPacket.zPosition / 32D);
      entity.setYaw((teleportPacket.yaw * 360) / 256F);
      entity.setPitch((teleportPacket.pitch * 360) / 256F);
    } else if (packet instanceof Packet35EntityHeadRotation) {
      Packet35EntityHeadRotation headRotatePacket = (Packet35EntityHeadRotation) packet;
      Entity entity = getEntityById(headRotatePacket.entityId);
      if (entity == null || !(entity instanceof LivingEntity)) return;
      ((LivingEntity) entity).setHeadYaw((headRotatePacket.headRotationYaw * 360) / 256F);
    } else if (packet instanceof Packet39AttachEntity) {
      Packet39AttachEntity attachEntityPacket = (Packet39AttachEntity) packet;
      Entity rider = getEntityById(attachEntityPacket.entityId);
      if (rider == null) return;
      Entity riding = null;
      if (attachEntityPacket.vehicleEntityId == -1) {
        if (rider.getRiding() != null) {
          rider.getRiding().setRider(null);
          rider.setRiding(null);
        }
      } else {
        riding = getEntityById(attachEntityPacket.vehicleEntityId);
        if (riding == null) return;
        rider.setRiding(riding);
        riding.setRider(rider);
      }
    } else if (packet instanceof Packet40EntityMetadata) {
      Packet40EntityMetadata metadataPacket = (Packet40EntityMetadata) packet;
      Entity entity = getEntityById(metadataPacket.entityId);
      if (entity == null) return;
      entity.updateMetadata(metadataPacket.getMetadata());
    } else if (packet instanceof Packet43Experience) {
      Packet43Experience experiencePacket = (Packet43Experience) packet;
      MainPlayerEntity player = bot.getPlayer();
      player.setExperienceLevel(experiencePacket.experienceLevel);
      player.setExperienceTotal(experiencePacket.experienceTotal);
    } else if (packet instanceof Packet51MapChunk) {
      if (bot.isMovementDisabled()) return;
      Packet51MapChunk mapChunkPacket = (Packet51MapChunk) packet;
      processChunk(
          mapChunkPacket.x,
          mapChunkPacket.z,
          mapChunkPacket.chunkData,
          mapChunkPacket.bitmask,
          mapChunkPacket.additionalBitmask,
          true,
          mapChunkPacket.biomes);
    } else if (packet instanceof Packet52MultiBlockChange) {
      Packet52MultiBlockChange multiBlockChangePacket = (Packet52MultiBlockChange) packet;
      if (multiBlockChangePacket.metadataArray == null) return;
      DataInputStream datainputstream =
          new DataInputStream(new ByteArrayInputStream(multiBlockChangePacket.metadataArray));
      try {
        for (int i = 0; i < multiBlockChangePacket.size; i++) {
          short word0 = datainputstream.readShort();
          short word1 = datainputstream.readShort();
          int id = (word1 & 0xfff) >> 4;
          int metadata = word1 & 0xf;
          int x = word0 >> 12 & 0xf;
          int z = word0 >> 8 & 0xf;
          int y = word0 & 0xff;
          setBlockIdAt(
              id,
              (multiBlockChangePacket.xPosition * 16) + x,
              y,
              (multiBlockChangePacket.zPosition * 16) + z);
          setBlockMetadataAt(
              metadata,
              (multiBlockChangePacket.xPosition * 16) + x,
              y,
              (multiBlockChangePacket.zPosition * 16) + z);
        }
      } catch (IOException exception) {
        exception.printStackTrace();
      }
    } else if (packet instanceof Packet53BlockChange) {
      Packet53BlockChange blockChangePacket = (Packet53BlockChange) packet;
      setBlockIdAt(
          blockChangePacket.type,
          blockChangePacket.xPosition,
          blockChangePacket.yPosition,
          blockChangePacket.zPosition);
      setBlockMetadataAt(
          blockChangePacket.metadata,
          blockChangePacket.xPosition,
          blockChangePacket.yPosition,
          blockChangePacket.zPosition);
    } else if (packet instanceof Packet56MapChunks) {
      if (bot.isMovementDisabled()) return;
      Packet56MapChunks chunkPacket = (Packet56MapChunks) packet;
      for (int i = 0; i < chunkPacket.primaryBitmap.length; i++)
        processChunk(
            chunkPacket.chunkX[i],
            chunkPacket.chunkZ[i],
            chunkPacket.chunkData[i],
            chunkPacket.primaryBitmap[i],
            chunkPacket.secondaryBitmap[i],
            chunkPacket.skylight,
            true);
    }
  }