Bug Closed · Resolved

StackOverflowError caused by random spawns

#1217 opened by Unknown 5 years ago

Unknownreported this bug

Summary

Dev builds since the last spawning rewrite raise StackOverflowError exceptions due to random spawning

Steps to reproduce

Install the latest MM builds

Create a mob with random spawning

Mob: https://pastebin.com/A0UrW6RG

Random spawn: https://pastebin.com/8Fxjs2J1

Move across the world, exceptions will be thrown in the console

Current behavior

Random spawning cause random exceptions in the console

Intended correct behavior

Random spawning working as expected

Server log file

https://pastebin.com/AkcLQK5X

Debug log snippet

https://pastebin.com/ntgcat4L

Unknowncommented

My temp-fix:

package it.feargames.mythicmobsfixes.fix;

import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
import io.lumine.xikage.mythicmobs.io.ConfigManager;
import io.lumine.xikage.mythicmobs.mobs.ActiveMob;
import io.lumine.xikage.mythicmobs.spawning.random.RandomSpawnPoint;
import io.lumine.xikage.mythicmobs.spawning.random.RandomSpawner;
import io.lumine.xikage.mythicmobs.spawning.random.RandomSpawnerManager;
import me.yamakaja.runtimetransformer.annotation.Inject;
import me.yamakaja.runtimetransformer.annotation.InjectionType;
import me.yamakaja.runtimetransformer.annotation.Transform;
import org.bukkit.event.entity.CreatureSpawnEvent;

@Transform(RandomSpawnerManager.class)
public abstract class RandomSpawnerManagerTransformer extends RandomSpawnerManager {

    private RandomSpawnerManagerTransformer(MythicMobs core) {
        super(core);
    }

    @Override
    @Inject(InjectionType.OVERRIDE)
    public AbstractEntity handleSpawnEvent(RandomSpawnPoint randomSpawnPoint) {
        // FIX START
        if (randomSpawnPoint.getReason() != CreatureSpawnEvent.SpawnReason.NATURAL)  {
            return null; // Ignore non-natural spawns
        }
        // FIX END
        if (randomSpawnPoint.getEntity() == null) {// 149
            return null;
        }
        if (listRandomSpawningR.isEmpty()) {// 150
            return null;
        }
        if (!ConfigManager.generateRSPoints()) {// 152
            landSpawnPoints.add(randomSpawnPoint);// 153
        }

        for (RandomSpawner randomSpawner : listRandomSpawningR) {
            if (!randomSpawner.checkSpawn(randomSpawnPoint) || !randomSpawner.isValid()) {
                continue;
            }
            ActiveMob mob = randomSpawner.spawn(randomSpawnPoint);
            return mob.getEntity();
        }
        return null;
    }
}
package it.feargames.mythicmobsfixes.fix;

import io.lumine.xikage.mythicmobs.mobs.entities.SpawnReason;
import me.yamakaja.runtimetransformer.annotation.Inject;
import me.yamakaja.runtimetransformer.annotation.InjectionType;
import me.yamakaja.runtimetransformer.annotation.Transform;

@Transform(SpawnReason.class)
public abstract class SpawnReasonTransformer {

    @Inject(InjectionType.OVERRIDE)
    public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getBukkitReason() {
        return org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CUSTOM;
    }
}
Unknowncommented

Should be fixed in the latest dev builds - requires testing

Unknowncommented

Fixed, thank you

Sign in to join the discussion.