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 w/ Tolkien Mobs Ore #139

Closed
WenXin20 opened this issue Jul 23, 2019 · 5 comments
Closed

Crash w/ Tolkien Mobs Ore #139

WenXin20 opened this issue Jul 23, 2019 · 5 comments
Assignees

Comments

@WenXin20
Copy link

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
@codetaylor
Copy link
Owner

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.

@WenXin20
Copy link
Author

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

@codetaylor
Copy link
Owner

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.

@WenXin20
Copy link
Author

WenXin20 commented Jul 23, 2019 via email

@GreatOrator
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants