Spigot (actually craftbukkit) has some bugs, namely persistent piglins and axolotls still count towards the mob cap. This is terrible, for example, this means a barter farm, axolotl aquarium or a piglin based wither skeleton farm can prevent mobs from spawning entirely. This is a patch for spigot that fixes it until it can be offically fixed.
- Git
- Maven
- Java 16 JDK
- BuildTools
See here under the "Running BuildTools" header for building spigot initially
All of these files are under Spigot/Spigot-Server
:
src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
:
In setFromBucket
change the this.persistenceRequired
line to set to true so it looks like this:
@Override
public void setFromBucket(boolean flag) {
this.entityData.set(Axolotl.FROM_BUCKET, flag);
this.persistenceRequired = true;
}
Currently spawning an axolotl from a bucket does not set its persistence which is what is considered for mob cap calculation.
src/main/java/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
:
In isTypeNotPersistent
make it return true
:
@Override
public boolean isTypeNotPersistent(double d0) {
return true;
}
Not sure why this change was made, it makes all piglins count to mob cap.
First commit your changes, cd to Spigot-Server
and git add .
and git commit -m "Piglin-Axoltol-Mob-Cap-Patch"
Then run makePatches.sh
and applyPatches.sh
in that order
cd to Spigot
(1 directory up from Spigot-Server
) and run mvn clean install
. The output jar will be in Spigot-Server/target
(it's the one called like spigot-1.17-R0.1-SNAPSHOT.jar
)
Congrats you now have a patched spigot jar!
I looked into it a little more. You are right, this spawn code is broken. Seems like the spigot devs are aware of this too, but don't want to put in the effort to fix it (this effort would I think be reverting all the patches - but I'm not sure whether or not this would break any api or plugins)
So knowing the persistence code won't be vanallified -
Your piglin patch is correct (with one caveat), I think it's vanilla minecraft that has the bugged isTypeNotPersistent implementation, probably a programmer creating Piglins was like, "hmm, isTypeNotPersistent method, I better implement this", set it to return !this.isPersistent(), which is technically correct .. but should not be implemented. Implementing it just manages to break the spawning code in spigot. The only thing is, your patch should instead delete the isTypeNotPersistent method from EntityPiglin.cpp, keep the original implementation (return true;) in place.
Your axolotl patch also looks correct. I think this was an implementation error in craftbukkit when the original commit (5b93c39d4b5b) was implemented. It should always set it to true. This patch should also be applied to EntityFish.java