#Crafting Recipe with custom remainder item

110 messages · Page 1 of 1 (latest)

untold star
#

in 1.20.6

winter pivot
#

I also want to know how

native zenith
#

did you manage it

#

what do you want to do

winter pivot
native zenith
#

ah ive done that before

#

i did it

#

by adding a custom recipe type

#

its 1.20.1 yarn mapping kotlin so

#

you cant just copy it but

winter pivot
#

Yeah, I'm on 1.21.6 fabric java

#

I ant find nothing on internet about it

native zenith
#

but the general idea is

#
override fun getRemainder(inventory: RecipeInputInventory): DefaultedList<ItemStack> {
    val l = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY)
    for ((i, v) in inventory.inputStacks.withIndex()) {
        if (tool.test(v)) {
            val new = v.copy()
            val broken = new.damage(toolDamage, RANDOM, null)
            if (broken) {
                new.decrement(1)
                new.damage = 0
            }
            l[i] = new
        }
    }
    return l
}
#

my code arent the best, my apoligies lol

#

1.21.6 might be after the enchantmanet changes

#

so you may need to do some fuax paramater to get unbreaking working

winter pivot
#

Okay, thank, this will help a lot

native zenith
#

but yeah your inventory is mapped to a list so the idea is

#

you want to find which index its in

#

then

#

return it in a new list in that index in getRemainder

winter pivot
#

yeah, this thing is getting me crazy gatotristemuitotristemesmo

native zenith
#

lol

#

where are you at

#

my code arent great for demonstration

winter pivot
native zenith
#

lmaooo

#

just ehhh

#

try and write something

#

ill give you pointer

#

so like first

#

make a class that extend CraftingRecipe

winter pivot
#

my code. I was trying to understand what is happing, imported the abstracted methods required and added a console log when the item is crafted (i think jesusbasquete )

winter pivot
native zenith
#

oh fair

#

kotlin doesnt differciate betwen the two

#

its just : thing

#

:3

#

well it does difffercisate

#

but i cant tell betwen the two

#

on github

#

ok so a better way to word it is
"you cannot tell between extending class and impliemnting interface by pure kotlin code without context"

#

eermmmm

#

im a bit sleep deprived

#

soryr

#

for being kinda

#

odd

#

anwyay yeahhh

#

that looks fine

#

so i would say

#

first do the serialization

#

what version are you on

#

1.21?

winter pivot
#

1.21.6

native zenith
#

ah so codec then

#

do you have a idea on what your recipe should looks like

winter pivot
#

Ive made a json file for the normal minecraft shapped craft thing before for this item

native zenith
#

Oh hmm shaped recipe would be a bit more akward

#

try extending shaped reicipe instead of implimenting CraftingRecipe

winter pivot
#

doesnt need to be shapped now, I would do what is easier for learning

native zenith
#

there is a fabric ingredient api

#

that may be easier but ive never used it

#

yeah im not sure

#

ehhh

#

I would

#

extend ShapedCraftingRecipe

#

overload the getRemainder method to leave some item

#

overload the get type and serialiser

#

maybe like
"M": {"item":"minecraft:mace", "remainder": true}

#

or even "M": { "remainder": true, "ingredient":{ "item":"minecraft:mace"}}

#

sorry if im confusing you

winter pivot
#

Like this? srry for being dumb joelspin

native zenith
#

so

#

youll need a custom serialiser

#

and you cant just call super

winter pivot
#

how do I learn things like that? Usually I see videos and docs, but I strugle so much finding this type of content

#

minecraft modding and fabric's api

native zenith
#

hmm

#

you can read pior art

#

and vinilla code

#

it took me a while to figure this one out too

#

i think i found some random mod that did the same thing

#

then yeahhh

#

now i know how to do it

#

:3

winter pivot
#

hmm okay, ill try to do it

native zenith
#

a neat trick is

#

go to github

#

search

#

type the stuff you wanna know about

#

filter it to java

#

then youll find a bunch of mod that used that function/method

#

sometime that helps

#

:3

winter pivot
#

ohh, good idea, thanks

#

ill try to figure out more about the serialization

native zenith
native zenith
#

this is what you need

#

but the other one would help