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:
Iterable<net.minecraft.world.item.ItemStack>, HandlerProvider, net.minecraft.core.TypedInstance<net.minecraft.world.level.block.entity.BlockEntityType<?>>, net.minecraft.util.debug.DebugValueSource, net.minecraft.world.Clearable, net.minecraft.world.Container, net.minecraft.world.entity.SlotProvider, 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 interface net.minecraft.world.Container
net.minecraft.world.Container.ContainerIteratorNested classes/interfaces inherited from interface net.minecraft.util.debug.DebugValueSource
net.minecraft.util.debug.DebugValueSource.Registration, net.minecraft.util.debug.DebugValueSource.ValueGetter<T> -
Field Summary
Fields inherited from class ExtendedBlockEntity
handlersFields inherited from class net.minecraft.world.level.block.entity.BlockEntity
level, remove, worldPositionFields inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_BUFFER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedExtendedContainerBlockEntity(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 TypeMethodDescriptionprotected voidapplyImplicitComponents(net.minecraft.core.component.DataComponentGetter components) booleancanPlaceItem(int slot, net.minecraft.world.item.ItemStack stack) booleancanPlaceItemThroughFace(int slot, net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.core.Direction side) booleancanTakeItem(net.minecraft.world.Container into, int slot, net.minecraft.world.item.ItemStack stack) booleancanTakeItemThroughFace(int slot, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction side) voidprotected voidcollectImplicitComponents(net.minecraft.core.component.DataComponentMap.Builder components) intThe comparator signal of the contents, for the block'sgetAnalogOutputSignal.int<T> TgetHandler(HandlerType<T> type, @Nullable net.minecraft.core.Direction side) net.minecraft.world.item.ItemStackgetItem(int slot) intintgetMaxStackSize(net.minecraft.world.item.ItemStack stack) int[]getSlotsForFace(net.minecraft.core.Direction side) booleanisEmpty()voidpreRemoveSideEffects(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) net.minecraft.world.item.ItemStackremoveItem(int slot, int count) net.minecraft.world.item.ItemStackremoveItemNoUpdate(int slot) voidvoidsetItem(int slot, net.minecraft.world.item.ItemStack stack) booleanstillValid(net.minecraft.world.entity.player.Player player) Methods inherited from class ExtendedBlockEntity
attachments, clientTick, get, invalidateHandlers, modify, serverTick, set, ticker, updateMethods inherited from class net.minecraft.world.level.block.entity.BlockEntity
addEntityType, applyComponents, applyComponentsFromItemStack, clearRemoved, collectComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getNameForReporting, getPosFromTag, getType, getUpdatePacket, getUpdateTag, hasLevel, isRemoved, isValidBlockState, loadAdditional, loadCustomOnly, loadStatic, loadWithComponents, parseCustomNameSafe, problemPath, registerDebugValues, removeComponentsFromTag, saveAdditional, saveCustomOnly, saveCustomOnly, saveWithFullMetadata, saveWithFullMetadata, saveWithId, saveWithoutMetadata, saveWithoutMetadata, setBlockState, setChanged, setComponents, setLevel, setRemoved, triggerEvent, typeHolderMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.world.Container
countItem, getEntitiesWithContainerOpen, getSlot, hasAnyMatching, hasAnyOf, iterator, startOpen, stopOpenMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface net.minecraft.world.entity.SlotProvider
getSlotsFromRangeMethods inherited from interface net.minecraft.core.TypedInstance
is, is, is, is, is, tags
-
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
-
getContainerAttachment
-
getLayout
-
getComparatorSignal
public int getComparatorSignal()The comparator signal of the contents, for the block'sgetAnalogOutputSignal. -
getHandler
@Nullable public <T> T getHandler(HandlerType<T> type, @Nullable @Nullable net.minecraft.core.Direction side) - Specified by:
getHandlerin interfaceHandlerProvider- Overrides:
getHandlerin classExtendedBlockEntity- Parameters:
side- the face asked through, ornullfor the holder as a whole (alwaysnullfor most entity lookups)- Returns:
- the handler, or
nullif this holder has none of that type on that side
-
setChanged
public void setChanged()- Specified by:
setChangedin interfacenet.minecraft.world.Container- Overrides:
setChangedin classnet.minecraft.world.level.block.entity.BlockEntity
-
preRemoveSideEffects
public void preRemoveSideEffects(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) - Overrides:
preRemoveSideEffectsin classnet.minecraft.world.level.block.entity.BlockEntity
-
collectImplicitComponents
protected void collectImplicitComponents(net.minecraft.core.component.DataComponentMap.Builder components) - Overrides:
collectImplicitComponentsin classnet.minecraft.world.level.block.entity.BlockEntity
-
applyImplicitComponents
protected void applyImplicitComponents(net.minecraft.core.component.DataComponentGetter components) - Overrides:
applyImplicitComponentsin classnet.minecraft.world.level.block.entity.BlockEntity
-
getSlotsForFace
public int[] getSlotsForFace(net.minecraft.core.Direction side) - Specified by:
getSlotsForFacein interfacenet.minecraft.world.WorldlyContainer
-
canPlaceItemThroughFace
public boolean canPlaceItemThroughFace(int slot, net.minecraft.world.item.ItemStack stack, @Nullable @Nullable net.minecraft.core.Direction side) - Specified by:
canPlaceItemThroughFacein interfacenet.minecraft.world.WorldlyContainer
-
canTakeItemThroughFace
public boolean canTakeItemThroughFace(int slot, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction side) - Specified by:
canTakeItemThroughFacein interfacenet.minecraft.world.WorldlyContainer
-
getContainerSize
public int getContainerSize()- Specified by:
getContainerSizein interfacenet.minecraft.world.Container
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfacenet.minecraft.world.Container
-
getItem
public net.minecraft.world.item.ItemStack getItem(int slot) - Specified by:
getItemin interfacenet.minecraft.world.Container
-
removeItem
public net.minecraft.world.item.ItemStack removeItem(int slot, int count) - Specified by:
removeItemin interfacenet.minecraft.world.Container
-
removeItemNoUpdate
public net.minecraft.world.item.ItemStack removeItemNoUpdate(int slot) - Specified by:
removeItemNoUpdatein interfacenet.minecraft.world.Container
-
setItem
public void setItem(int slot, net.minecraft.world.item.ItemStack stack) - Specified by:
setItemin interfacenet.minecraft.world.Container
-
getMaxStackSize
public int getMaxStackSize()- Specified by:
getMaxStackSizein interfacenet.minecraft.world.Container
-
getMaxStackSize
public int getMaxStackSize(net.minecraft.world.item.ItemStack stack) - Specified by:
getMaxStackSizein interfacenet.minecraft.world.Container
-
stillValid
public boolean stillValid(net.minecraft.world.entity.player.Player player) - Specified by:
stillValidin interfacenet.minecraft.world.Container
-
canPlaceItem
public boolean canPlaceItem(int slot, net.minecraft.world.item.ItemStack stack) - Specified by:
canPlaceItemin interfacenet.minecraft.world.Container
-
canTakeItem
public boolean canTakeItem(net.minecraft.world.Container into, int slot, net.minecraft.world.item.ItemStack stack) - Specified by:
canTakeItemin interfacenet.minecraft.world.Container
-
clearContent
public void clearContent()- Specified by:
clearContentin interfacenet.minecraft.world.Clearable
-