Jump to content

[1.8] [SOLVED] crash rendering projectile entity


Glistre

Recommended Posts

I am sure this is totally wrong. Could use some instruction on how to render entities and projectiles. . .does anyone know any good tutorials for 1.8 on rendering projectiles?

 

the #doRender from 1.7.10 no longer works at all, I thought if I removed that and added RenderManager in the constructor it would work, obviously not.  Should I start over and revisit EntityArrow class?

 

---- Minecraft Crash Report ----
// Everything's going to plan. No, really, that was supposed to happen.

Time: 7/29/16 8:22 AM
Description: Rendering item

java.lang.NullPointerException: Rendering item
at net.minecraft.item.ItemStack.getMetadata(ItemStack.java:280)
at net.minecraft.client.renderer.ItemModelMesher.getMetadata(ItemModelMesher.java:70)
at net.minecraft.client.renderer.ItemModelMesher.getItemModel(ItemModelMesher.java:43)
at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:360)
at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:411)
at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:293)
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:116)
at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:53)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:659)
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:470)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1137)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114)
at net.minecraft.client.Minecraft.run(Minecraft.java:376)
at net.minecraft.client.main.Main.main(Main.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at net.minecraft.item.ItemStack.getMetadata(ItemStack.java:280)
at net.minecraft.client.renderer.ItemModelMesher.getMetadata(ItemModelMesher.java:70)
at net.minecraft.client.renderer.ItemModelMesher.getItemModel(ItemModelMesher.java:43)
at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:360)

-- Item being rendered --
Details:
Item Type: null
Item Aux: ~~ERROR~~ NullPointerException: null
Item NBT: null
Item Foil: ~~ERROR~~ NullPointerException: null
Stacktrace:
at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:411)
at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:293)
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:116)
at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:53)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:659)
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:470)

