Preventing More Than 1 item in Inventory

Started by Alec Cature on

Topic category: Help with modding (Java Edition)

Last seen on 15:47, 1. Jun 2024
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Preventing More Than 1 item in Inventory

Hello, I'm making a backpack item for my mod that I wish to only have 1 of at a time, but I can't prevent players from placing extra ones in their inventory.

I'm currently able to prevent pickups by cancelling the 'Entity picks up item' trigger and its already set to max stack size 1, but I can't figure out how to prevent the following:
- Clicking and dragging backpack into inventory
- Shift-clicking backpack into inventory
- Recently crafted backpacks being placed in inventory
- Any other method to place more than 1 into the inventory

I do NOT want the extra backpack to be deleted, and if possible, would like the backpack to remain on the cursor similar to how you can't place an item in an output slot.

Last seen on 15:47, 1. Jun 2024
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't seem to get this to…
Thu, 03/21/2024 - 21:23

I can't seem to get this to work with 'in inventory tick' triggers either because I can't find a way to detect when there's more than 1, let alone only dropping the extra one and not both if you do.

Any help would be greatly appreciated!