Posted October 25, 201311 yr hey i get this error when i try to call on .blockID of my block Error: Cannot Make a static reference to a non-static field "CobaltBlock.blockID" World Gen Class package ca.WorldGen; import java.util.Random; import ca.CobaltOre; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import cpw.mods.fml.common.IWorldGenerator; public class CobaltOreGen implements IWorldGenerator{ @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { // TODO Auto-generated method stub switch(world.provider.dimensionId) { case -1: generateNether(); break; case 0: generateSurface(world, random, chunkX*16, chunkZ*16); break; case 1: generateEnd(); break; } } public void generateNether() { //we're not doing ore ore in the nether } public void generateSurface(World world, Random rand, int chunkX, int chunkZ) { for (int i = 0; i < 30; i++) { int randPosX = chunkX + rand.nextInt(16); int randPosY = rand.nextInt(64); int randPosZ = chunkZ + rand.nextInt(16); (new WorldGenMinable(CobaltOre.blockID, 10)).generate(world, rand, randPosX, randPosY, randPosZ); } } public void generateEnd() { //we're not going to generate in the end either } } Main Class package ca; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import cpw.mods.fml.common.IWorldGenerator; 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.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import ca.proxys.CommonProxy; @Mod(modid="ca", name="customarmor", version="0.0.2") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class ca { public static final String modid ="Custom_Armor"; // Says where the client and server 'proxy' code is loaded. @SidedProxy(clientSide="db.mods.ca.proxys.ClientProxy", serverSide="db.mods.ca.proxys.CommonProxy") public static CommonProxy proxy; @EventHandler // used in 1.6.2 //@PreInit // used in 1.5.2 public void preInit(FMLPreInitializationEvent event) { // Stub Method } @EventHandler // used in 1.6.2 //@Init // used in 1.5.2 public void load(FMLInitializationEvent event) { proxy.registerRenderers(); //Items final Item CobaltIngot = new CobaltIngot(501) .setMaxStackSize(32) .setCreativeTab(CreativeTabs.tabMaterials) .setUnlocalizedName("CobaltIngot"); //Block Details //Cobalt final Block CobaltBlock = new CobaltBlock(500, Material.iron) .setResistance(9999.0F) .setHardness(0.5F).setStepSound(Block.soundStoneFootstep) .setUnlocalizedName("CobaltBlock") .setCreativeTab(CreativeTabs.tabBlock); final Block CobaltOre = new CobaltOre(502, Material.iron) .setResistance(9999.0F) .setHardness(0.5F).setStepSound(Block.soundStoneFootstep) .setUnlocalizedName("CobaltOre") .setCreativeTab(CreativeTabs.tabBlock); //Define World Gen //CobaltOreGen CobaltOreGenb = new CobaltOreGen(); //Register World Generation //GameRegistry.registerWorldGenerator(CobaltOreGenb); } @EventHandler // used in 1.6.2 //@PostInit // used in 1.5.2 public void postInit(FMLPostInitializationEvent event) { // Stub Method } //Items public static final Item CobaltIngot = new CobaltIngot(501) .setMaxStackSize(32) .setCreativeTab(CreativeTabs.tabMaterials) .setUnlocalizedName("CobaltIngot"); //Block Details //Cobalt public static final Block CobaltBlock = new CobaltBlock(500, Material.iron) .setResistance(9999.0F) .setHardness(0.5F).setStepSound(Block.soundStoneFootstep) .setUnlocalizedName("CobaltBlock") .setCreativeTab(CreativeTabs.tabBlock); public static final Block CobaltOre = new CobaltOre(501, Material.iron) .setResistance(9999.0F) .setHardness(0.5F).setStepSound(Block.soundStoneFootstep) .setUnlocalizedName("CobaltOre") .setCreativeTab(CreativeTabs.tabBlock); } Cobalt Ore Class(My Block) package ca; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; public class CobaltOre extends Block{ public CobaltOre(int id, Material Material) { super(id, Material); } public void registerIcons(IconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("customarmor:CobaltOre"); } }
October 25, 201311 yr You've overloaded your naming scheme. It can't tell the difference between CobaltBlock and CobaltBlock. (One of those is a class, the other is an instance of that class, which is which?) 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.
October 25, 201311 yr Rename the instance variable. That would fix it. I don't need to tell you how to fix it, because doing so would make me look patronizing. Select the variable, hit delete, type cobaltBlock with a lower case C, now rename allll the other ones to match.... 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.
October 25, 201311 yr new WorldGenMinable(CobaltOre.blockID, 10) And what's that? 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.
October 25, 201311 yr Author (new WorldGenMinable(ca.cobaltOre.blockID, 10)).generate(world, rand, randPosX, randPosY, randPosZ); if i under stood you correctly if i didnt im sorry
October 25, 201311 yr That should be correct. 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.
October 25, 201311 yr Author i have that but i get the error : Cannot Make a static reference to a non-static field
October 25, 201311 yr Then you haven't found all 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.
October 25, 201311 yr Modder Support topic subtitle: "(...) please keep in mind that this is not a Java school. You are expected to have basic knowledge of Java before posting here." Basic Java includes the understanding of OOP logic. Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.
October 26, 201311 yr Author Modder Support topic subtitle: "(...) please keep in mind that this is not a Java school. You are expected to have basic knowledge of Java before posting here." Basic Java includes the understanding of OOP logic. Go To the tutorial for the basics it requires that. but it also says you could learn it along the way. so im learning it along the way
October 26, 201311 yr Do you or do you not know what "a static reference" and a "a non-static field" are? 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.
October 26, 201311 yr Thanks Draco. And the way you're doing it is great . I just want to say, if you get any compile time errors, this is Java, and if you google it you'll most certainly find a solution. These solutions don't have to be Minecraft related in any way off course. Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.
October 28, 201311 yr possibly the fact that this is not static: //Block Details //Cobalt No Static Here ---> final Block CobaltBlock = new CobaltBlock(500, Material.iron)
October 31, 201311 yr Author Thanks you i fixed to thanks to none of you. fuck the forge community its full of people who try to murder people who help
October 31, 201311 yr Thanks you i fixed to thanks to none of you. fuck the forge community its full of people who try to murder people who help 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. Did you finally name your variable something other than the same name as your class? And start referencing that variable properly? 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.
November 2, 201311 yr Author now its public static void cobaltOre = new CobaltOre blah blah blah. it works now.
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.