-- Screen render details --
Details:
Screen name: net.minecraft.client.gui.inventory.GuiContainerCreative
Mouse location: Scaled: (243, 32). Absolute: (486, 414)
Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityPlayerSP['Player897'/131, l='MpServer', x=276.93, y=102.01, z=422.72]]
Chunk stats: MultiplayerChunkCache: 577, 577
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: -162.00,64.00,478.00 - World: (-162,64,478), Chunk: (at 14,4,14 in -11,29; contains blocks -176,0,464 to -161,255,479), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Level time: 7091 game time, 7091 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 54 total; [EntityBat['Bat'/5888, l='MpServer', x=237.50, y=22.45, z=423.45], EntityBat['Bat'/5889, l='MpServer', x=228.23, y=22.22, z=421.34], EntityBat['Bat'/5890, l='MpServer', x=237.24, y=25.09, z=424.66], EntityBat['Bat'/6148, l='MpServer', x=206.27, y=22.38, z=473.29], EntityBat['Bat'/6149, l='MpServer', x=208.50, y=19.75, z=476.67], EntityWitch['Witch'/6153, l='MpServer', x=215.50, y=19.00, z=456.50], EntityWitch['Witch'/6154, l='MpServer', x=213.50, y=19.00, z=454.50], EntityWitch['Witch'/6155, l='MpServer', x=212.50, y=19.00, z=457.50], EntitySpider['Spider'/6165, l='MpServer', x=216.50, y=20.02, z=494.50], EntityCreeper['Creeper'/6170, l='MpServer', x=212.50, y=25.02, z=381.50], EntitySkeleton['Skeleton'/6174, l='MpServer', x=238.19, y=25.00, z=434.66], EntitySkeleton['Skeleton'/6175, l='MpServer', x=234.50, y=25.02, z=436.50], EntityZombie['Zombie'/6179, l='MpServer', x=230.50, y=21.02, z=432.50], EntityBat['Bat'/5926, l='MpServer', x=237.29, y=25.39, z=422.84], EntityBat['Bat'/5928, l='MpServer', x=234.50, y=23.19, z=424.56], EntitySkeleton['Skeleton'/6184, l='MpServer', x=201.50, y=23.02, z=472.50], EntityZombie['Zombie'/5932, l='MpServer', x=356.50, y=17.00, z=371.50], EntityZombie['Zombie'/5933, l='MpServer', x=355.50, y=17.00, z=371.50], EntityEnderman['Enderman'/6194, l='MpServer', x=212.50, y=20.02, z=456.50], EntityZombie['Zombie'/6195, l='MpServer', x=209.50, y=20.02, z=458.50], EntityZombie['Zombie'/6196, l='MpServer', x=207.50, y=20.02, z=460.50], EntitySkeleton['Skeleton'/6200, l='MpServer', x=222.50, y=22.02, z=502.50], EntitySkeleton['Skeleton'/6201, l='MpServer', x=220.50, y=22.02, z=500.50], EntitySkeleton['Skeleton'/6202, l='MpServer', x=225.50, y=22.02, z=501.50], EntityZombie['Zombie'/6206, l='MpServer', x=201.50, y=23.02, z=475.50], EntityZombie['Zombie'/6207, l='MpServer', x=199.50, y=23.02, z=471.50], EntityCreeper['Creeper'/5952, l='MpServer', x=238.29, y=25.00, z=418.47], EntityBat['Bat'/5964, l='MpServer', x=247.25, y=20.13, z=413.19], EntityCreeper['Creeper'/5967, l='MpServer', x=220.84, y=29.00, z=426.47], EntityPlayerSP['Player897'/131, l='MpServer', x=276.93, y=102.01, z=422.72], EntityZombie['Zombie'/5743, l='MpServer', x=241.50, y=26.00, z=404.50], EntityBat['Bat'/6000, l='MpServer', x=224.73, y=28.85, z=424.44], EntityWitch['Witch'/6019, l='MpServer', x=247.50, y=19.00, z=405.50], EntityBat['Bat'/6040, l='MpServer', x=239.51, y=21.22, z=421.96], EntityZombie['Zombie'/6043, l='MpServer', x=241.50, y=25.00, z=433.50], EntityBat['Bat'/6047, l='MpServer', x=224.91, y=29.08, z=344.70], EntitySkeleton['Skeleton'/6059, l='MpServer', x=239.06, y=32.00, z=407.56], EntitySkeleton['Skeleton'/6060, l='MpServer', x=234.50, y=31.00, z=410.50], EntityCreeper['Creeper'/6061, l='MpServer', x=234.50, y=31.00, z=408.50], EntitySkeleton['Skeleton'/6072, l='MpServer', x=240.24, y=28.00, z=425.25], EntitySkeleton['Skeleton'/6073, l='MpServer', x=233.60, y=27.55, z=428.54], EntityBat['Bat'/6076, l='MpServer', x=233.02, y=23.79, z=423.18], EntityBat['Bat'/6077, l='MpServer', x=227.44, y=29.93, z=425.45], EntityCreeper['Creeper'/6085, l='MpServer', x=233.11, y=27.00, z=426.09], EntityCreeper['Creeper'/6086, l='MpServer', x=229.50, y=27.00, z=427.50], EntityCreeper['Creeper'/6092, l='MpServer', x=197.50, y=19.00, z=464.50], EntitySkeleton['Skeleton'/6093, l='MpServer', x=208.58, y=20.00, z=460.94], EntitySkeleton['Skeleton'/6094, l='MpServer', x=205.50, y=20.00, z=470.50], EntityBat['Bat'/6099, l='MpServer', x=248.94, y=20.56, z=410.56], EntityCreeper['Creeper'/5858, l='MpServer', x=217.50, y=27.00, z=360.50], EntityCreeper['Creeper'/5859, l='MpServer', x=218.50, y=27.00, z=359.50], EntityBat['Bat'/5872, l='MpServer', x=216.56, y=33.10, z=409.41], EntitySpider['Spider'/6129, l='MpServer', x=207.50, y=19.00, z=478.50], EntityBat['Bat'/5887, l='MpServer', x=231.69, y=24.63, z=423.99]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:392)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2614)
at net.minecraft.client.Minecraft.run(Minecraft.java:398)
at net.minecraft.client.main.Main.main(Main.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)

