Jump to content

3D Custom Item Model Help


MrNegaBlox

Recommended Posts

I was making a custom 3D model for an item, yet once I go in 3rd person, I get a certain Stack Trace, I am wondering what is causing it. BTW, I'm using Techne to make the 3D model and I got the tutorial from iChun.

 

Main Class:

package bettermc.test;

import net.minecraft.block.Block;
import net.minecraft.block.BlockBreakable;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
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.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="BMC", name="BetterMC", version="1.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Test {
public static CreativeTabs tabBlasters = new CreativeTabs("tabBlasters") {
        public ItemStack getIconItemStack() {
                return new ItemStack(blasterRifle, 1, 0);
                
        }
};
public EnumToolMaterial mat;

        // The instance of your mod that Forge uses.
        @Instance("Test")
        public static Test instance;
        //public final static Item MagicEx1  = new MagicExtracter(5004).func_111206_d("bettermc:MagicDrag").setCreativeTab(tabBlasters).setUnlocalizedName("MagicE1");;;
        public final static Item Oore  = new GraxOre(5000).func_111206_d("bettermc:GraxOre").setCreativeTab(tabBlasters).setUnlocalizedName("GraxOre");;;
        //public final static Block Magic  = new MagicBlock(5003, Material.portal).func_111022_d("bettermc:Magic");
        public final static Item PhoenixBlade  = new BlazeBlade(5002).func_111206_d("bettermc:BlazeBlade").setCreativeTab(tabBlasters).setUnlocalizedName("PhoenixBlade");;;
        public final static Item blasterRifle = new Blaster(5001).setCreativeTab(tabBlasters).setUnlocalizedName("Blaster").func_111206_d("bettermc:Blaster");
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="bettermc.test.client.ClientProxy", serverSide="bettermc.test.CommonProxy")
        public static CommonProxy proxy;
        

        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
        	//MinecraftForge.setToolClass(MagicEx1, "MagicTool", 5);
        	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
        	config.load();
            //example
            int randomBlockID = config.getItem("GraxOre", 20001).getInt();

            int randomItemID = config.getItem("Phoenix Blaster", 20000).getInt();
            
            int PhoenixBladeID = config.getItem("PhoenixBlade", 20002).getInt();
        	config.save();
        	
        }
        
        @EventHandler
        public void Init(FMLInitializationEvent event) {

        	    //Register mob
        	

        	    //Localize mob name        	
        	LanguageRegistry.addName(Oore, "Nether Essence");
        	//LanguageRegistry.addName(MagicEx1, "Magic Extracter");
        	//LanguageRegistry.addName(Magic, "Magic Block");
        	LanguageRegistry.addName(PhoenixBlade, "Phoenix Blade");
        	GameRegistry.registerItem(Oore, "Nether Essence");
        	//GameRegistry.registerItem(MagicEx1, "Magic Extracter");
        	GameRegistry.registerItem(PhoenixBlade, "Phoenix Blade");
        	GameRegistry.registerItem(blasterRifle, "Phoenix Blaster");
        	//GameRegistry.registerBlock(Magic, "Magic");
            proxy.registerRenderers();
            LanguageRegistry.addName(blasterRifle, "Phoenix Blaster");
            RenderingRegistry.registerEntityRenderingHandler(EntityBlasterBolt.class, new RenderSnowball(Oore));
            LanguageRegistry.instance().addStringLocalization("itemGroup.tabBlasters", "en_US", "Blaze Phoenix Mod");
            ItemStack dirtStack = new ItemStack(Item.ingotIron);
            ItemStack cobblestack = new ItemStack(blasterRifle);
            ItemStack gravelStack = new ItemStack(Oore);
            GameRegistry.addRecipe(cobblestack, "x  ", " x ", " yx",
                    'x', dirtStack, 'y', gravelStack);
            ItemStack quartzstack = new ItemStack(Item.netherQuartz);
            ItemStack blazestack = new ItemStack(Item.blazePowder);
            GameRegistry.addShapelessRecipe(gravelStack, quartzstack, blazestack);
         
                }
        
            
        
            
        
        
        @EventHandler
        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
}
            

Renderer:

package bettermc.test;
import bettermc.test.Blaster;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

public class ItemRender implements IItemRenderer {

protected ModelPhoenixBlastereModel phoenix;
ResourceLocation texture =  new ResourceLocation("bettermc", "textures/items/PhoenixModel.png)");
        private static RenderItem renderItem = new RenderItem();
        

        @Override
        public boolean handleRenderType(ItemStack itemStack, ItemRenderType type) {
                switch(type){
                case EQUIPPED: return true;
                default: return false;
                }
        }

