Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on canCaveSpiderSpawn with Negative Y Position #7

Closed
T0paz opened this issue Jul 22, 2021 · 2 comments
Closed

Crash on canCaveSpiderSpawn with Negative Y Position #7

T0paz opened this issue Jul 22, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@T0paz
Copy link

T0paz commented Jul 22, 2021

Server Exception:

java.lang.IllegalArgumentException: bound must be positive
	at java.util.Random.nextInt(Random.java:388)
	at com.github.galatynf.sihywtcamd.Utils.canCaveSpiderSpawn(Utils.java:21)
	at net.minecraft.entity.mob.HostileEntity.handler$dhb000$changeCaveSpiderSpawn(HostileEntity:525)
	at net.minecraft.entity.mob.HostileEntity.canSpawnInDark(HostileEntity)
	at net.minecraft.entity.SpawnRestriction.canSpawn(SpawnRestriction:156)
	at net.minecraft.world.SpawnHelper.canSpawn(SpawnHelper:329)
	at net.minecraft.world.SpawnHelper.spawnEntitiesInChunk(SpawnHelper:262)
	at net.minecraft.world.SpawnHelper.spawnEntitiesInChunk(SpawnHelper:199)
	at net.minecraft.world.SpawnHelper.spawn(SpawnHelper:187)
	at net.minecraft.server.world.ServerChunkManager.method_20801(ServerChunkManager:368)
	at java.util.ArrayList.forEach(ArrayList.java:1511)
	at net.minecraft.server.world.ServerChunkManager.tickChunks(ServerChunkManager:355)
	at net.minecraft.server.world.ServerChunkManager.tick(ServerChunkManager:324)
	at net.minecraft.server.world.ServerWorld.tick(ServerWorld:372)
	at net.minecraft.server.MinecraftServer.tickWorlds(MinecraftServer:891)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer:831)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer:96)
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer:697)
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer:270)
	at java.lang.Thread.run(Thread.java:831)

com.github.galatynf.sihywtcamd.utils
Line 21: random.nextInt((int) Math.cbrt(pos.getY())) assumes the Y position of the attempted spawn is never negative. This doesn't hold true for the experimental 1.17 datapack deepening cave generation to negative Y levels. Either abs(), round or offset this.

@charlyb01 charlyb01 added the bug Something isn't working label Jul 22, 2021
@charlyb01
Copy link
Member

I thought that it could work but I actually forgot that I put a random generated with the Y position haha. Alright, I'll fix that quickly for this weekend. Thanks for the report! =)

@charlyb01
Copy link
Member

I changed the behavior of the spawning so you won't have this crash anymore. However, cave spiders may not spawn at all. Indeed, the datapack from Mojang override every mob spawn, so you may not see guardians too spawn naturally I guess. I don't know much about datapacks but maybe you can just delete lines about spawn and it will keep the normal values (it may also crash the datapacks idk), or add new lines in the datapack to let the cave spiders spawn (should work I guess but you would have to do it for every single biome and find good values for mob spawn)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants