Esempio n. 1
0
 public void handleBlockDig(Packet14BlockDig packet14blockdig) {
   WorldServer worldserver = mcServer.getWorldManager(playerEntity.dimension);
   if (packet14blockdig.status == 4) {
     playerEntity.dropCurrentItem();
     return;
   }
   boolean flag =
       worldserver.field_819_z =
           worldserver.worldProvider.worldType != 0
               || mcServer.configManager.isOp(playerEntity.username);
   boolean flag1 = false;
   if (packet14blockdig.status == 0) {
     flag1 = true;
   }
   if (packet14blockdig.status == 2) {
     flag1 = true;
   }
   int i = packet14blockdig.xPosition;
   int j = packet14blockdig.yPosition;
   int k = packet14blockdig.zPosition;
   if (flag1) {
     double d = playerEntity.posX - ((double) i + 0.5D);
     double d1 = playerEntity.posY - ((double) j + 0.5D);
     double d3 = playerEntity.posZ - ((double) k + 0.5D);
     double d5 = d * d + d1 * d1 + d3 * d3;
     if (d5 > 36D) {
       return;
     }
   }
   ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
   int l = (int) MathHelper.abs(i - chunkcoordinates.posX);
   int i1 = (int) MathHelper.abs(k - chunkcoordinates.posZ);
   if (l > i1) {
     i1 = l;
   }
   if (packet14blockdig.status == 0) {
     if (i1 > 16 || flag) {
       playerEntity.itemInWorldManager.func_324_a(i, j, k, packet14blockdig.face);
     } else {
       playerEntity.playerNetServerHandler.sendPacket(
           new Packet53BlockChange(i, j, k, worldserver));
     }
   } else if (packet14blockdig.status == 2) {
     playerEntity.itemInWorldManager.func_22045_b(i, j, k);
     if (worldserver.getBlockId(i, j, k) != 0) {
       playerEntity.playerNetServerHandler.sendPacket(
           new Packet53BlockChange(i, j, k, worldserver));
     }
   } else if (packet14blockdig.status == 3) {
     double d2 = playerEntity.posX - ((double) i + 0.5D);
     double d4 = playerEntity.posY - ((double) j + 0.5D);
     double d6 = playerEntity.posZ - ((double) k + 0.5D);
     double d7 = d2 * d2 + d4 * d4 + d6 * d6;
     if (d7 < 256D) {
       playerEntity.playerNetServerHandler.sendPacket(
           new Packet53BlockChange(i, j, k, worldserver));
     }
   }
   worldserver.field_819_z = false;
 }
Esempio n. 2
0
  protected void initialWorldChunkLoad() {
    boolean var1 = true;
    boolean var2 = true;
    boolean var3 = true;
    boolean var4 = true;
    int var5 = 0;
    this.setUserMessage("menu.generatingTerrain");
    byte var6 = 0;
    logger.info("Preparing start region for level " + var6);
    WorldServer var7 = this.worldServers[var6];
    BlockPos var8 = var7.getSpawnPoint();
    long var9 = getCurrentTimeMillis();

    for (int var11 = -192; var11 <= 192 && this.isServerRunning(); var11 += 16) {
      for (int var12 = -192; var12 <= 192 && this.isServerRunning(); var12 += 16) {
        long var13 = getCurrentTimeMillis();

        if (var13 - var9 > 1000L) {
          this.outputPercentRemaining("Preparing spawn area", var5 * 100 / 625);
          var9 = var13;
        }

        ++var5;
        var7.theChunkProviderServer.loadChunk(var8.getX() + var11 >> 4, var8.getZ() + var12 >> 4);
      }
    }

    this.clearCurrentTask();
  }
Esempio n. 3
0
  /** par1 indicates if a log message should be output. */
  protected void saveAllWorlds(boolean dontLog) {
    if (!this.worldIsBeingDeleted) {
      WorldServer[] var2 = this.worldServers;
      int var3 = var2.length;

      for (int var4 = 0; var4 < var3; ++var4) {
        WorldServer var5 = var2[var4];

        if (var5 != null) {
          if (!dontLog) {
            logger.info(
                "Saving chunks for level \'"
                    + var5.getWorldInfo().getWorldName()
                    + "\'/"
                    + var5.provider.getDimensionName());
          }

          try {
            var5.saveAllChunks(true, (IProgressUpdate) null);
          } catch (MinecraftException var7) {
            logger.warn(var7.getMessage());
          }
        }
      }
    }
  }
Esempio n. 4
0
  /** Saves all necessary data as preparation for stopping the server. */
  public void stopServer() {
    if (!this.worldIsBeingDeleted) {
      logger.info("Stopping server");

      if (this.getNetworkSystem() != null) {
        this.getNetworkSystem().terminateEndpoints();
      }

      if (this.serverConfigManager != null) {
        logger.info("Saving players");
        this.serverConfigManager.saveAllPlayerData();
        this.serverConfigManager.removeAllPlayers();
      }

      if (this.worldServers != null) {
        logger.info("Saving worlds");
        this.saveAllWorlds(false);

        for (int var1 = 0; var1 < this.worldServers.length; ++var1) {
          WorldServer var2 = this.worldServers[var1];
          var2.flush();
        }
      }

      if (this.usageSnooper.isSnooperRunning()) {
        this.usageSnooper.stopSnooper();
      }
    }
  }
 public void func_72367_e(EntityPlayerMP p_72367_1_) {
   func_72391_b(p_72367_1_);
   WorldServer worldserver = p_72367_1_.func_71121_q();
   worldserver.func_72900_e(p_72367_1_);
   worldserver.func_73040_p().func_72695_c(p_72367_1_);
   field_72404_b.remove(p_72367_1_);
   func_72384_a(new Packet201PlayerInfo(p_72367_1_.field_71092_bJ, false, 9999));
 }
  /** Updates Client side signs */
  public void handleUpdateSign(Packet130UpdateSign par1Packet130UpdateSign) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);

    if (worldserver.blockExists(
        par1Packet130UpdateSign.xPosition,
        par1Packet130UpdateSign.yPosition,
        par1Packet130UpdateSign.zPosition)) {
      TileEntity tileentity =
          worldserver.getBlockTileEntity(
              par1Packet130UpdateSign.xPosition,
              par1Packet130UpdateSign.yPosition,
              par1Packet130UpdateSign.zPosition);

      if (tileentity instanceof TileEntitySign) {
        TileEntitySign tileentitysign = (TileEntitySign) tileentity;

        if (!tileentitysign.isEditable()) {
          mcServer.logWarningMessage(
              (new StringBuilder())
                  .append("Player ")
                  .append(playerEntity.username)
                  .append(" just tried to change non-editable sign")
                  .toString());
          return;
        }
      }

      for (int i = 0; i < 4; i++) {
        boolean flag = true;

        if (par1Packet130UpdateSign.signLines[i].length() > 15) {
          flag = false;
        } else {
          for (int l = 0; l < par1Packet130UpdateSign.signLines[i].length(); l++) {
            if (ChatAllowedCharacters.allowedCharacters.indexOf(
                    par1Packet130UpdateSign.signLines[i].charAt(l))
                < 0) {
              flag = false;
            }
          }
        }

        if (!flag) {
          par1Packet130UpdateSign.signLines[i] = "!?";
        }
      }

      if (tileentity instanceof TileEntitySign) {
        int j = par1Packet130UpdateSign.xPosition;
        int k = par1Packet130UpdateSign.yPosition;
        int i1 = par1Packet130UpdateSign.zPosition;
        TileEntitySign tileentitysign1 = (TileEntitySign) tileentity;
        System.arraycopy(par1Packet130UpdateSign.signLines, 0, tileentitysign1.signText, 0, 4);
        tileentitysign1.onInventoryChanged();
        worldserver.markBlockNeedsUpdate(j, k, i1);
      }
    }
  }
 public void func_72375_a(EntityPlayerMP p_72375_1_, WorldServer p_72375_2_) {
   WorldServer worldserver = p_72375_1_.func_71121_q();
   if (p_72375_2_ != null) {
     p_72375_2_.func_73040_p().func_72695_c(p_72375_1_);
   }
   worldserver.func_73040_p().func_72683_a(p_72375_1_);
   worldserver.field_73059_b.func_73158_c(
       (int) p_72375_1_.field_70165_t >> 4, (int) p_72375_1_.field_70161_v >> 4);
 }