        @Override
        public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
                        ItemRendererHelper helper) {
                return false;
        }

        @Override
        public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
        	switch(type){
        	case EQUIPPED:{
        		GL11.glPushMatrix();
        		Minecraft.getMinecraft().renderEngine.func_110581_b(texture);
        		phoenix.render((Entity)data[1], 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0625f);
        		GL11.glPopMatrix();
        	}
		default:
			break;
        	}
        }
}

Model Class:

package bettermc.test;
import bettermc.test.Blaster;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

public class ItemRender implements IItemRenderer {

protected ModelPhoenixBlastereModel phoenix;
ResourceLocation texture =  new ResourceLocation("bettermc", "textures/items/PhoenixModel.png)");
        private static RenderItem renderItem = new RenderItem();
        

        @Override
        public boolean handleRenderType(ItemStack itemStack, ItemRenderType type) {
                switch(type){
                case EQUIPPED: return true;
                default: return false;
                }
        }

        @Override
        public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
                        ItemRendererHelper helper) {
                return false;
        }

        @Override
        public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
        	switch(type){
        	case EQUIPPED:{
        		GL11.glPushMatrix();
        		Minecraft.getMinecraft().renderEngine.func_110581_b(texture);
        		phoenix.render((Entity)data[1], 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0625f);
        		GL11.glPopMatrix();
        	}
		default:
			break;
        	}
        }
}
[/Code]

Item(Its a spade cause I was trying to make it not look like an item in hand and more like a sword):
[code]
package bettermc.test;

import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class Blaster extends ItemSpade {

public Blaster(int id) {
	super(id, EnumToolMaterial.PHOENIX);



}


 @Override
 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) {
   if(par3EntityPlayer.capabilities.isCreativeMode||par3EntityPlayer.inventory.consumeInventoryItem(Item.redstone.itemID))
   {
     par2World.playSoundAtEntity(par3EntityPlayer, "random.fuse", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
     
     par2World.spawnEntityInWorld(new EntityBlasterBolt(par2World, par3EntityPlayer));
     }
   
  return par1ItemStack;
   }
}

Stack Trace:

2014-01-02 21:53:12 [sEVERE] [Minecraft-Client] ########## GL ERROR ##########
2014-01-02 21:53:12 [sEVERE] [Minecraft-Client] @ Post render
2014-01-02 21:53:12 [sEVERE] [Minecraft-Client] 1283: Stack overflow
2014-01-02 21:53:12 [iNFO] [sTDERR] java.lang.NullPointerException
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at bettermc.test.ItemRender.renderItem(ItemRender.java:45)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraftforge.client.ForgeHooksClient.renderEquippedItem(ForgeHooksClient.java:207)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.ItemRenderer.renderItem(ItemRenderer.java:89)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.ItemRenderer.renderItem(ItemRenderer.java:68)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderPlayer.renderSpecials(RenderPlayer.java:408)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderPlayer.renderEquippedItems(RenderPlayer.java:519)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RendererLivingEntity.func_130000_a(RendererLivingEntity.java:218)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderPlayer.func_130009_a(RenderPlayer.java:166)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderPlayer.doRender(RenderPlayer.java:553)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderManager.renderEntityWithPosYaw(RenderManager.java:312)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderManager.renderEntity(RenderManager.java:281)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:524)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1160)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1006)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:934)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:826)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.client.main.Main.main(Main.java:93)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)
2014-01-02 21:53:12 [iNFO] [sTDERR] 	at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

Link to comment
Share on other sites

Read your f*ing error.

 

Null pointer at ItemRender line 45.

 

Look at the f*ing code that's there and figure out which object is null.  It's really f*ing obvious.

 

(Hint, there's only one object there that is using references to its properties or methods)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Here's the line that is throwing the error

phoenix.render((Entity)data[1], 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0625f);

Hmm.  Lets see.  The only object here is phoenix, lets go see where that's used elsewhere.

protected ModelPhoenixBlastereModel phoenix;

 

THAT'S FUNNY, ITS NEVER ASSIGNED A VALUE.  LAWL.  NO WONDER IT'S NULL!

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Ok I may sound and probably am stupid with Java (I'm new, intermediate, not fluent, I learn from tutorials, I get what they say, but I have things to learn), But How would I assign this a value? I mean I get that is referencing the class, but how do I make it NOT null, If you won't answer, then others will. Cause I don't know what values to put to make it not null, if I don't get it, ill look up on iChuns tut again.

Link to comment
Share on other sites

protected ModelPhoenixBlastereModel phoenix = new ModelPhoenixBlastereModel();

 

Possibly? Although I have no idea exactly what ModelPhoenixBlastereModel is other than badly named...

 

The dude with five posts figured it out.

 

You (the original poster) need to go learn Java before tinkering around with Minecraft some more.  This is a basic concept you need to know before modding can begin.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.

Announcements



×
×
  • Create New...

Important Information

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