Package com.minecolonies.api.util
Class WorldUtil
java.lang.Object
com.minecolonies.api.util.WorldUtil
Class which has world related util functions like chunk load checks
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetDimensionMaxHeight(net.minecraft.world.level.dimension.DimensionType dimensionType) Returns a dimensions max heightstatic intgetDimensionMinHeight(net.minecraft.world.level.dimension.DimensionType dimensionType) Returns a dimension min heightstatic <T extends net.minecraft.world.entity.Entity>
List<? extends T>getEntitiesWithinBuilding(@NotNull net.minecraft.world.level.Level world, @NotNull Class<? extends T> clazz, @NotNull IBuilding building, Predicate<? super T> predicate) Get all entities within a building.static <T extends net.minecraft.world.entity.LivingEntity>
TgetNearestEntity(List<? extends T> entityList, net.minecraft.world.entity.Mob livingEntity, int x, int y, int z, double lookDistance) Get the closest entity, cheaper than mojank.static net.minecraft.world.entity.player.PlayergetNearestPlayer(net.minecraft.world.entity.Mob livingEntity, int x, int y, int z, double lookDistance) Get nearest player, our own cheaper check.static booleanisAABBLoaded(net.minecraft.world.level.Level world, net.minecraft.world.phys.AABB box) Returns whether an axis aligned bb is entirely loaded.static booleanisBlockLoaded(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos) Checks if the block is loaded for block accessstatic booleanisChunkLoaded(net.minecraft.world.level.LevelAccessor world, int x, int z) Returns whether a chunk is fully loadedstatic booleanisChunkLoaded(net.minecraft.world.level.LevelAccessor world, net.minecraft.world.level.ChunkPos pos) Returns whether a chunk is fully loadedstatic booleanisDayTime(net.minecraft.world.level.Level world) Check if it's currently day inn the world.static booleanisEntityBlockLoaded(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos) Checks if the block is loaded for ticking entities(not all chunks tick entities)static booleanisEntityChunkLoaded(net.minecraft.world.level.LevelAccessor world, int x, int z) Returns whether an entity ticking chunk is loaded at the positionstatic booleanisEntityChunkLoaded(net.minecraft.world.level.LevelAccessor world, net.minecraft.world.level.ChunkPos pos) Returns whether an entity ticking chunk is loaded at the positionstatic booleanisInWorldHeight(int yBlock, net.minecraft.world.level.Level world) Check if a given block y is within world boundsstatic booleanisNetherType(@NotNull net.minecraft.world.level.Level world) Check if a world is of the nether type.static booleanisOfWorldType(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.resources.ResourceKey<net.minecraft.world.level.dimension.DimensionType> type) Check if a world has a specific dimension type.static booleanisOverworldType(@NotNull net.minecraft.world.level.Level world) Check if a world is of the overworld type.static booleanisPastNoon(net.minecraft.world.level.Level world) Check if it's currently afternoon the world.static booleanisPastTime(net.minecraft.world.level.Level world, int pastTime) Check if it's currently day inn the world.static booleanisPeaceful(@NotNull net.minecraft.world.level.Level world) Check to see if the world is peaceful.static voidmarkChunkDirty(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) Mark a chunk at a position dirty if loaded.static booleanremoveBlock(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos, boolean isMoving) See World#removeBLockstatic booleansetBlockState(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Custom set block state, with 1 instead of default flag 3, to skip vanilla's path notify upon block change, making setBlockState expensive.static booleansetBlockState(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags) Custom set block state, skips vanilla's path notify upon block change, making setBlockState expensive.
-
Constructor Details
-
WorldUtil
public WorldUtil()
-
-
Method Details
-
isBlockLoaded
public static boolean isBlockLoaded(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos) Checks if the block is loaded for block access- Parameters:
world- world to usepos- position to check- Returns:
- true if block is accessible/loaded
-
isChunkLoaded
public static boolean isChunkLoaded(net.minecraft.world.level.LevelAccessor world, int x, int z) Returns whether a chunk is fully loaded- Parameters:
world- world to check onx- chunk positionz- chunk position- Returns:
- true if loaded
-
markChunkDirty
public static void markChunkDirty(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) Mark a chunk at a position dirty if loaded.- Parameters:
world- the world to mark it dirty in.pos- the position within the chunk.
-
isChunkLoaded
public static boolean isChunkLoaded(net.minecraft.world.level.LevelAccessor world, net.minecraft.world.level.ChunkPos pos) Returns whether a chunk is fully loaded- Parameters:
world- world to check onpos- chunk position- Returns:
- true if loaded
-
isEntityBlockLoaded
public static boolean isEntityBlockLoaded(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos) Checks if the block is loaded for ticking entities(not all chunks tick entities)- Parameters:
world- world to usepos- position to check- Returns:
- true if block is accessible/loaded
-
isEntityChunkLoaded
public static boolean isEntityChunkLoaded(net.minecraft.world.level.LevelAccessor world, int x, int z) Returns whether an entity ticking chunk is loaded at the position- Parameters:
world- world to check onx- chunk positionz- chunk position- Returns:
- true if loaded
-
isEntityChunkLoaded
public static boolean isEntityChunkLoaded(net.minecraft.world.level.LevelAccessor world, net.minecraft.world.level.ChunkPos pos) Returns whether an entity ticking chunk is loaded at the position- Parameters:
world- world to check onpos- chunk position- Returns:
- true if loaded
-
isAABBLoaded
public static boolean isAABBLoaded(net.minecraft.world.level.Level world, net.minecraft.world.phys.AABB box) Returns whether an axis aligned bb is entirely loaded.- Parameters:
world- world to check on.box- the box.- Returns:
- true if loaded.
-
isDayTime
public static boolean isDayTime(net.minecraft.world.level.Level world) Check if it's currently day inn the world.- Parameters:
world- the world to check.- Returns:
- true if so.
-
isPastTime
public static boolean isPastTime(net.minecraft.world.level.Level world, int pastTime) Check if it's currently day inn the world.- Parameters:
world- the world to check.- Returns:
- true if so.
-
isPastNoon
public static boolean isPastNoon(net.minecraft.world.level.Level world) Check if it's currently afternoon the world.- Parameters:
world- the world to check.- Returns:
- true if so.
-
isOverworldType
public static boolean isOverworldType(@NotNull @NotNull net.minecraft.world.level.Level world) Check if a world is of the overworld type.- Parameters:
world- the world to check.- Returns:
- true if so.
-
isNetherType
public static boolean isNetherType(@NotNull @NotNull net.minecraft.world.level.Level world) Check if a world is of the nether type.- Parameters:
world- the world to check.- Returns:
- true if so.
-
isOfWorldType
public static boolean isOfWorldType(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.resources.ResourceKey<net.minecraft.world.level.dimension.DimensionType> type) Check if a world has a specific dimension type.- Parameters:
world- the world to check.type- the type to compare.- Returns:
- true if it matches.
-
isPeaceful
public static boolean isPeaceful(@NotNull @NotNull net.minecraft.world.level.Level world) Check to see if the world is peaceful.There are several checks performed here, currently both gamerule and difficulty.
- Parameters:
world- world to check- Returns:
- true if peaceful
-
setBlockState
public static boolean setBlockState(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Custom set block state, with 1 instead of default flag 3, to skip vanilla's path notify upon block change, making setBlockState expensive. The state change still affects neighbours and is synced- Parameters:
world- world to usepos- position to setstate- state to set
-
setBlockState
public static boolean setBlockState(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags) Custom set block state, skips vanilla's path notify upon block change, making setBlockState expensive.- Parameters:
world- world to usepos- position to setstate- state to setflags- flags to use
-
removeBlock
public static boolean removeBlock(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos, boolean isMoving) See World#removeBLock- Parameters:
world- world to remove a blockpos- position the block is removed atisMoving- moving flag- Returns:
- true if success
-
getEntitiesWithinBuilding
public static <T extends net.minecraft.world.entity.Entity> List<? extends T> getEntitiesWithinBuilding(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull Class<? extends T> clazz, @NotNull @NotNull IBuilding building, @Nullable Predicate<? super T> predicate) Get all entities within a building.- Type Parameters:
T- the type of the predicate.- Parameters:
world- the world to check this for.clazz- the entity class.building- the building to check the range for.predicate- the predicate to check- Returns:
- a list of all within those borders.
-
getDimensionMaxHeight
public static int getDimensionMaxHeight(net.minecraft.world.level.dimension.DimensionType dimensionType) Returns a dimensions max height- Parameters:
dimensionType-- Returns:
-
getDimensionMinHeight
public static int getDimensionMinHeight(net.minecraft.world.level.dimension.DimensionType dimensionType) Returns a dimension min height- Parameters:
dimensionType-- Returns:
-
isInWorldHeight
public static boolean isInWorldHeight(int yBlock, net.minecraft.world.level.Level world) Check if a given block y is within world bounds- Parameters:
yBlock-world-- Returns:
-
getNearestPlayer
@Nullable public static net.minecraft.world.entity.player.Player getNearestPlayer(net.minecraft.world.entity.Mob livingEntity, int x, int y, int z, double lookDistance) Get nearest player, our own cheaper check.- Parameters:
livingEntity- the entity to check.x- pos xy- pos yz- pos zlookDistance- min distance.- Returns:
- closest player or null.
-
getNearestEntity
@Nullable public static <T extends net.minecraft.world.entity.LivingEntity> T getNearestEntity(List<? extends T> entityList, @Nullable net.minecraft.world.entity.Mob livingEntity, int x, int y, int z, double lookDistance) Get the closest entity, cheaper than mojank.- Type Parameters:
T- type of entity.- Parameters:
entityList- entity list to check.livingEntity- the entity they should be close to.x- pos xy- pos yz- pos zlookDistance- max distance.- Returns:
- the entity or null.
-