From 97acff70d1c2674c97e6de59bb5980f13f07f30d Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 25 May 2023 10:28:31 +0100 Subject: [PATCH] Added a separate item model for flowering zap leaves --- .../com/minelittlepony/unicopia/client/URenderers.java | 3 +++ .../unicopia/server/world/ZapAppleStageStore.java | 5 +++++ .../unicopia/models/item/flowering_zap_leaves.json | 3 +++ .../assets/unicopia/models/item/zap_leaves.json | 10 +++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/unicopia/models/item/flowering_zap_leaves.json diff --git a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java index 76adb3d4..e9b1c9c0 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java +++ b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java @@ -119,6 +119,9 @@ public interface URenderers { ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> { return EnchantableItem.isEnchanted(stack) ? 1 + EnchantableItem.getSpellKey(stack).getAffinity().ordinal() : 0; }); + ModelPredicateProviderRegistry.register(UBlocks.ZAP_LEAVES.asItem(), new Identifier("flowering"), (stack, world, entity, seed) -> { + return ZapAppleStageStore.Stage.byStack(stack) == ZapAppleStageStore.Stage.FLOWERING ? 1 : 0; + }); ColorProviderRegistry.ITEM.register((stack, i) -> { return i > 0 || !EnchantableItem.isEnchanted(stack) ? -1 : EnchantableItem.getSpellKey(stack).getColor(); }, UItems.GEMSTONE); diff --git a/src/main/java/com/minelittlepony/unicopia/server/world/ZapAppleStageStore.java b/src/main/java/com/minelittlepony/unicopia/server/world/ZapAppleStageStore.java index d61bfc84..82c47433 100644 --- a/src/main/java/com/minelittlepony/unicopia/server/world/ZapAppleStageStore.java +++ b/src/main/java/com/minelittlepony/unicopia/server/world/ZapAppleStageStore.java @@ -10,6 +10,7 @@ import com.minelittlepony.unicopia.util.Tickable; import net.minecraft.entity.EntityType; import net.minecraft.entity.LightningEntity; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.*; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; @@ -153,6 +154,10 @@ public class ZapAppleStageStore extends PersistentState implements Tickable { return VALUES[MathHelper.clamp(id, 0, VALUES.length)]; } + public static Stage byStack(ItemStack stack) { + return byId(stack.getDamage() + 1); + } + public boolean mustChangeInto(Stage to) { return this != to && (getNext() == to || this == HIBERNATING || to == HIBERNATING); } diff --git a/src/main/resources/assets/unicopia/models/item/flowering_zap_leaves.json b/src/main/resources/assets/unicopia/models/item/flowering_zap_leaves.json new file mode 100644 index 00000000..9e14ee8d --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/flowering_zap_leaves.json @@ -0,0 +1,3 @@ +{ + "parent": "unicopia:block/flowering_zap_leaves" +} \ No newline at end of file diff --git a/src/main/resources/assets/unicopia/models/item/zap_leaves.json b/src/main/resources/assets/unicopia/models/item/zap_leaves.json index 6a481c2e..3b2ce617 100644 --- a/src/main/resources/assets/unicopia/models/item/zap_leaves.json +++ b/src/main/resources/assets/unicopia/models/item/zap_leaves.json @@ -1,3 +1,11 @@ { - "parent": "unicopia:block/zap_leaves" + "parent": "unicopia:block/zap_leaves", + "overrides": [ + { + "predicate": { + "flowering": 1 + }, + "model": "unicopia:item/flowering_zap_leaves" + } + ] } \ No newline at end of file