Skip to content

Commit

Permalink
different appearance for fixed-rate contracts (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarden-zamir authored Nov 4, 2024
2 parents ac5a222 + d6fca8f commit 477c356
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kubejs/assets/wares/models/item/delivery_agreement.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"parent": "item/generated",
"textures": {
"layer0": "wares:item/delivery_agreement"
},
"overrides": [
{"predicate": { "count": 1.0000 },"model": "wares:item/fixed_rates_delivery_agreement"}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "wares:item/fixed_rates_delivery_agreement"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions kubejs/startup_scripts/predicates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// priority: -20

global.predicates = {}

/**
*
* @param {Internal.ItemStack} stack
* @returns
*/
global.predicates.waresPredicate = function (stack) {
if(!stack.nbt) return 0
return stack.nbt.ordered ? 0 : 1
};

//by @reveter from the kubejs discord
StartupEvents.postInit((event) => {
console.log("= predicate");
if (!Platform.isClientEnvironment) return;
const $ItemProperties = Java.loadClass(
"net.minecraft.client.renderer.item.ItemProperties"
);
console.log("= got class");
console.log($ItemProperties);

$ItemProperties.register(
Item.of("wares:delivery_agreement"),
new ResourceLocation("count"),
(stack, world, living, seed) => {
if(!global.predicates.waresPredicate) return 0;
return global.predicates.waresPredicate(stack);
}
);
});

0 comments on commit 477c356

Please sign in to comment.