Class SuperBlockEntityBehaviour

java.lang.Object
com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour
com.cake.azimuth.behaviour.SuperBlockEntityBehaviour

public abstract class SuperBlockEntityBehaviour extends com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour
Extended version of BlockEntityBehaviour designed for invasive additions of extra functionality for SmartBlockEntity, where you want to compose (or apply) almost full block entity functionality. This also includes some shorthands for accessing things such as block entity level, or getting a likewise behaviour on another block entity.
  • Field Summary

    Fields inherited from class com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour

    blockEntity
  • Constructor Summary

    Constructors
    Constructor
    Description
    SuperBlockEntityBehaviour(com.simibubi.create.foundation.blockEntity.SmartBlockEntity be)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.level.block.entity.BlockEntity
     
    net.minecraft.world.level.block.state.BlockState
     
    net.minecraft.world.level.Level
     
    static <T extends com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour>
    Optional<T>
    getOptional(net.minecraft.world.level.block.entity.BlockEntity be, com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType<T> type)
    Shorthand for getting an optional behaviour of a specific type from a level at a given position.
    static <T extends com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour>
    Optional<T>
    getOptional(net.minecraft.world.level.Level level, @NotNull net.minecraft.core.BlockPos pos, com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType<T> type)
    Shorthand for getting an optional behaviour of a specific type from a level at a given position.
    static <T extends com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour>
    T
    getOrThrow(net.minecraft.world.level.block.entity.BlockEntity be, com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType<T> type)
    Shorthand for getting an optional behaviour of a specific type from a level at a given position.
    static <T extends com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour>
    T
    getOrThrow(net.minecraft.world.level.Level level, @NotNull net.minecraft.core.BlockPos pos, com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType<T> type)
    Shorthand for getting an optional behaviour of a specific type from a level at a given position, and expect it.
    getSameBehaviour(net.minecraft.core.BlockPos otherPos)
    Shorthand for getting a complementary behaviour of the same type on another block entity.
    getSameBehaviour(net.minecraft.world.level.block.entity.BlockEntity otherBlockEntity)
    Shorthand for getting a complementary behaviour of the same type on another block entity.
    getSameBehaviourOptional(net.minecraft.core.BlockPos otherPos)
    Shorthand for getting an optional complementary behaviour of the same type on another block entity.
    getSameBehaviourOptional(net.minecraft.world.level.block.entity.BlockEntity otherBlockEntity)
    Shorthand for getting an optional complementary behaviour of the same type on another block entity.
    getSameBehaviourOrThrow(net.minecraft.core.BlockPos otherPos)
    Shorthand for getting a complementary behaviour of the same type on another block entity, and expect it to exist.
    getSameBehaviourOrThrow(net.minecraft.world.level.block.entity.BlockEntity otherBlockEntity)
    Shorthand for getting a complementary behaviour of the same type on another block entity, and expect it to exist.
    boolean
     
    boolean
     
    boolean
     
    void
    onBlockBroken(net.neoforged.neoforge.event.level.BlockEvent.BreakEvent event)
     
    void
    onBlockPlaced(net.neoforged.neoforge.event.level.BlockEvent.EntityPlaceEvent event)
     
    void
    onItemUse(net.neoforged.neoforge.event.entity.player.PlayerInteractEvent.RightClickBlock event)
     
    void
     
    void
    transform(net.minecraft.world.level.block.entity.BlockEntity be, com.simibubi.create.content.contraptions.StructureTransform structureTransformMixin)
     

    Methods inherited from class com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour

    destroy, get, get, getPos, getRequiredItems, getType, getWorld, initialize, isSafeNBT, lazyTick, onBlockChanged, onNeighborChanged, read, setLazyTickRate, tick, unload, write, writeSafe

    Methods inherited from class java.lang.Object

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

    • SuperBlockEntityBehaviour

      public SuperBlockEntityBehaviour(com.simibubi.create.foundation.blockEntity.SmartBlockEntity be)
  • Method Details

    • getLevel

      public net.minecraft.world.level.Level getLevel()
    • getBlockState

      public net.minecraft.world.level.block.state.BlockState getBlockState()
    • getBlockEntity

      public net.minecraft.world.level.block.entity.BlockEntity getBlockEntity()
    • sendData

      public void sendData()
    • hasLevel

      public boolean hasLevel()
    • isClientLevel

      public boolean isClientLevel()
    • isServerLevel

      public boolean isServerLevel()
    • transform

      public void transform(net.minecraft.world.level.block.entity.BlockEntity be, com.simibubi.create.content.contraptions.StructureTransform structureTransformMixin)
    • getOptional

      public static <T extends com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour> Optional<T> getOptional(net.minecraft.world.level.Level level, @NotNull @NotNull net.minecraft.core.BlockPos pos, com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType<T> type)
      Shorthand for getting an optional behaviour of a specific type from a level at a given position.
      Type Parameters:
      T - the type of the behaviour
      Parameters:
      level - the level to get the behaviour from
      pos - the position of the block entity to get the behaviour from
      type - the type of the behaviour to get
      Returns:
      an optional containing the behaviour if it exists and is of the correct type, or an empty optional if it doesn't exist, isn't loaded, or isn't a SmartBlockEntity.
    • getOrThrow

      public static <T extends com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour> T getOrThrow(net.minecraft.world.level.Level level, @NotNull @NotNull net.minecraft.core.BlockPos pos, com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType<T> type)
      Shorthand for getting an optional behaviour of a specific type from a level at a given position, and expect it. If you do not want to throw, then use getOptional(Level, BlockPos, BehaviourType) or BlockEntityBehaviour.get(BlockGetter, BlockPos, BehaviourType).
      Type Parameters:
      T - the type of the behaviour
      Parameters:
      level - the level to get the behaviour from
      pos - the position of the block entity to get the behaviour from
      type - the type of the behaviour to get
      Returns:
      an optional containing the behaviour if it exists and is of the correct type, or an empty optional if it doesn't exist, isn't loaded, or isn't a SmartBlockEntity.
    • getOptional

      public static <T extends com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour> Optional<T> getOptional(net.minecraft.world.level.block.entity.BlockEntity be, com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType<T> type)
      Shorthand for getting an optional behaviour of a specific type from a level at a given position.
      Type Parameters:
      T - the type of the behaviour
      Parameters:
      be - the block entity to get the behaviour from
      type - the type of the behaviour to get
      Returns:
      an optional containing the behaviour if it exists and is of the correct type, or an empty optional if it doesn't exist, isn't loaded, or isn't a SmartBlockEntity.
    • getOrThrow

      public static <T extends com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour> T getOrThrow(net.minecraft.world.level.block.entity.BlockEntity be, com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType<T> type)
      Shorthand for getting an optional behaviour of a specific type from a level at a given position. If you do not want to throw, then use getOptional(BlockEntity, BehaviourType) or BlockEntityBehaviour.get(BlockEntity, BehaviourType).
      Type Parameters:
      T - the type of the behaviour
      Parameters:
      be - the block entity to get the behaviour from
      type - the type of the behaviour to get
      Returns:
      an optional containing the behaviour if it exists and is of the correct type, or an empty optional if it doesn't exist, isn't loaded, or isn't a SmartBlockEntity.
    • getSameBehaviour

      @Nullable public <T extends SuperBlockEntityBehaviour> T getSameBehaviour(net.minecraft.core.BlockPos otherPos)
      Shorthand for getting a complementary behaviour of the same type on another block entity. This is designed for things such as multi-blocks, where you want to have the same behaviour on multiple block entities and have them interact with each other, but can also be used for other things such as linked machines.
      Example usage:
       if (controllerOffset != null && getLevel() != null) {
           final BlockPos controllerPos = getPos().offset(controllerOffset);
           CogwheelChainComponentBehaviour controller = this.getComplementaryBehaviour(controllerPos);
           if (controller != null) {
               controller.chainsToRefund = 0;
           }
       }
       
      Type Parameters:
      T - the type of the current behaviour, used to ensure the returned value is of the correct type
      Parameters:
      otherPos - the position of the other block entity to get the behaviour from
      Returns:
      the complementary behaviour if it exists and is of the same type, or null if it doesn't exist, isn't loaded, or isn't of the same type.
    • getSameBehaviourOptional

      public <T extends SuperBlockEntityBehaviour> Optional<T> getSameBehaviourOptional(net.minecraft.core.BlockPos otherPos)
      Shorthand for getting an optional complementary behaviour of the same type on another block entity. This is designed for things such as multi-blocks, where you want to have the same behaviour on multiple block entities and have them interact with each other, but can also be used for other things such as linked machines.
      Example usage:
       if (controllerOffset != null && getLevel() != null) {
           final BlockPos controllerPos = getPos().offset(controllerOffset);
           this.<CogwheelChainComponentBehaviour>getComplementaryBehaviourOptional(controllerPos)
              .ifPresent(controller -> controller.chainsToRefund = 0);
       }
       
      Type Parameters:
      T - the type of the current behaviour, used to ensure the optional is of the correct type
      Parameters:
      otherPos - the position of the other block entity to get the behaviour from
      Returns:
      an optional containing the complementary behaviour if it exists and is of the same type, or an empty optional if it doesn't exist, isn't loaded, or isn't of the same type.
    • getSameBehaviourOrThrow

      public <T extends SuperBlockEntityBehaviour> T getSameBehaviourOrThrow(net.minecraft.core.BlockPos otherPos)
      Shorthand for getting a complementary behaviour of the same type on another block entity, and expect it to exist. If you do not want to throw, then use getSameBehaviourOptional(BlockPos) or getSameBehaviour(BlockPos).
      Type Parameters:
      T - the type of the current behaviour, used to ensure the returned value is of the correct type
      Parameters:
      otherPos - the position of the other block entity to get the behaviour from
      Returns:
      the complementary behaviour if it exists and is of the same type
      Throws:
      IllegalStateException - if the complementary behaviour does not exist, is not loaded, or is of a different type
    • getSameBehaviour

      @Nullable public <T extends SuperBlockEntityBehaviour> T getSameBehaviour(net.minecraft.world.level.block.entity.BlockEntity otherBlockEntity)
      Shorthand for getting a complementary behaviour of the same type on another block entity. This is designed for things such as multi-blocks, where you want to have the same behaviour on multiple block entities and have them interact with each other, but can also be used for other things such as linked machines.
      Example usage:
       if (getLevel() != null) {
           CogwheelChainComponentBehaviour other = this.getComplementaryBehaviour(otherBlockEntity);
           if (other != null) {
               other.chainsToRefund = 0;
           }
       }
       
      Type Parameters:
      T - the type of the current behaviour, used to ensure the returned value is of the correct type
      Parameters:
      otherBlockEntity - the other block entity to get the behaviour from
      Returns:
      the complementary behaviour if it exists and is of the same type, or null if it doesn't exist, isn't loaded, or isn't of the same type.
    • getSameBehaviourOptional

      public <T extends SuperBlockEntityBehaviour> Optional<T> getSameBehaviourOptional(net.minecraft.world.level.block.entity.BlockEntity otherBlockEntity)
      Shorthand for getting an optional complementary behaviour of the same type on another block entity. This is designed for things such as multi-blocks, where you want to have the same behaviour on multiple block entities and have them interact with each other, but can also be used for other things such as linked machines.
      Example usage:
       if (controllerOffset != null && getLevel() != null) {
           final BlockPos controllerPos = getPos().offset(controllerOffset);
           this.<CogwheelChainComponentBehaviour>getComplementaryBehaviourOptional(controllerPos)
              .ifPresent(controller -> controller.chainsToRefund = 0);
       }
       
      Type Parameters:
      T - the type of the current behaviour, used to ensure the optional is of the correct type
      Parameters:
      otherBlockEntity - the other block entity to get the behaviour from
      Returns:
      an optional containing the complementary behaviour if it exists and is of the same type, or an empty optional if it doesn't exist, isn't loaded, or isn't of the same type.
    • getSameBehaviourOrThrow

      public <T extends SuperBlockEntityBehaviour> T getSameBehaviourOrThrow(net.minecraft.world.level.block.entity.BlockEntity otherBlockEntity)
      Shorthand for getting a complementary behaviour of the same type on another block entity, and expect it to exist. If you do not want to throw, then use getSameBehaviourOptional(BlockEntity) or getSameBehaviour(BlockEntity).
      Type Parameters:
      T - the type of the current behaviour, used to ensure the returned value is of the correct type
      Parameters:
      otherBlockEntity - the other block entity to get the behaviour from
      Returns:
      the complementary behaviour if it exists and is of the same type
      Throws:
      IllegalStateException - if the complementary behaviour does not exist or is of a different type
    • onBlockBroken

      public void onBlockBroken(net.neoforged.neoforge.event.level.BlockEvent.BreakEvent event)
    • onItemUse

      public void onItemUse(net.neoforged.neoforge.event.entity.player.PlayerInteractEvent.RightClickBlock event)
    • onBlockPlaced

      public void onBlockPlaced(net.neoforged.neoforge.event.level.BlockEvent.EntityPlaceEvent event)