#Crafting Recipe with custom remainder item
110 messages · Page 1 of 1 (latest)
I also want to know how
ohh
did you manage it
what do you want to do
I have a recipe that needs to have a Mace as a remainder. It also has to take 1 durability damage. I couldnt manage it yet
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
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
Okay, thank, this will help a lot
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
yeah, this thing is getting me crazy 
actually I think the problem is that I dont know anything about kotlin
lmaooo
just ehhh
try and write something
ill give you pointer
so like first
make a class that extend CraftingRecipe
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
)
its a interface, can just implement
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?
1.21.6
Ive made a json file for the normal minecraft shapped craft thing before for this item
Oh hmm shaped recipe would be a bit more akward
try extending shaped reicipe instead of implimenting CraftingRecipe
doesnt need to be shapped now, I would do what is easier for learning
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
no its okay, you are cool
Like this? srry for being dumb 
close but not yet
so
youll need a custom serialiser
and you cant just call super

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
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
hmm okay, ill try to do it
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
Codecs are a serialization tool from Mojang's [DataFixerUpper] used to describe how objects can be transformed between different formats, such as JsonElements for JSON and Tags for NBT.
Stream codecs are a serialization tool used to describe how an object should be stored and read from a stream, such as buffers. Stream codecs are primarily used by Vanilla's networking system to sync data.
read this first
this is what you need
but the other one would help