Package net.minecraft.world

Examples of net.minecraft.world.WorldServer


    }

    @SubscribeEvent
    public void tickEndEvent(TickEvent.WorldTickEvent e)
    {
        WorldServer world = (WorldServer) e.world;
        // it needs saving. save it.
        String name = world.provider.getDimensionName();
        int id = world.provider.dimensionId;
        if (worlds.contains(id))
        {
            isSaving = true;
            ModuleBackup.msg(String.format(start, name));
            boolean bl = world.levelSaving;
            world.levelSaving = false;
            try
            {
                world.saveAllChunks(true, (IProgressUpdate) null);
            }
            catch (MinecraftException e1)
            {
                OutputHandler.exception(Level.SEVERE, String.format(failed, name), e1);
                ModuleBackup.msg(String.format(failed, name));
View Full Code Here


        }
    }

    private void list(ICommandSender sender, int dim, String key)
    {
        WorldServer world = DimensionManager.getWorld(dim);

        HashMultimap<String, Ticket> modTickets = HashMultimap.create();
        HashMultimap<String, Ticket> playerTickets = HashMultimap.create();

        for (Ticket ticket : ForgeChunkManager.getPersistentChunksFor(world).values())
View Full Code Here

        }

    /*
         * Get the world
     */
        WorldServer world = null;
        if (FunctionHelper.isNumeric(args[0]))
        {
            world = DimensionManager.getWorld(parseInt(sender, args[0]));
        }
        else if ((args[0].equalsIgnoreCase("here") || args[0].equalsIgnoreCase("world")) && sender instanceof EntityPlayer)
View Full Code Here

{
    // patch method
    public static void processUpdateSign(NetHandlerPlayServer net, C12PacketUpdateSign p_147343_1_)
    {
        net.playerEntity.func_143004_u();
        WorldServer worldserver = net.serverController.worldServerForDimension(net.playerEntity.dimension);

        if (worldserver.blockExists(p_147343_1_.func_149588_c(), p_147343_1_.func_149586_d(), p_147343_1_.func_149585_e()))
        {
            TileEntity tileentity = worldserver.getTileEntity(p_147343_1_.func_149588_c(), p_147343_1_.func_149586_d(), p_147343_1_.func_149585_e());

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

                if (!tileentitysign.func_145914_a() || tileentitysign.func_145911_b() != net.playerEntity)
                {
                    net.serverController.logWarning("Player " + net.playerEntity.getCommandSenderName() + " just tried to change non-editable sign");
                    return;
                }
            }

            int i;
            int j;

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

                if (p_147343_1_.func_149589_f()[j].length() > 15)
                {
                    flag = false;
                }
                else
                {
                    for (i = 0; i < p_147343_1_.func_149589_f()[j].length(); ++i)
                    {
                        if (!ChatAllowedCharacters.isAllowedCharacter(p_147343_1_.func_149589_f()[j].charAt(i)))
                        {
                            flag = false;
                        }
                    }
                }

                if (!flag)
                {
                    p_147343_1_.func_149589_f()[j] = "!?";
                }
            }

            if (tileentity instanceof TileEntitySign)
            {
                j = p_147343_1_.func_149588_c();
                int k = p_147343_1_.func_149586_d();
                i = p_147343_1_.func_149585_e();
                TileEntitySign tileentitysign1 = (TileEntitySign)tileentity;
                System.arraycopy(Preconditions.checkNotNull(onSignEditEvent(net, p_147343_1_)), 0, tileentitysign1.signText, 0, 4);
                tileentitysign1.markDirty();
                worldserver.markBlockForUpdate(j, k, i);
            }
        }
    }
View Full Code Here

            float percent = playersS * 100.0f / playersT;
            OutputHandler.felog.finer("Players sleeping: " + percent + "%");
            if (percent > 50)
            {
                WorldServer world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers[0];
                long time = world.getWorldInfo().getWorldTime() + 24000L;
                world.getWorldInfo().setWorldTime(time - time % 24000L);

                for (Object obj : world.playerEntities)
                {
                    EntityPlayer var2 = (EntityPlayer) obj;

View Full Code Here

        MinecraftServer.getServer().worldServers = tmp.toArray(new WorldServer[tmp.size()]);
    }

    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.func_73046_m();
        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());
    }
