Can't find my way in Mcreator

Started by AnotherDimension on

Topic category: Help with MCreator software

Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can't find my way in Mcreator

Halloj. I really like this Mcreator idea. Making modding easier for the average person is a stroke of genius.

Though I am brand new to this and can't really seem to get a grasp on how to make my mod. So I thought I'd ask for help :)

 

Here's the idea where I stumbled: An enchantment 'Picky' for the Bundle. Any item stored in a 'Picky Bundle' won't get picked up by the player. The concept's simple but I'm at a loss at how to do it 🤷‍♂️

 

So that's one☝ And the ✌ idea is for Bundles in general - While moving things around in inventory you'd shift + left/right click a Bundle to cycle the selected item with the next/previous bundled item (so shift + right click would give you the item at the bottom of the Bundle). It's just so clunky to have to take out every overlying item of what you're after.
The shift + right/left click can be any button combination really. To me that just felt like the most intuitive.

 

That's all! 😃

Thank you beforehand ! 😄

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you're looking for some…
Mon, 10/30/2023 - 12:37

If you're looking for some good tutorials, NorthWestTrees is a great way to get started with MCreator. Sometimes the best way to learn is to watch someone else work their way through stuff. Can't guarantee they'll have specifically what you need, but very useful just for some general stuff!

For your specific problem... item pickups are pretty difficult to mess with, they're one of those parts of the game that's kind of hard coded. There is probably a way to do this with custom code, but it's honestly above both of our paygrades.

Normally you would use itemstack iterators for something like this, (a special kind of function that lets you target every slot in the player's inventory), but this quickly gets really complicated: you would need one iterator to check if the player has an enchanted bundle, a second iterator to check the contents of that bundle, and then a third iterator to run back through the player's inventory for each slot in the bundle and check for matching items. This quickly gets horribly complicated, so you might wanna simplify it a bit by splitting it up into multiple procedures. (Partly 'cause I'm not totally sure myself if this many nested itemstack iterators would actually work.) 

  • You first want to make three player-persistent variables. (You can add custom variables in the 'variables' tab in your main workspaces. These are global variables, which means they're permanent in the world.) I'll call the first one 'has_picky_bundle,' (a logic variable that defaults to false),  the second one 'bundle_slot.' (a number variable that defaults to negative one), and the third one 'current_item.' (An itemstack variable that defaults to air.)
  • Then, for procedure 1, you want to first create a local number variable. (I'm calling it 'slot_number'), and a local logic variable, 'finished,' set to false by default. Local variables are like global variables, but they only run inside procedures, and are deleted when the procedure is finished. 
    • Set the global trigger of procedure 1 to 'on player update tick.' First, check if the player has a bundle in their inventory. (You don't need to run the procedure otherwise.) Then, add a repeat bracket set to repeat 27 times. (The number of slots in a player's inventory.) 
    • Inside, check if 'finished' is false. If it is, check if the item in slot 'slot_number' is a bundle, and has the 'Picky' enchantment, and then set 'slot_number' to itself, plus one. (This is like an itemstack iterator, except the variable means you can tell which slot you're currently on, which is important.) 
    • If an enchanted bundle is found, set 'finished' to true, (so it stops searching), set the global variable 'has_picky_bundle' to true, and 'bundle_slot' to whatever 'slot_number' is. (You now know the player has an enchanted bundle, and what slot it's in. Keeping in mind slot numbers start from zero and count up.) 
    • If at any time it doesn't find a bundle, you want to set 'has_picky_bundle' back to false, 'current_item' back to air, and 'slot_number' back to negative one. 
  • For procedure 2, you also want to set the global trigger to player update tick. Before running anything, check if the player's global variable 'has_picky_bundle' is true. This time you want to make a local itemstack variable, (I'll call it 'current_item,' and another local number variable, 'slot_number.'
    • Then, you want to make another repeat bracket, this time repeating 64 times. (The number of slots in a bundle.) Each time, set 'current_item' to the item in slot 'slot_number' of the bundle in slot 'bundle_slot' of the player's inventory. (I apologize in advance for this sentence.) 
    • Then, run procedure 3. (You can do this using the 'call procedure' function, in the advanced tab.)
    •  Then again set 'slot_number' to itself plus one, and set 'current_item' back to air.
  • And lastly, procedure 3 doesn't need to have any global trigger. You'll only be calling it from procedure 2. You again need to make a local 'slot_number' variable. (And 'thrown_item_number' local itemstack and number variables.)
    • First, check if the player has 'current_item' in their inventory. (Remember, current_item is whatever item from the bundle that the procedure is currently looking for.) 
    • If they do, run a repeat bracket again. It's basically just copy-and-paste from procedure 1, except now you're checking if the item in 'slot_number' matches 'current_item.' If it does, replace the item in slot 'slot_number'  with air, (if you want to destroy stuff).
    • If you instead want to launch stuff out of the player's inventory, set 'thrown_item_number' to the number of items in 'slot_number,' and then in a repeat bracket set to repeat 'thrown_item_number' times, spawn an itemstack 'current_item' with a really long pickup delay and really high velocity. (You could also just use another itemstack variable to just drop the stack as is, but launching every single item individually seems way more entertaining.)

...Suffice it to say, way more complicated than even I expected going into this. I promise not all modding stuff is this elaborate, you just happened to pick a really complicated issue! I can send some example screenshots if that would help.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh, and if you want a…
Mon, 10/30/2023 - 12:38

Oh, and if you want a slightly simpler way of doing this, you could just do procedures  1 and 2, (up to the point where you're going through each individual item from the bundle), but then just do an entity iterator and despawn an entities in a small radius that are both an itemstack and the same itemstack as the player's 'current_item,' essentially just despawning any itemstacks that are also in the player's bundle.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
And for procedure 2, you don…
Mon, 10/30/2023 - 12:41

And for procedure 2, you don't need a 'current_Item' local variable, just the global one, that's a mistake.

Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is a lot of info. Thank…
Wed, 12/06/2023 - 17:37

This is a lot of info. Thank you so much, Mind!