Wiki 9Minecraft Wiki 9Minecraft

Resupply Upgrade

Java EditionModGuides 4FAQ 10Items 5Blocks 2Gallery 4Recipes 9Related mods 60
DownloadSnes' Backpacks

Get the files on 9Minecraft

The resupply upgrade takes items from the backpack and places them in the player's inventory.

Technical Details

Every time a player performs a set of actions (event based), this is triggered and the logic is run. It goes as follows:

  • Check the resupply filter for items, and if it has some

    • Check the backpack for that item, and if it is present
      • Look through player's inventory for that item, and if they have a non-full stack
        • Increase the amount to full if you can, otherwise just as much as possible
          • Decrement that amount from the stackSize of the item in the backpack
  • You also have to make sure that the item being picked up doesn't interfere with this action if it is the same item.

  • The use cases for this event triggering are a bit complex as well.

  • Optimizations are possible. For example, onBlockPlaced means you can just look at the player's active slot for the stack to refill (unless you're using something like a builder's wand).

You can probably imagine this is one of the trickier upgrades to implement.