View Full Code Here

    /*
    * To be called by the server at the appropriate time, do not call from mod code.
    */
    public static void unloadWorlds(Hashtable<Integer, long[]> worldTickTimes) {
        for (int id : unloadQueue) {
            WorldServer w = worlds.get(id);
            try {
                if (w != null)
                {
                    w.saveAllChunks(true, null);
                }
                else
                {
                    FMLLog.warning("Unexpected world unload - world %d is already unloaded", id);
                }
            } catch (MinecraftException e) {
                e.printStackTrace();
            }
            finally
            {
                if (w != null)
                {
                    MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(w));
                    w.flush();
                    setWorld(id, null);
                }
            }
        }
        unloadQueue.clear();
View Full Code Here

        {
            return;
        }

        dormantChunkCache.put(world, CacheBuilder.newBuilder().maximumSize(dormantChunkCacheSize).<Long, Chunk>build());
        WorldServer worldServer = (WorldServer) world;
        File chunkDir = worldServer.getChunkSaveLocation();
        File chunkLoaderData = new File(chunkDir, "forcedchunks.dat");

        if (chunkLoaderData.exists() && chunkLoaderData.isFile())
        {
            ArrayListMultimap<String, Ticket> loadedTickets = ArrayListMultimap.<String, Ticket>create();
View Full Code Here

        // only persist persistent worlds
        if (!(world instanceof WorldServer))
        {
            return;
        }
        WorldServer worldServer = (WorldServer) world;
        File chunkDir = worldServer.getChunkSaveLocation();
        File chunkLoaderData = new File(chunkDir, "forcedchunks.dat");

        NBTTagCompound forcedChunkData = new NBTTagCompound();
        NBTTagList ticketList = new NBTTagList();
        forcedChunkData.setTag("TicketList", ticketList);
View Full Code Here

   * @param link destination
   * @return teleported entity
   */
  public Entity teleportEntity(Entity entity, TelDestination link)
  {
    WorldServer oldWorld, newWorld;
    EntityPlayerMP player;

    try
    {
      oldWorld = (WorldServer) entity.worldObj;
      newWorld = (WorldServer) link.dim;
      player = (entity instanceof EntityPlayerMP) ? (EntityPlayerMP) entity : null;
    }
    catch (Throwable e)
    {
      return entity;
    }

    if ( oldWorld == null )
      return entity;
    if ( newWorld == null )
      return entity;

    // Is something riding? Handle it first.
    if ( entity.riddenByEntity != null )
    {
      return teleportEntity( entity.riddenByEntity, link );
    }
    // Are we riding something? Dismount and tell the mount to go first.
    Entity cart = entity.ridingEntity;
    if ( cart != null )
    {
      entity.mountEntity( null );
      cart = teleportEntity( cart, link );
      // We keep track of both so we can remount them on the other side.
    }

    // load the chunk!
    WorldServer.class.cast( newWorld ).getChunkProvider().loadChunk( MathHelper.floor_double( link.x ) >> 4, MathHelper.floor_double( link.z ) >> 4 );

    boolean difDest = newWorld != oldWorld;
    if ( difDest )
    {
      if ( player != null )
      {
        if ( link.dim.provider instanceof StorageWorldProvider )
          Achievements.SpatialIOExplorer.addToPlayer( player );

        player.mcServer.getConfigurationManager().transferPlayerToDimension( player, link.dim.provider.dimensionId, new METeleporter( newWorld, link ) );
      }
      else
      {
        int entX = entity.chunkCoordX;
        int entZ = entity.chunkCoordZ;

        if ( (entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists( entX, entZ )) )
        {
          oldWorld.getChunkFromChunkCoords( entX, entZ ).removeEntity( entity );
          oldWorld.getChunkFromChunkCoords( entX, entZ ).isModified = true;
        }

        Entity newEntity = EntityList.createEntityByName( EntityList.getEntityString( entity ), newWorld );
        if ( newEntity != null )
        {
View Full Code Here

TOP

Related Classes of net.minecraft.world.WorldServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.