Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

  • 4 weeks later...
  • Author

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?

Your block of code doesn't show how you determine what each of those variables' values are, so I can't say for sure, but if neither block changed, then chances are the coordinates are not what you think they are - possibly you just got them backwards, i.e. setting each block to itself.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.