From 9094bd59a828e70cbd5de9f0bcfb6ae360e40a55 Mon Sep 17 00:00:00 2001 From: Zsolt Molnar Date: Sat, 18 Jan 2025 21:32:00 +0100 Subject: [PATCH] Support AzureLib Armor 3.X --- CHANGELOG.md | 1 + gradle.properties | 4 +- .../net/wizards/client/WizardsClientMod.java | 17 ++++++++ .../client/armor/WizardArmorModel.java | 24 ----------- .../client/armor/WizardArmorRenderer.java | 39 ++++++++++++++--- .../java/net/wizards/item/WizardArmor.java | 42 +------------------ 6 files changed, 54 insertions(+), 73 deletions(-) delete mode 100644 src/main/java/net/wizards/client/armor/WizardArmorModel.java diff --git a/CHANGELOG.md b/CHANGELOG.md index bdfff79..fbbb600 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 2.3.0 - Support Spell Engine 1.4 +- Support AzureLib Armor 3.X - Frost Nova freeze no longer works on any bosses - Frost spells deal +30% damage against `#minecraft:freeze_hurts_extra_types` - Frost spells deal -30% damage against `#minecraft:freeze_immune_entity_types` diff --git a/gradle.properties b/gradle.properties index 5fb8683..ab40784 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.21.1 yarn_mappings=1.21.1+build.3 # Loader -fabric_loader_version=0.16.3 +fabric_loader_version=0.16.5 fabric_api_version=0.102.0+1.21.1 # Mod @@ -17,7 +17,7 @@ minecraft_compat_version=1.21 # Dependencies azure_mc_version=1.21.1 -azure_lib_version=2.3.3 +azure_lib_version=3.0.1 tiny_config_version=2.3.2 runes_version=1.0.3+1.21.1 structure_pool_api_version=1.1.3+1.21.1 diff --git a/src/main/java/net/wizards/client/WizardsClientMod.java b/src/main/java/net/wizards/client/WizardsClientMod.java index 3c898f3..5157b1e 100644 --- a/src/main/java/net/wizards/client/WizardsClientMod.java +++ b/src/main/java/net/wizards/client/WizardsClientMod.java @@ -1,18 +1,24 @@ package net.wizards.client; +import mod.azure.azurelibarmor.rewrite.render.armor.AzArmorRenderer; +import mod.azure.azurelibarmor.rewrite.render.armor.AzArmorRendererRegistry; import net.fabricmc.api.ClientModInitializer; import net.minecraft.util.Identifier; import net.spell_engine.api.effect.CustomModelStatusEffect; import net.spell_engine.api.effect.CustomParticleStatusEffect; +import net.spell_engine.api.item.armor.Armor; import net.spell_engine.api.render.CustomModels; import net.wizards.WizardsMod; +import net.wizards.client.armor.WizardArmorRenderer; import net.wizards.client.effect.FrostShieldRenderer; import net.wizards.client.effect.FrozenParticles; import net.wizards.client.effect.FrozenRenderer; import net.wizards.client.effect.ArcaneChargeRenderer; import net.wizards.effect.Effects; +import net.wizards.item.Armors; import java.util.List; +import java.util.function.Supplier; public class WizardsClientMod implements ClientModInitializer { @Override @@ -36,5 +42,16 @@ public void onInitializeClient() { CustomParticleStatusEffect.register(Effects.frozen.effect, new FrozenParticles(2)); CustomModelStatusEffect.register(Effects.frozen.effect, new FrozenRenderer()); CustomModelStatusEffect.register(Effects.frostShield.effect, new FrostShieldRenderer()); + registerArmorRenderer(Armors.wizardRobeSet, WizardArmorRenderer::wizard); + registerArmorRenderer(Armors.arcaneRobeSet, WizardArmorRenderer::arcane); + registerArmorRenderer(Armors.fireRobeSet, WizardArmorRenderer::fire); + registerArmorRenderer(Armors.frostRobeSet, WizardArmorRenderer::frost); + registerArmorRenderer(Armors.netherite_arcane, WizardArmorRenderer::netheriteArcane); + registerArmorRenderer(Armors.netherite_fire, WizardArmorRenderer::netheriteFire); + registerArmorRenderer(Armors.netherite_frost, WizardArmorRenderer::netheriteFrost); + } + + private static void registerArmorRenderer(Armor.Set set, Supplier armorRendererSupplier) { + AzArmorRendererRegistry.register(armorRendererSupplier, set.head, set.chest, set.legs, set.feet); } } diff --git a/src/main/java/net/wizards/client/armor/WizardArmorModel.java b/src/main/java/net/wizards/client/armor/WizardArmorModel.java deleted file mode 100644 index 89eb583..0000000 --- a/src/main/java/net/wizards/client/armor/WizardArmorModel.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.wizards.client.armor; - -import mod.azure.azurelibarmor.common.api.client.model.GeoModel; -import net.minecraft.util.Identifier; -import net.wizards.WizardsMod; -import net.wizards.item.WizardArmor; - -public class WizardArmorModel extends GeoModel { - @Override - public Identifier getModelResource(WizardArmor object) { - return Identifier.of(WizardsMod.ID, "geo/wizard_robes.geo.json"); - } - - @Override - public Identifier getTextureResource(WizardArmor armor) { - var textureId = armor.getFirstLayerId(); - return Identifier.of(textureId.getNamespace(), "textures/armor/" + textureId.getPath() + ".png"); - } - - @Override - public Identifier getAnimationResource(WizardArmor animatable) { - return null; // Identifier.of(WizardsMod.ID, "animations/armor_idle.json"); - } -} diff --git a/src/main/java/net/wizards/client/armor/WizardArmorRenderer.java b/src/main/java/net/wizards/client/armor/WizardArmorRenderer.java index 830675e..00ed809 100644 --- a/src/main/java/net/wizards/client/armor/WizardArmorRenderer.java +++ b/src/main/java/net/wizards/client/armor/WizardArmorRenderer.java @@ -1,10 +1,37 @@ package net.wizards.client.armor; -import mod.azure.azurelibarmor.common.api.client.renderer.GeoArmorRenderer; -import net.wizards.item.WizardArmor; +import mod.azure.azurelibarmor.rewrite.render.armor.AzArmorRenderer; +import mod.azure.azurelibarmor.rewrite.render.armor.AzArmorRendererConfig; +import net.minecraft.util.Identifier; +import net.wizards.WizardsMod; -public class WizardArmorRenderer extends GeoArmorRenderer { - public WizardArmorRenderer() { - super(new WizardArmorModel()); +public class WizardArmorRenderer extends AzArmorRenderer { + public static WizardArmorRenderer wizard() { + return new WizardArmorRenderer("wizard_robes", "wizard_robe"); } -} + public static WizardArmorRenderer arcane() { + return new WizardArmorRenderer("wizard_robes", "arcane_robe"); + } + public static WizardArmorRenderer fire() { + return new WizardArmorRenderer("wizard_robes", "fire_robe"); + } + public static WizardArmorRenderer frost() { + return new WizardArmorRenderer("wizard_robes", "frost_robe"); + } + public static WizardArmorRenderer netheriteArcane() { + return new WizardArmorRenderer("wizard_robes", "netherite_arcane_robe"); + } + public static WizardArmorRenderer netheriteFire() { + return new WizardArmorRenderer("wizard_robes", "netherite_fire_robe"); + } + public static WizardArmorRenderer netheriteFrost() { + return new WizardArmorRenderer("wizard_robes", "netherite_frost_robe"); + } + + public WizardArmorRenderer(String modelName, String textureName) { + super(AzArmorRendererConfig.builder( + Identifier.of(WizardsMod.ID, "geo/" + modelName + ".geo.json"), + Identifier.of(WizardsMod.ID, "textures/armor/" + textureName + ".png") + ).build()); + } +} \ No newline at end of file diff --git a/src/main/java/net/wizards/item/WizardArmor.java b/src/main/java/net/wizards/item/WizardArmor.java index 00520c0..6816b82 100644 --- a/src/main/java/net/wizards/item/WizardArmor.java +++ b/src/main/java/net/wizards/item/WizardArmor.java @@ -1,51 +1,11 @@ package net.wizards.item; -import mod.azure.azurelibarmor.common.api.client.renderer.GeoArmorRenderer; -import mod.azure.azurelibarmor.common.api.common.animatable.GeoItem; -import mod.azure.azurelibarmor.common.internal.client.RenderProvider; -import mod.azure.azurelibarmor.common.internal.common.util.AzureLibUtil; -import mod.azure.azurelibarmor.core.animatable.instance.AnimatableInstanceCache; -import mod.azure.azurelibarmor.core.animation.AnimatableManager; -import net.minecraft.client.render.entity.model.BipedEntityModel; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; import net.minecraft.item.ArmorMaterial; -import net.minecraft.item.ItemStack; import net.minecraft.registry.entry.RegistryEntry; import net.spell_engine.api.item.armor.Armor; -import net.wizards.client.armor.WizardArmorRenderer; -import java.util.function.Consumer; - -public class WizardArmor extends Armor.CustomItem implements GeoItem { +public class WizardArmor extends Armor.CustomItem { public WizardArmor(RegistryEntry material, Type slot, Settings settings) { super(material, slot, settings); } - - // MARK: GeoItem - - @Override - public void createRenderer(Consumer consumer) { - consumer.accept(new RenderProvider() { - private GeoArmorRenderer renderer; - @Override - public BipedEntityModel getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, BipedEntityModel original) { - if (this.renderer == null) { - this.renderer = new WizardArmorRenderer(); - } - this.renderer.prepForRender(livingEntity, itemStack, equipmentSlot, original); - return this.renderer; - } - }); - } - - @Override - public void registerControllers(AnimatableManager.ControllerRegistrar controllers) { } - - private final AnimatableInstanceCache cache = AzureLibUtil.createInstanceCache(this); - - @Override - public AnimatableInstanceCache getAnimatableInstanceCache() { - return cache; - } }