6

Question: How to control the armor/equipment with which mobs spawnlive_help

ScotsMiser1/12/25 2:08 pm history
1/29/2025 4:38 am
mega7
How does one control the armor and equipment with which a mob spawns (e.g. zombie armor or drowned nautilus shells)?

So far, the only ways I can see are to either:

A) kill natural spawns and replace them with ones spawned via command[​s]
B) strip natural spawns of equipment/armor and 'requip' them via command[​s]

What I would prefer is to be able to modify the 'loot table' used during spawning (even better if this were available on a conditional basis).
Posted by
ScotsMiser
Level 57 : Grandmaster Miner
265

Create an account or sign in to comment.

19

mega7
01/28/2025 5:51 am
Level 47 : Master Muffin Engineer
history
I believe the only thing you can do in the worldgen folder is to straight up disable a mob from spawning completely, But just stopping them from having certain armors or tools by just editing one file is impossible to my knowledge.
You could just run a check on all mobs who are wearing the items you don't want them to be wearing, Put all the items you want to eliminate in one item tag file in your namespace, call it "unwanted_items.json" if you want.
Create 5 predicates, The first checks of a player has any of the unwanted armor pieces on any of his armor slots, If there are any, you run a function to check which exactly.
the other 4 predicates would check if a player has one of those unwanted armor pieces on each slot, so one for head chest leggings and boots.
(Predicates are very cheap when it comes to recourse management so create as many as you need)
And in the function ,which will run if the first predicate returns success, (any unwanted armor piece is found on any slot)
run the 4 commands which would check for each slot:

