Class SimpleMountedStorage

java.lang.Object
com.simibubi.create.api.contraption.storage.item.MountedItemStorage
com.simibubi.create.api.contraption.storage.item.WrapperMountedItemStorage<net.neoforged.neoforge.items.ItemStackHandler>
com.simibubi.create.api.contraption.storage.item.simple.SimpleMountedStorage
All Implemented Interfaces:
net.neoforged.neoforge.items.IItemHandler, net.neoforged.neoforge.items.IItemHandlerModifiable
Direct Known Subclasses:
ChestMountedStorage, DispenserMountedStorage, FallbackMountedStorage

public class SimpleMountedStorage extends WrapperMountedItemStorage<net.neoforged.neoforge.items.ItemStackHandler>
Widely-applicable mounted storage implementation. Gets an item handler from the mounted block, copies it to an ItemStackHandler, and then copies the inventory back to the target when unmounting. All blocks for which this mounted storage is registered must provide an IItemHandlerModifiable to Capabilities.ItemHandler.BLOCK.
To use this implementation, either register AllMountedStorageTypes.SIMPLE to your block manually, or add your block to the AllTags.AllBlockTags.SIMPLE_MOUNTED_STORAGE tag. It is also possible to extend this class to create your own implementation.
  • Field Details

  • Constructor Details

    • SimpleMountedStorage

      public SimpleMountedStorage(MountedItemStorageType<?> type, net.neoforged.neoforge.items.IItemHandler handler)
    • SimpleMountedStorage

      public SimpleMountedStorage(net.neoforged.neoforge.items.IItemHandler handler)
  • Method Details

    • unmount

      public void unmount(net.minecraft.world.level.Level level, net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.world.level.block.entity.BlockEntity be)
      Description copied from class: MountedItemStorage
      Un-mount this storage back into the world. The expected storage type of the target block has already been checked to make sure it matches this storage's type.
      Specified by:
      unmount in class MountedItemStorage
    • validate

      protected Optional<net.neoforged.neoforge.items.IItemHandlerModifiable> validate(net.neoforged.neoforge.items.IItemHandler handler)
      Make sure the targeted handler is valid for copying items back into. It is highly recommended to call super in overrides.
    • codec

      public static <T extends SimpleMountedStorage> com.mojang.serialization.MapCodec<T> codec(Function<net.neoforged.neoforge.items.IItemHandler,T> factory)