Module gomint.api

Interface World


  • public interface World
    Version:
    1.0
    Author:
    geNAZt, BlackyPaw
    • Method Detail

      • getWorldName

        String getWorldName()
        Gets the name of the world itself, i.e. the name of the directory it is stored in.
        Returns:
        The name of the world itself
      • getLevelName

        String getLevelName()
        Gets the level name of the world. This is the name found inside the NBT data of a world.
        Returns:
        The level name of the world
      • setSpawnLocation

        void setSpawnLocation​(Location location)
        Sets the spawn location of the world
        Parameters:
        location - The world's spawn location
      • getSpawnLocation

        Location getSpawnLocation()
        Gets the spawn location of the world.
        Returns:
        The world's spawn location
      • setDifficulty

        void setDifficulty​(Difficulty difficulty)
        Set the difficulty of the world
        Parameters:
        difficulty - The world's new difficulty
      • getDifficulty

        Difficulty getDifficulty()
        Returns the difficulty of the world
        Returns:
        The world's difficulty
      • getBlockAt

        <T extends Block> T getBlockAt​(BlockPosition pos)
        Get the block at that position or null if the position is not loaded in the world.
        Parameters:
        pos - of the position
        Returns:
        block which has been found at that position or null
      • getBlockAt

        <T extends Block> T getBlockAt​(int x,
                                       int y,
                                       int z)
        Get the block at that position or air if the position is not loaded in the world.
        Parameters:
        x - x coordinate
        y - y coordinate
        z - z coordinate
        Returns:
        block which has been found at that position or air (when chunk has not been loaded)
      • getBlockAt

        <T extends Block> T getBlockAt​(int x,
                                       int y,
                                       int z,
                                       WorldLayer layer)
        Get the block at that position or air if the position is not loaded in the world.
        Parameters:
        x - x coordinate
        y - y coordinate
        z - z coordinate
        layer - on which layer is this block
        Returns:
        block which has been found at that position or air (when chunk has not been loaded)
      • getGamerule

        <T> T getGamerule​(Gamerule<T> gamerule)
        Gets the value of the given gamerule set for this world.
        Type Parameters:
        T - The generic type of the gamerule
        Parameters:
        gamerule - The gamerule to get a value for
        Returns:
        The value of the gamerule
      • setGamerule

        <T> void setGamerule​(Gamerule<T> gamerule,
                             T value)
        Sets the value of the given gamerule for this world
        Type Parameters:
        T - The generic type of the gamerule
        Parameters:
        gamerule - The gamerule to set a value for
        value - The value which should be set
      • getPlayers

        Collection<EntityPlayer> getPlayers()
        Get a collection of players which are online on this world
        Returns:
        Collection of players online on this world
      • playSound

        void playSound​(Vector location,
                       Sound sound,
                       byte pitch,
                       SoundData data)
        Play a sound at the location given
        Parameters:
        location - The location where the sound should be played
        sound - The sound which should be played
        pitch - The pitch at which the sound should be played
        data - additional data for the sound
        Throws:
        IllegalArgumentException - when the sound data given is incorrect for the sound wanted to play
      • playSound

        void playSound​(Vector location,
                       Sound sound,
                       byte pitch)
        Play a sound at the location given
        Parameters:
        location - The location where the sound should be played
        sound - The sound which should be played
        pitch - The pitch at which the sound should be played
      • sendParticle

        void sendParticle​(Vector location,
                          Particle particle)
        Send a particle to this world
        Parameters:
        location - of the particle in the client
        particle - which should be send
      • sendParticle

        void sendParticle​(Vector location,
                          Particle particle,
                          ParticleData data)
        Send a particle to this world
        Parameters:
        location - of the particle in the client
        particle - which should be send
        data - data with which this particle should be send
        Throws:
        IllegalArgumentException - when the particle data is incorrect for the particle which should be send
      • getCollisionCubes

        List<AxisAlignedBB> getCollisionCubes​(Entity entity,
                                              AxisAlignedBB bb,
                                              boolean includeEntities)
        Get a list of bounding boxes which collide with the given box
        Parameters:
        entity - When includeEntities is true this is the entity which will be exempted
        bb - The bounding box which should be used to check for collision with
        includeEntities - Should we return blocks only or also entities? True for entities, false without entities
        Returns:
        either a list of collisions or null
      • createItemDrop

        EntityItemDrop createItemDrop​(Location location,
                                      ItemStack itemStack)
        Create a entity drop in the given world
        Parameters:
        location - for the item drop
        itemStack - which is stored inside the drop
        Returns:
        the created and spawned entity
      • unload

        void unload​(Consumer<EntityPlayer> playerConsumer)
        Unload this world. All remaining players in this world get called through the consumer
        Parameters:
        playerConsumer - which gets called for every player in this world
      • iterateBlocks

        <T extends Block> void iterateBlocks​(Class<T> blockClass,
                                             Consumer<T> blockConsumer)
        Iterate over all loaded chunks and find the blocks specified for the blockClass. This method is very expensive since it fully blocks the server until the search operation has been completed.
        Type Parameters:
        T - type of block
        Parameters:
        blockClass - for which we search
        blockConsumer - which gets called for every found block
      • iterateEntities

        <T extends Entity> void iterateEntities​(Class<T> entityClass,
                                                Consumer<T> entityConsumer)
        Iterate over all loaded chunks and find the entities specified for the entityClass.
        Type Parameters:
        T - type of entity
        Parameters:
        entityClass - for which we search
        entityConsumer - which gets called for every found entity
      • iterateChunks

        void iterateChunks​(Consumer<Chunk> chunkConsumer)
        Iterate over all loaded chunks in this world
        Parameters:
        chunkConsumer - which gets called for every chunk loaded
      • generateEmptyChunk

        Chunk generateEmptyChunk​(int x,
                                 int z)
        Generate a empty chunk
        Parameters:
        x - coordinate of the chunk
        z - coordinate of the chunk
        Returns:
        chunk with only air in it
      • getChunk

        Chunk getChunk​(int x,
                       int z)
        Get the chunk which has been asked
        Parameters:
        x - coordinate of the chunk
        z - coordinate of the chunk
        Returns:
        chunk or null when not generated
      • save

        void save()
        Save all data to disk
      • getHighestBlockAt

        Block getHighestBlockAt​(int x,
                                int z)
        Get the highest block at the given coordinates
        Parameters:
        x - coordinate
        z - coordinate
        Returns:
        highest block at the normal layer
      • getHighestBlockAt

        Block getHighestBlockAt​(int x,
                                int z,
                                WorldLayer layer)
        Get the highest block at the given coordinates. Please care this can be wrong, height calculations are always done on the normal layer. So the highest block on the underwater layer may be wrong at all times.
        Parameters:
        x - coordinate
        z - coordinate
        layer - on which we want to lookup
        Returns:
        highest block at the normal layer