NPE crash making refined storage pattern for dead bush
PaulMurrayCbr opened this issue ยท 4 comments
Issue type:
๐ Bug
Short description:
Game crash attempting to make a refined storage pattern for dead bush. I'm reporting it here, because the stack trace indicates that it's a problem in
org.cyclops.evilcraft.core.recipe.DeadBushRecipe.func_179532_b(DeadBushRecipe.java:38)
There are other dead bush issues:
#427
#617
but they are closed.
Steps to reproduce the problem:
- put down a refined storage creative controller and pattern grid
- right-click the pattern grid to get the UI
- put blank patterns into the pattern grid ui
- put sapling and shears into the crafting area
at this point, we would expect to see a dead bush in the pattern output area, but that area is blank. The game output immediately starts spitting out this:
11:07:41] [main/ERROR]: ########## GL ERROR ##########
[11:07:41] [main/ERROR]: @ Post render
[11:07:41] [main/ERROR]: 1283: Stack overflow
[11:07:41] [main/ERROR]: ########## GL ERROR ##########
[11:07:41] [main/ERROR]: @ Post render
[11:07:41] [main/ERROR]: 1283: Stack overflow
(... etc)
- drag the invisible output pattern into your inventory
The game crashes.
Versions:
Evilcraft: 0.10.50 EvilCraft-1.12.2-0.10.50.jar
CyclopsCore: 0.11.5 CyclopsCore-1.12.2-0.11.5.jar
Minecraft: 1.12.2
Forge: 14.23.1.2601 forge-1.12.2-14.23.1.2601.jar
Refined Storage: 1.5.32 refinedstorage-1.5.32.jar
Log file:
Suggested fix
The problem appears to be something to do with the way that the dead bush recipe performs a use on the shears. For a pattern in any autocrafting setup, there is not necessarily a specific pair of shears, perhaps.
A fix would be to remove the crafting recipe for dead bush altogether and instead create a dead bush when shears are used on saplings in the world.
Yeah - it may be that RS is calling the wrong thing to render an item.
I wonder if the shears use gets automatically incremented when the dead bush recipe is put on a regular crafting table? I'lll have a look..
... no, the vanilla crafting table seems to work as it should.
The relevant code in RS is:
for (IRecipe r : CraftingManager.REGISTRY) {
if (r.matches(inv, world)) {
recipe = r;
break;
}
}
if (recipe != null) {
ItemStack output = recipe.getCraftingResult(inv);
if (!output.isEmpty()) {
outputs.add(Comparer.stripTags(output.copy()));
// some lines deleted
for (ItemStack remaining : recipe.getRemainingItems(inv)) {
if (!remaining.isEmpty()) {
ItemStack cleaned = Comparer.stripTags(remaining.copy());
byproducts.add(cleaned);
}
}
}
}
RS asks the recipe "after you have executed, what items remain unconsumed in the crafting grid?" The problem is that RS isn't asking the recipe to actually go ahead and do anything, it's just asking what would remain. But EvilCraft takes the opportunity to increment the shear's usage counter.
Maybe this is an API problem with net.minecraft.item.crafting.IRecipe: the 'getRemainingItems' needs a boolean to ask whether it's an enquiry or an executing of the recipe
Maybe there's some other way that EvilCraft should be incrementing the usage counter when the recipe is performed (as opposed to when it's merely looked at).
Maybe RS shouldn't be using this method to work out if there are unconsumed items in a recipe.
Looking aroundm the recipe is passed a parameter inv:
InventoryCrafting inv = new InventoryCrafting(new Container() {
@Override
public boolean canInteractWith(EntityPlayer player) {
return false;
}
}, 3, 3);
It's suggestive that the problem line in evilcraft is
itemStack.damageItem(1, ForgeHooks.getCraftingPlayer());
An item being autocrafted won't have a player, perhaps. Maybe the deadbush recipe needs to invoke 'canInteractWith' โฆ although that needs the crafting player anyway, so we are back to square 1.
I wonder if there are recipes in other mods that have side-effects on unconsumed items. Does RS blow up with those, too?
The forge IRecipe API does not seem to have a method meaning "this recipe is now actually being invoked for real", which is when you would want to process side-effects.