Mob Spawner AI Issue and How to Potentially Fix It

Discussion in 'Suggestions' started by I_am_Merp, Apr 15, 2020.

  1. So, recently I've seen people complaining about how entities that are spawned from spawners have no AI, even when reloading the chunk. To tell you the truth, I sort of understand why that is a thing, and that's so that the public mob farms are less dangerous to newer players. So I've devised a solution, of sorts. Have the server tick for an entity that has AI within the public mob farm, then give it no AI if detected using the following command:
    data merge entity @e[type=!player,type=!wolf,type=!cat,sort=nearest,limit=1,nbt={NoAI:0b},x=4827,dx=4733,z=-4325,dz=-4258] {NoAI:1b}
    Quick rundown for those of you who aren't huge nerds like I am and are asking what branch of the English language this is coming from, basically this is testing for all entities that are not players, wolves, or cats (wolves and cats are included so that pets don't get endlessly stuck in the mob farms.) Then, it's sorting for the nearest entity with the NoAI tag disabled. It's searching for these within the given coordinates (they have been grabbed from the server itself by me) and then modifying their data so that they have no AI. This will allow mob farms other than the public ones to have entities with AI. Another reason why I have made it only look for entities with the NoAI tag set to 0b is so that the server doesn't lag as a result of the command spam. Although it does spam the command, it will only execute if there is an entity for it to check for, otherwise it will not run.
     
    Last edited: Apr 15, 2020
  2. It's not really about danger, it's more about lag. With the coronavirus, the server has a lot more players, so to increase TPS they put a lot of optimisations and changes, including completely removing spawned mob AI. A command running every tick looping through every entity on the server would have a huge impact. Hopefully they'll either improve the server hardware, or remove the limitations when the player count decreases again.
     
  3. Fair point, though my hope was that it would be put in the public mob spawner warp so it wouldn't lag a huge amount if it's sorting through the nearest entity without the set parameters instead of sorting through every entity on the server. To pile onto that, it could be run as a bukkit plugin in order to save resources rather than as a command block, which also spends resources ticking every other player's game. To combat that, the bukkit plugin applies it to the server client first, then sends the data out, which is the main reason why it would be faster in the first place. TL;DR - That is true, but it can also be optimized via the usage of plugins.
     
  4. By the public mob farm do you mean mob warp? Why apply AI to mobs in there? People want their mobs to have AI so villagers work in iron farms, bees work in bee farms etc. And yes, sure a plugin could decrease the impact somewhat, but I'm not sure what you mean by "spends resources ticking every other player's game". Command blocks have no interaction with players clients directly. And plugins would cause nearly as much lag as the command option, they still need to get a list of all entities, compare each one against a list of conditions, and apply a new tag to the ones that match every single tick.
     
  5. To answer your questions: yes, I did mean the mob warp. What I was saying was that it should apply NO AI to the mobs there so that other spawners in the world would allow mobs to spawn with AI. By "spends resources ticking every other player's game," I meant it'd have a lesser impact on players if the command block is only ticking from the server via a plugin. By that, I meant using the same plugin to disable mob AI from spawners to enable all mob AI from every other spawner except those ones so that players can properly use farms without them breaking. I agree that even then, having the server tick for entities with the specific parameters every in-game tick is taxing, but like I said, the same plugin could be used to only apply it to the mobs being spawned from those spawners. Maybe even add a plugin that allows players to turn on mob AI from specific spawners if that's too much.
     
  6. The mob warp only creates a very small amount of the mob spawns on the server. There are maybe 10 spawners at mob warp, and thousands in the rest of the server. Does "only apply it to the mobs being spawned from those spawners" mean "every other spawner apart from those in mob warp"? I don't think there is a plugin which does that, the setting is server-wide, not spawner specific.
     
  7. No, what I meant was to only run the plugin within a certain radius of the given coordinates, which I'm sure does exist.