KubeJS

KubeJS

61M Downloads

[1.18] Bug: Container Items are stacked in KubeJS recipes

cech12 opened this issue ยท 5 comments

commented

Minecraft Version

1.18.2

KubeJS Version

1802.5.4-build.506

Rhino Version

1802.1.14-build.190

Architectury Version

4.5.75

Forge/Fabric Version

Forge 40.1.52

Describe your issue

Hey,

I am the developer of the Ceramic Bucket, Wooden Bucket and the corresponding BucketLib mods and I have an issue with your recipe generation.

Test environment:

  • woodenbucket-1.18.2-1.0.2.1.jar
  • bucketlib-1.18.2-0.5.3.5.jar

When I add the following recipe with KubeJS

onEvent('recipes', e => {
e.shaped('minecraft:blaze_rod', ['BBB'], {B: 'woodenbucket:wooden_bucket'}).id('caveopolis:blaze_rod')
})

the buckets are weirdly stacked after getting the result item of the recipe.
grafik

When I add the same recipe as a json file through a data pack

{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "BBB"
  ],
  "key": {
    "B": {
      "item": "woodenbucket:wooden_bucket"
    }
  },
  "result": {
    "item": "minecraft:blaze_rod"
  }
}

the recipe works as intended and consumes the buckets after getting the result item of the recipe.
grafik

I don't know if my mod is doing something wrong or the hasContainerItem check in your recipe calculation isn't done correctly. I hope we could find and fix the issue. :)

Crash report/logs

No response

commented

Looks like the stack size increases by n-1, where n is the amount previously present in the container... This... might be because either one of us doesn't properly copy the stack in their container item checks. As a side note, shouldn't buckets be used up in recipes if they are already empty?

commented

Yes, empty buckets should be used up in recipes (like in the second intended example).
Vanilla crafting recipes are using the hasContainerItem check before getting the container item through getContainerItem. So, I hove no additional check there. Could that be the issue?

commented

Yep, may be a bug on our end then, we should probably add an additional has check here

public ItemStack getContainerItem(ItemStack stack) {
return stack.getContainerItem();
}

commented

My empty buckets return false in the hasContainerItem, but could return an ItemStack in getContainerItem.
https://github.com/cech12/BucketLib/blob/1.18/src/main/java/cech12/bucketlib/api/item/UniversalBucketItem.java#L441

commented

That would be great^^
I will also add the has check on my end to be save, if other mods are doing the same.