-- System Details --
Details:
Minecraft Version: 1.8
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_60, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 7218370616 bytes (6883 MB) / 8355053568 bytes (7968 MB) up to 8355053568 bytes (7968 MB)
JVM Flags: 4 total; -Xmx8192M -Xms8192M -Xmx8192M -Xms8192M
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.4.1577 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAAAA	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJAAAA	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.4.1577.jar) 
UCHIJAAAA	Forge{11.14.4.1577} [Minecraft Forge] (forgeSrc-1.8-11.14.4.1577.jar) 
UCHIJAAAA	glistremod{2.0} [Glistre Mod] (bin) 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 353.54' Renderer: 'GeForce GTX 980M/PCIe/SSE2'
Launched Version: 1.8
LWJGL: 2.9.1
OpenGL: GeForce GTX 980M/PCIe/SSE2 GL version 4.5.0 NVIDIA 353.54, NVIDIA Corporation
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

Using VBOs: No
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)

 

package com.glistre.glistremod.projectiles.tobyworstsword;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityPotion;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPotion;
import net.minecraft.potion.PotionHelper;
//import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

@SideOnly(Side.CLIENT)
public class TobyRenderProjectile extends Render
{
    private Item field_94151_a;
    private int field_94150_f;

    private static final ResourceLocation tobyWorstTextures = new ResourceLocation("glistremod:textures/toby_worst_projectile_1.png");
    
    public TobyRenderProjectile(RenderManager renderManager)
    {
        super(renderManager);
    }

    public TobyRenderProjectile(RenderManager renderManager, Item item, int par2) {
    	super (renderManager);
    	 this.field_94151_a = item;
         this.field_94150_f = par2;
}

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
/*    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        IIcon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f);

        if (icon != null)
        {
            GL11.glPushMatrix();
            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            this.bindEntityTexture(par1Entity);
            Tessellator tessellator = Tessellator.instance;

            if (icon == ItemPotion.func_94589_d("bottle_splash"))
            {
                int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false);
                float f2 = (float)(i >> 16 & 255) / 255.0F;
                float f3 = (float)(i >> 8 & 255) / 255.0F;
                float f4 = (float)(i & 255) / 255.0F;
                GL11.glColor3f(f2, f3, f4);
                GL11.glPushMatrix();
                this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay"));
                GL11.glPopMatrix();
                GL11.glColor3f(1.0F, 1.0F, 1.0F);
            }

            this.func_77026_a(tessellator, icon);
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
        }
    }*/



    protected boolean bindEntityTexture(Entity entity)
    {
        ResourceLocation resourcelocation = this.getEntityTexture(entity);

        if (resourcelocation == null)
        {
            return false;
        }
        else
        {
            this.bindTexture(resourcelocation);
            return true;
        }
    }

    public void bindTexture(ResourceLocation location)
    {
        this.renderManager.renderEngine.bindTexture(location);
    }

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
//      return TextureMap.locationItemsTexture;

	return this.tobyWorstTextures;
}
}

/*rotate projectile -default for GL11 ....playerViewY =1.0F, 1.0F, 1.0F */
/*   private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon)
    {
        float f = par2Icon.getMinU();
        float f1 = par2Icon.getMaxU();
        float f2 = par2Icon.getMinV();
        float f3 = par2Icon.getMaxV();
        float f4 = 1.0F;
        float f5 = 0.5F;
        float f6 = 0.25F;
        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 1.5F, 1.0F, 1.5F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        par1Tessellator.startDrawingQuads();
        par1Tessellator.setNormal(0.0F, 1.0F, 0.0F);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
        par1Tessellator.draw();
    }
    
//   GL11.glRotatef(par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
}*/

Link to comment
Share on other sites

This has nothing to do with rendering your projectile. This is Minecraft trying to render an ItemStack with a null item.

 

I worked on this a bit. ..but I cannot seem to figure out how the item would be null.  I have the following where I register the entity:

 

Entity Registry

public class GlistreEntityRegistry {

public static void GlistreMod(){
	initializeEntity();
	registerEntity();
}


