[SPIGOT-6278] Persistent piglins count towards mob cap Created: 15/Dec/20 Updated: 02/Jan/22 Resolved: 02/Jan/22 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | Bowserinator | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 4 |
Labels: | mobcap, piglin, spawning, spawnreason | ||
Environment: |
Windows 10 |
Version: | CraftBukkit git-Spigot-628435a-768d7fc (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT) |
Guidelines Read: | Yes |
Description |
Piglins with the persistence tag set to true after they have spawned (for example, naming piglins, or piglins that have picked up golden shovels) count towards the mob cap, which is not vanilla behavior. This has the effect that a lot of nametagged mobs, for example, can stop mobs from spawning when loaded by filling the mob cap. This affected my barter farm (which stops all other nether farms from working due to the piglins being loaded, which wouldn't happen in vanilla) and my wither skeleton farm (which uses nametagged piglins, so rates are much lower in spigot than vanilla).
Server config: spigot default Tested with fresh server, no plugins
Steps to reproduce:
You can further verify by:
EDIT: this issue only affects piglins, thanks Airtheon for testing |
Comments |
Comment by Josh B [ 01/Oct/21 ] |
Do we just edit the EntityPiglin.java to fix this? A friend runs our server and I'm not sure of the ins and outs of where to make this edit. |
Comment by Seth Johnson [ 25/Sep/21 ] |
This is a pretty significant bug. It prevents creation of a gold farm with a gold bartering farm, which pretty much are only useful in tandem.
I'm running Spigot 1.17.1 and would like to see this patched. Thank you. |
Comment by jacob1 [ 04/Jul/21 ] |
The fix for this is very simple. Bowserinator gave me a short patch, which I applied to my server, and persistent piglins no longer count towards the mob cap (restoring correct vanilla behavior).
The fix is in EntityPiglin.java , the isTypeNotPersistent should always "return true;". This is actually the default behavior from EntityInsentient.java. I looked at the spawning code and believe mojang may have implemented this method in EntityPiglin by mistake. It doesn't cause issues in vanilla mc, but because of spigot's differing logic, it is important that isTypeNotPersistent always returns true to keep hostile mob spawning working properly.
I've seen this same "return true" patch applied elsewhere, hope it can be fixed in spigot. |
Comment by Bowserinator [ 17/Feb/21 ] |
Someone brought this up again so I decided to investigate It appears the issue is in EntityPiglin.java:
@Override public boolean isTypeNotPersistent(double d0) { return !this.isPersistent(); } This means that the check for not counting a mob to the mob cap in SpawnerCreature.java:
if (entityinsentient.isTypeNotPersistent(0) && entityinsentient.isPersistent()){ continue; } will always be false, thus piglins are always counted to the mob cap. A solution would probably require a patch into EntityPiglin to match the patched mob cap check. |
Comment by Airtheon Thesalion [ 04/Jan/21 ] |
Update: to be honest, I can't find anything out of the ordinary, so I have no idea why it behaves like this. |
Comment by Airtheon Thesalion [ 15/Dec/20 ] |
EDIT: fyi you should remove the comma from the link, otherwise it won't work.
EDIT2: Spigot does have spawn reasons, I'm going to test if that matters somehow.
I see, well it is a CraftBukkit issue either way, as that is the server part that both Spigot and Paper base there stuff on. On the paper issue it seems it has something to do with the SpawnReason.NATURAL, however I don't think Spigot has spawn reasons. So it might be something deeper that Paper fixes somehow when the spawn reason is not natural. I believe it goes wrong in this part of the NMS code: // CraftBukkit start private boolean a(EnumCreatureType enumcreaturetype, int limit) { int i = limit * this.a / SpawnerCreature.b; // CraftBukkit end return this.b.getInt(enumcreaturetype) < i; } This paper issue might also be useful https://github.com/PaperMC/Paper/issues/1922 |
Comment by Bowserinator [ 15/Dec/20 ] |
It appears there's also an issue open for this on Paper: https://github.com/PaperMC/Paper/issues/4635 could it be a CraftBukkit issue? |
Comment by Airtheon Thesalion [ 15/Dec/20 ] |
To answer your edit, it does not affect all persistent mobs. I have tested your scenario with Piglins, Piglin Brutes, and Zombiefied Piglins. The latter 2 do not have the problem, so the issue seems to be specific to Piglins. I am not sure what the cause is yet, but being able to compare how Piglins and Piglin Brutes are implemented, will help with finding it. |