Class BlockEntityHelpers

java.lang.Object
org.cyclops.cyclopscore.helper.BlockEntityHelpers

public final class BlockEntityHelpers extends Object
Contains helper methods for various block entity specific things.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static boolean
    If block entities should be retrieved in an unsafe manner from the non-main thread.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <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>
    get(DimPos dimPos, Class<T> targetClazz)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UNSAFE_BLOCK_ENTITY_GETTER

      public static boolean UNSAFE_BLOCK_ENTITY_GETTER
      If 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

      public static <T> Optional<T> get(DimPos dimPos, Class<T> targetClazz)
      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.