Package org.cyclops.cyclopscore.helper
Class WorldHelpers
java.lang.Object
org.cyclops.cyclopscore.helper.WorldHelpers
Helpers for world related logic.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum chunk size for X and Z axis. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
efficientTick
(net.minecraft.world.level.Level world, int baseModulus, int... params) Check if an efficient tick can happen.static boolean
efficientTick
(net.minecraft.world.level.Level world, int baseModulus, net.minecraft.core.BlockPos blockPos) Check if an efficient tick can happen.static <T,
W extends net.minecraft.world.level.LevelAccessor>
TfoldArea
(W world, int[] areaMin, int[] areaMax, net.minecraft.core.BlockPos blockPos, WorldHelpers.WorldFoldingFunction<T, T, W> folder, T value) Loop over a 3D area while accumulating a value.static <T,
W extends net.minecraft.world.level.LevelAccessor>
TfoldArea
(W world, int area, net.minecraft.core.BlockPos blockPos, WorldHelpers.WorldFoldingFunction<T, T, W> folder, T value) Loop over a 3D area while accumulating a value.static net.minecraft.world.level.Level
-
Field Details
-
CHUNK_SIZE
public static final int CHUNK_SIZEThe maximum chunk size for X and Z axis.- See Also:
-
-
Constructor Details
-
WorldHelpers
public WorldHelpers()
-
-
Method Details
-
efficientTick
public static boolean efficientTick(net.minecraft.world.level.Level world, int baseModulus, int... params) Check if an efficient tick can happen. This is useful for opererations that should happen frequently, but not strictly every tick.- Parameters:
world
- The world to tick in.baseModulus
- The amount of ticks that could be skipped.params
- Optional parameters to further vary the tick occurences.- Returns:
- If a tick of some operation can occur.
-
efficientTick
public static boolean efficientTick(net.minecraft.world.level.Level world, int baseModulus, net.minecraft.core.BlockPos blockPos) Check if an efficient tick can happen. This is useful for opererations that should happen frequently, but not strictly every tick.- Parameters:
world
- The world to tick in.baseModulus
- The amount of ticks that could be skipped.blockPos
- The position to use as param.- Returns:
- If a tick of some operation can occur.
-
foldArea
public static <T,W extends net.minecraft.world.level.LevelAccessor> T foldArea(W world, int[] areaMin, int[] areaMax, net.minecraft.core.BlockPos blockPos, WorldHelpers.WorldFoldingFunction<T, T, W> folder, T value) Loop over a 3D area while accumulating a value.- Type Parameters:
T
- The type of value to accumulate.W
- The world type.- Parameters:
world
- The world.areaMin
- Radius array to start from {x, y, z}.areaMax
- Radius array to end at (inclusive) {x, y, z}.blockPos
- The position.folder
- The folding function.value
- The start value.- Returns:
- The resulting value.
-
foldArea
public static <T,W extends net.minecraft.world.level.LevelAccessor> T foldArea(W world, int area, net.minecraft.core.BlockPos blockPos, WorldHelpers.WorldFoldingFunction<T, T, W> folder, T value) Loop over a 3D area while accumulating a value.- Type Parameters:
T
- The type of value to accumulate.W
- The world type.- Parameters:
world
- The world.area
- Radius.blockPos
- The position.folder
- The folding function.value
- The start value.- Returns:
- The resulting value.
-
getActiveLevel
public static net.minecraft.world.level.Level getActiveLevel()- Returns:
- The current level client-side, or the overworld server-side.
-