buttilda / Headcrumbs

Headcrumbs
aww yiss
14 stars 21 forks source link

Server crashed, Exception ticking world / IllegalArgumentException ; appears related to enchantments / net.minecraft.enchantment.EnchantmentHelper.func_77504_a #25

Closed mjevans closed 9 years ago

mjevans commented 9 years ago

From the crash report is that while spawning a new mob a random enchantment was selected that in some way did not make sense.

( current source line for Etho.java:20 :: EnchantmentHelper.addRandomEnchantment(entity.getRNG(), axe, 1 + entity.getRNG().nextInt(30)); )

A quick and dirty work-around would be to catch the exception and re-roll for a different enchantment, possibly trying again up to (say 4 times) before giving /no/ enchantments on the item.

This would be less robust than a whitelist of known enchants, but more flexible. You might also want to capture combinations that didn't work in some way.

[19:36:00] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Exception ticking world at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:631) ~[MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334) ~[lt.class:?] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [li.class:?] Caused by: java.lang.IllegalArgumentException at net.minecraft.util.WeightedRandom.func_76273_a(WeightedRandom.java:28) ~[qv.class:?] at net.minecraft.util.WeightedRandom.func_76271_a(WeightedRandom.java:60) ~[qv.class:?] at net.minecraft.enchantment.EnchantmentHelper.func_77513_b(EnchantmentHelper.java:417) ~[afv.class:?] at net.minecraft.enchantment.EnchantmentHelper.func_77504_a(EnchantmentHelper.java:316) ~[afv.class:?] at ganymedes01.headcrumbs.entity.vip.Etho.onSpawn(Etho.java:20) ~[Etho.class:?] at ganymedes01.headcrumbs.entity.EntityCelebrity.func_110161_a(EntityCelebrity.java:205) ~[EntityCelebrity.class:?] at net.minecraft.world.SpawnerAnimals.func_77192_a(SpawnerAnimals.java:176) ~[aho.class:?] at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:161) ~[mt.class:?] at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:625) ~[MinecraftServer.class:?] ... 4 more

buttilda commented 9 years ago

Strange, it's not crashing in my code, it's crashing inside minecraft, for some reason it didn't find any enchantments and decided to purposefully crash (because, you know, that makes sense ಠ_ಠ).

Not sure what to do, it seems to be a rare event since no one else has reported it yet...

mjevans commented 9 years ago

It's quite likely that it depends on a combination of other mods being installed and that most packs which use your mod don't have that particular combination of mods.

There was a similar crash in RogueLike Dungeons, but now they apply specifically targeted enchants as a different workaround.

buttilda commented 9 years ago

If it keeps happening with other mods in your pack then yeah, it's probably a mod causing it. I'd recommend finding out which mod it is and let its authors know. Instead of everyone else having to implement workarounds

mjevans commented 9 years ago

You're literally asking for a /random set of effects/ without doing /anything/ to check if they conflict.

My supposition is just that, a theory, without any real way of testing it. Nothing in the stack trace blames any software except the Minecraft stack and this mod.

Wrap your calls to APIs you don't own in try/catch blocks, and actually catch errors.

buttilda commented 9 years ago

If there's a mod ASMing into minecraft it wouldn't show up in the stacktrace. What would happen is the stacktrace would point to the wrong lines in the actual code (which turns out it does). So my guess remains that it's some mod you having doing something it shouldn't (or doing something wrong) and breaking the method that enchants items.

I don't call any APIs I don't own (apart from the TiC one but that's in somewhere else entirely, and it is inside a try/catch)

P3rf3ctXZer0 commented 9 years ago

I am going to reopen this because it happened with head-crumbs alone. after upgrading past 1289 the latest fprge version is 352

P3rf3ctXZer0 commented 9 years ago

Sorry to bring that on you ... also I really need you to find a way to remove hardcoded ID's its totally causing me problems even before the crash issue.

buttilda commented 9 years ago

What hardcoded id? The mob id can be changed in the config file. It's just kind of hidden (forge sorts the file entries and doesn't' allow me to set a custom order), you can find it after all the name lists.

buttilda commented 9 years ago

Also, the crash still doesn't make much sense... Do you have any mods that add their own enchantments installed?

P3rf3ctXZer0 commented 9 years ago

... Okay you should ask CannibalVox for help ... he knows more than me.

buttilda commented 9 years ago

Done. No one will spawn with enchanted items anymore.