Posted December 22, 201311 yr i have tried to find a string that allows me to load my texture in the custom folder assets/modpack/texture/block. it looks like this code should work but it dosnt load the texture. Hope someone can tell me why it dosn't work because its really annoying. package ModPack; import java.util.Random; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; public class Redgemore extends Block { public Redgemore(int par1, String texture) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); } public int idDropped(int par1, Random par2Random, int par3) { return ModPack.Redgem.itemID; } public int quantityDropped(Random random) { return 1; } public void registerIcons(IconRegister reg) { this.blockIcon = reg.registerIcon("modpack:Redgem_ore"); } }
December 22, 201311 yr i have tried to find a string that allows me to load my texture in the custom folder assets/modpack/texture/block. it looks like this code should work but it dosnt load the texture. Hope someone can tell me why it dosn't work because its really annoying. package ModPack; import java.util.Random; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; public class Redgemore extends Block { public Redgemore(int par1, String texture) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); } public int idDropped(int par1, Random par2Random, int par3) { return ModPack.Redgem.itemID; } public int quantityDropped(Random random) { return 1; } public void registerIcons(IconRegister reg) { this.blockIcon = reg.registerIcon("modpack:Redgem_ore"); } } try @Override public void registerIcons(IconRegister reg) { this.blockIcon = reg.registerIcon("modpack:Redgem_ore"); }
December 23, 201311 yr Adding an override annotation and changing nothing else is going to Jack and Shite. Some annotations do things at runtime....the Override one is not one of them. 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.
December 23, 201311 yr i have tried to find a string that allows me to load my texture in the custom folder assets/modpack/texture/block. it looks like this code should work but it dosnt load the texture. Hope someone can tell me why it dosn't work because its really annoying. package ModPack; import java.util.Random; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; public class Redgemore extends Block { public Redgemore(int par1, String texture) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); } public int idDropped(int par1, Random par2Random, int par3) { return ModPack.Redgem.itemID; } public int quantityDropped(Random random) { return 1; } public void registerIcons(IconRegister reg) { this.blockIcon = reg.registerIcon("modpack:Redgem_ore"); } } try @Override public void registerIcons(IconRegister reg) { this.blockIcon = reg.registerIcon("modpack:Redgem_ore"); } I would try public Redgemore(int par1, String texture) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); } //into public Redgemore(int par1, Material material) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); setTextureName("modpack:Redgem_ore"); } Then make sure that your block is declared in your main/base class, with registering them into your load method.
December 23, 201311 yr I would try public Redgemore(int par1, String texture) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); } //into public Redgemore(int par1, Material material) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); setTextureName("modpack:Redgem_ore"); } And the material variable is going unused. Either pass it to super, or get rid of it. 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.
December 23, 201311 yr Change Redgem to lowercase. And also make sure all the files and folders where the textures are located at are lowercase. If you really want help, give that modder a thank you. Modders LOVE thank yous.
December 23, 201311 yr Author then i try public Redgemore(int par1, String texture) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); } //into public Redgemore(int par1, Material material) { super(par1, Material.iron); setCreativeTab(CreativeTabs.tabBlock); setTextureName("modpack:Redgem_ore"); } my game crashes if it helps im gonna show you the main javaclass package ModPack; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraftforge.common.EnumHelper; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraftforge.common.EnumHelper; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import ModPack.Projector; @Mod(modid="ModPackInof.ID",name="ModPackInfo.NAME",version="ModPackInfo.VERS") @NetworkMod(clientSideRequired=true,serverSideRequired=false) public class ModPack { public static final String modid = "ModPack"; @Instance(modid) public static ModPack instance; /* * ToolMaterial */ //Telling forge that we are creating these //items public static Item Redgem; public static Item RedgemPickaxe; //Blocks public static Block Redgemblock; public static Block Redgemore; public static Block Bluecobblestoneblock; public static Block Bluestoneblock; public final static Block Projector = new Projector(200, Material.rock); //tools //Declaring Init @Init public void load(FMLInitializationEvent event){ // define items RedgemPickaxe= new Items(2004).setUnlocalizedName("RedgemPickaxe"); Redgem = new Items(2000).setUnlocalizedName("Redgem"); // define blocks Redgemblock = new Redgemblock(2001, "Redgemblock").setUnlocalizedName("Redgem_block").setHardness(3.0F).setStepSound(Block.soundMetalFootstep).setResistance(15.0F); GameRegistry.registerBlock(Redgemblock, "Redgemblock"); Redgemore = new Redgemore(200, Material.iron).setUnlocalizedName("Redgem_block").setCreativeTab(CreativeTabs.tabBlock).setTextureName("modpack:Redgem_ore").setHardness(3.0F).setStepSound(Block.soundMetalFootstep).setResistance(15.0F); GameRegistry.registerBlock(Redgemore, "Redgemore"); Bluecobblestoneblock = new Bluecobblestoneblock(2002, "Bluecobblestoneblock").setUnlocalizedName("Bluecobblestone_block").setHardness(3.0F).setStepSound(Block.soundMetalFootstep).setResistance(15.0F); GameRegistry.registerBlock(Bluecobblestoneblock, "Bluecobblestoneblock"); Bluestoneblock = new Bluestoneblock(2003, "Bluestoneblock").setUnlocalizedName("Bluestone_block").setHardness(3.0F).setStepSound(Block.soundMetalFootstep).setResistance(15.0F); GameRegistry.registerBlock(Bluestoneblock, "Bluestoneblock"); GameRegistry.registerBlock(Projector,"Projector"); //adding names //items LanguageRegistry.addName(RedgemPickaxe, "RedgemPickaxe"); LanguageRegistry.addName(Redgem, "Redgem"); //blocks LanguageRegistry.addName(Redgemblock, "Block of Redgem"); LanguageRegistry.addName(Redgemore,"Redgem ore"); LanguageRegistry.addName(Bluecobblestoneblock, "Bluecobblestone"); LanguageRegistry.addName(Bluestoneblock, "Bluestone"); LanguageRegistry.addName(Bluecobblestoneblock, "Bluecobblestoneblock"); LanguageRegistry.addName(Projector, "Projector"); //crafting GameRegistry.addRecipe(new ItemStack(Redgemblock,1), new Object[]{ "TTT","TTT","TTT",'T',Redgem,}); GameRegistry.addShapelessRecipe(new ItemStack(Redgem,9), new Object[]{ Redgemblock}); //smelting GameRegistry.addSmelting(ModPack.Bluecobblestoneblock.blockID, new ItemStack(Bluestoneblock, 1), 5F); //rendering GameRegistry.registerTileEntity(TileEntityTest.class, "Projector"); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTest.class, new RendererProjector()); } }
December 23, 201311 yr And without the crash log, we can't help you. 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.
December 23, 201311 yr i have tried to find a string that allows me to load my texture in the custom folder assets/modpack/textures/blocks. Fixed that for you
December 23, 201311 yr I have no idea what you mean by custom folder, so I think you just mean assets of your mod, anyway: public class TestBlock extends Block { String texture; public TestBlock (int id, Material material, String t) { super(id, material); this.texture = t; } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { blockIcon = iconRegister.registerIcon("modname:" + texture); } } And then in modname.class public static final Block testBlock = new TestBlock(3000, Material.rock, "test"); Texture will be set from assets/modpack/textures/blocks/test.png Oh and to set Material as constant for all blocks just change public TestBlock (int id, String t) { super(id, Material.rock); this.texture = t; } 1.7.10 is no longer supported by forge, you are on your own.
December 23, 201311 yr Author And without the crash log, we can't help you. here is the crash report: ---- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 23-12-13 18:28 Description: There was a severe problem during mod loading that has caused the game to fail cpw.mods.fml.common.LoaderException: java.lang.NullPointerException at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:233) at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:196) at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:172) at ModPack.ModPack.load(ModPack.java:67) 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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:545) 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 com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) at com.google.common.eventbus.EventBus.post(EventBus.java:267) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:201) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:181) 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 com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) at com.google.common.eventbus.EventBus.post(EventBus.java:267) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:112) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:699) at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:249) at net.minecraft.client.Minecraft.startGame(Minecraft.java:509) at net.minecraft.client.Minecraft.run(Minecraft.java:808) at net.minecraft.client.main.Main.main(Main.java:93) 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:131) at net.minecraft.launchwrapper.Launch.main(Launch.java:27) Caused by: java.lang.NullPointerException at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:215) ... 40 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.6.4 Operating System: Windows 8 (amd64) version 6.2 Java Version: 1.7.0_45, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 869074392 bytes (828 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Suspicious classes: FML and Forge are installed IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v8.11 FML v6.4.45.953 Minecraft Forge 9.11.1.953 4 mods loaded, 4 mods active mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized FML{6.4.45.953} [Forge Mod Loader] (bin) Unloaded->Constructed->Pre-initialized->Initialized Forge{9.11.1.953} [Minecraft Forge] (bin) Unloaded->Constructed->Pre-initialized->Initialized ModPackInof.ID{ModPackInfo.VERS} [ModPackInfo.NAME] (bin) Unloaded->Constructed->Pre-initialized->Errored
December 23, 201311 yr Author is it possible anyone of you can make a java class i can import and see if that works??
December 24, 201311 yr You might want to set ServerSideRequired to true. On to the current problem though, which line is the error occuring on? at ModPack.ModPack.load(ModPack.java:67) Click on "ModPack.java:67" and tell us the line.
December 25, 201311 yr Hi It appears that the problem is in this part of the code assert block != null : "registerBlock: block cannot be null"; assert itemclass != null : "registerBlock: itemclass cannot be null"; int blockItemId = block.blockID - 256; block is null, which would normally be picked up by the assert (but I'm guessing you haven't enabled assertion testing) So I suspect your ModPack line 67 is calling registerBlock with a variable that you haven't initialised yet (is null) -TGG
December 25, 201311 yr Author Hi It appears that the problem is in this part of the code assert block != null : "registerBlock: block cannot be null"; assert itemclass != null : "registerBlock: itemclass cannot be null"; int blockItemId = block.blockID - 256; block is null, which would normally be picked up by the assert (but I'm guessing you haven't enabled assertion testing) So I suspect your ModPack line 67 is calling registerBlock with a variable that you haven't initialised yet (is null) -TGG where is it even saying that??
December 25, 201311 yr Hi If you look in the stacktrace, you'll notice these lines near the top cpw.mods.fml.common.LoaderException: java.lang.NullPointerException at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:233) at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:196) at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:172) at ModPack.ModPack.load(ModPack.java:67) and a bit further down Caused by: java.lang.NullPointerException at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:215) So when I look at GameRegistry.java lines 215 and 233, I find try { assert block != null : "registerBlock: block cannot be null"; assert itemclass != null : "registerBlock: itemclass cannot be null"; int blockItemId = block.blockID - 256; // line 215 Constructor<? extends ItemBlock> itemCtor; Item i; // .. some extra code removed ... } catch (Exception e) { FMLLog.log(Level.SEVERE, e, "Caught an exception during block registration"); throw new LoaderException(e); //line 233 } Which means that an error occurred on line 215, it threw an exception which was caught at line 233 and re-thrown. The error in the log is "null pointer exception", which means you tried to use a variable which wasn't initialised. In this case, the only possible variable on line 215 which could cause that is block. The stack trace also shows me that GameRegistry.java line 233 was called from line 196, which was called from line 172, which was called from your ModPack.java line 67. line 172 is inside this function public static void registerBlock(net.minecraft.block.Block block, String name) so I can be pretty sure that your ModPack.java line 67 looks something like registerBlock(myBlock, "mymod:myblock"); and that you've previously declared MyNewBlock myBlock; but forgotten to do myBlock = new MyNewBlock(number, material); -TGG
December 25, 201311 yr Author Hi If you look in the stacktrace, you'll notice these lines near the top cpw.mods.fml.common.LoaderException: java.lang.NullPointerException at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:233) at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:196) at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:172) at ModPack.ModPack.load(ModPack.java:67) and a bit further down Caused by: java.lang.NullPointerException at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:215) So when I look at GameRegistry.java lines 215 and 233, I find try { assert block != null : "registerBlock: block cannot be null"; assert itemclass != null : "registerBlock: itemclass cannot be null"; int blockItemId = block.blockID - 256; // line 215 Constructor<? extends ItemBlock> itemCtor; Item i; // .. some extra code removed ... } catch (Exception e) { FMLLog.log(Level.SEVERE, e, "Caught an exception during block registration"); throw new LoaderException(e); //line 233 } Which means that an error occurred on line 215, it threw an exception which was caught at line 233 and re-thrown. The error in the log is "null pointer exception", which means you tried to use a variable which wasn't initialised. In this case, the only possible variable on line 215 which could cause that is block. The stack trace also shows me that GameRegistry.java line 233 was called from line 196, which was called from line 172, which was called from your ModPack.java line 67. line 172 is inside this function public static void registerBlock(net.minecraft.block.Block block, String name) so I can be pretty sure that your ModPack.java line 67 looks something like registerBlock(myBlock, "mymod:myblock"); and that you've previously declared MyNewBlock myBlock; but forgotten to do myBlock = new MyNewBlock(number, material); -TGG it fixed the crash, but it still dosnt load the texture, but thanks for the help on the crash note
December 25, 201311 yr Author Thanks for all the help at a close look to my main class and the advice i have been given i found out what was wrong, so thanks for the help everyone.
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.