Frinn38 / Custom-Machinery

A Minecraft Mod about creating custom machines that works
GNU Lesser General Public License v3.0
45 stars 17 forks source link

Tool with damage can't make recipe run even after ignore its NBT with kubejs #47

Closed Malnormala closed 2 years ago

Malnormala commented 2 years ago

I tried to use kubejs to add recipes What I wanted to do is to damage this diamond sword to make an andesite alloy. Here are two way I came up with to achieve this, but neither of them worked. the recipe run only when the sword do not have any damaged, what bothered me is that 'ignoreNBT' truly worked because if I delete it, enchanted sword can't be used. I also tested many conditions, even I used tag it still the same. and another question, I can't find the way to set the mode of Durability Requirement using kubejs

`onEvent('recipes', event => {

event.recipes.custommachinery.custom_machine("custommachinery:seal_engraving_table_hand", 200)
.requireItem(Item.of("kubejs:lapis_glue",2),"input1")
.requireItem(Item.of("minecraft:andesite",1),"input2")
.damageItemTag(Item.of("minecraft:diamond_sword").ignoreNBT(),1,"input3")
.requireItem(Item.of("kubejs:concept_orientation_strength_1",1),"input4").chance(0)
.produceItem(Item.of("create:andesite_alloy",1), "output1")

}) onEvent('recipes', event => {

event.recipes.custommachinery.custom_machine("custommachinery:seal_engraving_table_hand", 200)
.requireItem(Item.of("kubejs:lapis_glue",2),"input1")
.requireItem(Item.of("minecraft:andesite",1),"input2")
.damageItemTag("#forge:swords",1,"input3")
.requireItem(Item.of("kubejs:concept_orientation_strength_1",1),"input4").chance(0)
.produceItem(Item.of("create:andesite_alloy",1), "output1")

})` image can't run(with damage) image can run (without damage)

Malnormala commented 2 years ago

Instead, I found that once I used /reroad, the recipe could run correctly once, but only once.

Frinn38 commented 2 years ago

Using kubeJS integration you don't need to specify the mode for durability requirement, basically .damageItem is input mode and .repairItem is output mode.

.damageItemTag(Item.of("minecraft:diamond_sword").ignoreNBT(),1,"input3") This shouldn't even work, as .damageItemTag need a tag as first parameter and not an item.

I also don't think #forge:swords is a valid item tag (except if you add it yourself, in that case nevermind), as I can't see it in the forge tags folder.

Simply using .damageItem(Item.of("minecraft:diamond_sword"), 1, "input3") should work, if you don't specify any nbt the recipe won't care, so even if the sword is enchanted the requirement should run.

I don't know what .ignoreNBT does (probably some KubeJS dark magic), but I advise you not to use it with CM recipes, in most cases it will just be ignored anyway.

Malnormala commented 2 years ago

I'm sorry that in fact exactly did so but I copied wrong code on the issue because I tried to change my code to solve the question and I forget to change it back

Malnormala commented 2 years ago

now I tried my code again but the problem still exist Sword with damage can't make the recipe run `onEvent('recipes', event => {

event.recipes.custommachinery.custom_machine("custommachinery:seal_engraving_table_hand", 200)
.requireItem(Item.of("kubejs:lapis_glue",2),"input1")
.requireItem(Item.of("minecraft:andesite",1),"input2")
.damageItem(Item.of("minecraft:diamond_sword"),1,"input3")
.requireItem(Item.of("kubejs:concept_orientation_strength_1",1),"input4").chance(0)
.produceItem(Item.of("create:andesite_alloy",1), "output1")

})` image

Frinn38 commented 2 years ago

There was actually an bug in the durability requirement, thanks for reporting it. I just pushed an update that should fix it (1.16.5-0.5.8d).

Malnormala commented 2 years ago

it seems that it still can only work once in 0.5.8d and 0.5.8e

Malnormala commented 2 years ago

seems only fixed when I use datapacks to write recipes

Frinn38 commented 2 years ago

Ok I used a very old kubejs version in my workspace, that's why it worked here be not in a modpack with latest kubejs version. I updated kubejs and fixed the issue (hopefully) and pushed an update (1.16.5-0.5.8f).

Malnormala commented 2 years ago

Thanks a lot, now it can work correctly

Frinn38 commented 2 years ago

Nice ^^