Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Allow Changing Crafting Remainders

Open CJDevZ opened this issue 6 months ago • 4 comments

  • added a method and field to CraftItemEvent
  • made them used in ResultSlot
  • ServerGamePacketListenerImpl, the class calling CraftItemEvent, sets ResultSlot's static list

CJDevZ avatar Jun 16 '25 15:06 CJDevZ

You also seem to have made your NMS changes a feature patch. The changes you introduced there are more fitting to be added as a file patch. Please change that

Strokkur424 avatar Jun 16 '25 15:06 Strokkur424

Thanks for the feedback @Strokkur424 😄

CJDevZ avatar Jun 16 '25 17:06 CJDevZ

This is a bit of an invasive change, with requiring the resultslot change looking very hacky. The only reason I am a little iffy about introducing api here is that it possibly looks like this may be reworked a bit in the future.

craftingRemainingItem is one of the last manually defined fields that aren't backed by components anymore, which is indicative to me that this may be on some kind of future cleanup list on Mojang's end. Issue is obviously overriding the leftovers like this is a bit tricky with what is currently given api wise.

Owen1212055 avatar Jun 20 '25 20:06 Owen1212055

I've implemented it in this way because I didn't want to change up how and where the Event is called. Hence the hacky field in ResultSlot. If there's a better way, please say so.

Of course Mojang will make this change pretty much obsolete in the future, but when that happens this change can either be reverted or adjusted depending on how they do it.

There also may be some workaround by cancelling or setting the Result of the CraftItemEvent, but then a developer would need to implement ResultSlot's code themselves.

CJDevZ avatar Jun 21 '25 14:06 CJDevZ