BuildCraft|Core

BuildCraft|Core

7M Downloads

Crashing when crafting in Advanced Crafting Table recipe with leftover(s)

mnn opened this issue · 5 comments

commented

I think it's the same problem as in #615.

Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
    at buildcraft.silicon.TileAdvancedCraftingTable$InternalInventoryCrafting.setInventorySlotContents(TileAdvancedCraftingTable.java:89)
    at monnef.jaffas.food.crafting.PersistentItemsCraftingHandler.doSubstitution(PersistentItemsCraftingHandler.java:122)
    at monnef.jaffas.food.crafting.PersistentItemsCraftingHandler.handlePersistentItems(PersistentItemsCraftingHandler.java:89)
    at monnef.jaffas.food.crafting.PersistentItemsCraftingHandler.onCrafting(PersistentItemsCraftingHandler.java:64)
    at cpw.mods.fml.common.registry.GameRegistry.onItemCrafted(GameRegistry.java:322)
    at net.minecraft.inventory.SlotCrafting.onPickupFromSlot(SlotCrafting.java:118)
    at buildcraft.silicon.TileAdvancedCraftingTable.craftItem(TileAdvancedCraftingTable.java:330)
    at buildcraft.silicon.TileAdvancedCraftingTable.updateEntity(TileAdvancedCraftingTable.java:287)
    at net.minecraft.world.World.updateEntities(World.java:2209)
    at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:550)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:668)
    ... 4 more

Code of the crafting handler is here. The slot number should be fine (checked on line 110).

commented

I fixed the NPE, but I highly recommend you add leftovers to the player inventory instead of the crafting grid.

Since the ACT provides a fake player inventory for output, they will end up in the output section of the GUI if you add them to the player inventory.

Note, my NPE fix will result in rejecting the operation that caused it (trying to manipulate an empty slot on the crafting grid).

Treat the ACT just like a player, just don't touch the crafting grid, and everything will work fine.

commented

@CovertJaguar Thanks for fix and advice, I'll fix it on my end :).

commented

Perhaps log a message once per broken recipe so that people are aware that
funny behaviour isn't because of broken code at bc's end
On 11 Oct 2013 23:28, "monnef" [email protected] wrote:

@CovertJaguar https://github.com/CovertJaguar Thanks for fix and
advice, I'll fix it on my end :).


Reply to this email directly or view it on GitHubhttps://github.com//issues/1270#issuecomment-26136738
.

commented

Personally, I'm more of the opinion that the Crafting Handler system itself is broken. =P

I'm sure it must be possible to design a less problematic hook.

My personal experiences with my Crafting Handlers in Railcraft is that dupe exploits and other weirdness are very hard to eliminate entirely. Especially when it seems like every mod adds their own version of a crafting table, and each one behaves slightly differently.

For the record, I think the Auto-Workbench will spit any items that get added to the player inventory onto the ground.

I don't even think the Forestry Workbench supports Crafting Handlers at all.

commented

Perhaps log a message once per broken recipe so that people are aware that funny behaviour isn't because of broken code at bc's end

It's about point of view - if you take vanilla crafting as baseline (crafting table and crafting in player inventory) then the BC crafting is broken, because it behaves differently from vanilla crafting. (But it's more convenient returning leftovers directly to player's inventory. Reason I have it implemented as returning to a crafting matrix is because there used to be problems with crafting blocks/items from other mods [e.g. no fake player, not fully implemented inventory of a fake player] and returning it directly to crafting matrix didn't crash a game or destroy leftovers.)