Started by
CodeLovingBison
on
Topic category: Help with Minecraft modding (Java Edition)
For my mod, I need a procedure that counts mobs..
---------------------------------------------------------------------
Example: If there are 5 mobs nearby --> /say hi
---------------------------------------------------------------------
I know you can do it with /scoreboard command, but this procedure is made for entitys, so adding scoreboards for each mob is very frustrating...
---------------------------------------------------------------------
Please help! I will be very thankful to people, who can answer this hard question.
---------------------------------------------------------------------
Edited by CodeLovingBison on Sat, 04/24/2021 - 11:07
this isn't really hard to make in MCreator since 2020.5, which introduced the entity iterator in a procedure and makes this task easier! so here's how you can do it:
you can download the procedure at https://www.mediafire.com/file/r5787t3yh71tz1d/mob_counter.ptpl/file and import it in MCreator.
and that's all! :D
one small issue though: it sends a decimal (double) in the message instead of a whole number (integer), so something like 7 mobs around you would send "7.0" instead of just "7", which looks ugly (we're obviously counting mobs, so it's clear to use only whole numbers). but it's actually quite easy to fix by editing the code.
first, find where the local variable is declared. you will see that it looks like "double mob_count = 0", and in the next line is "mob_count = (double) 0". we don't want a double variable type, since it's a decimal number. so remove the line "mob_count = (double) 0;" and change "double" to "int".
after that, go find
and remove "(double)".
Example:
Every player tick update,
the variable mob_count is getting increased by 1
for each entity at XYZ in cube² with size 16.
As long as mob_count is => 5,
your fall distance is getting overridden with 0 blocks
for the next tick,
which means, you'll not being able to get
any fall damage the next tick.
Here's the picture.
O my god, thank you so much!
I can't thank you guys enough!!!
NOW MY DREAMS WILL COME TRUE!
haha, that's good to hear! go wild with what you can do under different conditions, there are so many possibilities with it by adapting the procedure! :)
Sorry for me being so annoying, but what do you think of my mod? (You can see it in my icon)
Its my first mod, and im really proud of it.
It even has dino stampedes!
I tried applying the same code but for nbt virables (since this procedure is made for entitys).
-------------------------------------------------------
Example: if there is an entity(of type) next to 5 custom_entitys, "say hi"
-------------------------------------------------------
And when I spawn a single entity(of type), (even tho, it needs to be more than one!)
next to my custom_entity, it executes the code "say hi" for every tick without stopping, unless you get out of range.
-------------------------------------------------------
Conclusion: 1. Executes the code without five entitys..
2.Executes the code for every tick (more than one time)..
-------------------------------------------------------
Here's the code: https://ibb.co/Mh3x4cY
-------------------------------------------------------
TRUST ME, ITS IMPORTANT!
-------------------------------------------------------
The code was written "On Entity Tick Update" of my custom entity...
Can I see your Mod a bit more nearly? Is it uploaded somewhere? Cus than I can say more about it. But the Dino in your icon looks cool!
The mod is currently is not released. Will be released (not soon). And thanks for asking!
If you want to see, I have some spoilers of the upcoming mobs wich live in the new cave biomes..
Morganocudon: (lives in big colony's underground): https://ibb.co/DVBrJy0
Gue Lizard: (A small lizard, wich lives in the new "Gue Caves" Gue in the caves.. Well call it sculks older brother.): https://ibb.co/20zKr4V