    public static Item tobie_worst_projectile_1;

public static int modEntityID = 0;

public static void initializeEntity(){


        tobie_worst_projectile_1 = new TobyEntitySword(Item.ToolMaterial.IRON).setUnlocalizedName("tobie_worst_projectile_1");

}

public static void registerEntity() {


        // TOBIE'S WORST ENEMY	
   	    GameRegistry.registerItem(tobie_worst_projectile_1, "tobie_worst_projectile_1");  
        EntityRegistry.registerModEntity(TobyEntityProjectile.class, "tobie_worst_projectile_1", ++modEntityID, GlistreMod.instance, 80, 3, true);


}

public static void registerRenders(){

	registerRender(tobie_worst_projectile_1);

}

public static void registerRender(Item item){
	RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
 	renderItem.getItemModelMesher().register(tobie_worst_projectile_1, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));


}

}

Client Proxy:
[code]
package com.glistre.glistremod.proxies;

import java.awt.Color;

import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

import com.glistre.glistremod.GlistreMod;
import com.glistre.glistremod.init.BlockRegistry;
import com.glistre.glistremod.init.GlistreEntityRegistry;
import com.glistre.glistremod.init.ItemRegistry;
import com.glistre.glistremod.init.Recipes;
import com.glistre.glistremod.projectiles.tobyworstsword.TobyEntityProjectile;
import com.glistre.glistremod.projectiles.tobyworstsword.TobyRenderProjectile;
import com.glistre.glistremod.tabs.TabRegistry;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.registry.EntityRegistry;


public class ClientProxy extends CommonProxy {

@Override
public void Init(){
	this.registerRenders();
	ItemRegistry.registerRenders();
	BlockRegistry.registerRenders();
	GlistreEntityRegistry.registerRenders();
	TabRegistry.registerRenders();

}

@Override
public void registerRenders(){

       RenderingRegistry.registerEntityRenderingHandler(TobyEntityProjectile.class, new TobyRenderProjectile(Minecraft.getMinecraft().getRenderManager(), GlistreEntityRegistry.tobie_worst_projectile_1, Minecraft.getMinecraft().getRenderItem()));
}

}

 

Main class:

package com.glistre.glistremod;


@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY, canBeDeactivated = true)

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;

@Mod.Instance(Reference.MOD_ID)	
public static GlistreMod instance;

