Class ShelfBlockEntity

java.lang.Object
net.minecraft.block.entity.BlockEntity
net.minecraft.block.entity.ShelfBlockEntity
All Implemented Interfaces:
Iterable<ItemStack>, Inventory, ListInventory, Clearable, HeldItemContext, DebugTrackable

public class ShelfBlockEntity extends BlockEntity implements HeldItemContext, ListInventory
Mappings:
Namespace Name
named net/minecraft/block/entity/ShelfBlockEntity
intermediary net/minecraft/class_11597
official ehv
  • Field Details

    • SLOT_COUNT

      public static final int SLOT_COUNT
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named SLOT_COUNT Lnet/minecraft/block/entity/ShelfBlockEntity;SLOT_COUNT:I
      intermediary field_61441 Lnet/minecraft/class_11597;field_61441:I
      official b Lehv;b:I
    • LOGGER

      private static final Logger LOGGER
      Mappings:
      Namespace Name Mixin selector
      named LOGGER Lnet/minecraft/block/entity/ShelfBlockEntity;LOGGER:Lorg/slf4j/Logger;
      intermediary field_61442 Lnet/minecraft/class_11597;field_61442:Lorg/slf4j/Logger;
      official c Lehv;c:Lorg/slf4j/Logger;
    • ALIGN_ITEMS_TO_BOTTOM_KEY

      private static final String ALIGN_ITEMS_TO_BOTTOM_KEY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named ALIGN_ITEMS_TO_BOTTOM_KEY Lnet/minecraft/block/entity/ShelfBlockEntity;ALIGN_ITEMS_TO_BOTTOM_KEY:Ljava/lang/String;
      intermediary field_62078 Lnet/minecraft/class_11597;field_62078:Ljava/lang/String;
      official d Lehv;d:Ljava/lang/String;
    • heldStacks

      private final DefaultedList<ItemStack> heldStacks
      Mappings:
      Namespace Name Mixin selector
      named heldStacks Lnet/minecraft/block/entity/ShelfBlockEntity;heldStacks:Lnet/minecraft/util/collection/DefaultedList;
      intermediary field_61443 Lnet/minecraft/class_11597;field_61443:Lnet/minecraft/class_2371;
      official e Lehv;e:Ljt;
    • alignItemsToBottom

      private boolean alignItemsToBottom
      Mappings:
      Namespace Name Mixin selector
      named alignItemsToBottom Lnet/minecraft/block/entity/ShelfBlockEntity;alignItemsToBottom:Z
      intermediary field_62079 Lnet/minecraft/class_11597;field_62079:Z
      official f Lehv;f:Z
  • Constructor Details

    • ShelfBlockEntity

      public ShelfBlockEntity(BlockPos pos, BlockState state)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/block/entity/ShelfBlockEntity;<init>(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V
      intermediary <init> Lnet/minecraft/class_11597;<init>(Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;)V
      official <init> Lehv;<init>(Lja;Lejm;)V
  • Method Details

    • readData

      protected void readData(ReadView view)
      Reads data from nbt. Subclasses should override this if they store a persistent data.

      NBT is a storage format; therefore, a data from NBT is loaded to a block entity instance's fields, which are used for other operations instead of the NBT. The data is written back to NBT when saving the block entity.

      nbt might not have all expected keys, or might have a key whose value does not meet the requirement (such as the type or the range). This method should fall back to a reasonable default value instead of throwing an exception.

      Overrides:
      readData in class BlockEntity
      See Also:
      • invalid reference
        #writeNbt
      Mappings:
      Namespace Name Mixin selector
      named readData Lnet/minecraft/block/entity/BlockEntity;readData(Lnet/minecraft/storage/ReadView;)V
      intermediary method_11014 Lnet/minecraft/class_2586;method_11014(Lnet/minecraft/class_11368;)V
      official a Legg;a(Lfip;)V
    • writeData

      protected void writeData(WriteView view)
      Writes data to nbt. Subclasses should override this if they store a persistent data.

      NBT is a storage format; therefore, a data from NBT is loaded to a block entity instance's fields, which are used for other operations instead of the NBT. The data is written back to NBT when saving the block entity.

      Overrides:
      writeData in class BlockEntity
      See Also:
      • invalid reference
        #readNbt
      Mappings:
      Namespace Name Mixin selector
      named writeData Lnet/minecraft/block/entity/BlockEntity;writeData(Lnet/minecraft/storage/WriteView;)V
      intermediary method_11007 Lnet/minecraft/class_2586;method_11007(Lnet/minecraft/class_11372;)V
      official a Legg;a(Lfir;)V
    • toUpdatePacket

      public BlockEntityUpdateS2CPacket toUpdatePacket()
      Description copied from class: BlockEntity
      Returns the packet to send to nearby players when the block entity's observable state changes, or null to not send the packet.

      If the data returned by initial chunk data is suitable for updates, the following shortcut can be used to create an update packet: BlockEntityUpdateS2CPacket.create(this). The NBT will be passed to

      invalid reference
      #readNbt
      on the client.

      "Observable state" is a state that clients can observe without specific interaction. For example, CampfireBlockEntity's cooked items are observable states, but chests' inventories are not observable states, since the player must first open that chest before they can see the contents.

      To sync block entity data using this method, use serverWorld.getChunkManager().markForUpdate(this.getPos());.

      Overrides:
      toUpdatePacket in class BlockEntity
      Returns:
      the packet to send to nearby players when the block entity's observable state changes, or null to not send the packet
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named toUpdatePacket Lnet/minecraft/block/entity/ShelfBlockEntity;toUpdatePacket()Lnet/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket;
      intermediary method_72667 Lnet/minecraft/class_11597;method_72667()Lnet/minecraft/class_2622;
      official k Lehv;k()Lacx;
    • toInitialChunkDataNbt

      public NbtCompound toInitialChunkDataNbt(RegistryWrapper.WrapperLookup registries)
      Returns the serialized state of this block entity that is observable by clients.

      This is sent alongside the initial chunk data, as well as when the block entity implements toUpdatePacket() and decides to use the default BlockEntityUpdateS2CPacket.

      "Observable state" is a state that clients can observe without specific interaction. For example, CampfireBlockEntity's cooked items are observable states, but chests' inventories are not observable states, since the player must first open that chest before they can see the contents.

      To send all NBT data of this block entity saved to disk, return BlockEntity.createNbt(net.minecraft.registry.RegistryWrapper.WrapperLookup).

      Overrides:
      toInitialChunkDataNbt in class BlockEntity
      Returns:
      the serialized state of this block entity that is observable by clients
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named toInitialChunkDataNbt Lnet/minecraft/block/entity/BlockEntity;toInitialChunkDataNbt(Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Lnet/minecraft/nbt/NbtCompound;
      intermediary method_16887 Lnet/minecraft/class_2586;method_16887(Lnet/minecraft/class_7225$class_7874;)Lnet/minecraft/class_2487;
      official a Legg;a(Ljm$a;)Lup;
    • getHeldStacks

      public DefaultedList<ItemStack> getHeldStacks()
      Specified by:
      getHeldStacks in interface ListInventory
      Mappings:
      Namespace Name Mixin selector
      named getHeldStacks Lnet/minecraft/inventory/ListInventory;getHeldStacks()Lnet/minecraft/util/collection/DefaultedList;
      intermediary method_72652 Lnet/minecraft/class_11596;method_72652()Lnet/minecraft/class_2371;
      official h Lehp;h()Ljt;
    • canPlayerUse

      public boolean canPlayerUse(PlayerEntity player)
      Specified by:
      canPlayerUse in interface Inventory
      Returns:
      whether player can use this inventory
      See Also:
      API Note:
      Implementations should check the distance between the inventory holder and player. For convenience, this interface offers two methods used by block entities to implement this check.
      Mappings:
      Namespace Name Mixin selector
      named canPlayerUse Lnet/minecraft/inventory/Inventory;canPlayerUse(Lnet/minecraft/entity/player/PlayerEntity;)Z
      intermediary method_5443 Lnet/minecraft/class_1263;method_5443(Lnet/minecraft/class_1657;)Z
      official a Lcbj;a(Lczl;)Z
    • swapStackNoMarkDirty

      public ItemStack swapStackNoMarkDirty(int slot, ItemStack stack)
      Mappings:
      Namespace Name Mixin selector
      named swapStackNoMarkDirty Lnet/minecraft/block/entity/ShelfBlockEntity;swapStackNoMarkDirty(ILnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;
      intermediary method_72666 Lnet/minecraft/class_11597;method_72666(ILnet/minecraft/class_1799;)Lnet/minecraft/class_1799;
      official d Lehv;d(ILdhp;)Ldhp;
    • markDirty

      public void markDirty(RegistryEntry.Reference<GameEvent> gameEvent)
      Mappings:
      Namespace Name Mixin selector
      named markDirty Lnet/minecraft/block/entity/ShelfBlockEntity;markDirty(Lnet/minecraft/registry/entry/RegistryEntry$Reference;)V
      intermediary method_72665 Lnet/minecraft/class_11597;method_72665(Lnet/minecraft/class_6880$class_6883;)V
      official a Lehv;a(Ljk$c;)V
    • markDirty

      public void markDirty()
      Marks this block entity as dirty and that it needs to be saved. This also triggers comparator update.

      This must be called when something changed in a way that affects the saved NBT; otherwise, the game might not save the block entity.

      Specified by:
      markDirty in interface Inventory
      Overrides:
      markDirty in class BlockEntity
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named markDirty Lnet/minecraft/block/entity/BlockEntity;markDirty()V
      intermediary method_5431 Lnet/minecraft/class_2586;method_5431()V
      official e Legg;e()V
    • readComponents

      protected void readComponents(ComponentsAccess components)
      Overrides:
      readComponents in class BlockEntity
      Mappings:
      Namespace Name Mixin selector
      named readComponents Lnet/minecraft/block/entity/BlockEntity;readComponents(Lnet/minecraft/component/ComponentsAccess;)V
      intermediary method_57568 Lnet/minecraft/class_2586;method_57568(Lnet/minecraft/class_9473;)V
      official a Legg;a(Lkk;)V
    • addComponents

      protected void addComponents(ComponentMap.Builder builder)
      Overrides:
      addComponents in class BlockEntity
      Mappings:
      Namespace Name Mixin selector
      named addComponents Lnet/minecraft/block/entity/BlockEntity;addComponents(Lnet/minecraft/component/ComponentMap$Builder;)V
      intermediary method_57567 Lnet/minecraft/class_2586;method_57567(Lnet/minecraft/class_9323$class_9324;)V
      official a Legg;a(Lkm$a;)V
    • removeFromCopiedStackData

      public void removeFromCopiedStackData(WriteView view)
      Overrides:
      removeFromCopiedStackData in class BlockEntity
      Mappings:
      Namespace Name Mixin selector
      named removeFromCopiedStackData Lnet/minecraft/block/entity/BlockEntity;removeFromCopiedStackData(Lnet/minecraft/storage/WriteView;)V
      intermediary method_57569 Lnet/minecraft/class_2586;method_57569(Lnet/minecraft/class_11372;)V
      official b Legg;b(Lfir;)V
    • getEntityWorld

      public World getEntityWorld()
      Specified by:
      getEntityWorld in interface HeldItemContext
      Mappings:
      Namespace Name Mixin selector
      named getEntityWorld Lnet/minecraft/util/HeldItemContext;getEntityWorld()Lnet/minecraft/world/World;
      intermediary method_73183 Lnet/minecraft/class_11566;method_73183()Lnet/minecraft/class_1937;
      official an Lces;an()Ldrq;
    • getEntityPos

      public Vec3d getEntityPos()
      Specified by:
      getEntityPos in interface HeldItemContext
      Mappings:
      Namespace Name Mixin selector
      named getEntityPos Lnet/minecraft/util/HeldItemContext;getEntityPos()Lnet/minecraft/util/math/Vec3d;
      intermediary method_73189 Lnet/minecraft/class_11566;method_73189()Lnet/minecraft/class_243;
      official dD Lces;dD()Lfoh;
    • getBodyYaw

      public float getBodyYaw()
      Specified by:
      getBodyYaw in interface HeldItemContext
      Mappings:
      Namespace Name Mixin selector
      named getBodyYaw Lnet/minecraft/util/HeldItemContext;getBodyYaw()F
      intermediary method_73188 Lnet/minecraft/class_11566;method_73188()F
      official dY Lces;dY()F
    • shouldAlignItemsToBottom

      public boolean shouldAlignItemsToBottom()
      Mappings:
      Namespace Name Mixin selector
      named shouldAlignItemsToBottom Lnet/minecraft/block/entity/ShelfBlockEntity;shouldAlignItemsToBottom()Z
      intermediary method_73326 Lnet/minecraft/class_11597;method_73326()Z
      official l Lehv;l()Z