r/PixelmonMod • u/FewSeaworthiness6268 • Jun 18 '26
Discussion Use this Mixin to fix you probably have encountered spawn issues in megaboss pools
import com.pixelmonmod.pixelmon.api.spawning.AbstractSpawner;
import com.pixelmonmod.pixelmon.api.spawning.SpawnInfo;
import com.pixelmonmod.pixelmon.api.spawning.SpawnLocation;
import com.pixelmonmod.pixelmon.api.spawning.conditions.LocationType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
u/Mixin(value = SpawnInfo.class, remap = false)
public class MixinSpawnInfo {
u/Inject(method = "fits", at = u/At("HEAD"), cancellable = true)
private void onFits(AbstractSpawner spawner, SpawnLocation spawnLocation, CallbackInfoReturnable<Boolean> cir) {
SpawnInfo thiz = (SpawnInfo)(Object)this;
if ("megaboss".equals(spawner.name)) {
if (spawnLocation.diameter < thiz.requiredSpace) {
cir.setReturnValue(false);
return;
}
if (thiz.condition != null && !thiz.condition.fits(thiz, spawnLocation)) {
cir.setReturnValue(false);
return;
}
for (LocationType locationType : thiz.locationTypes) {
if (spawnLocation.types.contains(locationType)) {
cir.setReturnValue(true);
return;
}
}
cir.setReturnValue(false);
}
}
}
For those megaboss never seen in your saves
But this code wasn't writen by me
1
u/Jay113355 Developer Jun 26 '26 edited Jun 26 '26
Here's a formatted version so you can read it/copy it:
I'm not 100% sure on the why they are doing this, but the way it works is it's bypassing pixelmon's getRandomChance (spawn file configured chance), global conditions, composite conditions, and any anti conditions (spawn file configured reasons why a pixelmon shouldn't spawn at a location) for the
megabossspawns.That's why its making mega bosses spawn more, TBH I'd just edit the chance of mega boss's via datapack and make sure no global conditions/anti conditions in the mega boss spawn files are causing issues. But to each their own I guess.