Beispiel #1
0
  protected void b(ICommandListener icommandlistener, int i) {
    for (int j = 0; j < MinecraftServer.getServer().worldServer.length; ++j) {
      WorldServer worldserver = MinecraftServer.getServer().worldServer[j];

      worldserver.setDayTime(worldserver.getDayTime() + (long) i);
    }
  }
Beispiel #2
0
  public EntityPlayerMP(
      MinecraftServer par1MinecraftServer,
      World par2World,
      String par3Str,
      ItemInWorldManager par4ItemInWorldManager) {
    super(par2World, par3Str);
    par4ItemInWorldManager.thisPlayerMP = this;
    this.theItemInWorldManager = par4ItemInWorldManager;
    this.renderDistance = par1MinecraftServer.getConfigurationManager().getViewDistance();
    ChunkCoordinates var5 = par2World.getSpawnPoint();
    int var6 = var5.posX;
    int var7 = var5.posZ;
    int var8 = var5.posY;

    if (!par2World.provider.hasNoSky
        && par2World.getWorldInfo().getGameType() != EnumGameType.ADVENTURE) {
      int var9 = Math.max(5, par1MinecraftServer.getSpawnProtectionSize() - 6);
      var6 += this.rand.nextInt(var9 * 2) - var9;
      var7 += this.rand.nextInt(var9 * 2) - var9;
      var8 = par2World.getTopSolidOrLiquidBlock(var6, var7);
    }

    this.mcServer = par1MinecraftServer;
    this.stepHeight = 0.0F;
    this.yOffset = 0.0F;
    this.setLocationAndAngles(
        (double) var6 + 0.5D, (double) var8, (double) var7 + 0.5D, 0.0F, 0.0F);

    while (!par2World.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()) {
      this.setPosition(this.posX, this.posY + 1.0D, this.posZ);
    }
  }
Beispiel #3
0
 @ServerStarting
 public void serverStarting(FMLServerStartingEvent event) {
   MinecraftServer server = ModLoader.getMinecraftServerInstance();
   ICommandManager commandManager = server.getCommandManager();
   ServerCommandManager serverCommandManager = (ServerCommandManager) commandManager;
   serverCommandManager.registerCommand(new CommanduPerm());
 }
  public static void setWorld(int id, WorldServer world) {
    if (world != null) {
      worlds.put(id, world);
      weakWorldMap.put(world, world);
      MinecraftServer.getServer().worldTickTimes.put(id, new long[100]);
      FMLLog.info(
          "Loading dimension %d (%s) (%s)",
          id, world.getWorldInfo().getWorldName(), world.getMinecraftServer());
    } else {
      worlds.remove(id);
      MinecraftServer.getServer().worldTickTimes.remove(id);
      FMLLog.info("Unloading dimension %d", id);
    }

    ArrayList<WorldServer> tmp = new ArrayList<WorldServer>();
    if (worlds.get(0) != null) tmp.add(worlds.get(0));
    if (worlds.get(-1) != null) tmp.add(worlds.get(-1));
    if (worlds.get(1) != null) tmp.add(worlds.get(1));

    for (Entry<Integer, WorldServer> entry : worlds.entrySet()) {
      int dim = entry.getKey();
      if (dim >= -1 && dim <= 1) {
        continue;
      }
      tmp.add(entry.getValue());
    }

    MinecraftServer.getServer().worldServers = tmp.toArray(new WorldServer[tmp.size()]);
  }
  public static EntityPlayerMP getPlayerBaseServerFromPlayerUsername(
      String username, boolean ignoreCase) {
    MinecraftServer server = MinecraftServer.getServer();

    if (server != null) {
      if (ignoreCase) {
        return getPlayerForUsernameVanilla(server, username);
      } else {
        Iterator iterator = server.getConfigurationManager().playerEntityList.iterator();
        EntityPlayerMP entityplayermp;

        do {
          if (!iterator.hasNext()) {
            return null;
          }

          entityplayermp = (EntityPlayerMP) iterator.next();
        } while (!entityplayermp.getName().equalsIgnoreCase(username));

        return entityplayermp;
      }
    }

    GCLog.severe("Warning: Could not find player base server instance for player " + username);

    return null;
  }
