I want an item of mine to give an effect when it is inside of a backpack item that I made.

Started by m_ad_man on

Topic category: Feature requests and ideas for MCreator

Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I want an item of mine to give an effect when it is inside of a backpack item that I made.

I am making a "talisman" mod which contains items that give a potion effect while they are in the player's inventory. I have made a talisman bag with 9 slots and I would like to have the talisman bag give me the effects of the talismans inside of it, ie. regen, fire resistance, etc. I would like to ask if they could add a feature where the code can check if an item is in a certain inventory, or if there is already some way to do this.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If it's an item inside…
Wed, 01/17/2024 - 12:54

If it's an item inside another item's inventory, you won't be able to use the normal method. (using an itemstack iterator to check each slot of the player's inventory for an item, or simply using the 'item in inventory tick' trigger.) Instead, you will need to have the bag itself run a procedure. 

For the procedure, you want the bag to check each of its inventory slots, and add status effects corresponding to the talisman in each slot. You could do this by manually checking each inventory slot, or by using a recursive procedure. (You would make a repeat bracket that repeats nine times, and a local number variable I'll call 'bag-slot,' and then you would check the item in slot # 'bag-slot,' determine the status effect, and add +1 to 'bag-slot,' so the next time it repeats it checks the next slot.) For both methods, the 'get item in slot # of itemstack' should be a helpful function. 

You might also want to disable particles, (you can decide whether or not to have them enabled when you apply a potion effect), purely because multiple potion effects can get kind of distracting. ...Also, how about talismans that amplify or modify your other effects? Using some additional checks, and additional local number variables, you could pretty easily make a talisman that increases the potency or duration of other effects, or a tailsman that's more powerful the fewer tailsmans you have in the bag, tailsman that are more powerful in certain biomes/weather/times, etc. Sounds like a cool idea! 

Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
thank you! i will try and…
Wed, 01/17/2024 - 22:19

thank you! i will try and see if i can figure out how to do that.