diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java index 90bbed43..2179eab1 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java @@ -20,6 +20,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.Spell; import com.minelittlepony.unicopia.ability.magic.spell.ThrowableSpell; import com.minelittlepony.unicopia.ability.magic.spell.TimeControlAbilitySpell; import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; +import com.minelittlepony.unicopia.item.GemstoneItem; import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.util.RegistryUtils; import com.mojang.brigadier.context.CommandContext; @@ -133,6 +134,29 @@ public final class SpellType implements Affine, SpellPredicate< return affinity; } + public GemstoneItem.Shape getGemShape() { + if (this == NECROMANCY) return GemstoneItem.Shape.SKULL; + if (this == DARK_VORTEX) return GemstoneItem.Shape.VORTEX; + if (this == FROST || this == CHILLING_BREATH) return GemstoneItem.Shape.TRIANGLE; + if (this == SHIELD || this == ARCANE_PROTECTION) return GemstoneItem.Shape.SHIELD; + if (this == FLAME || this == SCORCH || this == INFERNAL || this == FIRE_BOLT) return GemstoneItem.Shape.FLAME; + if (this == MIMIC) return GemstoneItem.Shape.ARROW; + if (this == DISPEL_EVIL) return GemstoneItem.Shape.CROSS; + if (this == REVEALING) return GemstoneItem.Shape.CROSS; + if (this == SIPHONING) return GemstoneItem.Shape.LAMBDA; + if (this == VORTEX) return GemstoneItem.Shape.VORTEX; + if (this == FEATHER_FALL) return GemstoneItem.Shape.LAMBDA; + if (this == DISPLACEMENT) return GemstoneItem.Shape.BRUSH; + if (this == TRANSFORMATION) return GemstoneItem.Shape.BRUSH; + if (this == BUBBLE) return GemstoneItem.Shape.DONUT; + if (this == MIND_SWAP) return GemstoneItem.Shape.WAVE; + if (this == HYDROPHOBIC || this == CATAPULT) return GemstoneItem.Shape.ROCKET; + if (this == LIGHT) return GemstoneItem.Shape.STAR; + if (this == PORTAL) return GemstoneItem.Shape.RING; + if (this == AWKWARD) return GemstoneItem.Shape.ICE; + return GemstoneItem.Shape.ROUND; + } + public SpellTraits getTraits() { return traits; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java index 747465b5..704f90cb 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java +++ b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java @@ -122,7 +122,8 @@ public interface URenderers { register(URenderers::renderBedItem, UItems.CLOTH_BED, UItems.CLOUD_BED); register(URenderers::renderChestItem, UBlocks.CLOUD_CHEST.asItem()); PolearmRenderer.register(UItems.WOODEN_POLEARM, UItems.STONE_POLEARM, UItems.IRON_POLEARM, UItems.GOLDEN_POLEARM, UItems.DIAMOND_POLEARM, UItems.NETHERITE_POLEARM); - ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> EnchantableItem.isEnchanted(stack) ? EnchantableItem.getSpellKey(stack).getAffinity().getAlignment() : 0); + ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> EnchantableItem.getSpellKey(stack).getAffinity().getAlignment()); + ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("shape"), (stack, world, entity, seed) -> EnchantableItem.getSpellKey(stack).getGemShape().getId()); ModelPredicateProviderRegistry.register(UItems.ROCK_CANDY, new Identifier("count"), (stack, world, entity, seed) -> stack.getCount() / (float)stack.getMaxCount()); ModelPredicateProviderRegistry.register(UItems.BUTTERFLY, new Identifier("variant"), (stack, world, entity, seed) -> (float)ButterflyItem.getVariant(stack).ordinal() / ButterflyEntity.Variant.VALUES.length); ModelPredicateProviderRegistry.register(Unicopia.id("zap_cycle"), new ClampedModelPredicateProvider() { diff --git a/src/main/java/com/minelittlepony/unicopia/datagen/providers/ModelOverrides.java b/src/main/java/com/minelittlepony/unicopia/datagen/providers/ModelOverrides.java index d5ff1b05..c0744cbe 100644 --- a/src/main/java/com/minelittlepony/unicopia/datagen/providers/ModelOverrides.java +++ b/src/main/java/com/minelittlepony/unicopia/datagen/providers/ModelOverrides.java @@ -28,6 +28,13 @@ public final class ModelOverrides { this.model = model; } + public ModelOverrides addUniform(String key, Iterable values, Function idFunc, Function childModelSupplier) { + for (T t : values) { + addOverride(childModelSupplier.apply(t), key, idFunc.apply(t)); + } + return this; + } + public ModelOverrides addUniform(String key, int from, int to, Identifier model) { float step = 1F / to; for (int index = from; index <= to; index++) { diff --git a/src/main/java/com/minelittlepony/unicopia/datagen/providers/UModelProvider.java b/src/main/java/com/minelittlepony/unicopia/datagen/providers/UModelProvider.java index cc317eb5..6861d8ed 100644 --- a/src/main/java/com/minelittlepony/unicopia/datagen/providers/UModelProvider.java +++ b/src/main/java/com/minelittlepony/unicopia/datagen/providers/UModelProvider.java @@ -1,12 +1,14 @@ package com.minelittlepony.unicopia.datagen.providers; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.concurrent.CompletableFuture; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.datagen.DataCollector; import com.minelittlepony.unicopia.item.BedsheetsItem; +import com.minelittlepony.unicopia.item.GemstoneItem; import com.minelittlepony.unicopia.item.UItems; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; @@ -137,8 +139,7 @@ public class UModelProvider extends FabricModelProvider { // gemstone ModelOverrides.of(ItemModels.GENERATED) - .addOverride(ModelIds.getItemSubModelId(UItems.GEMSTONE, "_pure"), "affinity", 0) - .addOverride(ModelIds.getItemSubModelId(UItems.GEMSTONE, "_corrupted"), "affinity", 1) + .addUniform("shape", List.of(GemstoneItem.Shape.values()), GemstoneItem.Shape::getId, shape -> ModelIds.getItemSubModelId(UItems.GEMSTONE, "_" + shape.name().toLowerCase(Locale.ROOT))) .upload(UItems.GEMSTONE, itemModelGenerator); // fishing rod diff --git a/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java b/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java index dcc35a05..8cb17b77 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java @@ -1,12 +1,10 @@ package com.minelittlepony.unicopia.item; -import java.util.Arrays; +import java.util.Comparator; import java.util.List; import java.util.function.Predicate; - import org.jetbrains.annotations.Nullable; -import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; @@ -96,12 +94,13 @@ public class GemstoneItem extends Item implements MultiItem, EnchantableItem { @Override public List getDefaultStacks() { - return Arrays.stream(Affinity.VALUES) - .flatMap(i -> SpellType.byAffinity(i).stream() - .filter(type -> type.isObtainable()) - .map(type -> EnchantableItem.enchant(getDefaultStack(), type, i)) - ) - .toList(); + return SpellType.REGISTRY.stream() + .filter(SpellType::isObtainable) + .sorted( + Comparator., GemstoneItem.Shape>comparing(SpellType::getGemShape).thenComparing(Comparator.comparing(SpellType::getAffinity)) + ) + .map(type -> EnchantableItem.enchant(getDefaultStack(), type)) + .toList(); } @Override @@ -121,4 +120,29 @@ public class GemstoneItem extends Item implements MultiItem, EnchantableItem { return super.getName(); } + public enum Shape { + ARROW, + BRUSH, + CROSS, + DONUT, + FLAME, + ICE, + LAMBDA, + RING, + ROCKET, + ROUND, + SHIELD, + SKULL, + SPLINT, + STAR, + TRIANGLE, + VORTEX, + WAVE; + + public static final int LENGTH = values().length; + + public float getId() { + return ordinal() / (float)LENGTH; + } + } } diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index df8a8f2e..736626b1 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -544,7 +544,7 @@ "spell.unicopia.shield.lore": "Casts a protective shield around the user", "spell.unicopia.bubble": "Bubble", "spell.unicopia.bubble.lore": "Traps any creature it hits in a soap bubble", - "spell.unicopia.arcane_protection": "Arcane Protections", + "spell.unicopia.arcane_protection": "Arcane Protection", "spell.unicopia.arcane_protection.lore": "Creates a protective shroud over an area in which no other spells can be cast", "spell.unicopia.vortex": "Arcane Attraction", "spell.unicopia.vortex.lore": "Creates a magnetic force that pulls in other targets", diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_arrow.png b/src/main/resources/assets/unicopia/textures/item/gemstone_arrow.png new file mode 100644 index 00000000..e51a73ae Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_arrow.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_brush.png b/src/main/resources/assets/unicopia/textures/item/gemstone_brush.png new file mode 100644 index 00000000..fb7ebb21 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_brush.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_cross.png b/src/main/resources/assets/unicopia/textures/item/gemstone_cross.png new file mode 100644 index 00000000..c8670f00 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_cross.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_donut.png b/src/main/resources/assets/unicopia/textures/item/gemstone_donut.png new file mode 100644 index 00000000..4a47ebf5 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_donut.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_flame.png b/src/main/resources/assets/unicopia/textures/item/gemstone_flame.png new file mode 100644 index 00000000..f2b992ea Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_flame.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_ice.png b/src/main/resources/assets/unicopia/textures/item/gemstone_ice.png new file mode 100644 index 00000000..284fa195 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_ice.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_lambda.png b/src/main/resources/assets/unicopia/textures/item/gemstone_lambda.png new file mode 100644 index 00000000..2dc1d0e7 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_lambda.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_ring.png b/src/main/resources/assets/unicopia/textures/item/gemstone_ring.png new file mode 100644 index 00000000..e6e4aebd Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_ring.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_rocket.png b/src/main/resources/assets/unicopia/textures/item/gemstone_rocket.png new file mode 100644 index 00000000..a3c24a9d Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_rocket.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_pure.png b/src/main/resources/assets/unicopia/textures/item/gemstone_round.png similarity index 100% rename from src/main/resources/assets/unicopia/textures/item/gemstone_pure.png rename to src/main/resources/assets/unicopia/textures/item/gemstone_round.png diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_shield.png b/src/main/resources/assets/unicopia/textures/item/gemstone_shield.png new file mode 100644 index 00000000..2395fc6f Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_shield.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_skull.png b/src/main/resources/assets/unicopia/textures/item/gemstone_skull.png new file mode 100644 index 00000000..9da15bdd Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_skull.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_splint.png b/src/main/resources/assets/unicopia/textures/item/gemstone_splint.png new file mode 100644 index 00000000..8983ce9a Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_splint.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_star.png b/src/main/resources/assets/unicopia/textures/item/gemstone_star.png new file mode 100644 index 00000000..35d63424 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_star.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_triangle.png b/src/main/resources/assets/unicopia/textures/item/gemstone_triangle.png new file mode 100644 index 00000000..e1cec73f Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_triangle.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_vortex.png b/src/main/resources/assets/unicopia/textures/item/gemstone_vortex.png new file mode 100644 index 00000000..6554e9a9 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_vortex.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/gemstone_wave.png b/src/main/resources/assets/unicopia/textures/item/gemstone_wave.png new file mode 100644 index 00000000..eaeb6f4a Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/gemstone_wave.png differ