
FoodBuilder is broken
Nyxane opened this issue ยท 2 comments
Minecraft Version
1.21.1
KubeJS Version
2101.7.1-build.181
Rhino Version
2101.2.6-build.66
Architectury Version
Forge/Fabric Version
Neoforge 21.1.107
Describe your issue
Using the following Startup script, FoodBuilder(FoodProperties) does not yield the same FoodProperties
Notable effects:
Saturation gets set to (Nutrition * Saturation * 2) from FoodConstant.saturationByModifier
usingConvertsTo never gets initialized and is, null crashing the instance
ItemEvents.modification((event) => {
const $FoodBuilder = Java.loadClass("dev.latvian.mods.kubejs.item.FoodBuilder");
event.modify("*", (item) => {
if (item.get("food")) {
console.log(item.get("food"))
console.log($FoodBuilder(item.get("food")).build())
}
});
});
KubeJS/src/main/java/dev/latvian/mods/kubejs/item/FoodBuilder.java
Lines 122 to 124 in 9205ad7
KubeJS/src/main/java/dev/latvian/mods/kubejs/item/FoodBuilder.java
Lines 39 to 46 in 9205ad7
Crash report/logs
No response
That should be deprecated, currently KubeJS/Rhino can typewrap records like the FoodProperties is
just use []
like
ItemEvents.modification(event => {
event.modify("*", item => {
let originalFood = item.get("food")
if (originalFood) {
console.log(originalFood)
console.log(item)
item.setFood(
[originalFood.nutrition(),
originalFood.saturation(),
originalFood.canAlwaysEat(),
originalFood.eatSeconds(),
originalFood.usingConvertsTo(),
originalFood.effects()
])
}
let newFood = item.get("food")
console.log(newFood)
})
})
Btw @LatvianModder
[03:27:02] [Render thread/INFO] [KubeJS Startup/]: FoodProperties[nutrition=9, saturation=21.6, canAlwaysEat=false, eatSeconds=1.6, usingConvertsTo=Optional.empty, effects=[]] [net.minecraft.world.food.FoodProperties]
[03:27:02] [Render thread/INFO] [KubeJS Startup/]: ItemModifications[item=pamhc2foodextended:tomatosoupitem] [dev.latvian.mods.kubejs.item.ItemModificationKubeEvent$ItemModifications]
[03:27:02] [Render thread/INFO] [KubeJS Startup/]: FoodProperties[nutrition=9, saturation=21.6, canAlwaysEat=false, eatSeconds=1.6, usingConvertsTo=Optional[0 minecraft:air], effects=[]] [net.minecraft.world.food.FoodProperties]
is this Optional.empty
-> Optional[0 minecraft:air]
fine? ๐