@EventHandler	
public void preInit(FMLPreInitializationEvent event) {

 proxy.preInit();

@EventHandler
public static void init(FMLInitializationEvent event ) 
{


 BlockRegistry.init();
 BlockRegistry.register();	
//	 ItemRegistry.GlistreMod();
 ItemRegistry.init();  //Are these not needed since I have public void Init in the client proxy?
 ItemRegistry.register();
//	 TabRegistry.GlistreMod();
 TabRegistry.initializeTab();
	TabRegistry.registerTab();


   	FMLCommonHandler.instance().bus().register(instance);

	Recipes.initShapedRecipes();
	Recipes.initShapelessRecipes();
	Recipes.initSmeltingRecipes();
	GlistreEntityRegistry.GlistreMod();

	WorldGen.initWorldGen();
	BiomeRegistry.GlistreMod();
	DimensionRegistry.GlistreMod();

	 proxy.Init();
	 proxy.registerRenders();//can be done in any init phase but must be done AFTER items are registered

@EventHandler
public static void postInit( FMLPostInitializationEvent event ) 
{

proxy.postInit();

}		
}

 

At my wit's end and tried so many things just getting confused.  help needed 

Link to comment
Share on other sites

You are initializing the GlistreEntityRegistry after some other stuff such as creative tabs. I assume your creative tabs are trying to use the item defined in GlistreEntityRegistry.

 

I rearranged the main class (sorry left out where I initialize GlistreEntityRegistry)I still get the same crash although I put the TabRegistry after everything else:

public static void init(FMLInitializationEvent event ) 
{


 BlockRegistry.init();
 BlockRegistry.register();	

 ItemRegistry.init(); 
 ItemRegistry.register();

   	FMLCommonHandler.instance().bus().register(instance);

	Recipes.initShapedRecipes();
	Recipes.initShapelessRecipes();
	Recipes.initSmeltingRecipes();
	WorldGen.initWorldGen();
	BiomeRegistry.GlistreMod();
	DimensionRegistry.GlistreMod();

	GlistreEntityRegistry.initializeEntity();
	GlistreEntityRegistry.registerEntity();

                proxy.Init();
	proxy.registerRenders();//can be done in any init phase but must be done AFTER items are registered

	TabRegistry.initializeTab();
	TabRegistry.registerTab();

 

TabRegistry

package com.glistre.glistremod.tabs;

import java.util.List;

import com.glistre.glistremod.GlistreMod;
import com.glistre.glistremod.entities.placers.GlistreEntityMonsterPlacer;
import com.glistre.glistremod.init.BlockRegistry;
import com.glistre.glistremod.init.GlistreEntityRegistry;
import com.glistre.glistremod.init.ItemRegistry;

import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class TabRegistry {

public static void GlistreMod(){
	initializeTab();
	registerTab();
}

// the ray or blast bolt like an arrow
     public static Item blasterbolt_1;
     public int blasterbolt_1ID;
     public static Item enderbolt_1;
     public int enderbolt_1ID;
     public static Item sceptrebolt_1;
     public int sceptrebolt_1ID;


//DECLARE CREATIVE TABS
public static GlistreTabs glistre_tab_1;		
public static GlistreTabs tab_custom;
public static GlistreTabs tab_builder;
   	public static GlistreTabs tab_food;    	
public static GlistreTabs tab_potion;
public static void initializeTab(){

	//LOAD THE CREATIVE TABS
	glistre_tab_1 = new GlistreTabs("glistre_tab_1"){

		public Item getTabIconItem(){
			return (ItemRegistry.glistre_sword);
		}


		//puts in tab and displays in the order that you'd like
		public void displayAllReleventItems(List list) {

			list.add(new ItemStack(ItemRegistry.silver_sword_1));
			ItemStack enchant01 = new ItemStack(ItemRegistry.silver_sword_1);
			enchant01.addEnchantment(Enchantment.baneOfArthropods, ;
			list.add(enchant01);

			list.add(new ItemStack(ItemRegistry.glistre_sword));
			ItemStack enchant = new ItemStack(ItemRegistry.glistre_sword);
			enchant.addEnchantment(Enchantment.sharpness, 5);
			list.add(enchant);

			list.add(new ItemStack(ItemRegistry.mighty_sword));
			list.add(new ItemStack(ItemRegistry.mighty_ice_sword));

			list.add(new ItemStack(ItemRegistry.custom_bow_1));
			ItemStack enchant04 = new ItemStack(ItemRegistry.custom_bow_1);
    		enchant04.addEnchantment(Enchantment.infinity, 10);
    		enchant04.addEnchantment(Enchantment.power, 7);
    		list.add(enchant04);

			list.add(new ItemStack(ItemRegistry.blaster_gun_1));
			list.add(new ItemStack(ItemRegistry.ender_gun));

			list.add(new ItemStack(ItemRegistry.silver_helmet_1));
			list.add(new ItemStack(ItemRegistry.silver_chestplate_1));
			list.add(new ItemStack(ItemRegistry.silver_leggings_1));
			list.add(new ItemStack(ItemRegistry.silver_boots_1));
			ItemStack enchant0 = new ItemStack(ItemRegistry.silver_helmet_1);
			ItemStack enchant1 = new ItemStack(ItemRegistry.silver_chestplate_1);
			ItemStack enchant2 = new ItemStack(ItemRegistry.silver_leggings_1);
			ItemStack enchant3 = new ItemStack(ItemRegistry.silver_boots_1);
			enchant0.addEnchantment(Enchantment.protection, 4);
			enchant1.addEnchantment(Enchantment.blastProtection, 4);
			enchant2.addEnchantment(Enchantment.protection, 4);							
			enchant3.addEnchantment(Enchantment.protection, 4);
			enchant3.addEnchantment(Enchantment.featherFalling, 4);
    		list.add(enchant0);
    		list.add(enchant1);
    		list.add(enchant2);
    		list.add(enchant3);				

			list.add(new ItemStack(ItemRegistry.glistre_helmet_1));
			list.add(new ItemStack(ItemRegistry.glistre_chestplate_1));
			list.add(new ItemStack(ItemRegistry.glistre_leggings_1));
			list.add(new ItemStack(ItemRegistry.glistre_boots_1));
			ItemStack enchant4 = new ItemStack(ItemRegistry.glistre_helmet_1);
			ItemStack enchant5 = new ItemStack(ItemRegistry.glistre_chestplate_1);				
			ItemStack enchant6 = new ItemStack(ItemRegistry.glistre_leggings_1);				
			ItemStack enchant7 = new ItemStack(ItemRegistry.glistre_boots_1);				
			enchant4.addEnchantment(Enchantment.fireProtection, 4);
			enchant5.addEnchantment(Enchantment.fireProtection, 4);
			enchant6.addEnchantment(Enchantment.fireProtection, 4);
			enchant7.addEnchantment(Enchantment.fireProtection, 4);
    		list.add(enchant4);
    		list.add(enchant5);
    		list.add(enchant6);
    		list.add(enchant7);				

			list.add(new ItemStack(ItemRegistry.chain_helmet_1));
			list.add(new ItemStack(ItemRegistry.chain_chestplate_1));				
			list.add(new ItemStack(ItemRegistry.chain_leggings_1));			
			list.add(new ItemStack(ItemRegistry.chain_boots_1));	
			ItemStack enchant8 = new ItemStack(ItemRegistry.chain_helmet_1);
			ItemStack enchant9 = new ItemStack(ItemRegistry.chain_chestplate_1);
			ItemStack enchant10 = new ItemStack(ItemRegistry.chain_leggings_1);
			ItemStack enchant11 = new ItemStack(ItemRegistry.chain_boots_1);
			enchant8 = new ItemStack(ItemRegistry.chain_helmet_1);
			enchant9 = new ItemStack(ItemRegistry.chain_chestplate_1);
			enchant10 = new ItemStack(ItemRegistry.chain_leggings_1);
			enchant11 = new ItemStack(ItemRegistry.chain_boots_1);
    		enchant8.addEnchantment(Enchantment.projectileProtection, 5);
    		enchant9.addEnchantment(Enchantment.projectileProtection, 5);
    		enchant10.addEnchantment(Enchantment.projectileProtection, 5);
    		enchant11.addEnchantment(Enchantment.projectileProtection, 5);
    		list.add(enchant8);
    		list.add(enchant9);
    		list.add(enchant10);
    		list.add(enchant11);

		}

};

tab_custom = new GlistreTabs("tab_custom") {

		public Item getTabIconItem() {

			return (ItemRegistry.silver_pickaxe_1);
		}

		public void displayAllReleventItems(List list) {
			list.add(new ItemStack(ItemRegistry.silver_pickaxe_1));
			ItemStack enchant02 = new ItemStack(ItemRegistry.silver_pickaxe_1);
    		enchant02.addEnchantment(Enchantment.fortune, 4);
    		list.add(enchant02);
    		
			list.add(new ItemStack(ItemRegistry.glistre_pickaxe));
	    	ItemStack enchant03 = new ItemStack(ItemRegistry.glistre_pickaxe);
	    	enchant03.addEnchantment(Enchantment.efficiency, 3);
	    	enchant03.addEnchantment(Enchantment.unbreaking, 3);
	    	list.add(enchant03);
	    	
			list.add(new ItemStack(ItemRegistry.glistre_pickaxe_2));
			ItemStack enchant04 = new ItemStack(ItemRegistry.glistre_pickaxe_2);
	    	enchant04.addEnchantment(Enchantment.efficiency, 4);
	    	list.add(enchant04);
	    		
			list.add(new ItemStack(ItemRegistry.glistre_burner));
			list.add(new ItemStack(ItemRegistry.toby_king_burner));

			list.add(new ItemStack(ItemRegistry.wolf_howl));
			list.add(new ItemStack(ItemRegistry.wolves_howling));
			list.add(new ItemStack(ItemRegistry.sasquatch));
			list.add(new ItemStack(ItemRegistry.silver_ingot_1));
			list.add(new ItemStack(ItemRegistry.glistre_ingot));
			list.add(new ItemStack(ItemRegistry.glistre_dust));

			list.add(new ItemStack(ItemRegistry.item_spawn_egg));
			list.add(new ItemStack(ItemRegistry.item_spawn_egg_1));
			list.add(new ItemStack(ItemRegistry.item_spawn_egg_3));

		}

};

tab_food = new GlistreTabs("tab_food") {

	public Item getTabIconItem() {

		return (ItemRegistry.glistre_food_1);

	}
	public void displayAllReleventItems(List list) {
	list.add(new ItemStack(ItemRegistry.glistre_food_1));
	list.add(new ItemStack(ItemRegistry.glistre_food_2));	
	list.add(new ItemStack(ItemRegistry.nori));	
	list.add(new ItemStack(ItemRegistry.sushi));	
	}	
};

tab_builder = new GlistreTabs("tab_builder") {

	public Item getTabIconItem() {

		return new ItemStack(BlockRegistry.silver_ore_1).getItem();
	}

	public void displayAllReleventItems(List list) {

	list.add(new ItemStack(BlockRegistry.silver_ore_1));
	list.add(new ItemStack(BlockRegistry.silver_ore_2));
	list.add(new ItemStack(BlockRegistry.silver_ore_3));
	list.add(new ItemStack(BlockRegistry.silver_ore_4));
	list.add(new ItemStack(BlockRegistry.silver_block_1));
	list.add(new ItemStack(BlockRegistry.silver_block_2));
	list.add(new ItemStack(BlockRegistry.silver_block_3));
	list.add(new ItemStack(BlockRegistry.silver_block_4));
	list.add(new ItemStack(BlockRegistry.glistre_block_1));	
	list.add(new ItemStack(BlockRegistry.enchanted_block_1));
	list.add(new ItemStack(BlockRegistry.light_fire));	
	list.add(new ItemStack(BlockRegistry.light_portal));
	list.add(new ItemStack(BlockRegistry.light_toby_king_fire));	
	list.add(new ItemStack(BlockRegistry.light_toby_king_portal));				
	list.add(new ItemStack(BlockRegistry.liquid_ice));
	list.add(new ItemStack(BlockRegistry.block_seaweed));	
	}
};

tab_potion = new GlistreTabs("tab_potion"){

		public Item getTabIconItem() {
			return (ItemRegistry.poison_protection);
		}
		//puts in tab and displays in the order that you'd like
		public void displayAllReleventItems(List list) {

			list.add(new ItemStack(ItemRegistry.poison_protection));
			list.add(new ItemStack(GlistreEntityRegistry.splash_poison_protection));
			list.add(new ItemStack(ItemRegistry.nausea_protection));
			list.add(new ItemStack(ItemRegistry.vomitus));

			list.add(new ItemStack(GlistreEntityRegistry.tobie_worst_projectile_1));

			list.add(new ItemStack(ItemRegistry.sceptre_1));
			list.add(new ItemStack(ItemRegistry.sceptre_egg));
			list.add(new ItemStack(ItemRegistry.tobie_queen_egg));
			list.add(new ItemStack(ItemRegistry.tobie_king_egg));

			list.add(new ItemStack(TabRegistry.blasterbolt_1));
			list.add(new ItemStack(TabRegistry.enderbolt_1));
			list.add(new ItemStack(TabRegistry.sceptrebolt_1));
	}
};

}

public static void registerTab(){

}

public static void registerRenders(){

}
}

Link to comment
Share on other sites

You know better than me where you use this Item. It might also be in recipes, you tell me.

I will hunt for it seems like the item is getting called then before it's registered == NPE

 

EDIT: the problem is related to the TabRegistry because when I take out the custom tabs completely the item shows up without the crash

Link to comment
Share on other sites

One thing I've noticed is you are doing all of your initialization during the FMLInitializationEvent instead of the FMLPreInitializationEvent - in my experience, you should always register your blocks, items, etc. during pre-init.

 

okay will change that

Link to comment
Share on other sites

You know better than me where you use this Item. It might also be in recipes, you tell me.

 

Seems the problem was with blaster_bolt_1 in the Custom Tab Registry not registered first had nothing to do with tobie_worst_sword_1

 

But thanks you pointed me in the right direction!

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.