Add unique gem designs for different spells

This commit is contained in:
Sollace 2024-04-08 19:18:56 +01:00
parent 978b5e9854
commit 281e2ba26d
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
23 changed files with 70 additions and 13 deletions

View file

@ -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<T extends Spell> 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;
}

View file

@ -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() {

View file

@ -28,6 +28,13 @@ public final class ModelOverrides {
this.model = model;
}
public <T> ModelOverrides addUniform(String key, Iterable<T> values, Function<T, Float> idFunc, Function<T, Identifier> 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++) {

View file

@ -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

View file

@ -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,11 +94,12 @@ public class GemstoneItem extends Item implements MultiItem, EnchantableItem {
@Override
public List<ItemStack> getDefaultStacks() {
return Arrays.stream(Affinity.VALUES)
.flatMap(i -> SpellType.byAffinity(i).stream()
.filter(type -> type.isObtainable())
.map(type -> EnchantableItem.enchant(getDefaultStack(), type, i))
return SpellType.REGISTRY.stream()
.filter(SpellType::isObtainable)
.sorted(
Comparator.<SpellType<?>, GemstoneItem.Shape>comparing(SpellType::getGemShape).thenComparing(Comparator.comparing(SpellType::getAffinity))
)
.map(type -> EnchantableItem.enchant(getDefaultStack(), type))
.toList();
}
@ -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;
}
}
}

View file

@ -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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB