Fixed gemstones not changing texture to reflect their affinity

This commit is contained in:
Sollace 2023-05-25 10:28:59 +01:00
parent 97acff70d1
commit 7713f461e7
3 changed files with 14 additions and 7 deletions

View file

@ -3,19 +3,21 @@ package com.minelittlepony.unicopia;
import net.minecraft.util.Formatting;
public enum Affinity {
GOOD(Formatting.BLUE, -1),
NEUTRAL(Formatting.LIGHT_PURPLE, 0),
BAD(Formatting.RED, 1);
GOOD(Formatting.BLUE, -1, 0),
NEUTRAL(Formatting.LIGHT_PURPLE, 0, 0.5F),
BAD(Formatting.RED, 1, 1);
private final Formatting color;
private final int corruption;
private final float alignment;
public static final Affinity[] VALUES = values();
Affinity(Formatting color, int corruption) {
Affinity(Formatting color, int corruption, float alignment) {
this.color = color;
this.corruption = corruption;
this.alignment = alignment;
}
public Formatting getColor() {
@ -30,6 +32,10 @@ public enum Affinity {
return corruption;
}
public float getAlignment() {
return alignment;
}
public boolean isNeutral() {
return this == NEUTRAL;
}

View file

@ -20,6 +20,7 @@ import com.minelittlepony.unicopia.item.ChameleonItem;
import com.minelittlepony.unicopia.item.EnchantableItem;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.server.world.ZapAppleStageStore;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
@ -117,7 +118,7 @@ public interface URenderers {
PolearmRenderer.register(UItems.DIAMOND_POLEARM);
PolearmRenderer.register(UItems.NETHERITE_POLEARM);
ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> {
return EnchantableItem.isEnchanted(stack) ? 1 + EnchantableItem.getSpellKey(stack).getAffinity().ordinal() : 0;
return EnchantableItem.isEnchanted(stack) ? EnchantableItem.getSpellKey(stack).getAffinity().getAlignment() : 0;
});
ModelPredicateProviderRegistry.register(UBlocks.ZAP_LEAVES.asItem(), new Identifier("flowering"), (stack, world, entity, seed) -> {
return ZapAppleStageStore.Stage.byStack(stack) == ZapAppleStageStore.Stage.FLOWERING ? 1 : 0;

View file

@ -6,13 +6,13 @@
"overrides": [
{
"predicate": {
"affinity": 1
"affinity": 0
},
"model": "unicopia:item/gemstone_pure"
},
{
"predicate": {
"affinity": 3
"affinity": 1
},
"model": "unicopia:item/gemstone_corrupted"
}