Class ExtendedContainerBlockEntity

java.lang.Object
net.minecraft.world.level.block.entity.BlockEntity
net.ixdarklord.coolcatcore.api.block.ExtendedBlockEntity
net.ixdarklord.coolcatcore.api.block.ExtendedContainerBlockEntity
All Implemented Interfaces:
HandlerProvider, net.minecraft.world.Clearable, net.minecraft.world.Container, net.minecraft.world.WorldlyContainer

public abstract class ExtendedContainerBlockEntity extends ExtendedBlockEntity implements net.minecraft.world.WorldlyContainer
A ExtendedBlockEntity with an inventory. The inventory is a container attachment, so it saves and syncs like the rest of the data; the block entity itself is a WorldlyContainer, so hoppers, comparators, menus, and other mods' pipes (on both loaders) use it through the layout's faces and roles.

 public static final Attachment<SlotContainer> INVENTORY = MyMod.ATTACHMENTS.container("crusher_inventory", CRUSHER_LAYOUT).build();

 public CrusherBlockEntity(BlockPos pos, BlockState state) {
     super(MyBlockEntities.CRUSHER.get(), pos, state, INVENTORY);
 }
 
The contents spill when the block is broken, unless the layout keeps them. Add .sync(SyncPolicy.ALL) to the attachment when clients need the contents without a menu open (to render them).
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.level.block.entity.BlockEntity

    net.minecraft.world.level.block.entity.BlockEntity.DataComponentInput
  • Field Summary

    Fields inherited from class net.ixdarklord.coolcatcore.api.block.ExtendedBlockEntity

    handlers

    Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity

    level, remove, worldPosition

    Fields inherited from interface net.minecraft.world.Container

    DEFAULT_DISTANCE_BUFFER
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ExtendedContainerBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, Attachment<SlotContainer> containerAttachment)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    applyImplicitComponents(net.minecraft.world.level.block.entity.BlockEntity.DataComponentInput components)
     
    boolean
    canPlaceItem(int slot, net.minecraft.world.item.ItemStack stack)
     
    boolean
    canPlaceItemThroughFace(int slot, net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.core.Direction side)
     
    boolean
    canTakeItem(net.minecraft.world.Container into, int slot, net.minecraft.world.item.ItemStack stack)
     
    boolean
    canTakeItemThroughFace(int slot, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction side)
     
    void
     
    protected void
    collectImplicitComponents(net.minecraft.core.component.DataComponentMap.Builder components)
     
    int
    The comparator signal of the contents, for the block's getAnalogOutputSignal.
     
     
    int
     
    <T> T
    getHandler(HandlerType<T> type, @Nullable net.minecraft.core.Direction side)
     
    net.minecraft.world.item.ItemStack
    getItem(int slot)
     
     
    int
     
    int
    getMaxStackSize(net.minecraft.world.item.ItemStack stack)
     
    int[]
    getSlotsForFace(net.minecraft.core.Direction side)
     
    boolean
     
    void
    preRemoveSideEffects(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    Runs on the server right before the block is replaced by another and this block entity removed (26.1's BlockEntity.preRemoveSideEffects, which 1.21.1 lacks; called from a mixin on the block state's removal).
    net.minecraft.world.item.ItemStack
    removeItem(int slot, int count)
     
    net.minecraft.world.item.ItemStack
     
    void
     
    void
    setItem(int slot, net.minecraft.world.item.ItemStack stack)
     
    boolean
    stillValid(net.minecraft.world.entity.player.Player player)
     

    Methods inherited from class net.ixdarklord.coolcatcore.api.block.ExtendedBlockEntity

    attachments, clientTick, get, invalidateHandlers, modify, serverTick, set, ticker, update

    Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity

    addEntityType, applyComponents, applyComponentsFromItemStack, clearRemoved, collectComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPosFromTag, getType, getUpdatePacket, getUpdateTag, hasLevel, isRemoved, isValidBlockState, loadAdditional, loadCustomOnly, loadStatic, loadWithComponents, onlyOpCanSetNbt, parseCustomNameSafe, removeComponentsFromTag, saveAdditional, saveCustomAndMetadata, saveCustomOnly, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setComponents, setLevel, setRemoved, triggerEvent

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.world.Container

    countItem, hasAnyMatching, hasAnyOf, startOpen, stopOpen
  • Constructor Details

    • ExtendedContainerBlockEntity

      protected ExtendedContainerBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, Attachment<SlotContainer> containerAttachment)
  • Method Details

    • getContainer

      public SlotContainer getContainer()
    • getContainerAttachment

      public Attachment<SlotContainer> getContainerAttachment()
    • getLayout

      public ContainerLayout getLayout()
    • getComparatorSignal

      public int getComparatorSignal()
      The comparator signal of the contents, for the block's getAnalogOutputSignal.
    • getHandler

      @Nullable public <T> T getHandler(HandlerType<T> type, @Nullable @Nullable net.minecraft.core.Direction side)
      Specified by:
      getHandler in interface HandlerProvider
      Overrides:
      getHandler in class ExtendedBlockEntity
      Parameters:
      side - the face asked through, or null for the holder as a whole (always null for most entity lookups)
      Returns:
      the handler, or null if this holder has none of that type on that side
    • setChanged

      public void setChanged()
      Specified by:
      setChanged in interface net.minecraft.world.Container
      Overrides:
      setChanged in class net.minecraft.world.level.block.entity.BlockEntity
    • preRemoveSideEffects

      public void preRemoveSideEffects(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
      Description copied from class: ExtendedBlockEntity
      Runs on the server right before the block is replaced by another and this block entity removed (26.1's BlockEntity.preRemoveSideEffects, which 1.21.1 lacks; called from a mixin on the block state's removal).
      Overrides:
      preRemoveSideEffects in class ExtendedBlockEntity
    • collectImplicitComponents

      protected void collectImplicitComponents(net.minecraft.core.component.DataComponentMap.Builder components)
      Overrides:
      collectImplicitComponents in class net.minecraft.world.level.block.entity.BlockEntity
    • applyImplicitComponents

      protected void applyImplicitComponents(net.minecraft.world.level.block.entity.BlockEntity.DataComponentInput components)
      Overrides:
      applyImplicitComponents in class net.minecraft.world.level.block.entity.BlockEntity
    • getSlotsForFace

      public int[] getSlotsForFace(net.minecraft.core.Direction side)
      Specified by:
      getSlotsForFace in interface net.minecraft.world.WorldlyContainer
    • canPlaceItemThroughFace

      public boolean canPlaceItemThroughFace(int slot, net.minecraft.world.item.ItemStack stack, @Nullable @Nullable net.minecraft.core.Direction side)
      Specified by:
      canPlaceItemThroughFace in interface net.minecraft.world.WorldlyContainer
    • canTakeItemThroughFace

      public boolean canTakeItemThroughFace(int slot, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction side)
      Specified by:
      canTakeItemThroughFace in interface net.minecraft.world.WorldlyContainer
    • getContainerSize

      public int getContainerSize()
      Specified by:
      getContainerSize in interface net.minecraft.world.Container
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface net.minecraft.world.Container
    • getItem

      public net.minecraft.world.item.ItemStack getItem(int slot)
      Specified by:
      getItem in interface net.minecraft.world.Container
    • removeItem

      public net.minecraft.world.item.ItemStack removeItem(int slot, int count)
      Specified by:
      removeItem in interface net.minecraft.world.Container
    • removeItemNoUpdate

      public net.minecraft.world.item.ItemStack removeItemNoUpdate(int slot)
      Specified by:
      removeItemNoUpdate in interface net.minecraft.world.Container
    • setItem

      public void setItem(int slot, net.minecraft.world.item.ItemStack stack)
      Specified by:
      setItem in interface net.minecraft.world.Container
    • getMaxStackSize

      public int getMaxStackSize()
      Specified by:
      getMaxStackSize in interface net.minecraft.world.Container
    • getMaxStackSize

      public int getMaxStackSize(net.minecraft.world.item.ItemStack stack)
      Specified by:
      getMaxStackSize in interface net.minecraft.world.Container
    • stillValid

      public boolean stillValid(net.minecraft.world.entity.player.Player player)
      Specified by:
      stillValid in interface net.minecraft.world.Container
    • canPlaceItem

      public boolean canPlaceItem(int slot, net.minecraft.world.item.ItemStack stack)
      Specified by:
      canPlaceItem in interface net.minecraft.world.Container
    • canTakeItem

      public boolean canTakeItem(net.minecraft.world.Container into, int slot, net.minecraft.world.item.ItemStack stack)
      Specified by:
      canTakeItem in interface net.minecraft.world.Container
    • clearContent

      public void clearContent()
      Specified by:
      clearContent in interface net.minecraft.world.Clearable