Posted May 7, 201411 yr I am trying to put all my Items and Blocks into there own section on Creative Mode but for some reason Blocks are not working with it the Item section is working find but when I click on the second option witch is the Blocks Option it crashes and closes:/ here is my code CreativeTabBlocks package com.MoreEverything.creativetabs; import java.util.List; import com.MoreEverything.Item.MoreItems; import com.MoreEverything.Item.Ruby; import com.MoreEverything.block.MoreBlocks; import com.MoreEverything.block.RandomOreBlock; import com.MoreEverything.block.RubyBlock; import com.MoreEverything.block.RubyOreBlock; import com.MoreEverything.block.TinOreBlock; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class CreativeTabBlocks extends CreativeTabs { public CreativeTabBlocks(int id, String unlocalizedName) { super(id, unlocalizedName); } @SideOnly(Side.CLIENT) public Item getTabIconItem() { return Item.getItemFromBlock(MoreBlocks.RubyBlock); } @SideOnly(Side.CLIENT) public void displayAllReleventItems(List itemList) { itemList.add(new ItemStack(MoreBlocks.RubyOreBlock)); itemList.add(new ItemStack(MoreBlocks.TinOreBlock)); itemList.add(new ItemStack(MoreBlocks.RandomOreBlock)); itemList.add(new ItemStack(MoreBlocks.RubyBlock)); } } Blocks RubyOreBlock package com.MoreEverything.block; import java.util.Random; import com.MoreEverything.lib.Strings; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; public class RubyOreBlock extends Block { public static Block RubyOreBlock; private CreativeTabs tabBlocks; public RubyOreBlock(Material p_i45394_1_) { super(p_i45394_1_); // TODO Auto-generated constructor stub } { this.setBlockName(Strings.RubyOreBlock); this.setHardness(5.0f); this.setCreativeTab(tabBlocks); this.setResistance(3f); this.setStepSound(Block.soundTypeStone); this.setHarvestLevel("pickaxe", 2); } } TinOreBlock package com.MoreEverything.block; import java.util.Random; import com.MoreEverything.lib.Strings; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; public class TinOreBlock extends Block { public static Block TinOreBlock; private CreativeTabs tabBlocks; public TinOreBlock(Material p_i45394_1_) { super(p_i45394_1_); // TODO Auto-generated constructor stub } { this.setBlockName(Strings.TinOreBlock); this.setCreativeTab(tabBlocks); this.setHardness(3.0f); this.setResistance(3.0f); this.setStepSound(Block.soundTypeStone); this.setHarvestLevel("pickaxe", 1); } } RandomOreBlock package com.MoreEverything.block; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; import com.MoreEverything.lib.Strings; public class RandomOreBlock extends Block { public static Block RandomOreBlock; private CreativeTabs tabStandard; public RandomOreBlock(Material p_i45394_1_) { super(p_i45394_1_); // TODO Auto-generated constructor stub } { this.setBlockName(Strings.RandomOreBlock); this.setCreativeTab(tabStandard); this.setHardness(4.0f); this.setResistance(3f); this.setStepSound(Block.soundTypeStone); this.setHarvestLevel("pickaxe", 2); } private Item itemDropped = null; private int quantityDropped = 0; @Override public Item getItemDropped(int metadata, Random random, int fortune) { switch(random.nextInt(20)) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: return Items.coal; case 11: case 12: case 13: return Items.iron_ingot; case 14: case 15: return Items.gold_ingot; case 16: return Items.diamond; case 17: return Items.emerald; default: return Items.egg; } } @Override public int quantityDropped(int meta, int fortune, Random random) { if(itemDropped == Items.coal) { quantityDropped = 5; } else if(itemDropped == Items.iron_ingot) { quantityDropped = 3; } else if(itemDropped == Items.gold_ingot) { quantityDropped = 2; } else if(itemDropped == Items.diamond) { quantityDropped = 1; } else if(itemDropped == Items.emerald) { quantityDropped = 1; } else { return quantityDropped = 1; } return quantityDropped; } } RubyBlock package com.MoreEverything.block; import java.util.Random; import com.MoreEverything.lib.Strings; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; public class RubyBlock extends Block { public static Block RubyBlock; private CreativeTabs tabBlocks; public RubyBlock(Material p_i45394_1_) { super(p_i45394_1_); // TODO Auto-generated constructor stub } { this.setBlockName(Strings.RubyBlock); this.setHardness(5.0f); this.setCreativeTab(tabBlocks); this.setResistance(3f); this.setStepSound(Block.soundTypeStone); this.setHarvestLevel("pickaxe", 2); } public static void mainRegistry() { // TODO Auto-generated method stub } } Please help I really want this to work
May 8, 201411 yr Crash log? can we also see your main mod file (where you initialize your custom creative tabs) Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
May 8, 201411 yr In all your block classes, the tabBlocks variable is still null. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
May 8, 201411 yr Author I don't know why it won't work just want to make it tidy all the content from my mod in it's own creativetabs Here is my Main Class package com.OresandTools.Main; import com.OresandTools.CreativeTabs.CreativeTabItems; import com.OresandTools.CreativeTabs.CreativeTabOres; import com.OresandTools.CreativeTabs.CreativeTabTools; import com.OresandTools.Items.Ruby; import com.OresandTools.Lib.Strings; import com.OresandTools.World.OresWorldGenerator; import com.OresandTools.World.RubyOre; import com.OresandTools.World.TinOre; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraftforge.common.util.EnumHelper; 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.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid = Strings.MODID, name = Strings.name, version = Strings.version) public class MainRegistry { @SidedProxy(clientSide = "com.OresandTools.Main.ClientProxy", serverSide = "com.OresandTools.Main.ServerProxy") public static ServerProxy proxy; @Instance(Strings.MODID) public static MainRegistry modInstance; /** * Loads before * @param PreEvent */ //Tools //public static final Item.ToolMaterial Rubym = EnumHelper.addToolMaterial("RubyM", 2, 350, 5.0F, 2.0F, 16); //public static Item RubyPickaxe = new RubyPickaxe(5000, Rubym); //public static Item RubySpade = new RubySpade(5001, Rubym); //public static Item RubyAxe = new RubyAxe(5002, Rubym); //public static Item RubySword = new RubySword(5003, Rubym); //public static Item RubyHoe = new RubyHoe(5004, Rubym); //Creative Tabs public static final CreativeTabs tabItems = new CreativeTabItems(CreativeTabs.getNextID(), "Items"); public static final CreativeTabs tabTools = new CreativeTabTools(CreativeTabs.getNextID(), "Tools"); public static final CreativeTabs tabOres = new CreativeTabOres(CreativeTabs.getNextID(), "Ores"); @Mod.EventHandler public static void PreLoad(FMLPreInitializationEvent PreEvent){ //Tabs //Ore RubyOre.mainRegistry(); TinOre.mainRegistry(); //Items Ruby.mainRegistry(); //Blocks //Tools //Crafting CraftingHandler.init(); //Proxy's proxy.registerRenderThings(); //WorldOre OresWorldGenerator.mainRegistry(); } /** * Loads during * @param event */ @EventHandler public static void Load(FMLInitializationEvent event){ } /** * Loads after * @param PostEvent */ @EventHandler public static void PostLoad(FMLPostInitializationEvent PostEvent){ } //Tool Registry //public MainRegistry() { //GameRegistry.registerItem(RubyPickaxe, "Ruby Pickaxe"); //GameRegistry.registerItem(RubySpade, "Ruby Spade"); //GameRegistry.registerItem(RubyAxe, "Ruby Axe"); //GameRegistry.registerItem(RubySword, "Ruby Sword"); //GameRegistry.registerItem(RubyHoe, "Ruby Hoe"); //Creative Tab Language Registry //Tool Language Registry //LanguageRegistry.addName(RubyPickaxe, "Ruby Pickaxe"); //LanguageRegistry.addName(RubySpade, "Ruby Shovel"); //LanguageRegistry.addName(RubyAxe, "Ruby Axe"); //LanguageRegistry.addName(RubySword, "Ruby Sword"); //LanguageRegistry.addName(RubyHoe, "Ruby Hoe"); } //} And here is the class where I am putting the block package com.OresandTools.CreativeTabs; import java.util.List; import com.OresandTools.Blocks.RubyOreBlock; import com.OresandTools.Items.Ruby; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class CreativeTabOres extends CreativeTabs { private Block RubyOreBlock; public CreativeTabOres(int id, String unlocalizedName) { super(id, unlocalizedName); } @SideOnly(Side.CLIENT) public Item getTabIconItem() { //return Item.getItemFromBlock(RubyOreBlock.RubyOreBlock); return Ruby.Ruby; } @SideOnly(Side.CLIENT) public void displayAllReleventItems(List itemList) { //Adds string with silk touch lv 1 //ItemStack string = new ItemStack(Items.string); //string.addEnchantment(Enchantment.silkTouch, 1); //itemList.add(string); //Adds wooden hoe //itemList.add(new ItemStack(RubyOreBlock)); Item.getItemFromBlock(RubyOreBlock); //Adds all fishing enchantments //this.addEnchantmentBooksToList(itemList, new EnumEnchantmentType[] { EnumEnchantmentType.fishing_rod}); } } And here is the crash log when I run it ---- Minecraft Crash Report ---- // Ouch. That hurt Time: 08/05/14 15:42 Description: Rendering item java.lang.NullPointerException: Rendering item at net.minecraft.item.ItemStack.getItemDamage(ItemStack.java:266) at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:415) at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:560) at net.minecraft.client.gui.inventory.GuiContainer.func_146977_a(GuiContainer.java:291) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:118) at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:44) at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:672) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1143) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1024) at net.minecraft.client.Minecraft.run(Minecraft.java:912) at net.minecraft.client.main.Main.main(Main.java:112) 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:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.item.ItemStack.getItemDamage(ItemStack.java:266) at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:415) -- 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:560) at net.minecraft.client.gui.inventory.GuiContainer.func_146977_a(GuiContainer.java:291) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:118) at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:44) at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:672) -- Screen render details -- Details: Screen name: net.minecraft.client.gui.inventory.GuiContainerCreative Mouse location: Scaled: (206, 36). Absolute: (619, 657) Screen size: Scaled: (456, 256). Absolute: (1366, 768). Scale factor of 3 -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['Player816'/216, l='MpServer', x=-263.75, y=87.65, z=112.91]] Chunk stats: MultiplayerChunkCache: 225, 225 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: World: (-256,64,116), Chunk: (at 0,4,4 in -16,7; contains blocks -256,0,112 to -241,255,127), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 4514 game time, 4514 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: 41 total; [EntitySquid['Squid'/137, l='MpServer', x=-210.07, y=46.00, z=173.55], EntitySheep['Sheep'/70, l='MpServer', x=-309.47, y=66.00, z=74.59], EntitySheep['Sheep'/71, l='MpServer', x=-311.50, y=65.00, z=70.78], EntitySquid['Squid'/66, l='MpServer', x=-317.32, y=45.01, z=176.35], EntitySquid['Squid'/76, l='MpServer', x=-315.46, y=45.40, z=167.72], EntitySquid['Squid'/77, l='MpServer', x=-305.47, y=46.00, z=166.53], EntitySquid['Squid'/131, l='MpServer', x=-204.62, y=49.41, z=174.89], EntitySheep['Sheep'/72, l='MpServer', x=-305.63, y=67.00, z=79.53], EntityBat['Bat'/132, l='MpServer', x=-223.31, y=29.10, z=177.88], EntitySquid['Squid'/73, l='MpServer', x=-314.31, y=44.40, z=153.17], EntitySquid['Squid'/74, l='MpServer', x=-314.37, y=47.38, z=148.90], EntityBat['Bat'/134, l='MpServer', x=-220.19, y=39.43, z=181.34], EntityBat['Bat'/75, l='MpServer', x=-307.61, y=31.00, z=158.94], EntitySquid['Squid'/152, l='MpServer', x=-203.25, y=46.00, z=168.47], EntityClientPlayerMP['Player816'/216, l='MpServer', x=-263.75, y=87.65, z=112.91], EntitySheep['Sheep'/83, l='MpServer', x=-303.09, y=67.00, z=70.97], EntitySquid['Squid'/95, l='MpServer', x=-282.32, y=47.00, z=149.33], EntityBat['Bat'/150, l='MpServer', x=-193.53, y=28.10, z=154.22], EntitySquid['Squid'/98, l='MpServer', x=-275.85, y=48.00, z=159.53], EntitySquid['Squid'/99, l='MpServer', x=-279.54, y=54.32, z=162.61], EntitySquid['Squid'/96, l='MpServer', x=-282.63, y=47.35, z=143.50], EntitySquid['Squid'/97, l='MpServer', x=-277.96, y=49.17, z=154.39], EntitySquid['Squid'/110, l='MpServer', x=-273.19, y=49.38, z=162.53], EntitySquid['Squid'/111, l='MpServer', x=-268.46, y=52.00, z=161.56], EntityBat['Bat'/108, l='MpServer', x=-256.25, y=62.10, z=41.47], EntitySquid['Squid'/109, l='MpServer', x=-269.50, y=52.00, z=158.64], EntityPig['Pig'/119, l='MpServer', x=-246.67, y=64.00, z=75.65], EntityPig['Pig'/118, l='MpServer', x=-241.78, y=64.00, z=66.34], EntitySquid['Squid'/114, l='MpServer', x=-271.47, y=49.31, z=158.43], EntitySquid['Squid'/113, l='MpServer', x=-270.65, y=51.40, z=163.38], EntitySquid['Squid'/112, l='MpServer', x=-266.48, y=55.43, z=161.76], EntitySheep['Sheep'/127, l='MpServer', x=-228.16, y=66.00, z=83.63], EntityBat['Bat'/58, l='MpServer', x=-343.25, y=31.10, z=75.38], EntitySheep['Sheep'/126, l='MpServer', x=-239.75, y=66.00, z=72.59], EntityPig['Pig'/125, l='MpServer', x=-235.78, y=63.00, z=70.81], EntityPig['Pig'/124, l='MpServer', x=-230.47, y=64.00, z=53.34], EntityBat['Bat'/182, l='MpServer', x=-189.86, y=28.27, z=162.24], EntityBat['Bat'/123, l='MpServer', x=-238.25, y=33.10, z=49.47], EntitySheep['Sheep'/121, l='MpServer', x=-246.87, y=64.00, z=79.47], EntityBat['Bat'/60, l='MpServer', x=-343.09, y=33.10, z=71.09], EntitySheep['Sheep'/120, l='MpServer', x=-254.53, y=64.00, z=64.81]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:412) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2523) at net.minecraft.client.Minecraft.run(Minecraft.java:934) at net.minecraft.client.main.Main.main(Main.java:112) 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:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 8 (amd64) version 6.2 Java Version: 1.7.0_51, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 687312912 bytes (655 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 14115 (790440 bytes; 0 MB) allocated, 610 (34160 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP v9.03 FML v7.2.165.1063 Minecraft Forge 10.12.1.1063 4 mods loaded, 4 mods active mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.165.1063} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1063.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.1.1063} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1063.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available oat{0.0.1 Alpha} [Ores and Tools] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Launched Version: 1.6 LWJGL: 2.9.0 OpenGL: Intel® HD Graphics 4000 GL version 4.0.0 - Build 9.17.10.2828, Intel 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) Vec3 Pool Size: 11552 (646912 bytes; 0 MB) allocated, 2934 (164304 bytes; 0 MB) used Anisotropic Filtering: Off (1) And here is the RubyOreBlock Class package com.OresandTools.Blocks; import java.util.Random; import com.OresandTools.Lib.Strings; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; public class RubyOreBlock extends Block { public static Block RubyOreBlock; public CreativeTabs tabOres; public RubyOreBlock(Material p_i45394_1_) { super(p_i45394_1_); // TODO Auto-generated constructor stub } { this.setBlockTextureName(Strings.MODID + ":RubyOreBlock"); this.setCreativeTab(tabOres); this.setBlockName(Strings.RubyOreBlock); this.setHardness(5.0f); this.setResistance(3f); this.setStepSound(Block.soundTypeStone); this.setHarvestLevel("pickaxe", 2); } public static void mainRegistry() { GameRegistry.registerBlock(RubyOreBlock, "RubyOreBlock"); } }
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.