Jump to content

[1.7.10]How to ensure world.setBlock successful?


D0431791

Recommended Posts

This problem may be found in many released mods.

The function world.setBlock is called by updateEntity function of a TileEntity.

I have tried the three set of codes below:

world.setBlock(x,y,z,Blocks.packed_ice);

world.setBlock(x,y,z,Blocks.packed_ice,0,2);

world.setBlock(x,y,z,Blocks.packed_ice,0,3);

However, sometimes world.setBlock is not successful.

When it is not successful, only the texture of the block changes, but the block is not changed; the player can right click the block to change the texture back.

 

I also have tried repeating setting block until the block is indeed changed, but it does not solve the problem.

 

What is the real solution on earth?

Link to comment
Share on other sites

  • 4 weeks later...

Sounds like you are setting the block on the client side - only ever call setBlock on the server side, i.e. when the world is not remote.

if (!worldObj.isRemote) {
  // logical server - okay to set block
  worldObj.setBlock(...);
}

I have tested the case setting a single block; it works fine.

 

However, the case swapping two blocks failed; neither blocks are changed.

		zbt=zb[i];
		zmt=zm[i];
		if(!world.isRemote){
			world.setBlock(zx[i],zy[i],zz[i],zb[j],zm[j],2);
			world.setBlock(zx[j],zy[j],zz[j],zbt,zmt,2);
		}

Is it solvable?

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.