My Lang file also isn't naming my items, so either I Didn't manage to initialize the item correctly or my Resources aren't set up properly.
However, to make items, they just show up with squares instead of anything usefull.
net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from RolePVP (RPVP)
Caused by: java.lang.NullPointerException
at com.cheese.rpvp.render.ItemRenderRegister.reg(ItemRenderRegister.java:18)
at com.cheese.rpvp.render.ItemRenderRegister.registerItemRenderer(ItemRenderRegister.java:14)
at com.cheese.rpvp.ClientProxy.preInit(ClientProxy.java:13)
at com.cheese.rpvp.Main.preInit(Main.java:23)
There's my error. Now for the codes.
@EventHandler
public void preInit(FMLPreInitializationEvent e) {
23 Main.proxy.preInit(e);
RPVPItems.createItems();
}
That's the first offending line,, just me invoking the Proxy files.
public class ClientProxy extends CommonProxy{
@Override
public void preInit(FMLPreInitializationEvent e) {
ItemRenderRegister.registerItemRenderer();
super.preInit(e);
}
Part of my ItemRenderer class that I had hoped to use to render multiple items down the line.
As you can see I invoke the method in my Preinitialization.
package com.cheese.rpvp.render;
import com.cheese.rpvp.Main;
import com.cheese.rpvp.items.RPVPItems;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
public final class ItemRenderRegister {
public static String modid = Main.MODID;
public static void registerItemRenderer(){
reg(RPVPItems.testitem);
}
public static void reg(Item item){
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
}
There's the entire Itemrenderer class. I send an item through to reg. This is where the nullpointerexception mainly takes place it seems.
package com.cheese.rpvp.items;
import net.minecraftforge.fml.common.registry.GameRegistry;
public final class RPVPItems {
public static BasicItem testitem = new BasicItem("testitem");
public static void createItems(){
GameRegistry.register(testitem);
}
}
This is the code I use to create items. Here's where I list them. It's just for generic items so I use one class for most of them.
package com.cheese.rpvp.items;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class BasicItem extends Item{
public BasicItem(String unlocalizedName){
super();
this.setUnlocalizedName(unlocalizedName);
this.setCreativeTab(CreativeTabs.MATERIALS);
this.setRegistryName(unlocalizedName);
}
}
Finally here's the class I use for BasicItem.
That should be all important classes. Now for hierarchy
Link to imgur
Here's a screenshot of how that's setup. as you can see I have a assets.rpvp.models.item with the Json listed here:
{
"parent": "item/generated",
"textures": {
"layer0": "rpvp:items/testitem"
},
"display": {
"thirdperson": {
"rotation": [-90,0,0],
"translation": [0,1,-3],
"scale": [0.55,0.55,0.55]
},
"firstperson": {
"rotation": [0,-135,25],
"translation": [0,4,2],
"scale": [1.7,1.7,1.7]
}
}
}
I've tried changing testitem to different things. I've tried changing my fully Caps RPVP to rpvp for the modid. nothing much helped. I keep getting a nullpointer even though I clearly state most locations.