Beispiel #6
0
  protected void func_147210_a(ICommandSender p_147210_1_, String p_147210_2_, String p_147210_3_) {
    BanEntry var4 = new BanEntry(p_147210_2_);
    var4.setBannedBy(p_147210_1_.getCommandSenderName());

    if (p_147210_3_ != null) {
      var4.setBanReason(p_147210_3_);
    }

    MinecraftServer.getServer().getConfigurationManager().getBannedIPs().put(var4);
    List var5 = MinecraftServer.getServer().getConfigurationManager().getPlayerList(p_147210_2_);
    String[] var6 = new String[var5.size()];
    int var7 = 0;
    EntityPlayerMP var9;

    for (Iterator var8 = var5.iterator();
        var8.hasNext();
        var6[var7++] = var9.getCommandSenderName()) {
      var9 = (EntityPlayerMP) var8.next();
      var9.playerNetServerHandler.kickPlayerFromServer("You have been IP banned.");
    }

    if (var5.isEmpty()) {
      notifyAdmins(p_147210_1_, "commands.banip.success", new Object[] {p_147210_2_});
    } else {
      notifyAdmins(
          p_147210_1_,
          "commands.banip.success.players",
          new Object[] {p_147210_2_, joinNiceString(var6)});
    }
  }
  /** Actually does the banning work. */
  protected void banIP(ICommandSender par1ICommandSender, String par2Str, String par3Str) {
    BanEntry banentry = new BanEntry(par2Str);
    banentry.setBannedBy(par1ICommandSender.getCommandSenderName());

    if (par3Str != null) {
      banentry.setBanReason(par3Str);
    }

    MinecraftServer.getServer().getConfigurationManager().getBannedIPs().put(banentry);
    List list = MinecraftServer.getServer().getConfigurationManager().getPlayerList(par2Str);
    String[] astring = new String[list.size()];
    int i = 0;
    EntityPlayerMP entityplayermp;

    for (Iterator iterator = list.iterator();
        iterator.hasNext();
        astring[i++] = entityplayermp.getEntityName()) {
      entityplayermp = (EntityPlayerMP) iterator.next();
      entityplayermp.playerNetServerHandler.kickPlayerFromServer("You have been IP banned.");
    }

    if (list.isEmpty()) {
      notifyAdmins(par1ICommandSender, "commands.banip.success", new Object[] {par2Str});
    } else {
      notifyAdmins(
          par1ICommandSender,
          "commands.banip.success.players",
          new Object[] {par2Str, joinNiceString(astring)});
    }
  }
