Jump to content

How to make a custom texture for wearing armor


awesomedude3595

Recommended Posts

public class ModItems {
public static final RegistryObject<ArmorItem> Silver_chestplate = Registration.Items.register("silver_chestplate", () ->
        new ArmorItem(ModArmorMaterials.silverMaterial, EquipmentSlotType.CHEST, new Item.Properties().tab(ItemGroup.TAB_COMBAT)));
public static final RegistryObject<ArmorItem> Silver_helmet = Registration.Items.register("silver_helmet", () ->
        new ArmorItem(ModArmorMaterials.silverMaterial, EquipmentSlotType.HEAD, new Item.Properties().tab(ItemGroup.TAB_COMBAT)));
public static final RegistryObject<ArmorItem> Silver_leggings = Registration.Items.register("silver_leggings", () ->
        new ArmorItem(ModArmorMaterials.silverMaterial, EquipmentSlotType.LEGS, new Item.Properties().tab(ItemGroup.TAB_COMBAT)));
public static final RegistryObject<ArmorItem> Silver_boots = Registration.Items.register("silver_boots", () ->
        new ArmorItem(ModArmorMaterials.silverMaterial, EquipmentSlotType.FEET, new Item.Properties().tab(ItemGroup.TAB_COMBAT)));
static void register() {}
}

 

public enum ModArmorMaterials implements IArmorMaterial {
        silverMaterial("silver", 7, new int[]{1, 3, 5, 2}, 25, SoundEvents.ARMOR_EQUIP_GOLD, 0.0F, 0.0F, () -> {
            return Ingredient.of(ModItems.Silver_ingot.get());
        });

        private static final int[] HEALTH_PER_SLOT = new int[]{13, 15, 16, 11};
        private final String name;
        private final int durabilityMultiplier;
        private final int[] slotProtections;
        private final int enchantmentValue;
        private final SoundEvent sound;
        private final float toughness;
        private final float knockbackResistance;
        private final LazyValue<Ingredient> repairIngredient;

        ModArmorMaterials(String p_i231593_3_, int p_i231593_4_, int[] p_i231593_5_, int p_i231593_6_, SoundEvent p_i231593_7_, float p_i231593_8_, float p_i231593_9_, Supplier<Ingredient> p_i231593_10_) {
            this.name = p_i231593_3_;
            this.durabilityMultiplier = p_i231593_4_;
            this.slotProtections = p_i231593_5_;
            this.enchantmentValue = p_i231593_6_;
            this.sound = p_i231593_7_;
            this.toughness = p_i231593_8_;
            this.knockbackResistance = p_i231593_9_;
            this.repairIngredient = new LazyValue<>(p_i231593_10_);
        }

        public int getDurabilityForSlot(EquipmentSlotType p_200896_1_) {
            return HEALTH_PER_SLOT[p_200896_1_.getIndex()] * this.durabilityMultiplier;
        }

        public int getDefenseForSlot(EquipmentSlotType p_200902_1_) {
            return this.slotProtections[p_200902_1_.getIndex()];
        }

        public int getEnchantmentValue() {
            return this.enchantmentValue;
        }

        public SoundEvent getEquipSound() {
            return this.sound;
        }

        public Ingredient getRepairIngredient() {
            return this.repairIngredient.get();
        }

        @OnlyIn(Dist.CLIENT)
        public String getName() {
            return this.name;
        }

        public float getToughness() {
            return this.toughness;
        }

        public float getKnockbackResistance() {
            return this.knockbackResistance;
        }
}

 

Link to comment
Share on other sites

6 minutes ago, awesomedude3595 said:

Is there a way I can get this to work in 1.16.5 I had already set it up as on the website you sent but it doesn't appear to work in 1.16.5

1.16.5 uses mojmap mappings and as such the method names are different compared to mcp when this tutorial was written. You will need to use either the forge bot on discord or linkie to find the translations. Eventually, I'll get around to updating this as there are a few better things to do in the current code like instead of sticking it in an interface to use DistExecutor and call somewhere else.

 

1 minute ago, awesomedude3595 said:

"silver"

You should specify the modid in the string name; otherwise, this will conflict with other mods adding silver armor.

2 minutes ago, awesomedude3595 said:

@OnlyIn(Dist.CLIENT)

Never use OnlyIn. It is for forge internal use only.

