Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Solved[1.15.2] 3D model Armor


Valtiel
 Share

Recommended Posts

 

First let me clarify that I use the google translator I speak Spanish so my writing may have errors

 

 

this class adds the 3d model to armoritem i use it because my mod adds various armor

package com.valtiel.vgirlarmor.item.armor;

import com.valtiel.vgirlarmor.proxy.ClientProxy;

import net.minecraft.client.renderer.entity.model.BipedModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.IArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class Girl_Armor extends ArmorItem
{

	 public final EquipmentSlotType type;
	
	 public Girl_Armor(IArmorMaterial mat, EquipmentSlotType type, Properties props) {
	        super(mat, type, props);
	        this.type = type;
	    }

	    @SuppressWarnings({ "rawtypes", "unchecked" })
		@Override
	    @OnlyIn(Dist.CLIENT)
	    public BipedModel getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, BipedModel original) {
	    	BipedModel armorModel = ClientProxy.armorModels.get(this);

			if (armorModel != null) {
				armorModel.bipedHead.showModel = armorSlot == EquipmentSlotType.HEAD;
				armorModel.bipedHeadwear.showModel = false;
				armorModel.bipedBody.showModel = armorSlot == EquipmentSlotType.CHEST || armorSlot == EquipmentSlotType.LEGS;
				armorModel.bipedRightArm.showModel = armorSlot == EquipmentSlotType.CHEST;
				armorModel.bipedLeftArm.showModel = armorSlot == EquipmentSlotType.CHEST;
				armorModel.bipedRightLeg.showModel = armorSlot == EquipmentSlotType.LEGS || armorSlot == EquipmentSlotType.FEET;
				armorModel.bipedLeftLeg.showModel = armorSlot == EquipmentSlotType.LEGS || armorSlot == EquipmentSlotType.FEET;
	    }
			return armorModel;
}
}

 

 

this is my armor class, when extending "girl armor" the 3d model is automatically added, if you only want to make an armor add the "girl armor" code and extend armoritem

 

ckage com.valtiel.vgirlarmor.item.armor;

import javax.annotation.Nonnull;

import com.valtiel.vgirlarmor.Girl_Armor_Mod;
import com.valtiel.vgirlarmor.item.ItemModHats;
import com.valtiel.vgirlarmor.item.ItemModShoes;
import com.valtiel.vgirlarmor.item.ItemModSkirts;
import com.valtiel.vgirlarmor.item.ItemModTops;

import net.minecraft.entity.Entity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.IArmorMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraftforge.registries.ForgeRegistries;

public class Diamond_Girl_Armor extends Girl_Armor
{

	
	    public static final IArmorMaterial DIAMOND_A = new IArmorMaterial() {
	        private final int[] damageReduction = {4, 6, 8, 4};
	       
	        
	        
	        @Override
	        public int getDurability(EquipmentSlotType slotIn) {
	            return 550;
	        }

	        @Override
	        public int getDamageReductionAmount(EquipmentSlotType slotIn) {
	            return damageReduction[slotIn.getIndex()];
	        }

	        @Override
	        public int getEnchantability() {
	            return 40;
	        }

	        @Override
	        public SoundEvent getSoundEvent() {
	            return SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND;
	        }

	        @Override
	        public Ingredient getRepairMaterial() {
	            Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("minecraft", "diamond"));
	            return Ingredient.fromItems(item);
	        }

	        @Override
	        public String getName() {
	            return "diamond_girl";
	        }

	        @Override
	        public float getToughness() {
	            return 3;
	        }
	    };

	    public final EquipmentSlotType type;

	    public Diamond_Girl_Armor(EquipmentSlotType type, IArmorMaterial mat, Properties props) {
	        super(mat, type, props);
	        this.type = type;
	    }

	    
	 
	    @Nonnull
	    @Override
	    public final String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlotType slot, String type){

	    	if(stack.getItem() == ItemModSkirts.Diamond_Skirt)
			{
				return Girl_Armor_Mod.modId + ":" + "/textures/models/armor/diamond_girl_armor_layer_2.png" ;
			}
	    	 else if(stack.getItem() == ItemModHats.Diamond_Hat || stack.getItem() == ItemModTops.Diamond_Top || stack.getItem() == ItemModShoes.Diamond_Shoes)
	    		   
			{
				return Girl_Armor_Mod.modId + ":" + "/textures/models/armor/diamond_girl_armor_layer_1.png" ;
			}
	    	 return null;
	}
	}

 

 

my model class, just an example

package com.valtiel.vgirlarmor.models;

import net.minecraft.client.renderer.entity.model.BipedModel;
import net.minecraft.client.renderer.model.ModelRenderer;

public class Girl_Armor_Model  extends BipedModel
{

	 
		    
	//fields
		ModelRenderer torso2;
	
		
		    
	  public Girl_Armor_Model(float expand)
	  {
	   super(expand, 0, 128, 64); 
	////torso2    
	    torso2 = new ModelRenderer(this, 16, 32);
	    torso2.func_228301_a_(-4F, 0F, -2F, 8, 12, 4, expand/(15.0F));
	    torso2.setRotationPoint(0F, 0F, 0F);
	    torso2.setTextureSize(128, 64);
	    torso2.mirror = true;
	    setRotation(torso2, 0F, 0F, 0F);
	    
	
	    
	    
	   
	    this.bipedBody.addChild(torso2);

	 } 
	  
		
		 private void setRotation(ModelRenderer model, float x, float y, float z)
		  {
		    model.rotateAngleX = x;
		    model.rotateAngleY = y;
		    model.rotateAngleZ = z;
		  } 
		
		}

 

itemMod

 

package com.valtiel.vgirlarmor.item;

import com.valtiel.vgirlarmor.Girl_Armor_Mod;
import com.valtiel.vgirlarmor.item.armor.Diamond_Girl_Armor;

import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.IForgeRegistry;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ItemModHats {

	
	public static final Item Diamond_Hat = new Diamond_Girl_Armor(EquipmentSlotType.HEAD, Diamond_Girl_Armor.DIAMOND_A, unstackable()).setRegistryName(Girl_Armor_Mod.modId, "diamond_hat");
	
	
	
	
    @SubscribeEvent
    public static void registerItems(RegistryEvent.Register<Item> evt) {
        IForgeRegistry<Item> registry = evt.getRegistry();
        registry.register(Diamond_Hat);
             
    }


    public static Item.Properties defaultBuilder() {
        return new Item.Properties().group(Girl_Armor_Mod.Girl_Armor_Hats);
    }

    private static Item.Properties unstackable() {
        return defaultBuilder().maxStackSize(1);
    }
}

 

 

finally client proxy, this registers the 3d model in the mod

package com.valtiel.vgirlarmor.proxy;

import java.util.HashMap;
import java.util.Map;

import com.valtiel.vgirlarmor.item.ItemModHats;
import com.valtiel.vgirlarmor.models.Girl_Armor_Model;

import net.minecraft.client.renderer.entity.model.BipedModel;
import net.minecraft.item.Item;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

@Mod.EventBusSubscriber(Dist.CLIENT)
public class ClientProxy implements IProxy {
	
	
	@SuppressWarnings("rawtypes")
	public static final Map<Item, BipedModel> armorModels = new HashMap<Item, BipedModel>();

    public void registerHandlers() {
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
        
        
        
        Girl_Armor_Model girlarmor = new Girl_Armor_Model(1.0F);
		Girl_Armor_Model girlskirt = new Girl_Armor_Model(0.5F);
        
		armorModels.put(ItemModHats.Diamond_Hat, girlarmor);
		armorModels.put(ItemModTops.Diamond_Top, girlarmor);
		armorModels.put(ItemModSkirts.Diamond_Skirt, girlskirt);
		armorModels.put(ItemModShoes.Diamond_Shoes, girlarmor);
		
		
		
    }

    private void clientSetup(FMLClientSetupEvent event) {
        
    }

}

 

 

with this code eliminate the problem of lag in second and third person

ZhPjfgP.png

Link to comment
Share on other sites

  • 1 year later...
Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.