Posted February 4, 201411 yr Hi again! I'm working on a mod letting spawn an asteroid (Darkmatter_Block) with a chance of one tenth every time a new Chunk is generated. It should be spawned inside a 200 block radius from the player (for now I only included the positive values) The problem is: I get an error at the World.setBlock(plX, plY, plZ, 500); line at the very end. Eclipse tells me that I should "change the modifier of '.setBlock()' to 'static' " in the world.class but that would cause the world.class not to work I begin to doubt that .setBlock() is even the right method but tbh I don't find anything coming close to making more sense. If anyone sees my fault I would really appreciate some help with this. Probably it's just me being a little retarded^^ Thank you in advance =) package darkmatter; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.world.World; import net.minecraftforge.event.world.WorldEvent; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; 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; @Mod(modid = darkmatter.modid, name = "Darkmatter", version = "1.0") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class darkmatter { public static final String modid = "Felixkeeg_Darkmatter"; public static Block Darkmatter_Block; public static Item Concentratedredstone_Item; public static Item Darkmatter_Item; @EventHandler public void load(FMLInitializationEvent event) { //Block Darkmatter_Block = new BlockDarkmatter_Block (500, Material.rock).setUnlocalizedName("Darkmatter_Block"); GameRegistry.registerBlock(Darkmatter_Block, modid + Darkmatter_Block.getUnlocalizedName().substring(5)); LanguageRegistry.addName(Darkmatter_Block, "Darkmatter Block"); //Item Darkmatter_Item = new Darkmatter_Item(5000).setUnlocalizedName("Darkmatter"); LanguageRegistry.addName(Darkmatter_Item, "Darkmatter"); Concentratedredstone_Item = new Concentratedredstone_Item(5001).setUnlocalizedName("Concentratedredstone"); LanguageRegistry.addName(Concentratedredstone_Item, "Concentrated Redstone"); //Crafting DarkmatterCrafting.loadRecipes(); } //Asteroid public void onChunkGenerate() { int varrand = (int) ((Math.random()*10)+1); if(10 <= varrand) { int extX = (int) ((Math.random()*200)+1); int extZ = (int) ((Math.random()*200)+1); int plX = (int)Minecraft.getMinecraft().thePlayer.posX + extX; int plY = 250; int plZ = (int)Minecraft.getMinecraft().thePlayer.posZ + extZ; World.setBlock(plX, plY, plZ, 500); } }; }
February 4, 201411 yr Eclipse is right about the error, but you are taking the wrong fix. You should listen to it and learn what "static" means. It is basic Java, you need to understand that.
February 4, 201411 yr World != world 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.
February 5, 201411 yr Author @GotoLink I know that I am not able to reference a non-static method in a static context normally but I do know there's a way to manage this, as I think this is the method they used for the setBlock Command of CommandBlocks in 1.7.2. If I am wrong and am using the wrong method I just want to know which method I gotta use in order to place a block at a position. @Draco18s I know it's not the same. world.setBlock() cannot be resolved, therefore World.setBlock() is the right option. I was just a little careless with the problem-description, sorry for that.
February 5, 201411 yr world.setBlock() cannot be resolved, therefore World.setBlock() is the right option. *Groan* No it's not. You need a f*ing reference to an instance of the World class to be able to setBlock. You can't do that with the World class itself. You're basically trying to do this: Integer integer = 10; Integer += 1; //this makes no f*ing sense Except that the first line is missing entirely. 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.
February 7, 201411 yr In other words, what you need is this World world = Minecraft.getMinecraft().theWorld; world.setBlock(plX, plY, plZ, 500); //Or whatever
February 7, 201411 yr In other words, what you need is this World world = Minecraft.getMinecraft().theWorld; world.setBlock(plX, plY, plZ, 500); //Or whatever Except that this is bad practice. IIRC, this will fail on the dedicated server side. 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.
February 7, 201411 yr 1) get passed a reference to it 2) DimensionManager.getWorld(id) 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.
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.