Sign in
Skip to main content

Commands let players perform actions and customize gameplay using text-based instructions. Use this topic to share feedback and ideas for improving commands and related tools.

103

Inventory Locking

9 Comments

Post a new comment:

Please sign in to leave a comment.

Sorted by oldest
  • 2
    Registered User commented
    Comment actions Permalink

    How about the syntax will be:

    /replaceitem entity @p slot.mainhand diamond_sword 0 lock

  • 0
    Registered User commented
    Comment actions Permalink

    Could work but then (as far as I know) you wouldn't be able to have empty slots.

  • 1
    Registered User commented
    Comment actions Permalink

    It would also be useful if hoppers / dropped could not then put into / take out of these slots.

  • 0
    Registered User commented
    Comment actions Permalink

    This is something I have wanted to request for some time now. It definitely lags the game when setting up locked inventory slots using the current set-up, and on bedrock it prevents players from being able to put stuff in an anvil cause it just despawns. This is truly an essential command for maps that want to limit inventories or simply set up an inventory upgrade purchase in a custom store.

  • 1
    Registered User commented
    Comment actions Permalink

    Xela S

    No, I think /inventorylock makes much more sense.

  • 0
    Registered User commented
    Comment actions Permalink

    This is possible it's part of /replaceitem

  • 1
    Registered User commented
    Comment actions Permalink

    Maybe this could instead be some NBT that you put on an item so it works on anything that puts an item in a slot, e.g.

    /give @a minecraft:iron_sword{Locked:1b}
  • 0
    Registered User commented
    Comment actions Permalink

    a fink its god wen its a data component thats easyer to use wen drop a item by command or other things

  • 0
    Registered User commented
    Comment actions Permalink

    Here's how I'd do it:
    All slots are stored as NBT data so make all slots data driven. The helmet slot, for instance, could look like this:

    {
    head: {
        count: 1,
       filter: ["#minecraft:helmets"],
    id: "minecraft:diamond_helmet",
      isLocked: 0b
      }
    }

    A regular slot would look like this:

    {
    count: 1,
    filter: [],
    id: "minecraft:stone",
    isLocked: 0b,
     Slot: 0b
    }

    This way if isLocked is set to true, only commands can edit it (similar to Curse of Binding), and anything listed in filter limits what the slot can accept (similar to the current armor, fuel, etc slots).
    Whether it becomes its own command, or a branch off /item, you could use the slot sources as a shortcut to affecting specific slots.

    Either that, or swap out isLocked for a functionality enum. 'Both' = place and retrieve, 'Retrieve' = retrieve only (useful for 'result slots'), and 'None' = no interaction, command only.


    This change would allow datapack devs and map makers to achieve custom gameplay that we're already forcing using unnecessary tick commands that hurts the performance of the game.