terrarium-earth / Spirit

A Spirit-ual continuation of the Soul Shards mod.
Other
10 stars 21 forks source link

Iron Golems not spawning correctly #44

Open Sniper2580Sam opened 1 year ago

Sniper2580Sam commented 1 year ago

Attempted to use a cage with a maxed out soul shard that was filled with iron golems however the spawn rates differ from other mobs? It seems like they spawn must less frequently and the also commonly only spawn a single golem rather than the 9 that was expected.

Additionally when you use a different mob and place the spawner in the air the mobs will spawn in the air and drop to the ground. If you place one with an iron golem in the air, it just will not spawn a golem.

Just a few weird behaviours when putting golem souls in the cages

immeraufdemhund commented 1 year ago

@Sniper2580Sam I'm not a dev on this project nor does what I'm saying help you in anyway. but this was bugging me too so I did some digging and it looks like it has to do with this line of code: https://github.com/terrarium-earth/Spirit/blob/2c31ce3247225613f45274e9e3df9a7a5f49c702/common/src/main/java/me/codexadrian/spirit/blocks/blockentity/SoulCageSpawner.java#L103

I cloned the code and ran it manually (I wish I knew how to spawn things in with properties instead of spawning in 90 iron golems and killing them all with a spirit sword with soul reaper 3 and sharpness 5 lolol).

I then changed the code to have lots more logging so now that same line looks like this

                    if (spawned instanceof Mob mob) {
                        boolean notIgnoreSpawnConditions = !tier.ignoreSpawnConditions();
                        boolean mobCantSpawnFromSpawner = !mob.checkSpawnRules(level, MobSpawnType.SPAWNER);
                        boolean canEvenBeSpawned = notIgnoreSpawnConditions && mobCantSpawnFromSpawner;
                        boolean isNotObstructed = !mob.checkSpawnObstruction(level);
                        logger.debug("we have a mob here:notIgnoreSpawnConditions:{} mobCantSpawnFromSpawner:{} canEvenBeSpawned:{} isNotObstructed:{}", notIgnoreSpawnConditions, mobCantSpawnFromSpawner, canEvenBeSpawned, isNotObstructed);
                        if (canEvenBeSpawned || isNotObstructed) {
                            logger.debug("why did we even spawn a mob anyway??!?");
                            this.delay(tier);
                            return;
                        }

                        logger.debug("finalized Spawn of mob");
                        mob.finalizeSpawn(serverLevel, level.getCurrentDifficultyAt(spawned.blockPosition()), MobSpawnType.SPAWNER, null, null);
                    }

the log file shows this

[18:21:23] [Server thread/DEBUG] (Spirit) -.doServerSideThings(level, blockPos)[ServerLevel[world], 3, -57, 3]. nearbyRange: -1
[18:21:23] [Server thread/DEBUG] (Spirit) checking if spawner is turned off: controlledByRedstone: true hasRedstoneSignal: false
[18:21:23] [Server thread/DEBUG] (Spirit) noCollisionForSuggestedSpawnLocation:true x:6.62245653246317 y:-56.0 z:3.226817428889901
[18:21:23] [Server thread/DEBUG] (Spirit) check canSpawn = ignoreSpawnConditions:true || canSpawn:true
[18:21:23] [Server thread/DEBUG] (Spirit) we have a mob here:notIgnoreSpawnConditions:false mobCantSpawnFromSpawner:false canEvenBeSpawned:false isNotObstructed:true
[18:21:23] [Server thread/DEBUG] (Spirit) why did we even spawn a mob anyway??!?

hopefully I can figure out something... maybe to get iron we should just spawn in zombies? not as effective though

immeraufdemhund commented 1 year ago

ok so with the spawner on teh ground like you said the isObstructed is opposite and I get all the spawns. I had the spawner 3 levels (currently it's at y -60, before it was y-57).. i'll experiment with a few more heights and if I have a trap door on top or not