Class MountedItemStorage
java.lang.Object
com.simibubi.create.api.contraption.storage.item.MountedItemStorage
- All Implemented Interfaces:
net.neoforged.neoforge.items.IItemHandler,net.neoforged.neoforge.items.IItemHandlerModifiable
- Direct Known Subclasses:
CreativeCrateMountedStorage,WrapperMountedItemStorage
public abstract class MountedItemStorage
extends Object
implements net.neoforged.neoforge.items.IItemHandlerModifiable
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<MountedItemStorage> static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, MountedItemStorage> final MountedItemStorageType<? extends MountedItemStorage> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable net.minecraft.world.MenuProvidercreateMenuProvider(net.minecraft.network.chat.Component name, net.neoforged.neoforge.items.IItemHandlerModifiable handler, Predicate<net.minecraft.world.entity.player.Player> stillValid, Consumer<net.minecraft.world.entity.player.Player> onClose) protected net.neoforged.neoforge.items.IItemHandlerModifiablegetHandlerForMenu(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo info, Contraption contraption) Get the item handler that will be used by this storage's menu.protected net.minecraft.network.chat.ComponentgetMenuName(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo info, Contraption contraption) booleanhandleInteraction(net.minecraft.server.level.ServerPlayer player, Contraption contraption, net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo info) Handle a player clicking on this mounted storage.protected booleanisMenuValid(net.minecraft.server.level.ServerPlayer player, Contraption contraption, net.minecraft.world.phys.Vec3 pos) protected voidplayClosingSound(net.minecraft.server.level.ServerLevel level, net.minecraft.world.phys.Vec3 pos) Play the sound made by closing this storage's GUI.protected voidplayOpeningSound(net.minecraft.server.level.ServerLevel level, net.minecraft.world.phys.Vec3 pos) Play the sound made by opening this storage's GUI.abstract voidunmount(net.minecraft.world.level.Level level, net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.world.level.block.entity.BlockEntity be) Un-mount this storage back into the world.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.items.IItemHandler
extractItem, getSlotLimit, getSlots, getStackInSlot, insertItem, isItemValidMethods inherited from interface net.neoforged.neoforge.items.IItemHandlerModifiable
setStackInSlot
-
Field Details
-
CODEC
-
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,MountedItemStorage> STREAM_CODEC -
type
-
-
Constructor Details
-
MountedItemStorage
-
-
Method Details
-
unmount
public abstract 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) 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. -
handleInteraction
public boolean handleInteraction(net.minecraft.server.level.ServerPlayer player, Contraption contraption, net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo info) Handle a player clicking on this mounted storage. This is always called on the server. The default implementation will try to open a generic GUI for standard inventories. For this to work, this storage must have 1-6 complete rows of 9 slots.- Returns:
- true if the interaction was successful
-
getHandlerForMenu
protected net.neoforged.neoforge.items.IItemHandlerModifiable getHandlerForMenu(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo info, Contraption contraption) Get the item handler that will be used by this storage's menu. This is useful for handling multi-blocks, such as double chests. -
isMenuValid
protected boolean isMenuValid(net.minecraft.server.level.ServerPlayer player, Contraption contraption, net.minecraft.world.phys.Vec3 pos) - Parameters:
player- the player who opened the menupos- the center of this storage in-world- Returns:
- true if a GUI opened for this storage is still valid
-
getMenuName
protected net.minecraft.network.chat.Component getMenuName(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo info, Contraption contraption) - Returns:
- the title to be shown in the GUI when this storage is opened
-
createMenuProvider
@Nullable protected @Nullable net.minecraft.world.MenuProvider createMenuProvider(net.minecraft.network.chat.Component name, net.neoforged.neoforge.items.IItemHandlerModifiable handler, Predicate<net.minecraft.world.entity.player.Player> stillValid, Consumer<net.minecraft.world.entity.player.Player> onClose) - Returns:
- a MenuProvider that provides the menu players will see when opening this storage
-
playOpeningSound
protected void playOpeningSound(net.minecraft.server.level.ServerLevel level, net.minecraft.world.phys.Vec3 pos) Play the sound made by opening this storage's GUI. -
playClosingSound
protected void playClosingSound(net.minecraft.server.level.ServerLevel level, net.minecraft.world.phys.Vec3 pos) Play the sound made by closing this storage's GUI.
-