Link to comment
Share on other sites

9 minutes ago, ChampionAsh5357 said:

1.16.5 uses mojmap mappings and as such the method names are different compared to mcp when this tutorial was written. You will need to use either the forge bot on discord or linkie to find the translations. Eventually, I'll get around to updating this as there are a few better things to do in the current code like instead of sticking it in an interface to use DistExecutor and call somewhere else.

 

You should specify the modid in the string name; otherwise, this will conflict with other mods adding silver armor.

Never use OnlyIn. It is for forge internal use only.

thx I made these changes and now it works!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Issue with the player skills mod. Looks like it needs the KubeJS mod installed?
    • ---- Minecraft Crash Report ---- // Don't do that. Time: 25.03.2023, 11:31 Description: Exception in server tick loop java.lang.NoClassDefFoundError: dev/latvian/mods/kubejs/KubeJSPlugin     at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?] {}     at java.lang.ClassLoader.defineClass(ClassLoader.java:1012) ~[?:?] {}     at cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:116) ~[securejarhandler-1.0.3.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.lambda$findClass$16(ModuleClassLoader.java:216) ~[securejarhandler-1.0.3.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:226) ~[securejarhandler-1.0.3.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:216) ~[securejarhandler-1.0.3.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:132) ~[securejarhandler-1.0.3.jar:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {}     at net.impleri.playerskills.PlayerSkillsEvents.beforeServerStart(PlayerSkillsEvents.java:70) ~[player-skills-1.18.2-1.0.0.jar%2394!/:?] {re:classloading}     at dev.architectury.event.forge.EventHandlerImplCommon.event(EventHandlerImplCommon.java:403) ~[architectury-4.11.89-forge.jar%2358!/:?] {re:classloading}     at net.minecraftforge.eventbus.ASMEventHandler_356_EventHandlerImplCommon_event_ServerAboutToStartEvent.invoke(.dynamic) ~[?:?] {}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-5.0.3.jar%232!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-5.0.3.jar%232!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-5.0.3.jar%232!/:?] {}     at net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(ServerLifecycleHooks.java:86) ~[forge-1.18.2-40.2.0-universal.jar%23124!/:?] {re:classloading}     at net.minecraft.client.server.IntegratedServer.m_7038_(IntegratedServer.java:63) ~[client-1.18.2-20220404.173914-srg.jar%23119!/:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:mixins.essential.json:server.integrated.MixinIntegratedServer,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:661) ~[client-1.18.2-20220404.173914-srg.jar%23119!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:mixins.essential.json:server.MinecraftServerMixin_PvPGameRule,pl:mixin:APP:mixins.essential.json:server.Mixin_PublishServerStatusResponse,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_177918_(MinecraftServer.java:261) ~[client-1.18.2-20220404.173914-srg.jar%23119!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:mixins.essential.json:server.MinecraftServerMixin_PvPGameRule,pl:mixin:APP:mixins.essential.json:server.Mixin_PublishServerStatusResponse,pl:mixin:A}     at java.lang.Thread.run(Thread.java:833) [?:?] {re:mixin} Caused by: java.lang.ClassNotFoundException: dev.latvian.mods.kubejs.KubeJSPlugin     at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[?:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {}     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:134) ~[securejarhandler-1.0.3.jar:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {}     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:134) ~[securejarhandler-1.0.3.jar:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {}     ... 19 more  
    • You might be able to make it work by using the sound directly? i.e. something like: SoundInstance sound = new SimpleSoundInstance(...); Minecraft.getInstance().getSoundManager().play(sound); But I guess you would need to use an AccessTransformer to make the SimpleSoundInstance constructor that takes a ResourceLocation instead of a SoundEvent publicly accessible. https://forge.gemwire.uk/wiki/Access_Transformers
    • Use java 17. Mixin does not support java 20 (which only came out last week).
    • From what I understand (which might be incorrect, I am not an expert on this), it doesn't use the local client registry for those registries that have data sent from a multiplayer server. SoundEvents is one of those registries. So in multiplayer your SoundEvent effectively won't exist unless it is also registered on the server?   The logic can be found here (and its related methods): https://github.com/MinecraftForge/MinecraftForge/blob/bb49b9e6dc7525ae0fa935abf6eec18b36091bd6/src/main/java/net/minecraftforge/registries/GameData.java#L656
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.