Jump to content

Rendering and Binding of 3D Modeled Armor


sullos

Recommended Posts

Hello, everyone,

I have been trying to bind my custom model to my armor items.

I do not have any crashes its just that when i put my armor on, it stays as the non modeled version, using a texture i setup for temporary use.

For making reading easier

  • SArmorFull is the name of my model class
  • sArmor is the armor material and is also the file that extends ItemArmor
  • anything to do with a hand drill is just a model/item that i have already implemeted

 

 

Below is my Clientproxy

package com.sullos.Main;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import Model.ItemRendererTutItem;
import com.sullos.item.MItems;
import com.sullos.item.sArmor;
import com.sullos.models.SArmorFull;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.item.Item;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxy extends ServerProxy {
public static final Map<Item, ModelBiped> armorModels = new HashMap<Item, ModelBiped>();

public static void register_renderers(){

	com.sullos.models.SArmorFull custom_armor = new SArmorFull(1F);
	com.sullos.models.SArmorFull custom_legs = new SArmorFull(0.5F);

	armorModels.put(MainRegistry.sHelmet, custom_armor);
	armorModels.put(MainRegistry.sChest, custom_armor);
	armorModels.put(MainRegistry.sPants, custom_legs);
	armorModels.put(MainRegistry.sBoots, custom_armor);

}
//This is just for My 3D hand modeled drill

@Override	
public void registerRenders() {
	MinecraftForgeClient.registerItemRenderer(MItems.handDrill, new ItemRendererTutItem());

}

}

 

My serverproxy

package com.sullos.Main;

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

import com.sullos.models.SArmorFull;

import net.minecraft.client.model.ModelBiped;
import net.minecraft.item.Item;

public class ServerProxy {  
public static final Map<Item, ModelBiped> armorModels = new HashMap<Item, ModelBiped>();

private ModelBiped SArmorFull;

public int addArmor(String armor){
	return 0;

}

public void registerRenders() {


}

public static void registerRenderInfo(){


}


public ModelBiped getArmorModel(ModelBiped SArmorFull) {
	return SArmorFull;
}

public static void register_renderers() {


}


}

 

My Main Registry

package com.sullos.Main;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;

import com.sullos.blocks.MBlocks;
import com.sullos.creativetabs.MCreativeTabs;
import com.sullos.item.MItems;
import com.sullos.item.sArmor;
import com.sullos.lib.RefStrings;
import com.sullos.world.MWorld;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid = RefStrings.MODID , name = RefStrings.NAME , version = RefStrings.VERSION)
public class MainRegistry {

@SidedProxy(clientSide = RefStrings.CLIENTSIDE , serverSide = RefStrings.SERVERSIDE)
public static ServerProxy proxy_server;
public static ClientProxy proxy_client;

public static int sHelmetID;
public static int sChestID;
public static int sPantsID;
public static int sBootsID;

public static Item sHelmet;
public static Item sChest;
public static Item sPants;
public static Item sBoots;

public static ArmorMaterial sArmor = EnumHelper.addArmorMaterial("SullosArmor", 33, new int[]{8, 16, 14, 8}, 30);

@EventHandler
public void preInit(FMLPreInitializationEvent e){
	MCreativeTabs.initialiseTabs();
	MBlocks.mainRegistry();
	MItems.mainRegistry();
	sHelmet = new sArmor(sArmor, sHelmetID, 0).setUnlocalizedName("sHelmet").setCreativeTab(MCreativeTabs.tabTools).setTextureName(RefStrings.MODID + ":sHelmet");
	sChest = new sArmor(sArmor, sChestID, 1).setUnlocalizedName("sChest").setCreativeTab(MCreativeTabs.tabTools).setTextureName(RefStrings.MODID + ":sChest");
	sPants = new sArmor(sArmor, sPantsID, 2).setUnlocalizedName("sPants").setCreativeTab(MCreativeTabs.tabTools).setTextureName(RefStrings.MODID + ":sPants");
	sBoots = new sArmor(sArmor, sBootsID, 3).setUnlocalizedName("sBoots").setCreativeTab(MCreativeTabs.tabTools).setTextureName(RefStrings.MODID + ":sBoots");

	MWorld.mainRegistry();
	CraftingManager.mainRegistry();
	ClientProxy.registerRenderInfo();
	ClientProxy.register_renderers();

	proxy_server.registerRenders();
}
@EventHandler
public void init(FMLInitializationEvent e){

	GameRegistry.registerItem(MainRegistry.sHelmet, "sHelmet");
	GameRegistry.registerItem(MainRegistry.sChest, "sChest");
	GameRegistry.registerItem(MainRegistry.sPants, "sPants");
	GameRegistry.registerItem(MainRegistry.sBoots, "sBoots");


}
@EventHandler
public static void PostLoad(FMLPostInitializationEvent PostEvent){

}
}

 

My sArmor File

package com.sullos.item;

import com.sullos.Main.ClientProxy;
import com.sullos.Main.MainRegistry;
import com.sullos.Main.Resource;
import com.sullos.Main.sPotion;
import com.sullos.creativetabs.MCreativeTabs;
import com.sullos.lib.RefStrings;
import com.sullos.models.SArmorFull;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class sArmor extends ItemArmor{

public sArmor(ArmorMaterial p_i45325_1_, int p_i45325_2_, int p_i45325_3_) {
	super(p_i45325_1_, p_i45325_2_, p_i45325_3_);

	this.setMaxStackSize(2);
	this.setCreativeTab(MCreativeTabs.tabTools);

}

@Override 
@SideOnly(Side.CLIENT) 
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { 
	ModelBiped armorModel = ClientProxy.armorModels.get(this);

	if(armorModel != null){ 
	armorModel.bipedHead.showModel = armorSlot == 0; 
	armorModel.bipedHeadwear.showModel = armorSlot == 0; 
	armorModel.bipedBody.showModel = armorSlot == 1 || armorSlot == 2;
	armorModel.bipedRightArm.showModel = armorSlot == 1; 
	armorModel.bipedLeftArm.showModel = armorSlot == 1; 
	armorModel.bipedRightLeg.showModel = armorSlot == 2 || armorSlot == 3; 
	armorModel.bipedLeftLeg.showModel = armorSlot == 2 || armorSlot == 3; 
	armorModel.isSneak = entityLiving.isSneaking(); 
	armorModel.isRiding = entityLiving.isRiding(); 
	armorModel.isChild = entityLiving.isChild(); 
	  armorModel.heldItemRight = 0;
          armorModel.aimedBow = false;
         
          EntityPlayer player = (EntityPlayer)entityLiving;
         
          ItemStack held_item = player.getEquipmentInSlot(0);
         
          if (held_item != null){
                  armorModel.heldItemRight = 1;
                 
                  if (player.getItemInUseCount() > 0){
                         
                          EnumAction enumaction = held_item.getItemUseAction();
                         
                          if (enumaction == EnumAction.bow){
                                  armorModel.aimedBow = true;
                          }else if (enumaction == EnumAction.block){
                                  armorModel.heldItemRight = 3;
                          }
                         
                  }
                 
          }
         
         
          }
         
          return armorModel;
  }


 public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
 {
        if(stack.getItem() == MItems.sHelmet || stack.getItem() == MItems.sChest || stack.getItem()  == MItems.sBoots){
        	return RefStrings.MODID + ":textures/armor/sArmor1.png";
        }else if(stack.getItem() == MItems.sPants){
        	return RefStrings.MODID + ":textures/armor/sArmor2.png";
        }else{
        	return null;
        } 

 

If you need to see my Model file then just ask though from the many tutorials i have seen it should be set up just fine.

 

Note i have come here because i have been everywhere else looking for a way to make it work but i cannot seem to actually make it work.

The model may not be binding to the items or the model will not render i am not sure.

If anyone has any coding advice or code that can help me i would be extremely grateful!

Thanks

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



×
×
  • Create New...

Important Information

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