NeoForge icon indicating copy to clipboard operation
NeoForge copied to clipboard

Fix extremely longstanding issues of PlayerEvent.ItemSmeltedEvent

Open Tslat opened this issue 1 year ago • 2 comments

Forge patched in ItemSmeltedEvent into checkTakeAchievements of FurnaceResultSlot a long time ago, and ever since then the event has had one major flaw, that eliminates a huge chunk of use-cases.

image

It's been on my list of 'broken in forge' bugs for a long time, but now we have NeoForge yay

Foreword: There's actually two bugs below.. but only one is functionally critical

Basically, when extracting a stack from the FurnaceResultSlot, the stack provided is the exact stack the player attempts to extract, regardless of whether it's successful or not. This means that the event is actually providing an inaccurate value to modders when attempting to use the stack to determine how many things were smelted.

Here's an example result table for a stack of 64 iron ingots smelted, and the resultant event stack size: Left click - 64 Right click - 32 Shift click - 64 Shift click with only 5 spaces left in inventory - 64

Problem here? the stack is always the stack attempted, even if the player doesn't have space when shift clicking/quicktransferring

Solution: pass in the removeCount variable, which keeps track of exactly how much is being removed (move the event up a line so it resets removeCount after the event)

BUG 2: When shift-clicking the stack, MC fires checkTakeAchievements twice, with the second call being for an empty stack. Don't call the event if the removecount or stack is 0. You're currently firing it twice for every shift-click extraction

Tslat avatar Jul 24 '24 04:07 Tslat

Could you create a PR for this, cause yes this seems like a bug?

marchermans avatar Jul 24 '24 09:07 marchermans

Fun fact: Mojang made the same mistake. See https://bugs.mojang.com/browse/MC-65198.

Technici4n avatar Jul 24 '24 23:07 Technici4n

🚀 This issue has been resolved in NeoForge version 21.3.24-beta, as part of #1440.

neoforged-releases[bot] avatar Nov 10 '24 14:11 neoforged-releases[bot]