Package org.cyclops.cyclopscore.helper
Class BlockEntityHelpers
java.lang.Object
org.cyclops.cyclopscore.helper.BlockEntityHelpers
Contains helper methods for various block entity specific things.
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
If block entities should be retrieved in an unsafe manner from the non-main thread. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Optional<T>
get
(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, Class<T> targetClazz) Safely cast a block entity.static <T> Optional<T>
Safely cast a block entity.static <C> net.minecraftforge.common.util.LazyOptional<C>
getCapability
(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side, net.minecraftforge.common.capabilities.Capability<C> capability) Safely get a capability from a block entity.static <C> net.minecraftforge.common.util.LazyOptional<C>
getCapability
(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraftforge.common.capabilities.Capability<C> capability) Safely get a capability from a block entity.static <C> net.minecraftforge.common.util.LazyOptional<C>
getCapability
(DimPos dimPos, net.minecraft.core.Direction side, net.minecraftforge.common.capabilities.Capability<C> capability) Safely get a capability from a block entity.static <C> net.minecraftforge.common.util.LazyOptional<C>
getCapability
(DimPos dimPos, net.minecraftforge.common.capabilities.Capability<C> capability) Safely get a capability from a block entity.
-
Field Details
-
UNSAFE_BLOCK_ENTITY_GETTER
public static boolean UNSAFE_BLOCK_ENTITY_GETTERIf block entities should be retrieved in an unsafe manner from the non-main thread. USE WITH CAUTION!!!
-
-
Constructor Details
-
BlockEntityHelpers
public BlockEntityHelpers()
-
-
Method Details
-
get
Safely cast a block entity.- Type Parameters:
T
- The type of block entity to cast at.- Parameters:
dimPos
- The dimensional position of the block providing the block entity.targetClazz
- The class to cast to.- Returns:
- The optional block entity.
-
get
public static <T> Optional<T> get(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, Class<T> targetClazz) Safely cast a block entity.- Type Parameters:
T
- The type of block entity to cast at.- Parameters:
level
- The level.pos
- The position of the block providing the block entity.targetClazz
- The class to cast to.- Returns:
- The optional block entity.
-
getCapability
public static <C> net.minecraftforge.common.util.LazyOptional<C> getCapability(DimPos dimPos, net.minecraftforge.common.capabilities.Capability<C> capability) Safely get a capability from a block entity.- Type Parameters:
C
- The capability instance.- Parameters:
dimPos
- The dimensional position of the block providing the block entity.capability
- The capability.- Returns:
- The lazy optional capability.
-
getCapability
public static <C> net.minecraftforge.common.util.LazyOptional<C> getCapability(DimPos dimPos, net.minecraft.core.Direction side, net.minecraftforge.common.capabilities.Capability<C> capability) Safely get a capability from a block entity.- Type Parameters:
C
- The capability instance.- Parameters:
dimPos
- The dimensional position of the block providing the block entity.side
- The side to get the capability from.capability
- The capability.- Returns:
- The lazy optional capability.
-
getCapability
public static <C> net.minecraftforge.common.util.LazyOptional<C> getCapability(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraftforge.common.capabilities.Capability<C> capability) Safely get a capability from a block entity.- Type Parameters:
C
- The capability instance.- Parameters:
level
- The level.pos
- The position of the block of the block entity providing the capability.capability
- The capability.- Returns:
- The lazy optional capability.
-
getCapability
public static <C> net.minecraftforge.common.util.LazyOptional<C> getCapability(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side, net.minecraftforge.common.capabilities.Capability<C> capability) Safely get a capability from a block entity.- Type Parameters:
C
- The capability instance.- Parameters:
level
- The level.pos
- The position of the block of the block entity providing the capability.side
- The side to get the capability from.capability
- The capability.- Returns:
- The lazy optional capability.
-