Pyrotech

Pyrotech

897k Downloads

Crash w/ Tolkien Mobs Ore

WenXin20 opened this issue · 5 comments

commented

Issue Description

I have a crash that occurs after mining any ore from the Tolkien Mobs mod.

What Happens

I found Mithril Ore and Morgul Iron Ore, both gave me a crash after mining it. I assume that the Ammolite Ore from the mod would also crash.

What You Expect to Happen

The block usually drops itself.

Script

No script used.

Crash Log

Link

Affected Versions

  • Minecraft: v1.12.2
  • Forge: v14.23.5.2838
  • CraftTweaker: v4.1.19
  • Dropt: v1.15.1
  • Pyrotech: v1.2.8
  • Athenaeum: v1.17.3
  • Tolkien Mobs v1.12.19.41.0
commented

Thanks for the report!

Ok, so here's what's happening.

Pyrotech is hooking BlockEvent.HarvestDropsEvent and calling block.getItem(world, pos, state), passing the state from the event, which is the state of the block before it was destroyed.

Tolkien Mobs' (TM) override for getItem is assuming that the block is still in the world when the method is called and, instead of using the given state parameter, it tries to get the state from the world:

@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state) {
    int oreTypeDrop = world.getBlockState(pos).getValue(ORE_TYPE).getMeta();

    return new ItemStack(this, 1, oreTypeDrop);
}

At this point, the state parameter has the correct blockstate, but the in-world blockstate is minecraft:air which doesn't have the ORE_TYPE property. Since it can't find the property, it crashes:

Caused by: java.lang.IllegalArgumentException: Cannot get property PropertyEnum{name=type, clazz=class com.greatorator.tolkienmobs.block.BlockOres$EnumType, values=[MITHRIL, MORGULIRON, NETHER_MITHRIL, NETHER_MORGULIRON, ENDER_MITHRIL, ENDER_MORGULIRON, AMMOLITE, NETHER_AMMOLITE, ENDER_AMMOLITE]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]}

The root of the problem is the TM mod not using the given state, however, Pyrotech should not assume that other mods won't assume that the block is still in the world when this method is called.

The best solution is to fix the root problem. The second best solution is for Pyrotech to catch any exceptions, log them, and move on.

commented

I'll go ahead and report this to Tolkien Mobs as well.

commented
commented

This problem should no longer hard crash in 1.2.9 -- it will still have an error, but it should just log the error and continue.

commented

Sorry to comment on closed issue, but codetaylor, do you possibly have any ideas on how to fix this? I am currently looking at it but the challenge is because I need to check for meta due to how I manage my different ores