Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello, i need help with my java code because the armor texture don't work in game .. i put down my code

Sorry for my English, I'm a french guy !! <3

 

Here it's the class : ItemRubyArmor

Spoiler

package items;

import com.neverslands.tutorial.Reference;
import com.neverslands.tutorial.Tutorial;

import init.ModArmor;
import net.minecraft.entity.Entity;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

public class ItemRubyArmor extends ItemArmor {

    public ItemRubyArmor(ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn, String unlocalizedName) {
        super(materialIn, renderIndexIn, equipmentSlotIn);
        this.setUnlocalizedName(unlocalizedName);
        this.setRegistryName(new ResourceLocation(Reference.MOD_ID, unlocalizedName));
    }
    
    public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
        String layer = "1";
        if(type == null) type ="";
        if(EntityEquipmentSlot.LEGS.equals(ModArmor.rubyleggings)) {
            layer = "2";
        }
        else if(EntityEquipmentSlot.HEAD.equals(ModArmor.rubyhelmet) || EntityEquipmentSlot.CHEST.equals(ModArmor.rubychestplate) || EntityEquipmentSlot.FEET.equals(ModArmor.rubyboots)) {
            layer = "1";
        }
        return "ntm:textures/models/armor/ruby_layer_" + layer + ".png";
    }
}

 

Here it's the class : ModArmor

Spoiler

package init;

import java.util.logging.Logger;

import com.neverslands.tutorial.Reference;
import com.neverslands.tutorial.Tutorial;

import items.ItemRubyArmor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;
import scala.actors.threadpool.helpers.Utils;

public class ModArmor {
    public static ArmorMaterial rubyMaterial = EnumHelper.addArmorMaterial("tin",  Reference.MOD_ID + ":tin", 15, new int[] {3,8,8,3}, 9, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 2.0F);
    
    public static Item rubyhelmet;
    public static Item rubychestplate;
    public static Item rubyleggings;
    public static Item rubyboots;
    
    public static void init() {
        rubyhelmet = new ItemRubyArmor(rubyMaterial, 1, EntityEquipmentSlot.HEAD, "rubyhelmet").setCreativeTab(Tutorial.tabTutorial);
        rubychestplate = new ItemRubyArmor(rubyMaterial, 1, EntityEquipmentSlot.CHEST, "rubychestplate").setCreativeTab(Tutorial.tabTutorial);
        rubyleggings = new ItemRubyArmor(rubyMaterial, 2, EntityEquipmentSlot.LEGS, "rubyleggings").setCreativeTab(Tutorial.tabTutorial);
        rubyboots = new ItemRubyArmor(rubyMaterial, 1, EntityEquipmentSlot.FEET, "rubyboots").setCreativeTab(Tutorial.tabTutorial);
    }
    
    public static void register() {
        GameRegistry.register(rubyhelmet);
        GameRegistry.register(rubychestplate);
        GameRegistry.register(rubyleggings);
        GameRegistry.register(rubyboots);
    }
    
    public static void registerRenders() {
        registerRender(rubyhelmet);
        registerRender(rubychestplate);
        registerRender(rubyleggings);
        registerRender(rubyboots);
    }
    
    private static void registerRender(Item item) {
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }
}

 

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.