Skip to content

Commit

Permalink
fix: trade mixing recipes not displaying names. Also added a hidden r…
Browse files Browse the repository at this point in the history
…ecipe without names that only uses ids for backwards compat
  • Loading branch information
Yarden-zamir committed Nov 5, 2024
1 parent ec4980e commit b729aa5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions kubejs/server_scripts/base/recipe_managers/wares.manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,23 @@ function tradeBranch(outputTrades, inputTrades) {
// outputTrades.map((trade) => trade.item),
// inputTrades.map((trade) => getTradeNbtNameFilter(trade.completedItem))
// );

let hiddenUniversalRecipe = e.recipes.create.mixing(
outputTrades.map((trade) => trade.item),
inputTrades.map((trade) => getTradeNbtIdFilter(trade.completedItem, true))
);
let random_string_id_10_chars= Math.random().toString(36).substring(7);
hiddenUniversalRecipe.id = random_string_id_10_chars + "/hidden";

});
}
function getTradeNbtIdFilter(item) {
function getTradeNbtIdFilter(item, compat) {
if (!item.getNbt()) return item.weakNBT();
if (item.nbt.get("id") == null) return item.weakNBT();
return Item.of(item.id).withNBT({"id": item.nbt.get("id")}).weakNBT();
if (compat) return Item.of(item.id).withNBT({"id": item.nbt.get("id")}).weakNBT();
return Item.of(item.id).withNBT({
"id": item.nbt.get("id"), 'ordered': item.nbt.get("ordered"), "display": item.nbt.get("display")
}).weakNBT();
}
console.info("Loading wares manager");
ServerEvents.lowPriorityData((event) => {
Expand Down

0 comments on commit b729aa5

Please sign in to comment.