Package team.lodestar.lodestone.helpers
Class BlockHelper
java.lang.Object
team.lodestar.lodestone.helpers.BlockHelper
A collection of various helper methods related to all your blocky needs.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.phys.Vec3fromBlockPos(net.minecraft.core.BlockPos pos) Converts a block position into a Vec3 entry.static <T> Collection<T>getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int range) Returns a list of block entities within a radius around a position.static <T> Collection<T>getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int z) Returns a list of block entities within an XZ radius around a position.static <T> Collection<T>getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int y, int z) Returns a list of block entities within an XYZ radius around a position.static <T> Collection<T>getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x1, int y1, int z1, int x2, int y2, int z2) Returns a list of block entities within set coordinates.static <T> Collection<T>getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int y, int z, Predicate<T> predicate) Returns a list of block entities within an XYZ range, with a predicate for conditional checks.static <T> Collection<T>getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int z, Predicate<T> predicate) Returns a list of block entities within an XZ range, with a predicate for conditional checks.static <T> Collection<T>getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int range, Predicate<T> predicate) Returns a list of block entities within a range, with a predicate for conditional checks.static <T> Collection<T>getBlockEntities(Class<T> type, net.minecraft.world.level.Level world, net.minecraft.world.phys.AABB bb) Returns a list of block entities within an AABB.static <T> Stream<T>getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int range) Returns a list of block entities within a radius around a position, as streamstatic <T> Stream<T>getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int z) Returns a list of block entities within an XZ radius around a position, as streamstatic <T> Stream<T>getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int y, int z) Returns a list of block entities within an XYZ radius around a position, as streamstatic <T> Stream<T>getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x1, int y1, int z1, int x2, int y2, int z2) Returns a list of block entities within set coordinates, as streamstatic <T> Stream<T>getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int y, int z, Predicate<T> predicate) Returns a list of block entities within an XYZ range, with a predicate for conditional checks, as streamqstatic <T> Stream<T>getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int z, Predicate<T> predicate) Returns a list of block entities within an XZ range, with a predicate for conditional checks, as streamstatic <T> Stream<T>getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int range, Predicate<T> predicate) Returns a list of block entities within a range, with a predicate for conditional checks, as streamstatic <T> Stream<T>getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level world, net.minecraft.world.phys.AABB bb) Returns a list of block entities within an AABB, as streamstatic Collection<net.minecraft.core.BlockPos>getBlocks(net.minecraft.core.BlockPos pos, int x, int y, int z) Returns a list of block positions within a XYZ radius around a position.static Collection<net.minecraft.core.BlockPos>getBlocks(net.minecraft.core.BlockPos pos, int x1, int y1, int z1, int x2, int y2, int z2) Returns a list of block positions within set coordinates.static Collection<net.minecraft.core.BlockPos>getBlocks(net.minecraft.core.BlockPos pos, int x, int y, int z, Predicate<net.minecraft.core.BlockPos> predicate) Returns a list of block positions within a XYZ radius around a position, with a predicate for conditional checks.static Collection<net.minecraft.core.BlockPos>getBlocks(net.minecraft.core.BlockPos pos, int range, Predicate<net.minecraft.core.BlockPos> predicate) Returns a list of block positions within a radius around a position, with a predicate for conditional checks.static Stream<net.minecraft.core.BlockPos>getBlocksStream(net.minecraft.core.BlockPos pos, int x, int y, int z) Returns a list of block positions within a XYZ radius around a position, as streamstatic Stream<net.minecraft.core.BlockPos>getBlocksStream(net.minecraft.core.BlockPos pos, int x1, int y1, int z1, int x2, int y2, int z2) Returns a list of block positions within set coordinates, as streamstatic Stream<net.minecraft.core.BlockPos>getBlocksStream(net.minecraft.core.BlockPos pos, int x, int y, int z, Predicate<net.minecraft.core.BlockPos> predicate) Returns a list of block positions within a XYZ radius around a position, with a predicate for conditional checks, as streamstatic Stream<net.minecraft.core.BlockPos>getBlocksStream(net.minecraft.core.BlockPos pos, int range, Predicate<net.minecraft.core.BlockPos> predicate) Returns a list of block positions within a radius around a position, with a predicate for conditional checks, as streamstatic net.minecraft.world.level.block.state.BlockStategetBlockStateWithExistingProperties(net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) Copies all properties from oldState to newState, given that an individual property exists on the newState.static Collection<net.minecraft.core.BlockPos>getNeighboringBlocks(net.minecraft.core.BlockPos current) Quick method to get all blocks neighboring a block.static Stream<net.minecraft.core.BlockPos>getNeighboringBlocksStream(net.minecraft.core.BlockPos current) Quick method to get all blocks neighboring a block, as stream.static Collection<net.minecraft.core.BlockPos>getPath(net.minecraft.core.BlockPos start, net.minecraft.core.BlockPos end, int speed, boolean inclusive, net.minecraft.world.level.Level level) static Collection<net.minecraft.core.BlockPos>getPlaneOfBlocks(net.minecraft.core.BlockPos pos, int x, int z) static Collection<net.minecraft.core.BlockPos>getPlaneOfBlocks(net.minecraft.core.BlockPos pos, int x1, int z1, int x2, int z2) static Collection<net.minecraft.core.BlockPos>getPlaneOfBlocks(net.minecraft.core.BlockPos pos, int x, int z, Predicate<net.minecraft.core.BlockPos> predicate) static Collection<net.minecraft.core.BlockPos>getPlaneOfBlocks(net.minecraft.core.BlockPos pos, int range, Predicate<net.minecraft.core.BlockPos> predicate) static Stream<net.minecraft.core.BlockPos>getPlaneOfBlocksStream(net.minecraft.core.BlockPos pos, int x, int z) static Stream<net.minecraft.core.BlockPos>getPlaneOfBlocksStream(net.minecraft.core.BlockPos pos, int x1, int z1, int x2, int z2) static Stream<net.minecraft.core.BlockPos>getPlaneOfBlocksStream(net.minecraft.core.BlockPos pos, int x, int z, Predicate<net.minecraft.core.BlockPos> predicate) static Stream<net.minecraft.core.BlockPos>getPlaneOfBlocksStream(net.minecraft.core.BlockPos pos, int range, Predicate<net.minecraft.core.BlockPos> predicate) static Collection<net.minecraft.core.BlockPos>getSphereOfBlocks(net.minecraft.core.BlockPos pos, float range) static Collection<net.minecraft.core.BlockPos>getSphereOfBlocks(net.minecraft.core.BlockPos pos, float width, float height) static Collection<net.minecraft.core.BlockPos>getSphereOfBlocks(net.minecraft.core.BlockPos pos, float width, float height, Predicate<net.minecraft.core.BlockPos> predicate) static Collection<net.minecraft.core.BlockPos>getSphereOfBlocks(net.minecraft.core.BlockPos pos, float range, Predicate<net.minecraft.core.BlockPos> predicate) static Stream<net.minecraft.core.BlockPos>getSphereOfBlocksStream(net.minecraft.core.BlockPos pos, float range) static Stream<net.minecraft.core.BlockPos>getSphereOfBlocksStream(net.minecraft.core.BlockPos pos, float width, float height) static Stream<net.minecraft.core.BlockPos>getSphereOfBlocksStream(net.minecraft.core.BlockPos pos, float width, float height, Predicate<net.minecraft.core.BlockPos> predicate) static Stream<net.minecraft.core.BlockPos>getSphereOfBlocksStream(net.minecraft.core.BlockPos pos, float range, Predicate<net.minecraft.core.BlockPos> predicate) static net.minecraft.core.BlockPosloadBlockPos(net.minecraft.nbt.CompoundTag tag) Loads a block position from nbt.static net.minecraft.core.BlockPosloadBlockPos(net.minecraft.nbt.CompoundTag tag, String extra) Loads a block position from nbt with extra text as input.static <T extends Comparable<T>>
net.minecraft.world.level.block.state.BlockStatenewStateWithOldProperty(net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, net.minecraft.world.level.block.state.properties.Property<T> property) static net.minecraft.nbt.CompoundTagsaveBlockPos(net.minecraft.nbt.CompoundTag compoundNBT, net.minecraft.core.BlockPos pos) Saves a block position to nbt.static net.minecraft.nbt.CompoundTagsaveBlockPos(net.minecraft.nbt.CompoundTag compoundNBT, net.minecraft.core.BlockPos pos, String extra) Saves a block position to nbt with extra text to differentiate it.static net.minecraft.world.level.block.state.BlockStatesetBlockStateWithExistingProperties(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState newState, int flags) Copies BlockState properties from a BlockState already in the world, and replaces it with a newState with matching property values.static voidupdateAndNotifyState(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) static voidupdateAndNotifyState(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) static voidupdateState(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) static voidupdateState(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) static net.minecraft.world.phys.Vec3withinBlock(Random rand, net.minecraft.core.BlockPos pos) Generates a randomly picked position within a block
-
Constructor Details
-
BlockHelper
public BlockHelper()
-
-
Method Details
-
getBlockStateWithExistingProperties
public static net.minecraft.world.level.block.state.BlockState getBlockStateWithExistingProperties(net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) Copies all properties from oldState to newState, given that an individual property exists on the newState.- Parameters:
oldState- - State to copy properties from.newState- - State to apply copied property values to.- Returns:
- - NewState with adjusted properties.
-
setBlockStateWithExistingProperties
public static net.minecraft.world.level.block.state.BlockState setBlockStateWithExistingProperties(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState newState, int flags) Copies BlockState properties from a BlockState already in the world, and replaces it with a newState with matching property values. -
newStateWithOldProperty
public static <T extends Comparable<T>> net.minecraft.world.level.block.state.BlockState newStateWithOldProperty(net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, net.minecraft.world.level.block.state.properties.Property<T> property) -
saveBlockPos
public static net.minecraft.nbt.CompoundTag saveBlockPos(net.minecraft.nbt.CompoundTag compoundNBT, net.minecraft.core.BlockPos pos) Saves a block position to nbt. -
saveBlockPos
public static net.minecraft.nbt.CompoundTag saveBlockPos(net.minecraft.nbt.CompoundTag compoundNBT, net.minecraft.core.BlockPos pos, String extra) Saves a block position to nbt with extra text to differentiate it. -
loadBlockPos
public static net.minecraft.core.BlockPos loadBlockPos(net.minecraft.nbt.CompoundTag tag) Loads a block position from nbt. -
loadBlockPos
public static net.minecraft.core.BlockPos loadBlockPos(net.minecraft.nbt.CompoundTag tag, String extra) Loads a block position from nbt with extra text as input. -
getBlockEntities
public static <T> Collection<T> getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int range, Predicate<T> predicate) Returns a list of block entities within a range, with a predicate for conditional checks. -
getBlockEntitiesStream
public static <T> Stream<T> getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int range, Predicate<T> predicate) Returns a list of block entities within a range, with a predicate for conditional checks, as stream -
getBlockEntities
public static <T> Collection<T> getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int z, Predicate<T> predicate) Returns a list of block entities within an XZ range, with a predicate for conditional checks. -
getBlockEntitiesStream
public static <T> Stream<T> getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int z, Predicate<T> predicate) Returns a list of block entities within an XZ range, with a predicate for conditional checks, as stream -
getBlockEntities
public static <T> Collection<T> getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int y, int z, Predicate<T> predicate) Returns a list of block entities within an XYZ range, with a predicate for conditional checks. -
getBlockEntitiesStream
public static <T> Stream<T> getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int y, int z, Predicate<T> predicate) Returns a list of block entities within an XYZ range, with a predicate for conditional checks, as streamq -
getBlockEntities
public static <T> Collection<T> getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int range) Returns a list of block entities within a radius around a position. -
getBlockEntitiesStream
public static <T> Stream<T> getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int range) Returns a list of block entities within a radius around a position, as stream- Parameters:
type- - Class of the block entity to search forlevel- - Level to search inpos- - Position to search aroundrange- - Radius to search in- Returns:
- - Stream of block entities
-
getBlockEntities
public static <T> Collection<T> getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int z) Returns a list of block entities within an XZ radius around a position. -
getBlockEntitiesStream
public static <T> Stream<T> getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int z) Returns a list of block entities within an XZ radius around a position, as stream- Parameters:
type- - Class of the block entity to search forlevel- - Level to search inpos- - Position to search aroundx- - Radius to search in Xz- - Radius to search in Z- Returns:
- - Stream of block entities
-
getBlockEntities
public static <T> Collection<T> getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int y, int z) Returns a list of block entities within an XYZ radius around a position. -
getBlockEntitiesStream
public static <T> Stream<T> getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x, int y, int z) Returns a list of block entities within an XYZ radius around a position, as stream- Parameters:
type- - Class of the block entity to search forlevel- - Level to search inpos- - Position to search aroundx- - Radius to search in Xy- - Radius to search in Yz- - Radius to search in Z- Returns:
- - Stream of block entities
-
getBlockEntities
public static <T> Collection<T> getBlockEntities(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x1, int y1, int z1, int x2, int y2, int z2) Returns a list of block entities within set coordinates. -
getBlockEntitiesStream
public static <T> Stream<T> getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int x1, int y1, int z1, int x2, int y2, int z2) Returns a list of block entities within set coordinates, as stream -
getBlockEntities
public static <T> Collection<T> getBlockEntities(Class<T> type, net.minecraft.world.level.Level world, net.minecraft.world.phys.AABB bb) Returns a list of block entities within an AABB. -
getBlockEntitiesStream
public static <T> Stream<T> getBlockEntitiesStream(Class<T> type, net.minecraft.world.level.Level world, net.minecraft.world.phys.AABB bb) Returns a list of block entities within an AABB, as stream -
getBlocks
public static Collection<net.minecraft.core.BlockPos> getBlocks(net.minecraft.core.BlockPos pos, int range, Predicate<net.minecraft.core.BlockPos> predicate) Returns a list of block positions within a radius around a position, with a predicate for conditional checks. -
getBlocksStream
public static Stream<net.minecraft.core.BlockPos> getBlocksStream(net.minecraft.core.BlockPos pos, int range, Predicate<net.minecraft.core.BlockPos> predicate) Returns a list of block positions within a radius around a position, with a predicate for conditional checks, as stream -
getBlocks
public static Collection<net.minecraft.core.BlockPos> getBlocks(net.minecraft.core.BlockPos pos, int x, int y, int z, Predicate<net.minecraft.core.BlockPos> predicate) Returns a list of block positions within a XYZ radius around a position, with a predicate for conditional checks. -
getBlocksStream
public static Stream<net.minecraft.core.BlockPos> getBlocksStream(net.minecraft.core.BlockPos pos, int x, int y, int z, Predicate<net.minecraft.core.BlockPos> predicate) Returns a list of block positions within a XYZ radius around a position, with a predicate for conditional checks, as stream -
getBlocks
public static Collection<net.minecraft.core.BlockPos> getBlocks(net.minecraft.core.BlockPos pos, int x, int y, int z) Returns a list of block positions within a XYZ radius around a position. -
getBlocksStream
public static Stream<net.minecraft.core.BlockPos> getBlocksStream(net.minecraft.core.BlockPos pos, int x, int y, int z) Returns a list of block positions within a XYZ radius around a position, as stream -
getBlocks
public static Collection<net.minecraft.core.BlockPos> getBlocks(net.minecraft.core.BlockPos pos, int x1, int y1, int z1, int x2, int y2, int z2) Returns a list of block positions within set coordinates. -
getBlocksStream
public static Stream<net.minecraft.core.BlockPos> getBlocksStream(net.minecraft.core.BlockPos pos, int x1, int y1, int z1, int x2, int y2, int z2) Returns a list of block positions within set coordinates, as stream -
getPlaneOfBlocks
public static Collection<net.minecraft.core.BlockPos> getPlaneOfBlocks(net.minecraft.core.BlockPos pos, int range, Predicate<net.minecraft.core.BlockPos> predicate) -
getPlaneOfBlocksStream
-
getPlaneOfBlocks
public static Collection<net.minecraft.core.BlockPos> getPlaneOfBlocks(net.minecraft.core.BlockPos pos, int x, int z, Predicate<net.minecraft.core.BlockPos> predicate) -
getPlaneOfBlocksStream
-
getPlaneOfBlocks
public static Collection<net.minecraft.core.BlockPos> getPlaneOfBlocks(net.minecraft.core.BlockPos pos, int x, int z) -
getPlaneOfBlocksStream
public static Stream<net.minecraft.core.BlockPos> getPlaneOfBlocksStream(net.minecraft.core.BlockPos pos, int x, int z) -
getPlaneOfBlocks
public static Collection<net.minecraft.core.BlockPos> getPlaneOfBlocks(net.minecraft.core.BlockPos pos, int x1, int z1, int x2, int z2) -
getPlaneOfBlocksStream
public static Stream<net.minecraft.core.BlockPos> getPlaneOfBlocksStream(net.minecraft.core.BlockPos pos, int x1, int z1, int x2, int z2) -
getSphereOfBlocks
public static Collection<net.minecraft.core.BlockPos> getSphereOfBlocks(net.minecraft.core.BlockPos pos, float range, Predicate<net.minecraft.core.BlockPos> predicate) -
getSphereOfBlocksStream
-
getSphereOfBlocks
public static Collection<net.minecraft.core.BlockPos> getSphereOfBlocks(net.minecraft.core.BlockPos pos, float width, float height, Predicate<net.minecraft.core.BlockPos> predicate) -
getSphereOfBlocksStream
-
getSphereOfBlocks
public static Collection<net.minecraft.core.BlockPos> getSphereOfBlocks(net.minecraft.core.BlockPos pos, float range) -
getSphereOfBlocksStream
public static Stream<net.minecraft.core.BlockPos> getSphereOfBlocksStream(net.minecraft.core.BlockPos pos, float range) -
getSphereOfBlocks
public static Collection<net.minecraft.core.BlockPos> getSphereOfBlocks(net.minecraft.core.BlockPos pos, float width, float height) -
getSphereOfBlocksStream
public static Stream<net.minecraft.core.BlockPos> getSphereOfBlocksStream(net.minecraft.core.BlockPos pos, float width, float height) -
getNeighboringBlocks
public static Collection<net.minecraft.core.BlockPos> getNeighboringBlocks(net.minecraft.core.BlockPos current) Quick method to get all blocks neighboring a block. -
getNeighboringBlocksStream
public static Stream<net.minecraft.core.BlockPos> getNeighboringBlocksStream(net.minecraft.core.BlockPos current) Quick method to get all blocks neighboring a block, as stream. -
getPath
public static Collection<net.minecraft.core.BlockPos> getPath(net.minecraft.core.BlockPos start, net.minecraft.core.BlockPos end, int speed, boolean inclusive, net.minecraft.world.level.Level level) -
updateState
public static void updateState(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) -
updateState
public static void updateState(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) -
updateAndNotifyState
public static void updateAndNotifyState(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) -
updateAndNotifyState
public static void updateAndNotifyState(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) -
fromBlockPos
public static net.minecraft.world.phys.Vec3 fromBlockPos(net.minecraft.core.BlockPos pos) Converts a block position into a Vec3 entry.- Parameters:
pos- the block position- Returns:
- the vec3 representation.
-
withinBlock
public static net.minecraft.world.phys.Vec3 withinBlock(Random rand, net.minecraft.core.BlockPos pos) Generates a randomly picked position within a block- Parameters:
rand- an instance of randompos- the position the block is centered around- Returns:
- The randomized vector position
-