execute as @s if predicate (the predicate which checks the head slot) run item replace entity @s armor.head with air
execute as @s if predicate (the predicate which checks the chest slot) run item replace entity @s armor.chest with air
execute as @s if predicate (the predicate which checks the leggings slot) run item replace entity @s armor.legs with air
execute as @s if predicate (the predicate which checks the boots slot) run item replace entity @s armor.feet with air
2
mega7
01/28/2025 5:56 am
Level 47 : Master Muffin Engineer
history
P.S.
You should also create an entity tag for entities you want to check for. And in the tick.mcfunction the command should be:
execute as @e[type=#namespace:(entity tag name)] if predicate (the one that checks all slots) run function (the function that runs the 4 commands above)

You could also make use of the /return command to end a function early and reduce the amounts of functions needed and slightly upgrade performance but it barely changes anything so nevermind.

The thing I put above is a system to remove all unwanted armors (you can add one extra predicate if you also wanna check for tools), if you want another light weight system to add your own loot table to mobs I can give that too, it is almost the same way but with different things
2
ScotsMiser
01/28/2025 6:16 pm
Level 57 : Grandmaster Miner
Thank you, while you seem to be talking about lpayer armor/gear, I'm guressing simply changing the targeting would allow this system to work for mobs [e.g. the sort of thing I was discussing here Wither King [reskinned Wither Skelton] ]

Among you other helpful bits of info was that replace entity @s armor.head with airwould not result in somehow making airblocks obtainable…

As you can probably tell, I'm still quite new to the function/predicate/function fiddling 😊
2
mega7
01/29/2025 4:38 am
Level 47 : Master Muffin Engineer
It's fine lol
As long as whatever you wanted worked out that's awesome,
also there is truly no obtainable item called "air" block. there exists 3 types of airs, cave air, normal air and i forgot the last's name. but all can never be put in an item. and replacing anything with air or searching for air means that this place is empty
2
JackFire03
01/28/2025 3:22 am
Level 31 : Artisan Pokémon Pirate
It is hard code so you can either A or B. Or C, you can move to mod.
2
ScotsMiser
01/28/2025 4:16 am
Level 57 : Grandmaster Miner
How would one then be able to specify armor & gear with wich a mob spawned? (Preferably so as to emulate the function of a loot table)
1
JackFire03
01/28/2025 6:47 am
Level 31 : Artisan Pokémon Pirate
as far as i know, loot table control which loot they give when they die, shear, etc. They dont control which in their inventory when they spawn. You can control them via datapack by give the one you replace a tag then add the loot you want to loot table using that tag
2
ScotsMiser
01/28/2025 6:09 pm
Level 57 : Grandmaster Miner
Yes, it would probably have been clearer if I'd put 'loot table' in quotes…

My point was that (logically) there must be something structured roughly like a "loot table" that is used to generate the armor and equipment of spawning mobs and that I would like to be able to edit that "spawning_gear_table" directly.
1
JackFire03
01/28/2025 6:19 pm
Level 31 : Artisan Pokémon Pirate
Well didnt people already told you? You can't because it is hard code. You can only either A, B or C, move to mod/plugin. Datapack currently cant do such thing directly. There might in the near future cuz Mojang are overhauling these "hard code". You might try as well D, unpromising waiting for Mojang overhaul this so you can edit it directly.
2
ScotsMiser
01/28/2025 6:25 pm
Level 57 : Grandmaster Miner
No so definitively (and – unfortunately – not all of what one is told is perfectly correct).
[​Also unfortuntaely, MS/Mj does not seem to maintain/promulgate despositive documentation (at least for java, I've found something that may be such for br)]
2
imalittlhigh
01/15/2025 11:02 am
Level 64 : High Grandmaster Sweetheart Stack
only thing i can think of is that there is maybe something that can do this in worldgen but from having a quick look at misode i cant rly find anything that seems that useful
You could ofc rebuild the vanilla spawning algorithm and disable natural spawns but idk about reducing lag with that method ^^
2
ScotsMiser
01/16/2025 9:31 am
Level 57 : Grandmaster Miner
Yes, I looked there myself (just in case as I'd have thought mob spawning would be done afterwards) and couldn't find anyrthing relevant.

It seems to be that one must modify those the game genrerates as the tables for spawning do not seem accessible [ readily, if at all].
1
ICanGamez
01/14/2025 9:54 pm
He/Him • Level 55 : Grandmaster Blockhead Imposter
you could always do an /item replace entity @s armor.ARMOR_SLOT_HERE with ITEM_OF_CHOICE 1
and tag the entity like stop and then do execute unless tagged entity then the command
the item replace command can work for any slot but depends on if your trying to change a loot table or just what the entity has.
hope this finds you well!!
3
ScotsMiser
01/15/2025 12:19 am
Level 57 : Grandmaster Miner
Thank you for the reply, that does seem to be the direction this is going…
[​What I am still hoping to find is a way to modify the 'loot_tables' MC uses in spawning mobs in the first place… but am beginning to suspect that those are not accessible.]

I'd not thought of tagging checked instances of the mob type to avoid constant rechecking: that ought to make the approach significantly more efficient.
[​Looks like I need to study up on commands/functions]
2
ICanGamez
01/16/2025 5:09 pm
He/Him • Level 55 : Grandmaster Blockhead Imposter
Yeah sadly i think if your wanting to change what mobs wear idk if you can do it through loot tables, but this was the best answer i can pull rn. Unless your wanting to just change the loot dropped by mobs not counting their armor, other than that idk.
2
sniffercraft34
01/12/2025 2:21 pm
He/Him • Level 58 : Grandmaster Mythical Sniffer
You will need to detect a zombie without a tag, like armorZombie and then teleport it below and kill it, but before that summon a zombie with that tag
I can’t get the command yet because I’m on mobile, but I will when I can I will and I could also make a template for you
3
ScotsMiser
01/12/2025 2:38 pm
Level 57 : Grandmaster Miner
Thank you, that may represent part of the solution, but I think I've not been clear:
   what I'd like to do is be able to change the chances for various armor gear spawning with mobs; for instance to produce drowned that spawn wearing turtle shells or that have a 0% chance of having a fishing rod. (Ideally with a s little added lag as possible, thus my hope to be able to avoid the scan for / kill / replace option.)
2
sniffercraft34
01/13/2025 12:02 pm
He/Him • Level 58 : Grandmaster Mythical Sniffer
I don't really think there is a way to do that without at least some lag, sorry
That is the only way I know
2

Welcome