Everything posted by oldcheese
-
[1.10] [solved]Nullpointerexception when trying to Skin items. (I put it in preinit instead of init)
I do use this funciton in Preinit. Preinit calls RegisterItemrenderer(); which is a method that contains the line of code you quoted. The way It seems to work is when I put my ItemRenderer in my Init instead of my preInit everything works just fine.
-
[1.10] [solved]Nullpointerexception when trying to Skin items. (I put it in preinit instead of init)
How would I even change this? I've changed my code so that items are created first, then the proxies are called @EventHandler public void preInit(FMLPreInitializationEvent e) { RPVPItems.createItems(); Main.proxy.preInit(e); } so now the items exist, then it calls the preinit in the proxies. Which means that my items should exist before I attempt to render them. Is there some other way to fix my Item existing? Perhaps the way I make items is wrong? I've used the method above, but even when I Initialize my item right in the start by adding to the code before the preinit it won't really change the crash. Edit: I'm an idiot. is Rendering items an INIT task instead of preinit? Because it worked perfectly when I added it to the init code instead of PreInit. Jesus christ I spend like 5 hours staring at this code and it turns out it's a little tiny thing that could've easily been avoided if I re-read the documentation for a second Thanks for the help!
-
[1.10] [solved]Nullpointerexception when trying to Skin items. (I put it in preinit instead of init)
The items aren't a problem. I'm able to create the item in game when I comment out my Renderer. The renderer is causing a nullpointer. Changing the order changed nothing for me. I'm getting the exact same error.
-
[1.10] [solved]Nullpointerexception when trying to Skin items. (I put it in preinit instead of init)
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.
-
Saving data to player.dat file
Darn. Thanks everyone for the quick replies. I'll use IEEP for now. Thanks all!
-
Saving data to player.dat file
Hi. I'm experimenting with making mods, and one of the things I'd really love to do is add a weapon that basically 'saves' to a player. So you pick up a blank weapon, and if player variable X = 2 then it's a sword with 5 damage that sets people on fire. if X = 1 then It's a sword that blinds. So far so good. I made a simple orb that is right clicked to create the weapon depending on X, then changes back if dropped or logged out. I'm using a simple item that sets a variable to 2 when clicked to test all this, what I CAN'T figure out is how to save a variable to the player! My general guess would be to make a eventhandler for login/logout that would load/save an NBT. but I have no idea how to save a NBT tag to the player.dat file, is there a specific way to save it? sorry if I say dumb stuff my english isn't very good and I can't say what I'm doing very well. but I hope you guys can help on how to save Variable to the player.
IPS spam blocked by CleanTalk.