Esempio n. 1
0
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length < 1) {
      throw new WrongUsageException("commands.tp.usage", new Object[0]);
    } else {
      EntityPlayerMP var3;

      if (par2ArrayOfStr.length != 2 && par2ArrayOfStr.length != 4) {
        var3 = getCommandSenderAsPlayer(par1ICommandSender);
      } else {
        var3 = func_82359_c(par1ICommandSender, par2ArrayOfStr[0]);

        if (var3 == null) {
          throw new PlayerNotFoundException();
        }
      }

      if (par2ArrayOfStr.length != 3 && par2ArrayOfStr.length != 4) {
        if (par2ArrayOfStr.length == 1 || par2ArrayOfStr.length == 2) {
          EntityPlayerMP var11 =
              func_82359_c(par1ICommandSender, par2ArrayOfStr[par2ArrayOfStr.length - 1]);

          if (var11 == null) {
            throw new PlayerNotFoundException();
          }

          if (var11.worldObj != var3.worldObj) {
            notifyAdmins(par1ICommandSender, "commands.tp.notSameDimension", new Object[0]);
            return;
          }

          var3.mountEntity((Entity) null);
          var3.playerNetServerHandler.setPlayerLocation(
              var11.posX, var11.posY, var11.posZ, var11.rotationYaw, var11.rotationPitch);
          notifyAdmins(
              par1ICommandSender,
              "commands.tp.success",
              new Object[] {var3.getEntityName(), var11.getEntityName()});
        }
      } else if (var3.worldObj != null) {
        int var4 = par2ArrayOfStr.length - 3;
        double var5 = this.func_82368_a(par1ICommandSender, var3.posX, par2ArrayOfStr[var4++]);
        double var7 =
            this.func_82367_a(par1ICommandSender, var3.posY, par2ArrayOfStr[var4++], 0, 0);
        double var9 = this.func_82368_a(par1ICommandSender, var3.posZ, par2ArrayOfStr[var4++]);
        var3.mountEntity((Entity) null);
        var3.setPositionAndUpdate(var5, var7, var9);
        notifyAdmins(
            par1ICommandSender,
            "commands.tp.success.coordinates",
            new Object[] {
              var3.getEntityName(), Double.valueOf(var5), Double.valueOf(var7), Double.valueOf(var9)
            });
      }
    }
  }
 public void func_30002_A() {
   if (ridingEntity != null) {
     mountEntity(ridingEntity);
   }
   if (riddenByEntity != null) {
     riddenByEntity.mountEntity(this);
   }
   if (sleeping) {
     wakeUpPlayer(true, false, false);
   }
 }
  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));
    }
  }