Esempio n. 8
0
 public void func_6006_a(Packet7UseEntity packet7useentity) {
   WorldServer worldserver = mcServer.getWorldManager(playerEntity.dimension);
   Entity entity = worldserver.func_6158_a(packet7useentity.targetEntity);
   if (entity != null
       && playerEntity.canEntityBeSeen(entity)
       && playerEntity.getDistanceSqToEntity(entity) < 36D) {
     if (packet7useentity.isLeftClick == 0) {
       playerEntity.useCurrentItemOnEntity(entity);
     } else if (packet7useentity.isLeftClick == 1) {
       playerEntity.attackTargetEntityWithCurrentItem(entity);
     }
   }
 }
Esempio n. 9
0
  public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper) {
    playerSnooper.addClientStat("whitelist_enabled", Boolean.valueOf(false));
    playerSnooper.addClientStat("whitelist_count", Integer.valueOf(0));

    if (this.serverConfigManager != null) {
      playerSnooper.addClientStat("players_current", Integer.valueOf(this.getCurrentPlayerCount()));
      playerSnooper.addClientStat("players_max", Integer.valueOf(this.getMaxPlayers()));
      playerSnooper.addClientStat(
          "players_seen", Integer.valueOf(this.serverConfigManager.getAvailablePlayerDat().length));
    }

    playerSnooper.addClientStat("uses_auth", Boolean.valueOf(this.onlineMode));
    playerSnooper.addClientStat("gui_state", this.getGuiEnabled() ? "enabled" : "disabled");
    playerSnooper.addClientStat(
        "run_time",
        Long.valueOf(
            (getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
    playerSnooper.addClientStat(
        "avg_tick_ms", Integer.valueOf((int) (MathHelper.average(this.tickTimeArray) * 1.0E-6D)));
    int var2 = 0;

    if (this.worldServers != null) {
      for (int var3 = 0; var3 < this.worldServers.length; ++var3) {
        if (this.worldServers[var3] != null) {
          WorldServer var4 = this.worldServers[var3];
          WorldInfo var5 = var4.getWorldInfo();
          playerSnooper.addClientStat(
              "world[" + var2 + "][dimension]", Integer.valueOf(var4.provider.getDimensionId()));
          playerSnooper.addClientStat("world[" + var2 + "][mode]", var5.getGameType());
          playerSnooper.addClientStat("world[" + var2 + "][difficulty]", var4.getDifficulty());
          playerSnooper.addClientStat(
              "world[" + var2 + "][hardcore]", Boolean.valueOf(var5.isHardcoreModeEnabled()));
          playerSnooper.addClientStat(
              "world[" + var2 + "][generator_name]", var5.getTerrainType().getWorldTypeName());
          playerSnooper.addClientStat(
              "world[" + var2 + "][generator_version]",
              Integer.valueOf(var5.getTerrainType().getGeneratorVersion()));
          playerSnooper.addClientStat(
              "world[" + var2 + "][height]", Integer.valueOf(this.buildLimit));
          playerSnooper.addClientStat(
              "world[" + var2 + "][chunks_loaded]",
              Integer.valueOf(var4.getChunkProvider().getLoadedChunkCount()));
          ++var2;
        }
      }
    }

    playerSnooper.addClientStat("worlds", Integer.valueOf(var2));
  }
Esempio n. 10
0
  /**
   * WARNING : directly calls
   * getActiveAnvilConverter().deleteWorldDirectory(theWorldServer[0].getSaveHandler().getWorldDirectoryName());
   */
  public void deleteWorldAndStopServer() {
    this.worldIsBeingDeleted = true;
    this.getActiveAnvilConverter().flushCache();

    for (int var1 = 0; var1 < this.worldServers.length; ++var1) {
      WorldServer var2 = this.worldServers[var1];

      if (var2 != null) {
        var2.flush();
      }
    }

    this.getActiveAnvilConverter()
        .deleteWorldDirectory(this.worldServers[0].getSaveHandler().getWorldDirectoryName());
    this.initiateShutdown();
  }
Esempio n. 11
0
 public EntityTracker(WorldServer par1WorldServer) {
   trackedEntitySet = new HashSet();
   trackedEntityHashTable = new IntHashMap();
   field_72795_a = par1WorldServer;
   maxTrackingDistanceThreshold =
       par1WorldServer.getMinecraftServer().func_71203_ab().func_72372_a();
 }
Esempio n. 12
0
  public Entity getEntityFromUuid(UUID uuid) {
    WorldServer[] var2 = this.worldServers;
    int var3 = var2.length;

    for (int var4 = 0; var4 < var3; ++var4) {
      WorldServer var5 = var2[var4];

      if (var5 != null) {
        Entity var6 = var5.getEntityFromUuid(uuid);

        if (var6 != null) {
          return var6;
        }
      }
    }

    return null;
  }
 public void func_72377_c(EntityPlayerMP p_72377_1_) {
   func_72384_a(new Packet201PlayerInfo(p_72377_1_.field_71092_bJ, true, 1000));
   field_72404_b.add(p_72377_1_);
   WorldServer worldserver;
   for (worldserver = field_72400_f.func_71218_a(p_72377_1_.field_71093_bK);
       !worldserver.func_72945_a(p_72377_1_, p_72377_1_.field_70121_D).isEmpty();
       p_72377_1_.func_70107_b(
           p_72377_1_.field_70165_t, p_72377_1_.field_70163_u + 1.0D, p_72377_1_.field_70161_v)) {}
   worldserver.func_72838_d(p_72377_1_);
   func_72375_a(p_72377_1_, null);
   EntityPlayerMP entityplayermp;
   for (Iterator iterator = field_72404_b.iterator();
       iterator.hasNext();
       p_72377_1_.field_71135_a.func_72567_b(
           new Packet201PlayerInfo(
               entityplayermp.field_71092_bJ, true, entityplayermp.field_71138_i))) {
     entityplayermp = (EntityPlayerMP) iterator.next();
   }
 }
  public void handleUseEntity(Packet7UseEntity par1Packet7UseEntity) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);
    Entity entity = worldserver.getEntityByID(par1Packet7UseEntity.targetEntity);

    if (entity != null) {
      boolean flag = playerEntity.canEntityBeSeen(entity);
      double d = 36D;

      if (!flag) {
        d = 9D;
      }

      if (playerEntity.getDistanceSqToEntity(entity) < d) {
        if (par1Packet7UseEntity.isLeftClick == 0) {
          playerEntity.interactWith(entity);
        } else if (par1Packet7UseEntity.isLeftClick == 1) {
          playerEntity.attackTargetEntityWithCurrentItem(entity);
        }
      }
    }
  }
Esempio n. 15
0
  public void setDifficultyForAllWorlds(EnumDifficulty difficulty) {
    for (int var2 = 0; var2 < this.worldServers.length; ++var2) {
      WorldServer var3 = this.worldServers[var2];

      if (var3 != null) {
        if (var3.getWorldInfo().isHardcoreModeEnabled()) {
          var3.getWorldInfo().setDifficulty(EnumDifficulty.HARD);
          var3.setAllowedSpawnTypes(true, true);
        } else if (this.isSinglePlayer()) {
          var3.getWorldInfo().setDifficulty(difficulty);
          var3.setAllowedSpawnTypes(var3.getDifficulty() != EnumDifficulty.PEACEFUL, true);
        } else {
          var3.getWorldInfo().setDifficulty(difficulty);
          var3.setAllowedSpawnTypes(this.allowSpawnMonsters(), this.canSpawnAnimals);
        }
      }
    }
  }
Esempio n. 16
0
  public void updateTimeLightAndEntities() {
    this.theProfiler.startSection("jobs");
    Queue var1 = this.futureTaskQueue;

    synchronized (this.futureTaskQueue) {
      while (!this.futureTaskQueue.isEmpty()) {
        try {
          ((FutureTask) this.futureTaskQueue.poll()).run();
        } catch (Throwable var9) {
          logger.fatal(var9);
        }
      }
    }

    this.theProfiler.endStartSection("levels");
    int var11;

    for (var11 = 0; var11 < this.worldServers.length; ++var11) {
      long var2 = System.nanoTime();

      if (var11 == 0 || this.getAllowNether()) {
        WorldServer var4 = this.worldServers[var11];
        this.theProfiler.startSection(var4.getWorldInfo().getWorldName());

        if (this.tickCounter % 20 == 0) {
          this.theProfiler.startSection("timeSync");
          this.serverConfigManager.sendPacketToAllPlayersInDimension(
              new S03PacketTimeUpdate(
                  var4.getTotalWorldTime(),
                  var4.getWorldTime(),
                  var4.getGameRules().getGameRuleBooleanValue("doDaylightCycle")),
              var4.provider.getDimensionId());
          this.theProfiler.endSection();
        }

        this.theProfiler.startSection("tick");
        CrashReport var6;

        try {
          var4.tick();
        } catch (Throwable var8) {
          var6 = CrashReport.makeCrashReport(var8, "Exception ticking world");
          var4.addWorldInfoToCrashReport(var6);
          throw new ReportedException(var6);
        }

        try {
          var4.updateEntities();
        } catch (Throwable var7) {
          var6 = CrashReport.makeCrashReport(var7, "Exception ticking world entities");
          var4.addWorldInfoToCrashReport(var6);
          throw new ReportedException(var6);
        }

        this.theProfiler.endSection();
        this.theProfiler.startSection("tracker");
        var4.getEntityTracker().updateTrackedEntities();
        this.theProfiler.endSection();
        this.theProfiler.endSection();
      }

      this.timeOfLastDimensionTick[var11][this.tickCounter % 100] = System.nanoTime() - var2;
    }

    this.theProfiler.endStartSection("connection");
    this.getNetworkSystem().networkTick();
    this.theProfiler.endStartSection("players");
    this.serverConfigManager.onTick();
    this.theProfiler.endStartSection("tickables");

    for (var11 = 0; var11 < this.playersOnline.size(); ++var11) {
      ((IUpdatePlayerListBox) this.playersOnline.get(var11)).update();
    }

    this.theProfiler.endSection();
  }
 public EntityPlayerMP func_72368_a(
     EntityPlayerMP p_72368_1_, int p_72368_2_, boolean p_72368_3_) {
   p_72368_1_.func_71121_q().func_73039_n().func_72787_a(p_72368_1_);
   p_72368_1_.func_71121_q().func_73039_n().func_72790_b(p_72368_1_);
   p_72368_1_.func_71121_q().func_73040_p().func_72695_c(p_72368_1_);
   field_72404_b.remove(p_72368_1_);
   field_72400_f.func_71218_a(p_72368_1_.field_71093_bK).func_72973_f(p_72368_1_);
   ChunkCoordinates chunkcoordinates = p_72368_1_.func_70997_bJ();
   p_72368_1_.field_71093_bK = p_72368_2_;
   Object obj;
   if (field_72400_f.func_71242_L()) {
     obj = new DemoWorldManager(field_72400_f.func_71218_a(p_72368_1_.field_71093_bK));
   } else {
     obj = new ItemInWorldManager(field_72400_f.func_71218_a(p_72368_1_.field_71093_bK));
   }
   EntityPlayerMP entityplayermp =
       new EntityPlayerMP(
           field_72400_f,
           field_72400_f.func_71218_a(p_72368_1_.field_71093_bK),
           p_72368_1_.field_71092_bJ,
           ((ItemInWorldManager) (obj)));
   entityplayermp.func_71049_a(p_72368_1_, p_72368_3_);
   entityplayermp.field_70157_k = p_72368_1_.field_70157_k;
   entityplayermp.field_71135_a = p_72368_1_.field_71135_a;
   WorldServer worldserver = field_72400_f.func_71218_a(p_72368_1_.field_71093_bK);
   func_72381_a(entityplayermp, p_72368_1_, worldserver);
   if (chunkcoordinates != null) {
     ChunkCoordinates chunkcoordinates1 =
         EntityPlayer.func_71056_a(
             field_72400_f.func_71218_a(p_72368_1_.field_71093_bK), chunkcoordinates);
     if (chunkcoordinates1 != null) {
       entityplayermp.func_70012_b(
           (float) chunkcoordinates1.field_71574_a + 0.5F,
           (float) chunkcoordinates1.field_71572_b + 0.1F,
           (float) chunkcoordinates1.field_71573_c + 0.5F,
           0.0F,
           0.0F);
       entityplayermp.func_71063_a(chunkcoordinates);
     } else {
       entityplayermp.field_71135_a.func_72567_b(new Packet70GameEvent(0, 0));
     }
   }
   worldserver.field_73059_b.func_73158_c(
       (int) entityplayermp.field_70165_t >> 4, (int) entityplayermp.field_70161_v >> 4);
   for (;
       !worldserver.func_72945_a(entityplayermp, entityplayermp.field_70121_D).isEmpty();
       entityplayermp.func_70107_b(
           entityplayermp.field_70165_t,
           entityplayermp.field_70163_u + 1.0D,
           entityplayermp.field_70161_v)) {}
   entityplayermp.field_71135_a.func_72567_b(
       new Packet9Respawn(
           entityplayermp.field_71093_bK,
           (byte) entityplayermp.field_70170_p.field_73013_u,
           entityplayermp.field_70170_p.func_72912_H().func_76067_t(),
           entityplayermp.field_70170_p.func_72800_K(),
           entityplayermp.field_71134_c.func_73081_b()));
   ChunkCoordinates chunkcoordinates2 = worldserver.func_72861_E();
   entityplayermp.field_71135_a.func_72569_a(
       entityplayermp.field_70165_t,
       entityplayermp.field_70163_u,
       entityplayermp.field_70161_v,
       entityplayermp.field_70177_z,
       entityplayermp.field_70125_A);
   entityplayermp.field_71135_a.func_72567_b(
       new Packet6SpawnPosition(
           chunkcoordinates2.field_71574_a,
           chunkcoordinates2.field_71572_b,
           chunkcoordinates2.field_71573_c));
   func_72354_b(entityplayermp, worldserver);
   worldserver.func_73040_p().func_72683_a(entityplayermp);
   worldserver.func_72838_d(entityplayermp);
   field_72404_b.add(entityplayermp);
   entityplayermp.func_71116_b();
   return entityplayermp;
 }
 public void func_72356_a(EntityPlayerMP p_72356_1_, int p_72356_2_) {
   int i = p_72356_1_.field_71093_bK;
   WorldServer worldserver = field_72400_f.func_71218_a(p_72356_1_.field_71093_bK);
   p_72356_1_.field_71093_bK = p_72356_2_;
   WorldServer worldserver1 = field_72400_f.func_71218_a(p_72356_1_.field_71093_bK);
   p_72356_1_.field_71135_a.func_72567_b(
       new Packet9Respawn(
           p_72356_1_.field_71093_bK,
           (byte) p_72356_1_.field_70170_p.field_73013_u,
           worldserver1.func_72912_H().func_76067_t(),
           worldserver1.func_72800_K(),
           p_72356_1_.field_71134_c.func_73081_b()));
   worldserver.func_72973_f(p_72356_1_);
   p_72356_1_.field_70128_L = false;
   double d = p_72356_1_.field_70165_t;
   double d1 = p_72356_1_.field_70161_v;
   double d2 = 8D;
   if (p_72356_1_.field_71093_bK == -1) {
     d /= d2;
     d1 /= d2;
     p_72356_1_.func_70012_b(
         d, p_72356_1_.field_70163_u, d1, p_72356_1_.field_70177_z, p_72356_1_.field_70125_A);
     if (p_72356_1_.func_70089_S()) {
       worldserver.func_72866_a(p_72356_1_, false);
     }
   } else if (p_72356_1_.field_71093_bK == 0) {
     d *= d2;
     d1 *= d2;
     p_72356_1_.func_70012_b(
         d, p_72356_1_.field_70163_u, d1, p_72356_1_.field_70177_z, p_72356_1_.field_70125_A);
     if (p_72356_1_.func_70089_S()) {
       worldserver.func_72866_a(p_72356_1_, false);
     }
   } else {
     ChunkCoordinates chunkcoordinates = worldserver1.func_73054_j();
     d = chunkcoordinates.field_71574_a;
     p_72356_1_.field_70163_u = chunkcoordinates.field_71572_b;
     d1 = chunkcoordinates.field_71573_c;
     p_72356_1_.func_70012_b(d, p_72356_1_.field_70163_u, d1, 90F, 0.0F);
     if (p_72356_1_.func_70089_S()) {
       worldserver.func_72866_a(p_72356_1_, false);
     }
   }
   if (i != 1) {
     d = MathHelper.func_76125_a((int) d, 0xfe363d00, 0x1c9c300);
     d1 = MathHelper.func_76125_a((int) d1, 0xfe363d00, 0x1c9c300);
     if (p_72356_1_.func_70089_S()) {
       worldserver1.func_72838_d(p_72356_1_);
       p_72356_1_.func_70012_b(
           d, p_72356_1_.field_70163_u, d1, p_72356_1_.field_70177_z, p_72356_1_.field_70125_A);
       worldserver1.func_72866_a(p_72356_1_, false);
       (new Teleporter()).func_77185_a(worldserver1, p_72356_1_);
     }
   }
   p_72356_1_.func_70029_a(worldserver1);
   func_72375_a(p_72356_1_, worldserver);
   p_72356_1_.field_71135_a.func_72569_a(
       p_72356_1_.field_70165_t,
       p_72356_1_.field_70163_u,
       p_72356_1_.field_70161_v,
       p_72356_1_.field_70177_z,
       p_72356_1_.field_70125_A);
   p_72356_1_.field_71134_c.func_73080_a(worldserver1);
   func_72354_b(p_72356_1_, worldserver1);
   func_72385_f(p_72356_1_);
   PotionEffect potioneffect;
   for (Iterator iterator = p_72356_1_.func_70651_bq().iterator();
       iterator.hasNext();
       p_72356_1_.field_71135_a.func_72567_b(
           new Packet41EntityEffect(p_72356_1_.field_70157_k, potioneffect))) {
     potioneffect = (PotionEffect) iterator.next();
   }
 }
  public void func_72355_a(NetworkManager p_72355_1_, EntityPlayerMP p_72355_2_) {
    func_72380_a(p_72355_2_);
    p_72355_2_.func_70029_a(field_72400_f.func_71218_a(p_72355_2_.field_71093_bK));
    p_72355_2_.field_71134_c.func_73080_a((WorldServer) p_72355_2_.field_70170_p);
    String s = "local";
    if (p_72355_1_.func_74430_c() != null) {
      s = p_72355_1_.func_74430_c().toString();
    }
    field_72406_a.info(
        (new StringBuilder())
            .append(p_72355_2_.field_71092_bJ)
            .append("[")
            .append(s)
            .append("] logged in with entity id ")
            .append(p_72355_2_.field_70157_k)
            .append(" at (")
            .append(p_72355_2_.field_70165_t)
            .append(", ")
            .append(p_72355_2_.field_70163_u)
            .append(", ")
            .append(p_72355_2_.field_70161_v)
            .append(")")
            .toString());
    WorldServer worldserver = field_72400_f.func_71218_a(p_72355_2_.field_71093_bK);
    ChunkCoordinates chunkcoordinates = worldserver.func_72861_E();
    func_72381_a(p_72355_2_, null, worldserver);
    NetServerHandler netserverhandler = new NetServerHandler(field_72400_f, p_72355_1_, p_72355_2_);
    netserverhandler.func_72567_b(
        new Packet1Login(
            p_72355_2_.field_70157_k,
            worldserver.func_72912_H().func_76067_t(),
            p_72355_2_.field_71134_c.func_73081_b(),
            worldserver.func_72912_H().func_76093_s(),
            worldserver.field_73011_w.field_76574_g,
            worldserver.field_73013_u,
            worldserver.func_72800_K(),
            func_72352_l()));
    netserverhandler.func_72567_b(
        new Packet6SpawnPosition(
            chunkcoordinates.field_71574_a,
            chunkcoordinates.field_71572_b,
            chunkcoordinates.field_71573_c));
    netserverhandler.func_72567_b(new Packet202PlayerAbilities(p_72355_2_.field_71075_bZ));
    func_72354_b(p_72355_2_, worldserver);
    func_72384_a(
        new Packet3Chat(
            (new StringBuilder())
                .append("\247e")
                .append(p_72355_2_.field_71092_bJ)
                .append(" joined the game.")
                .toString()));
    func_72377_c(p_72355_2_);
    netserverhandler.func_72569_a(
        p_72355_2_.field_70165_t,
        p_72355_2_.field_70163_u,
        p_72355_2_.field_70161_v,
        p_72355_2_.field_70177_z,
        p_72355_2_.field_70125_A);
    field_72400_f.func_71212_ac().func_71745_a(netserverhandler);
    netserverhandler.func_72567_b(new Packet4UpdateTime(worldserver.func_72820_D()));
    if (field_72400_f.func_71202_P().length() > 0) {
      p_72355_2_.func_71115_a(field_72400_f.func_71202_P(), field_72400_f.func_71227_R());
    }
    PotionEffect potioneffect;
    for (Iterator iterator = p_72355_2_.func_70651_bq().iterator();
        iterator.hasNext();
        netserverhandler.func_72567_b(
            new Packet41EntityEffect(p_72355_2_.field_70157_k, potioneffect))) {
      potioneffect = (PotionEffect) iterator.next();
    }

    p_72355_2_.func_71116_b();
  }
Esempio n. 20
0
 public void handleFlying(Packet10Flying packet10flying) {
   WorldServer worldserver = mcServer.getWorldManager(playerEntity.dimension);
   field_22003_h = true;
   if (!hasMoved) {
     double d = packet10flying.yPosition - lastPosY;
     if (packet10flying.xPosition == lastPosX
         && d * d < 0.01D
         && packet10flying.zPosition == lastPosZ) {
       hasMoved = true;
     }
   }
   if (hasMoved) {
     if (playerEntity.ridingEntity != null) {
       float f = playerEntity.rotationYaw;
       float f1 = playerEntity.rotationPitch;
       playerEntity.ridingEntity.updateRiderPosition();
       double d2 = playerEntity.posX;
       double d4 = playerEntity.posY;
       double d6 = playerEntity.posZ;
       double d8 = 0.0D;
       double d9 = 0.0D;
       if (packet10flying.rotating) {
         f = packet10flying.yaw;
         f1 = packet10flying.pitch;
       }
       if (packet10flying.moving
           && packet10flying.yPosition == -999D
           && packet10flying.stance == -999D) {
         d8 = packet10flying.xPosition;
         d9 = packet10flying.zPosition;
       }
       playerEntity.onGround = packet10flying.onGround;
       playerEntity.onUpdateEntity(true);
       playerEntity.moveEntity(d8, 0.0D, d9);
       playerEntity.setPositionAndRotation(d2, d4, d6, f, f1);
       playerEntity.motionX = d8;
       playerEntity.motionZ = d9;
       if (playerEntity.ridingEntity != null) {
         worldserver.func_12017_b(playerEntity.ridingEntity, true);
       }
       if (playerEntity.ridingEntity != null) {
         playerEntity.ridingEntity.updateRiderPosition();
       }
       mcServer.configManager.func_613_b(playerEntity);
       lastPosX = playerEntity.posX;
       lastPosY = playerEntity.posY;
       lastPosZ = playerEntity.posZ;
       worldserver.updateEntity(playerEntity);
       return;
     }
     if (playerEntity.func_22057_E()) {
       playerEntity.onUpdateEntity(true);
       playerEntity.setPositionAndRotation(
           lastPosX, lastPosY, lastPosZ, playerEntity.rotationYaw, playerEntity.rotationPitch);
       worldserver.updateEntity(playerEntity);
       return;
     }
     double d1 = playerEntity.posY;
     lastPosX = playerEntity.posX;
     lastPosY = playerEntity.posY;
     lastPosZ = playerEntity.posZ;
     double d3 = playerEntity.posX;
     double d5 = playerEntity.posY;
     double d7 = playerEntity.posZ;
     float f2 = playerEntity.rotationYaw;
     float f3 = playerEntity.rotationPitch;
     if (packet10flying.moving
         && packet10flying.yPosition == -999D
         && packet10flying.stance == -999D) {
       packet10flying.moving = false;
     }
     if (packet10flying.moving) {
       d3 = packet10flying.xPosition;
       d5 = packet10flying.yPosition;
       d7 = packet10flying.zPosition;
       double d10 = packet10flying.stance - packet10flying.yPosition;
       if (!playerEntity.func_22057_E()
           && (d10 > 1.6499999999999999D || d10 < 0.10000000000000001D)) {
         kickPlayer("Illegal stance");
         logger.warning(
             (new StringBuilder())
                 .append(playerEntity.username)
                 .append(" had an illegal stance: ")
                 .append(d10)
                 .toString());
         return;
       }
       if (Math.abs(packet10flying.xPosition) > 32000000D
           || Math.abs(packet10flying.zPosition) > 32000000D) {
         kickPlayer("Illegal position");
         return;
       }
     }
     if (packet10flying.rotating) {
       f2 = packet10flying.yaw;
       f3 = packet10flying.pitch;
     }
     playerEntity.onUpdateEntity(true);
     playerEntity.ySize = 0.0F;
     playerEntity.setPositionAndRotation(lastPosX, lastPosY, lastPosZ, f2, f3);
     if (!hasMoved) {
       return;
     }
     double d11 = d3 - playerEntity.posX;
     double d12 = d5 - playerEntity.posY;
     double d13 = d7 - playerEntity.posZ;
     double d14 = d11 * d11 + d12 * d12 + d13 * d13;
     if (d14 > 100D) {
       logger.warning(
           (new StringBuilder())
               .append(playerEntity.username)
               .append(" moved too quickly!")
               .toString());
       kickPlayer("You moved too quickly :( (Hacking?)");
       return;
     }
     float f4 = 0.0625F;
     boolean flag =
         worldserver
                 .getCollidingBoundingBoxes(
                     playerEntity, playerEntity.boundingBox.copy().getInsetBoundingBox(f4, f4, f4))
                 .size()
             == 0;
     playerEntity.moveEntity(d11, d12, d13);
     d11 = d3 - playerEntity.posX;
     d12 = d5 - playerEntity.posY;
     if (d12 > -0.5D || d12 < 0.5D) {
       d12 = 0.0D;
     }
     d13 = d7 - playerEntity.posZ;
     d14 = d11 * d11 + d12 * d12 + d13 * d13;
     boolean flag1 = false;
     if (d14 > 0.0625D && !playerEntity.func_22057_E()) {
       flag1 = true;
       logger.warning(
           (new StringBuilder())
               .append(playerEntity.username)
               .append(" moved wrongly!")
               .toString());
       System.out.println(
           (new StringBuilder())
               .append("Got position ")
               .append(d3)
               .append(", ")
               .append(d5)
               .append(", ")
               .append(d7)
               .toString());
       System.out.println(
           (new StringBuilder())
               .append("Expected ")
               .append(playerEntity.posX)
               .append(", ")
               .append(playerEntity.posY)
               .append(", ")
               .append(playerEntity.posZ)
               .toString());
     }
     playerEntity.setPositionAndRotation(d3, d5, d7, f2, f3);
     boolean flag2 =
         worldserver
                 .getCollidingBoundingBoxes(
                     playerEntity, playerEntity.boundingBox.copy().getInsetBoundingBox(f4, f4, f4))
                 .size()
             == 0;
     if (flag && (flag1 || !flag2) && !playerEntity.func_22057_E()) {
       teleportTo(lastPosX, lastPosY, lastPosZ, f2, f3);
       return;
     }
     AxisAlignedBB axisalignedbb =
         playerEntity
             .boundingBox
             .copy()
             .expand(f4, f4, f4)
             .addCoord(0.0D, -0.55000000000000004D, 0.0D);
     if (!mcServer.allowFlight && !worldserver.func_27069_b(axisalignedbb)) {
       if (d12 >= -0.03125D) {
         playerInAirTime++;
         if (playerInAirTime > 80) {
           logger.warning(
               (new StringBuilder())
                   .append(playerEntity.username)
                   .append(" was kicked for floating too long!")
                   .toString());
           kickPlayer("Flying is not enabled on this server");
           return;
         }
       }
     } else {
       playerInAirTime = 0;
     }
     playerEntity.onGround = packet10flying.onGround;
     mcServer.configManager.func_613_b(playerEntity);
     playerEntity.handleFalling(playerEntity.posY - d1, packet10flying.onGround);
   }
 }
  public void handlePlace(Packet15Place par1Packet15Place) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);
    ItemStack itemstack = playerEntity.inventory.getCurrentItem();
    boolean flag = false;
    int i = par1Packet15Place.getXPosition();
    int j = par1Packet15Place.getYPosition();
    int k = par1Packet15Place.getZPosition();
    int l = par1Packet15Place.getDirection();
    boolean flag1 =
        worldserver.actionsAllowed =
            worldserver.provider.worldType != 0
                || mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)
                || mcServer.isSinglePlayer();

    if (par1Packet15Place.getDirection() == 255) {
      if (itemstack == null) {
        return;
      }

      playerEntity.theItemInWorldManager.tryUseItem(playerEntity, worldserver, itemstack);
    } else if (par1Packet15Place.getYPosition() < mcServer.getBuildLimit() - 1
        || par1Packet15Place.getDirection() != 1
            && par1Packet15Place.getYPosition() < mcServer.getBuildLimit()) {
      ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
      int i1 = MathHelper.abs_int(i - chunkcoordinates.posX);
      int j1 = MathHelper.abs_int(k - chunkcoordinates.posZ);

      if (i1 > j1) {
        j1 = i1;
      }

      if (field_72587_r
          && playerEntity.getDistanceSq((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D)
              < 64D
          && (j1 > 16 || flag1)) {
        playerEntity.theItemInWorldManager.activateBlockOrUseItem(
            playerEntity,
            worldserver,
            itemstack,
            i,
            j,
            k,
            l,
            par1Packet15Place.getXOffset(),
            par1Packet15Place.getYOffset(),
            par1Packet15Place.getZOffset());
      }

      flag = true;
    } else {
      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet3Chat(
              (new StringBuilder())
                  .append("\2477Height limit for building is ")
                  .append(mcServer.getBuildLimit())
                  .toString()));
      flag = true;
    }

    if (flag) {
      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet53BlockChange(i, j, k, worldserver));

      if (l == 0) {
        j--;
      }

      if (l == 1) {
        j++;
      }

      if (l == 2) {
        k--;
      }

      if (l == 3) {
        k++;
      }

      if (l == 4) {
        i--;
      }

      if (l == 5) {
        i++;
      }

      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet53BlockChange(i, j, k, worldserver));
    }

    itemstack = playerEntity.inventory.getCurrentItem();

    if (itemstack != null && itemstack.stackSize == 0) {
      playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null;
      itemstack = null;
    }

    if (itemstack == null || itemstack.getMaxItemUseDuration() == 0) {
      playerEntity.playerInventoryBeingManipulated = true;
      playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] =
          ItemStack.copyItemStack(
              playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem]);
      Slot slot =
          playerEntity.craftingInventory.getSlotFromInventory(
              playerEntity.inventory, playerEntity.inventory.currentItem);
      playerEntity.craftingInventory.updateCraftingResults();
      playerEntity.playerInventoryBeingManipulated = false;

      if (!ItemStack.areItemStacksEqual(
          playerEntity.inventory.getCurrentItem(), par1Packet15Place.getItemStack())) {
        sendPacketToPlayer(
            new Packet103SetSlot(
                playerEntity.craftingInventory.windowId,
                slot.slotNumber,
                playerEntity.inventory.getCurrentItem()));
      }
    }

    worldserver.actionsAllowed = false;
  }
  public void handleBlockDig(Packet14BlockDig par1Packet14BlockDig) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);

    if (par1Packet14BlockDig.status == 4) {
      playerEntity.dropOneItem();
      return;
    }

    if (par1Packet14BlockDig.status == 5) {
      playerEntity.stopUsingItem();
      return;
    }

    boolean flag =
        worldserver.actionsAllowed =
            worldserver.provider.worldType != 0
                || mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)
                || mcServer.isSinglePlayer();
    boolean flag1 = false;

    if (par1Packet14BlockDig.status == 0) {
      flag1 = true;
    }

    if (par1Packet14BlockDig.status == 2) {
      flag1 = true;
    }

    int i = par1Packet14BlockDig.xPosition;
    int j = par1Packet14BlockDig.yPosition;
    int k = par1Packet14BlockDig.zPosition;

    if (flag1) {
      double d = playerEntity.posX - ((double) i + 0.5D);
      double d1 = (playerEntity.posY - ((double) j + 0.5D)) + 1.5D;
      double d3 = playerEntity.posZ - ((double) k + 0.5D);
      double d5 = d * d + d1 * d1 + d3 * d3;

      if (d5 > 36D) {
        return;
      }

      if (j >= mcServer.getBuildLimit()) {
        return;
      }
    }

    ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
    int l = MathHelper.abs_int(i - chunkcoordinates.posX);
    int i1 = MathHelper.abs_int(k - chunkcoordinates.posZ);

    if (l > i1) {
      i1 = l;
    }

    if (par1Packet14BlockDig.status == 0) {
      if (i1 > 16 || flag) {
        playerEntity.theItemInWorldManager.onBlockClicked(i, j, k, par1Packet14BlockDig.face);
      } else {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    } else if (par1Packet14BlockDig.status == 2) {
      playerEntity.theItemInWorldManager.uncheckedTryHarvestBlock(i, j, k);

      if (worldserver.getBlockId(i, j, k) != 0) {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    } else if (par1Packet14BlockDig.status == 1) {
      playerEntity.theItemInWorldManager.destroyBlockInWorldPartially(i, j, k);

      if (worldserver.getBlockId(i, j, k) != 0) {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    } else if (par1Packet14BlockDig.status == 3) {
      double d2 = playerEntity.posX - ((double) i + 0.5D);
      double d4 = playerEntity.posY - ((double) j + 0.5D);
      double d6 = playerEntity.posZ - ((double) k + 0.5D);
      double d7 = d2 * d2 + d4 * d4 + d6 * d6;

      if (d7 < 256D) {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    }

    worldserver.actionsAllowed = false;
  }
  public void handleFlying(Packet10Flying par1Packet10Flying) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);
    field_72584_h = true;

    if (playerEntity.playerHasConqueredTheEnd) {
      return;
    }

    if (!field_72587_r) {
      double d = par1Packet10Flying.yPosition - lastPosY;

      if (par1Packet10Flying.xPosition == lastPosX
          && d * d < 0.01D
          && par1Packet10Flying.zPosition == lastPosZ) {
        field_72587_r = true;
      }
    }

    if (field_72587_r) {
      if (playerEntity.ridingEntity != null) {
        float f = playerEntity.rotationYaw;
        float f1 = playerEntity.rotationPitch;
        playerEntity.ridingEntity.updateRiderPosition();
        double d2 = playerEntity.posX;
        double d4 = playerEntity.posY;
        double d6 = playerEntity.posZ;
        double d8 = 0.0D;
        double d9 = 0.0D;

        if (par1Packet10Flying.rotating) {
          f = par1Packet10Flying.yaw;
          f1 = par1Packet10Flying.pitch;
        }

        if (par1Packet10Flying.moving
            && par1Packet10Flying.yPosition == -999D
            && par1Packet10Flying.stance == -999D) {
          if (par1Packet10Flying.xPosition > 1.0D || par1Packet10Flying.zPosition > 1.0D) {
            System.err.println(
                (new StringBuilder())
                    .append(playerEntity.username)
                    .append(" was caught trying to crash the server with an invalid position.")
                    .toString());
            kickPlayerFromServer("Nope!");
            return;
          }

          d8 = par1Packet10Flying.xPosition;
          d9 = par1Packet10Flying.zPosition;
        }

        playerEntity.onGround = par1Packet10Flying.onGround;
        playerEntity.onUpdateEntity();
        playerEntity.moveEntity(d8, 0.0D, d9);
        playerEntity.setPositionAndRotation(d2, d4, d6, f, f1);
        playerEntity.motionX = d8;
        playerEntity.motionZ = d9;

        if (playerEntity.ridingEntity != null) {
          worldserver.uncheckedUpdateEntity(playerEntity.ridingEntity, true);
        }

        if (playerEntity.ridingEntity != null) {
          playerEntity.ridingEntity.updateRiderPosition();
        }

        mcServer.getConfigurationManager().func_72358_d(playerEntity);
        lastPosX = playerEntity.posX;
        lastPosY = playerEntity.posY;
        lastPosZ = playerEntity.posZ;
        worldserver.updateEntity(playerEntity);
        return;
      }

      if (playerEntity.isPlayerSleeping()) {
        playerEntity.onUpdateEntity();
        playerEntity.setPositionAndRotation(
            lastPosX, lastPosY, lastPosZ, playerEntity.rotationYaw, playerEntity.rotationPitch);
        worldserver.updateEntity(playerEntity);
        return;
      }

      double d1 = playerEntity.posY;
      lastPosX = playerEntity.posX;
      lastPosY = playerEntity.posY;
      lastPosZ = playerEntity.posZ;
      double d3 = playerEntity.posX;
      double d5 = playerEntity.posY;
      double d7 = playerEntity.posZ;
      float f2 = playerEntity.rotationYaw;
      float f3 = playerEntity.rotationPitch;

      if (par1Packet10Flying.moving
          && par1Packet10Flying.yPosition == -999D
          && par1Packet10Flying.stance == -999D) {
        par1Packet10Flying.moving = false;
      }

      if (par1Packet10Flying.moving) {
        d3 = par1Packet10Flying.xPosition;
        d5 = par1Packet10Flying.yPosition;
        d7 = par1Packet10Flying.zPosition;
        double d10 = par1Packet10Flying.stance - par1Packet10Flying.yPosition;

        if (!playerEntity.isPlayerSleeping()
            && (d10 > 1.6499999999999999D || d10 < 0.10000000000000001D)) {
          kickPlayerFromServer("Illegal stance");
          logger.warning(
              (new StringBuilder())
                  .append(playerEntity.username)
                  .append(" had an illegal stance: ")
                  .append(d10)
                  .toString());
          return;
        }

        if (Math.abs(par1Packet10Flying.xPosition) > 32000000D
            || Math.abs(par1Packet10Flying.zPosition) > 32000000D) {
          kickPlayerFromServer("Illegal position");
          return;
        }
      }

      if (par1Packet10Flying.rotating) {
        f2 = par1Packet10Flying.yaw;
        f3 = par1Packet10Flying.pitch;
      }

      playerEntity.onUpdateEntity();
      playerEntity.ySize = 0.0F;
      playerEntity.setPositionAndRotation(lastPosX, lastPosY, lastPosZ, f2, f3);

      if (!field_72587_r) {
        return;
      }

      double d11 = d3 - playerEntity.posX;
      double d12 = d5 - playerEntity.posY;
      double d13 = d7 - playerEntity.posZ;
      double d14 = Math.min(Math.abs(d11), Math.abs(playerEntity.motionX));
      double d15 = Math.min(Math.abs(d12), Math.abs(playerEntity.motionY));
      double d16 = Math.min(Math.abs(d13), Math.abs(playerEntity.motionZ));
      double d17 = d14 * d14 + d15 * d15 + d16 * d16;

      if (d17 > 100D
          && (!mcServer.isSinglePlayer()
              || !mcServer.getServerOwner().equals(playerEntity.username))) {
        logger.warning(
            (new StringBuilder())
                .append(playerEntity.username)
                .append(" moved too quickly! ")
                .append(d11)
                .append(",")
                .append(d12)
                .append(",")
                .append(d13)
                .append(" (")
                .append(d14)
                .append(", ")
                .append(d15)
                .append(", ")
                .append(d16)
                .append(")")
                .toString());
        setPlayerLocation(
            lastPosX, lastPosY, lastPosZ, playerEntity.rotationYaw, playerEntity.rotationPitch);
        return;
      }

      float f4 = 0.0625F;
      boolean flag =
          worldserver
              .getCollidingBoundingBoxes(
                  playerEntity, playerEntity.boundingBox.copy().contract(f4, f4, f4))
              .isEmpty();

      if (playerEntity.onGround && !par1Packet10Flying.onGround && d12 > 0.0D) {
        playerEntity.addExhaustion(0.2F);
      }

      playerEntity.moveEntity(d11, d12, d13);
      playerEntity.onGround = par1Packet10Flying.onGround;
      playerEntity.addMovementStat(d11, d12, d13);
      double d18 = d12;
      d11 = d3 - playerEntity.posX;
      d12 = d5 - playerEntity.posY;

      if (d12 > -0.5D || d12 < 0.5D) {
        d12 = 0.0D;
      }

      d13 = d7 - playerEntity.posZ;
      d17 = d11 * d11 + d12 * d12 + d13 * d13;
      boolean flag1 = false;

      if (d17 > 0.0625D
          && !playerEntity.isPlayerSleeping()
          && !playerEntity.theItemInWorldManager.isCreative()) {
        flag1 = true;
        logger.warning(
            (new StringBuilder())
                .append(playerEntity.username)
                .append(" moved wrongly!")
                .toString());
      }

      playerEntity.setPositionAndRotation(d3, d5, d7, f2, f3);
      boolean flag2 =
          worldserver
              .getCollidingBoundingBoxes(
                  playerEntity, playerEntity.boundingBox.copy().contract(f4, f4, f4))
              .isEmpty();

      if (flag && (flag1 || !flag2) && !playerEntity.isPlayerSleeping()) {
        setPlayerLocation(lastPosX, lastPosY, lastPosZ, f2, f3);
        return;
      }

      AxisAlignedBB axisalignedbb =
          playerEntity
              .boundingBox
              .copy()
              .expand(f4, f4, f4)
              .addCoord(0.0D, -0.55000000000000004D, 0.0D);

      if (!mcServer.isFlightAllowed()
          && !playerEntity.theItemInWorldManager.isCreative()
          && !worldserver.isAABBNonEmpty(axisalignedbb)) {
        if (d18 >= -0.03125D) {
          ticksForFloatKick++;

          if (ticksForFloatKick > 80) {
            logger.warning(
                (new StringBuilder())
                    .append(playerEntity.username)
                    .append(" was kicked for floating too long!")
                    .toString());
            kickPlayerFromServer("Flying is not enabled on this server");
            return;
          }
        }
      } else {
        ticksForFloatKick = 0;
      }

      playerEntity.onGround = par1Packet10Flying.onGround;
      mcServer.getConfigurationManager().func_72358_d(playerEntity);
      playerEntity.updateFlyingState(playerEntity.posY - d1, par1Packet10Flying.onGround);
    }
  }
Esempio n. 24
0
  /**
   * adds all chunks within the spawn radius of the players to eligibleChunksForSpawning. pars: the
   * world, hostileCreatures, passiveCreatures. returns number of eligible chunks.
   */
  public int findChunksForSpawning(
      WorldServer par1WorldServer, boolean par2, boolean par3, boolean par4) {
    if (!par2 && !par3) {
      return 0;
    } else {
      eligibleChunksForSpawning.clear();
      int var3;
      int var6;

      for (var3 = 0; var3 < par1WorldServer.playerEntities.size(); ++var3) {
        EntityPlayer var4 = (EntityPlayer) par1WorldServer.playerEntities.get(var3);
        int var5 = MathHelper.floor_double(var4.posX / 16.0D);
        var6 = MathHelper.floor_double(var4.posZ / 16.0D);
        byte var7 = 8;

        for (int var8 = -var7; var8 <= var7; ++var8) {
          for (int var9 = -var7; var9 <= var7; ++var9) {
            boolean var10 = var8 == -var7 || var8 == var7 || var9 == -var7 || var9 == var7;
            ChunkCoordIntPair var11 = new ChunkCoordIntPair(var8 + var5, var9 + var6);

            if (!var10) {
              eligibleChunksForSpawning.put(var11, Boolean.valueOf(false));
            } else if (!eligibleChunksForSpawning.containsKey(var11)) {
              eligibleChunksForSpawning.put(var11, Boolean.valueOf(true));
            }
          }
        }
      }

      var3 = 0;
      ChunkCoordinates var31 = par1WorldServer.getSpawnPoint();
      EnumCreatureType[] var32 = EnumCreatureType.values();
      var6 = var32.length;

      for (int var33 = 0; var33 < var6; ++var33) {
        EnumCreatureType var34 = var32[var33];

        if ((!var34.getPeacefulCreature() || par3)
            && (var34.getPeacefulCreature() || par2)
            && par1WorldServer.countEntities(var34.getCreatureClass())
                <= var34.getMaxNumberOfCreature() * eligibleChunksForSpawning.size() / 256) {
          Iterator var35 = eligibleChunksForSpawning.keySet().iterator();
          label108:
          while (var35.hasNext()) {
            ChunkCoordIntPair var37 = (ChunkCoordIntPair) var35.next();

            if (!((Boolean) eligibleChunksForSpawning.get(var37)).booleanValue()) {
              ChunkPosition var36 =
                  getRandomSpawningPointInChunk(par1WorldServer, var37.chunkXPos, var37.chunkZPos);
              int var12 = var36.x;
              int var13 = var36.y;
              int var14 = var36.z;

              if (!par1WorldServer.isBlockNormalCube(var12, var13, var14)
                  && par1WorldServer.getBlockMaterial(var12, var13, var14)
                      == var34.getCreatureMaterial()) {
                int var15 = 0;
                int var16 = 0;

                while (var16 < 3) {
                  int var17 = var12;
                  int var18 = var13;
                  int var19 = var14;
                  byte var20 = 6;
                  SpawnListEntry var21 = null;
                  EntityLivingData entitylivingdata = null;
                  int var22 = 0;

                  while (true) {
                    if (var22 < 4) {
                      label101:
                      {
                        var17 +=
                            par1WorldServer.rand.nextInt(var20)
                                - par1WorldServer.rand.nextInt(var20);
                        var18 += par1WorldServer.rand.nextInt(1) - par1WorldServer.rand.nextInt(1);
                        var19 +=
                            par1WorldServer.rand.nextInt(var20)
                                - par1WorldServer.rand.nextInt(var20);

                        if (canCreatureTypeSpawnAtLocation(
                            var34, par1WorldServer, var17, var18, var19)) {
                          float var23 = (float) var17 + 0.5F;
                          float var24 = (float) var18;
                          float var25 = (float) var19 + 0.5F;

                          if (par1WorldServer.getClosestPlayer(
                                  (double) var23, (double) var24, (double) var25, 24.0D)
                              == null) {
                            float var26 = var23 - (float) var31.posX;
                            float var27 = var24 - (float) var31.posY;
                            float var28 = var25 - (float) var31.posZ;
                            float var29 = var26 * var26 + var27 * var27 + var28 * var28;

                            if (var29 >= 576.0F) {
                              if (var21 == null) {
                                var21 =
                                    spawnRandomCreature(
                                        par1WorldServer, var34, var17, var18, var19);

                                if (var21 == null) {
                                  break label101;
                                }
                              }

                              EntityLiving var38;

                              try {
                                var38 =
                                    (EntityLiving)
                                        var21
                                            .entityClass
                                            .getConstructor(new Class[] {World.class})
                                            .newInstance(new Object[] {par1WorldServer});
                              } catch (Exception var30) {
                                var30.printStackTrace();
                                return var3;
                              }

                              var38.setLocationAndAngles(
                                  (double) var23,
                                  (double) var24,
                                  (double) var25,
                                  par1WorldServer.rand.nextFloat() * 360.0F,
                                  0.0F);

                              if (var38.getCanSpawnHere()) {
                                ++var15;
                                par1WorldServer.spawnEntityInWorld(var38);
                                entitylivingdata = var38.onSpawnWithEgg(entitylivingdata);

                                if (var15 >= var38.getMaxSpawnedInChunk()) {
                                  continue label108;
                                }
                              }

                              var3 += var15;
                            }
                          }
                        }

                        ++var22;
                        continue;
                      }
                    }

                    ++var16;
                    break;
                  }
                }
              }
            }
          }
        }
      }

      return var3;
    }
  }
  public void onUpdateEntity(boolean flag) {
    super.onUpdate();
    for (int i = 0; i < inventory.getSizeInventory(); i++) {
      ItemStack itemstack = inventory.getStackInSlot(i);
      if (itemstack == null
          || !Item.itemsList[itemstack.itemID].func_28019_b()
          || playerNetServerHandler.getNumChunkDataPackets() > 2) {
        continue;
      }
      Packet packet =
          ((ItemMapBase) Item.itemsList[itemstack.itemID])
              .getUpdatePacket(itemstack, worldObj, this);
      if (packet != null) {
        playerNetServerHandler.sendPacket(packet);
      }
    }

    if (flag && !loadedChunks.isEmpty()) {
      ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) loadedChunks.get(0);
      if (chunkcoordintpair != null) {
        boolean flag1 = false;
        if (playerNetServerHandler.getNumChunkDataPackets() < 4) {
          flag1 = true;
        }
        if (flag1) {
          WorldServer worldserver = mcServer.getWorldManager(dimension);
          loadedChunks.remove(chunkcoordintpair);
          playerNetServerHandler.sendPacket(
              new Packet51MapChunk(
                  chunkcoordintpair.chunkXPos * 16,
                  0,
                  chunkcoordintpair.chunkZPos * 16,
                  16,
                  worldserver.worldYMax,
                  16,
                  worldserver));
          List list =
              worldserver.getTileEntityList(
                  chunkcoordintpair.chunkXPos * 16,
                  0,
                  chunkcoordintpair.chunkZPos * 16,
                  chunkcoordintpair.chunkXPos * 16 + 16,
                  worldserver.worldYMax,
                  chunkcoordintpair.chunkZPos * 16 + 16);
          for (int j = 0; j < list.size(); j++) {
            getTileEntityInfo((TileEntity) list.get(j));
          }
        }
      }
    }
    if (inPortal) {
      if (mcServer.propertyManagerObj.getBooleanProperty("allow-nether", true)) {
        if (currentCraftingInventory != personalCraftingInventory) {
          usePersonalCraftingInventory();
        }
        if (ridingEntity != null) {
          mountEntity(ridingEntity);
        } else {
          timeInPortal += 0.0125F;
          if (timeInPortal >= 1.0F) {
            timeInPortal = 1.0F;
            timeUntilPortal = 10;
            byte byte0 = 0;
            if (dimension == -1) {
              byte0 = 0;
            } else {
              byte0 = -1;
            }
            mcServer.configManager.sendPlayerToOtherDimension(this, byte0);
            field_35220_ce = -1;
            lastHealth = -1;
            field_35221_cc = -1;
            triggerAchievement(AchievementList.portal);
          }
        }
        inPortal = false;
      }
    } else {
      if (timeInPortal > 0.0F) {
        timeInPortal -= 0.05F;
      }
      if (timeInPortal < 0.0F) {
        timeInPortal = 0.0F;
      }
    }
    if (timeUntilPortal > 0) {
      timeUntilPortal--;
    }
    if (getEntityHealth() != lastHealth
        || field_35221_cc != foodStats.getFoodLevel()
        || (foodStats.getSaturationLevel() == 0.0F) != field_35222_cd) {
      playerNetServerHandler.sendPacket(
          new Packet8UpdateHealth(
              getEntityHealth(), foodStats.getFoodLevel(), foodStats.getSaturationLevel()));
      lastHealth = getEntityHealth();
      field_35221_cc = foodStats.getFoodLevel();
      field_35222_cd = foodStats.getSaturationLevel() == 0.0F;
    }
    if (experienceTotal != field_35220_ce) {
      field_35220_ce = experienceTotal;
      playerNetServerHandler.sendPacket(
          new Packet43Experience(experience, experienceTotal, experienceLevel));
    }
  }
 public void func_72354_b(EntityPlayerMP p_72354_1_, WorldServer p_72354_2_) {
   p_72354_1_.field_71135_a.func_72567_b(new Packet4UpdateTime(p_72354_2_.func_72820_D()));
   if (p_72354_2_.func_72896_J()) {
     p_72354_1_.field_71135_a.func_72567_b(new Packet70GameEvent(1, 0));
   }
 }
Esempio n. 27
0
 public void handlePlace(Packet15Place packet15place) {
   WorldServer worldserver = mcServer.getWorldManager(playerEntity.dimension);
   ItemStack itemstack = playerEntity.inventory.getCurrentItem();
   boolean flag =
       worldserver.field_819_z =
           worldserver.worldProvider.worldType != 0
               || mcServer.configManager.isOp(playerEntity.username);
   if (packet15place.direction == 255) {
     if (itemstack == null) {
       return;
     }
     playerEntity.itemInWorldManager.func_6154_a(playerEntity, worldserver, itemstack);
   } else {
     int i = packet15place.xPosition;
     int j = packet15place.yPosition;
     int k = packet15place.zPosition;
     int l = packet15place.direction;
     ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
     int i1 = (int) MathHelper.abs(i - chunkcoordinates.posX);
     int j1 = (int) MathHelper.abs(k - chunkcoordinates.posZ);
     if (i1 > j1) {
       j1 = i1;
     }
     if (hasMoved
         && playerEntity.getDistanceSq((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D)
             < 64D
         && (j1 > 16 || flag)) {
       playerEntity.itemInWorldManager.activeBlockOrUseItem(
           playerEntity, worldserver, itemstack, i, j, k, l);
     }
     playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
     if (l == 0) {
       j--;
     }
     if (l == 1) {
       j++;
     }
     if (l == 2) {
       k--;
     }
     if (l == 3) {
       k++;
     }
     if (l == 4) {
       i--;
     }
     if (l == 5) {
       i++;
     }
     playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
   }
   itemstack = playerEntity.inventory.getCurrentItem();
   if (itemstack != null && itemstack.stackSize == 0) {
     playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null;
   }
   playerEntity.isChangingQuantityOnly = true;
   playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] =
       ItemStack.func_20117_a(
           playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem]);
   Slot slot =
       playerEntity.currentCraftingInventory.func_20127_a(
           playerEntity.inventory, playerEntity.inventory.currentItem);
   playerEntity.currentCraftingInventory.updateCraftingMatrix();
   playerEntity.isChangingQuantityOnly = false;
   if (!ItemStack.areItemStacksEqual(
       playerEntity.inventory.getCurrentItem(), packet15place.itemStack)) {
     sendPacket(
         new Packet103SetSlot(
             playerEntity.currentCraftingInventory.windowId,
             slot.id,
             playerEntity.inventory.getCurrentItem()));
   }
   worldserver.field_819_z = false;
 }