Funwayguy / RecipeResearch

...because who magically wakes up with a universe worth of recipe knowledge. Get studying!
4 stars 1 forks source link

Client crash while researching wood planks #3

Closed ruyanve closed 9 years ago

ruyanve commented 9 years ago

I broke it! Testing a strange mix of mods I get this: http://pastebin.com/FSNMJeBh

Funwayguy commented 9 years ago

I believe this is a bug with KoreSample not RecipeResearch directly.

ruyanve commented 9 years ago

I guess @ScottKillen should take a look then...

ScottKillen commented 9 years ago

@Funwayguy The problem is this: You are trying to get a texture for a subblock that does not exist. There is no sane answer that getIcon can give in this case.

This used to be a problem with NEI and other mods, but ChickenBones used exception handling to recover from cases like this...and indeed that is precisely the purpose of exception handling. You can easily catch the IndexOutOfBoundsException and recover in a way that makes sense for your purposes.

You will have this problem with other mods as well if you assume that your requests are always valid.

I hope this is helpful.

BTW, very cool mod idea. :+1:

Funwayguy commented 9 years ago

@ScottKillen I will likely add the try-catch statement but the sane answer is to use a modulus call on the sub-block meta number to wrap the ID around into acceptable range. Here's an example for the textbook in this mod: https://github.com/Funwayguy/RecipeResearch/blob/master/src/main/java/reciperesearch/items/ItemRecipeTextbook.java#L110 It may not be an accurate representation of the block/item with the given damage value but it's better than letting Minecraft crash when somebody does something unexpected.

PS: You could alternatively use 'MathHelper.clamp_int' instead which is what vanilla Minecraft uses in some cases

Funwayguy commented 9 years ago

Handling for this should be covered in 1.0.17 now

ruyanve commented 9 years ago

Awesome, thank you! I will do intensive testing over the next couple of days and report back. This will be an essential part of "Viribus Unitis", I've read and understood your modpack permissions and will act accordingly.