I added some fluid recipes with the help of modifyResult, to be able to do crafts like "fuel tank with 123 lava + lava bucket = fuel tank with 223 lava". Everything works well on localhost creative test world, but on server only the "fake recipe" is activated, and every craft is replaces with item with exactly 100 units of fluid.
Any help?
const BUCKET_DELTA = 100;
ServerEvents.recipes((event) => {
if (global.isNormalMode == false) {
return;
}
const bucketFilledRecipes = [
{
itemId: "create_sa:small_fueling_tank",
bucketId: "minecraft:lava_bucket",
fluidTag: "tagStock",
fluidCapacity: 800,
}
// ...
];
bucketFilledRecipes.forEach((recipe) => {
const previewNbt = {};
previewNbt[recipe.fluidTag] = BUCKET_DELTA;
event
.shaped(Item.of(recipe.itemId, previewNbt).weakNBT(), [" B ", " I "], {
I: recipe.itemId,
B: recipe.bucketId,
})
.modifyResult((grid, result) => {
const vessel = grid.find(recipe.itemId);
const newNbt = {};
newNbt[recipe.fluidTag] = Math.min(
recipe.fluidCapacity,
BUCKET_DELTA + (vessel.nbt[recipe.fluidTag] || 0)
);
return result.withNBT(Object.assign({}, vessel.nbt, newNbt));
})
.id(
[
"hypercube:fill_",
recipe.itemId.split(":")[1],
"_with_",
recipe.bucketId.split(":")[1],
].join("")
);
});
});