Beispiel #8
0
  private void setOwner(final GameProfile owner) {
    this.owner = owner;

    this.markDirty();

    if (this.owner == null) {
      return;
    }

    final MinecraftServer server = MinecraftServer.getServer();

    if (server == null) {
      return;
    }

    if (!this.owner.isComplete() || this.owner.getProperties().get("textures").isEmpty()) {
      final GameProfile cachedOwner =
          server.getPlayerProfileCache().getGameProfileForUsername(this.owner.getName());

      if (cachedOwner != null) {
        this.owner = cachedOwner;

        if (this.owner.getProperties().get("textures").isEmpty()) {
          this.owner = server.getMinecraftSessionService().fillProfileProperties(this.owner, true);
        }
      }
    }
  }
  @Override
  public void processCommand(ICommandSender sender, String[] params) {
    MinecraftServer server = MinecraftServer.getServer();
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);
    WorldServer world =
        server.worldServerForDimension(player.getEntityWorld().provider.dimensionId);

    if (!TFCOptions.enableDebugMode) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Debug Mode Required"));
      return;
    }

    if (params.length == 0) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk"));
      Chunk chunk = world.getChunkFromBlockCoords((int) player.posX, (int) player.posZ);
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = 0; y < 256; y++) {
            Block id = chunk.getBlock(x, y, z);
            if (id != TFCBlocks.Ore
                && id != TFCBlocks.Ore2
                && id != TFCBlocks.Ore3
                && id != Blocks.bedrock)
              world.setBlock(
                  x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    } else if (params.length == 1) {
      TFC_Core.sendInfoMessage(
          player,
          new ChatComponentText(
              "Stripping Chunks Within a Radius of " + Integer.parseInt(params[0])));
      int radius = Integer.parseInt(params[0]);
      for (int i = -radius; i <= radius; i++) {
        for (int k = -radius; k <= radius; k++) {
          Chunk chunk =
              world.getChunkFromBlockCoords(
                  (int) player.posX + (i * 16), (int) player.posZ + (k * 16));
          for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
              for (int y = 0; y < 256; y++) {
                Block id = chunk.getBlock(x, y, z);
                if (id != TFCBlocks.Ore
                    && id != TFCBlocks.Ore2
                    && id != TFCBlocks.Ore3
                    && id != Blocks.bedrock)
                  world.setBlock(
                      x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    }
  }
  private void removeDuplicateCommands(MinecraftServer server) {
    if (server.getCommandManager() instanceof CommandHandler) {
      try {
        Set<String> commandNames = new HashSet<String>();
        Set<String> toRemoveNames = new HashSet<String>();
        CommandHandler cmdMng = (CommandHandler) server.getCommandManager();

        for (Object cmdObj : cmdMng.commandSet) {
          ICommand cmd = (ICommand) cmdObj;
          if (!commandNames.add(cmd.getCommandName())) {
            OutputHandler.debug("Duplicate command found! Name:" + cmd.getCommandName());
            toRemoveNames.add(cmd.getCommandName());
          }
        }
        Set toRemove = new HashSet();
        for (Object cmdObj : cmdMng.commandSet) {
          ICommand cmd = (ICommand) cmdObj;
          if (toRemoveNames.contains(cmd.getCommandName())) {
            Class<?> cmdClass = cmd.getClass();
            if (!cmdClass.getPackage().getName().contains("ForgeEssentials")) {
              OutputHandler.debug(
                  "Removing command '"
                      + cmd.getCommandName()
                      + "' from class: "
                      + cmdClass.getName());
              toRemove.add(cmd.getCommandName());
            }
          }
        }
        cmdMng.commandSet.removeAll(toRemove);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
 @EventHandler
 public void onServerStart(FMLServerStartingEvent evt) {
   MinecraftServer server = MinecraftServer.getServer();
   ICommandManager command = server.getCommandManager();
   ServerCommandManager manager = (ServerCommandManager) command;
   manager.registerCommand(new ServerCommandsVC());
 }
  private void handleChestPage(Packet250CustomPayload packet) {
    DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));

    try {
      int x = inputStream.readInt();
      int y = inputStream.readInt();
      int z = inputStream.readInt();
      int d = inputStream.readInt();

      MinecraftServer s = MinecraftServer.getServer();
      WorldServer w = s.worldServerForDimension(d);
      TileEntity te = w.getBlockTileEntity(x, y, z);
      if (te instanceof YC_TileEntityBlockChest) {
        int t = 0;
        t = inputStream.readInt();
        int l = inputStream.readInt();
        String PlayerName = "";
        for (int i = 0; i < l; i++) {
          PlayerName = PlayerName + ((char) inputStream.readInt());
        }
        ((YC_TileEntityBlockChest) te).handlePacketDataPage(t, PlayerName);
        PacketDispatcher.sendPacketToAllAround(x, y, z, 16, d, te.getDescriptionPacket());
      }
    } catch (IOException e) {
      e.printStackTrace();
      return;
    }
  }
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    MinecraftServer var3 = MinecraftServer.getServer();
    par1ICommandSender.sendChatToPlayer(
        par1ICommandSender.translateString("commands.save.start", new Object[0]));

    if (var3.getConfigurationManager() != null) {
      var3.getConfigurationManager().saveAllPlayerData();
    }

    try {
      for (int var4 = 0; var4 < var3.worldServers.length; ++var4) {
        if (var3.worldServers[var4] != null) {
          WorldServer var5 = var3.worldServers[var4];
          boolean var6 = var5.levelSaving;
          var5.levelSaving = false;
          var5.saveAllChunks(true, (IProgressUpdate) null);
          var5.levelSaving = var6;
        }
      }
    } catch (MinecraftException var7) {
      notifyAdmins(par1ICommandSender, "commands.save.failed", new Object[] {var7.getMessage()});
      return;
    }

    notifyAdmins(par1ICommandSender, "commands.save.success", new Object[0]);
  }
 @Override
 public IMessage onMessage(PacketRobesPowerNBT message, MessageContext ctx) {
   try {
     ItemStack stack =
         MinecraftServer.getServer()
             .worldServerForDimension(message.dim)
             .getPlayerEntityByName(message.player)
             .inventory
             .armorInventory[2];
     ((NBTTagCompound) stack.stackTagCompound.getTag("powers"))
         .setInteger(message.key, message.value);
     MinecraftServer.getServer()
             .worldServerForDimension(message.dim)
             .getPlayerEntityByName(message.player)
             .inventory
             .armorInventory[2] =
         stack;
   } catch (Exception e) {
     Lumberjack.warn(
         "Unable to add element "
             + message.key
             + " (amount "
             + String.valueOf(message.value)
             + ")");
   }
   return null;
 }
Beispiel #15
0
  protected void func_147210_a(ICommandSender p_147210_1_, String p_147210_2_, String p_147210_3_) {
    BanEntry var4 = new BanEntry(p_147210_2_);
    var4.func_73687_a(p_147210_1_.func_70005_c_());
    if (p_147210_3_ != null) {
      var4.func_73689_b(p_147210_3_);
    }

    MinecraftServer.func_71276_C().func_71203_ab().func_72363_f().func_73706_a(var4);
    List var5 = MinecraftServer.func_71276_C().func_71203_ab().func_72382_j(p_147210_2_);
    String[] var6 = new String[var5.size()];
    int var7 = 0;

    EntityPlayerMP var9;
    for (Iterator var8 = var5.iterator(); var8.hasNext(); var6[var7++] = var9.func_70005_c_()) {
      var9 = (EntityPlayerMP) var8.next();
      var9.field_71135_a.func_147360_c("You have been IP banned.");
    }

    if (var5.isEmpty()) {
      func_71522_a(p_147210_1_, "commands.banip.success", new Object[] {p_147210_2_});
    } else {
      func_71522_a(
          p_147210_1_,
          "commands.banip.success.players",
          new Object[] {p_147210_2_, func_71527_a(var6)});
    }
  }
 public boolean func_72353_e(String p_72353_1_) {
   return field_72414_i.contains(p_72353_1_.trim().toLowerCase())
       || field_72400_f.func_71264_H()
           && field_72400_f.field_71305_c[0].func_72912_H().func_76086_u()
           && field_72400_f.func_71214_G().equalsIgnoreCase(p_72353_1_)
       || field_72407_n;
 }
  public EntityPlayerMP func_72366_a(String p_72366_1_) {
    ArrayList arraylist = new ArrayList();
    Object obj = field_72404_b.iterator();
    do {
      if (!((Iterator) (obj)).hasNext()) {
        break;
      }
      EntityPlayerMP entityplayermp = (EntityPlayerMP) ((Iterator) (obj)).next();
      if (entityplayermp.field_71092_bJ.equalsIgnoreCase(p_72366_1_)) {
        arraylist.add(entityplayermp);
      }
    } while (true);
    EntityPlayerMP entityplayermp1;
    for (obj = arraylist.iterator();
        ((Iterator) (obj)).hasNext();
        entityplayermp1.field_71135_a.func_72565_c("You logged in from another location")) {
      entityplayermp1 = (EntityPlayerMP) ((Iterator) (obj)).next();
    }

    if (field_72400_f.func_71242_L()) {
      obj = new DemoWorldManager(field_72400_f.func_71218_a(0));
    } else {
      obj = new ItemInWorldManager(field_72400_f.func_71218_a(0));
    }
    return new EntityPlayerMP(
        field_72400_f, field_72400_f.func_71218_a(0), p_72366_1_, ((ItemInWorldManager) (obj)));
  }
  public static void initDimension(int dim) {
    WorldServer overworld = getWorld(0);
    if (overworld == null) {
      throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!");
    }
    try {
      DimensionManager.getProviderType(dim);
    } catch (Exception e) {
      System.err.println("Cannot Hotload Dim: " + e.getMessage());
      return; // If a provider hasn't been registered then we can't hotload the dim
    }
    MinecraftServer mcServer = overworld.getMinecraftServer();
    ISaveHandler savehandler = overworld.getSaveHandler();
    WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo());

    WorldServer world =
        (dim == 0
            ? overworld
            : new WorldServerMulti(
                mcServer,
                savehandler,
                overworld.getWorldInfo().getWorldName(),
                dim,
                worldSettings,
                overworld,
                mcServer.theProfiler));
    world.addWorldAccess(new WorldManager(mcServer, world));
    MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
    if (!mcServer.isSinglePlayer()) {
      world.getWorldInfo().setGameType(mcServer.getGameType());
    }

    mcServer.func_147139_a(mcServer.func_147135_j());
  }
  protected void func_147210_a(ICommandSender p_147210_1_, String p_147210_2_, String p_147210_3_) {
    IPBanEntry ipbanentry =
        new IPBanEntry(p_147210_2_, (Date) null, p_147210_1_.getName(), (Date) null, p_147210_3_);
    MinecraftServer.getServer().getConfigurationManager().getBannedIPs().addEntry(ipbanentry);
    List list =
        MinecraftServer.getServer()
            .getConfigurationManager()
            .getPlayersMatchingAddress(p_147210_2_);
    String[] astring = new String[list.size()];
    int i = 0;
    EntityPlayerMP entityplayermp;

    for (Iterator iterator = list.iterator();
        iterator.hasNext();
        astring[i++] = entityplayermp.getName()) {
      entityplayermp = (EntityPlayerMP) iterator.next();
      entityplayermp.playerNetServerHandler.kickPlayerFromServer("You have been IP banned.");
    }

    if (list.isEmpty()) {
      notifyOperators(p_147210_1_, this, "commands.banip.success", new Object[] {p_147210_2_});
    } else {
      notifyOperators(
          p_147210_1_,
          this,
          "commands.banip.success.players",
          new Object[] {p_147210_2_, joinNiceString(astring)});
    }
  }
Beispiel #20
0
  public void func_71515_b(ICommandSender par1ICommandSender, String par2ArrayOfStr[]) {
    if (par2ArrayOfStr.length == 1) {
      if (par2ArrayOfStr[0].equals("start")) {
        func_71522_a(par1ICommandSender, "commands.debug.start", new Object[0]);
        MinecraftServer.func_71276_C().func_71223_ag();
        field_71551_a = System.currentTimeMillis();
        field_71550_b = MinecraftServer.func_71276_C().func_71259_af();
        return;
      }

      if (par2ArrayOfStr[0].equals("stop")) {
        if (!MinecraftServer.func_71276_C().field_71304_b.profilingEnabled) {
          throw new CommandException("commands.debug.notStarted", new Object[0]);
        } else {
          long l = System.currentTimeMillis();
          int i = MinecraftServer.func_71276_C().func_71259_af();
          long l1 = l - field_71551_a;
          int j = i - field_71550_b;
          func_71548_a(l1, j);
          MinecraftServer.func_71276_C().field_71304_b.profilingEnabled = false;
          func_71522_a(
              par1ICommandSender,
              "commands.debug.stop",
              new Object[] {Float.valueOf((float) l1 / 1000F), Integer.valueOf(j)});
          return;
        }
      }
    }

    throw new WrongUsageException("commands.debug.usage", new Object[0]);
  }
  public EntityPlayer(
      MinecraftServer minecraftserver,
      World world,
      String s,
      PlayerInteractManager playerinteractmanager) {
    super(world);
    playerinteractmanager.player = this;
    this.playerInteractManager = playerinteractmanager;
    this.cq = minecraftserver.getPlayerList().o();
    ChunkCoordinates chunkcoordinates = world.getSpawn();
    int i = chunkcoordinates.x;
    int j = chunkcoordinates.z;
    int k = chunkcoordinates.y;

    if (!world.worldProvider.f && world.getWorldData().getGameType() != EnumGamemode.ADVENTURE) {
      int l = Math.max(5, minecraftserver.getSpawnProtection() - 6);

      i += this.random.nextInt(l * 2) - l;
      j += this.random.nextInt(l * 2) - l;
      k = world.i(i, j);
    }

    this.setPositionRotation((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F);
    this.server = minecraftserver;
    this.X = 0.0F;
    this.name = s;
    this.height = 0.0F;
    this.displayName = this.name; // CraftBukkit
    this.listName = this.name; // CraftBukkit
    this.canPickUpLoot = true; // CraftBukkit
  }
 public String func_96556_a() {
   return MinecraftServer.getServerConfigurationManager(this.mcServer).getCurrentPlayerCount()
       + " / "
       + MinecraftServer.getServerConfigurationManager(this.mcServer).getMaxPlayers()
       + "; "
       + MinecraftServer.getServerConfigurationManager(this.mcServer).playerEntityList;
 }
  /** 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 static void teleportPlayerOutOfMachineDimension(EntityPlayerMP player) {
    NBTTagCompound playerNBT = player.getEntityData();

    // Grab the CompactMachines entry from the player NBT data
    NBTTagCompound cmNBT = null;
    if (playerNBT.hasKey(Reference.MOD_ID)) {
      cmNBT = playerNBT.getCompoundTag(Reference.MOD_ID);
    }

    int targetDimension = 0;
    double targetX;
    double targetY;
    double targetZ;

    if (cmNBT != null && cmNBT.hasKey("oldPosX")) {
      // First try to grab the original position by looking at the CompactMachines NBT Tag
      targetDimension = cmNBT.getInteger("oldDimension");
      targetX = cmNBT.getDouble("oldPosX");
      targetY = cmNBT.getDouble("oldPosY");
      targetZ = cmNBT.getDouble("oldPosZ");
    } else if (playerNBT.hasKey("oldDimension")
        && playerNBT.getInteger("oldDimension") != ConfigurationHandler.dimensionId) {
      // Backwards compatibility - but these values are also being set by RandomThings
      // A problem exists in two cases:
      // a) A player entered the SpiritDimension from the CM dimension, RandomThings would set the
      // oldDimension to the CM dimension
      // b) A player entered the CM dimension from the SpectreDimension, CM did previously set the
      // oldDimension to the SpectreDimension
      // In both cases the player gets trapped in a loop between the two dimensions and has no way
      // of getting back to the overworld
      // We want to allow backwards compatibility with our old settings so players in a CM during an
      // update to a version containing this commit
      // would still be trapped in the two dimensions. We can break this cycle by not allowing to
      // get back to another CM using the
      // old system.
      // That's because CM never writes its own dimension into the oldDimension tag, only
      // RandomThings would do that.
      targetDimension = playerNBT.getInteger("oldDimension");
      targetX = playerNBT.getDouble("oldPosX");
      targetY = playerNBT.getDouble("oldPosY");
      targetZ = playerNBT.getDouble("oldPosZ");
    } else {
      ChunkCoordinates cc =
          MinecraftServer.getServer().worldServerForDimension(0).provider.getRandomizedSpawnPoint();
      targetX = cc.posX;
      targetY = cc.posY;
      targetZ = cc.posZ;
    }

    MinecraftServer.getServer()
        .getConfigurationManager()
        .transferPlayerToDimension(
            player,
            targetDimension,
            new TeleporterCM(MinecraftServer.getServer().worldServerForDimension(targetDimension)));
    player.setPositionAndUpdate(targetX, targetY, targetZ);
  }
  public static File getWorldDirectory(MinecraftServer server) {
    if (server.isDedicatedServer()) {
      return server.getFile("world");
    } else {
      File worldsDir = getAnvilFile(server);
      if (worldsDir == null) return null;

      return new File(worldsDir, server.getFolderName());
    }
  }
  public static void load(World world) {
    if (MinecraftServer.getServer() == server) return;

    System.out.println("Loading NEI");
    server = MinecraftServer.getServer();

    initDefaults();
    loadBannedBlocks();
    loadSavedConfig(world);
  }
 public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) {
   p_71515_1_.func_70006_a(
       p_71515_1_.func_70004_a(
           "commands.players.list",
           new Object[] {
             Integer.valueOf(MinecraftServer.func_71276_C().func_71233_x()),
             Integer.valueOf(MinecraftServer.func_71276_C().func_71275_y())
           }));
   p_71515_1_.func_70006_a(MinecraftServer.func_71276_C().func_71203_ab().func_72398_c());
 }
  public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) {
    if (p_71515_2_.length < 1) {
      throw new WrongUsageException("commands.tp.usage", new Object[0]);
    } else {
      MinecraftServer var3 = MinecraftServer.func_71276_C();
      EntityPlayerMP var4;
      if (p_71515_2_.length != 2 && p_71515_2_.length != 4) {
        var4 = (EntityPlayerMP) func_71521_c(p_71515_1_);
      } else {
        var4 = var3.func_71203_ab().func_72361_f(p_71515_2_[0]);
        if (var4 == null) {
          throw new PlayerNotFoundException();
        }
      }

      if (p_71515_2_.length != 3 && p_71515_2_.length != 4) {
        if (p_71515_2_.length == 1 || p_71515_2_.length == 2) {
          EntityPlayerMP var10 =
              var3.func_71203_ab().func_72361_f(p_71515_2_[p_71515_2_.length - 1]);
          if (var10 == null) {
            throw new PlayerNotFoundException();
          }

          var4.field_71135_a.func_72569_a(
              var10.field_70165_t,
              var10.field_70163_u,
              var10.field_70161_v,
              var10.field_70177_z,
              var10.field_70125_A);
          func_71522_a(
              p_71515_1_,
              "commands.tp.success",
              new Object[] {var4.func_70023_ak(), var10.func_70023_ak()});
        }
      } else if (var4.field_70170_p != null) {
        int var5 = p_71515_2_.length - 3;
        int var6 = 30000000;
        int var7 = func_71532_a(p_71515_1_, p_71515_2_[var5++], -var6, var6);
        int var8 = func_71532_a(p_71515_1_, p_71515_2_[var5++], 0, 256);
        int var9 = func_71532_a(p_71515_1_, p_71515_2_[var5++], -var6, var6);
        var4.func_70634_a(
            (double) ((float) var7 + 0.5F), (double) var8, (double) ((float) var9 + 0.5F));
        func_71522_a(
            p_71515_1_,
            "commands.tp.coordinates",
            new Object[] {
              var4.func_70023_ak(),
              Integer.valueOf(var7),
              Integer.valueOf(var8),
              Integer.valueOf(var9)
            });
      }
    }
  }
Beispiel #29
0
  public static void sendPacketToAllPlayers(Packet var0) {
    MinecraftServer var1 = FMLCommonHandler.instance().getMinecraftServerInstance();

    if (var1 != null) {
      var1.getServerConfigurationManager().sendAll(var0);
    } else {
      FMLLog.fine(
          "Attempt to send packet to all in dimension without a server instance available",
          new Object[0]);
    }
  }
Beispiel #30
0
 public void a(NBTTagCompound nbttagcompound) {
   super.a(nbttagcompound);
   if (nbttagcompound.b("playerGameType")) {
     // XXX Check this, it was only the last call to this.c.a
     if (MinecraftServer.D().am()) {
       this.c.a(MinecraftServer.D().g());
     } else {
       this.c.a(EnumGameType.a(nbttagcompound.e("playerGameType")));
     }
   }
 }