Posted December 30, 201212 yr Hey, i am trying to place a block when interacting with a mob. But when i just spawn it using this code: world.setBlockWithNotify((int)this.posX, (int)this.posY + 5, (int)this.posZ, MyBlock.block.blockID); it places it, and when i reload the world, it's gone. when i try this: if(!world.isRemote) world.setBlockWithNotify((int)this.posX, (int)this.posY + 5, (int)this.posZ, MethyrBlocks.methyrFarmSide.blockID); nothing happens (it wont even place the block) and when i try when the world IS remote, the same happens as doing nothing. when i type: System.out.println(world.isRemote); i get two true messages. Can somebody please help me with this, it's really annoying
December 30, 201212 yr Take the check for world.isRemote off. A block change must happen both client (world.isRemote) and server (!world.isRemote) side in order for it to stay there.
December 30, 201212 yr Author But as i said, thats not working, then i will see the block, but when i reload the world it will be disappeared... Thats (i think) caused by the fact that it only places the block server side, because world.isRemote gives me "true" twice
December 30, 201212 yr Make sure that you're doing it in code that will be run by the server, not the client Protip: try and find answers yourself before asking on the forum. It's pretty likely that there is an answer. Was I helpful? Give me a thank you! http://bit.ly/HZ03zy[/img] Tired of waiting for mods to port to bukkit? use BukkitForge! (now with a working version of WorldEdit!)
January 1, 201312 yr Make sure that you're doing it in code that will be run by the server, not the client Where exactly would you put that code?
January 1, 201312 yr In one of my blocks I have @Override public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) { par1World.setBlock(par2, par3 + 1, par4, 3004); par1World.setBlock(par2, par3 + 2, par4, 3005); } to place two other blocks directly above this block.
April 27, 201312 yr and how can i do that? Did you ever find out? I cant see to find any answer yet it must be possible, people must know how to get it
April 28, 201312 yr Well you are only saying the lines of code and with the !world.isRemote it seems fine.. So where are you calling these lines from as mentioned above you need to call them inn a method the server reads at all. It would probably help you get help faster and better if you provided more of your code for the action you are trying to do If you guys dont get it.. then well ya.. try harder...
April 28, 201312 yr I know, I imagine once one knows how to get them into a method the server reads it will be really simple and it will all make sense. But how, as laifsjo asked back in december, do we do that? World world = Minecraft.getMinecraft().theWorld; returns a world object, but the method scheduleBlockUpdate() of this world object does nothing, so calling world.setBlock() of this would to place for example a block of sand does not schedule an update, so the sand never starts to fall. So, how do we get the server world. how do we call methods from our mod on the server, either a real server on another machine, or the local one started by the minecraft client? How do we write code that is called by the server?
April 28, 201312 yr I know, I imagine once one knows how to get them into a method the server reads it will be really simple and it will all make sense. And it is, but it seems to be not said anywhere Please correct me if I am wrong, but the code runs on both the server and the client, but not at the same time, see here (http://www.minecraftforge.net/forum/index.php/topic,7929.msg40041.html#msg40041) for my original post and imagine a lot of head banging on a desk and me saying "why why why"
May 1, 201312 yr Hi What does @SideOnly(Side.CLIENT) actually do? I had thought it meant the code only ran or applied to the client or server side of the mod. But in my block I have this: @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { String tex; LogHelper.detail("Loading " + this.getUnlocalizedName2() + " rotting textures..."); iconBuffer = new Icon[16]; tex = Reference.MOD_ID + ":" + this.getUnlocalizedName2() + "_00"; iconBuffer[0] = iconRegister.registerIcon(tex); LogHelper.verbose("Loaded " + tex); tex = Reference.MOD_ID + ":" + this.getUnlocalizedName2() + "_01"; iconBuffer[1] = iconRegister.registerIcon(tex); Yet the log messages are being logged twice, so what is happening? I am trying to understand what it does? Thanks,
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.