Jump to content

world.isRemote problem


laifsjo

Recommended Posts

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 :/

Link to comment
Share on other sites

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!

 

 

width=635 height=903http://bit.ly/HZ03zy[/img]

 

 

Tired of waiting for mods to port to bukkit?

use BukkitForge! (now with a working version of WorldEdit!)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 months later...

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...

Link to comment
Share on other sites

 

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? 

 

 

 

 

Link to comment
Share on other sites

 

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  ;D

 

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"

Link to comment
Share on other sites

 

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,

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.