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
[MC1.12.1-1.7.0.11] Robot crafting destroys item recipe after crafting #2532
Comments
I just encountered this bug as well. Minecraft 1.12.2, OpenComputers-MC1.12.1-1.7.0.20. |
I ended up going into the code and adding a cheap fix for it myself. Hopefully they'll get around to properly fixing it soon. |
@SirDavidLudwig did you want to share you fix? |
@payonel I can share my fix, but I'm not certain if what I did is proper or not as I'm not much of a mod developer. |
@SirDavidLudwig I'd still like to see your fix! Thanks :) |
@payonel Sorry for the late reply, been busy with University. My fix is simply creating a copy of the item stack when passing it to the other methods to prevent any manipulating the direct reference. Specifically, this is what I changed in // Line 66 down I think
while (countCrafted < wantedCount) {
val result = CraftingManager.findMatchingRecipe(CraftingInventory, host.world)
if (result == null || result.getRecipeOutput.getCount < 1) break ()
countCrafted += result.getRecipeOutput.getCount
// Create the copy here, you don't necessarily have to store it,
// I just didn't want to create multiple copies
var output = result.getRecipeOutput.copy()
FMLCommonHandler.instance.firePlayerCraftingEvent(host.player, output, this) // Use it here
val surplus = mutable.ArrayBuffer.empty[ItemStack]
for (slot < -0 until getSizeInventory) {
val stack = getStackInSlot(slot)
if (!stack.isEmpty) {
decrStackSize(slot, 1)
val item = stack.getItem
if (item.hasContainerItem(stack)) {
val container = item.getContainerItem(stack)
if (container.isItemStackDamageable && container.getItemDamage > container.getMaxDamage) {
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(host.player, container, null))
} else if (!getStackInSlot(slot).isEmpty) {
surplus += container
} else {
setInventorySlotContents(slot, container)
}
}
}
}
save()
InventoryUtils.addToPlayerInventory(output, host.player) // And here
for (stack < -surplus) {
InventoryUtils.addToPlayerInventory(stack, host.player)
}
load()
} |
Thank you |
Thanks @SirDavidLudwig, fix seems to be working. Regarding the bug itself, probably it breaks only with recipes which produce multiple items, like iron nuggets out of an ingot. |
@neumond are you saying this fix breaks crafting iron->iron nuggets? |
No, reverse. Fix makes it work. Some recipes do work even with unpatched mod, but I can clearly remember that I got problems with recipes producing multiple outputs, like chips, nuggets. First craft goes successfully, but next crafts yield no result. OC API says that craft was successful and produced 0 items (true, 0). Then, as @stridervc noticed, even player can't craft that recipe. After applying fix I've made several successful crafts of iron->iron nuggets, using robot and player inventory, and it still works fine. |
generally problems we see in 1.12 repro in 1.11 |
@payonel yeah |
This handles basically all of the funky corner cases around crafting, including things like decrementing stacks and repairing items and all of the necessary event posting. Tested to work correctly with IC2's Forge Hammer too. Should fix MightyPirates#2532.
This handles basically all of the funky corner cases around crafting, including things like decrementing stacks and repairing items and all of the necessary event posting. Tested to work correctly with IC2's Forge Hammer too. Should fix #2532.
fixed in #2683 |
If you craft an item with a robot, that recipe's output item will be replaced with air, breaking the recipe until the server/client is restarted. I tested this with Forge 1.12.1-2485 and with the latest dev build of OpenComputers MC1.12.1-1.7.0.11 and no other mods.
The text was updated successfully, but these errors were encountered: