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

I feel like this must be something really obvious, because it seems very basic. I've got a custom door (which does not subclass vanilla BlockDoor - I'm adding and changing a lot of functionality so it's easiest to do from scratch), which opens and closes on right-click (as vanilla). In singleplayer this works fine, but in multiplayer there is a weird syncing problem. Visually, the door appears not to change its state - the model and the highlight bounding box stay the same. But the state does change on the server - if you try to walk through the door after 'closing' it (even though it still looks open), you bump into it (in a glitchy, jerky way), and can't get through.

 

Here is my onBlockActivated.

Spoiler

@Override
public boolean onBlockActivated(World world, BlockPos thisPos,
    	IBlockState thisState, EntityPlayer player, EnumHand hand,
        EnumFacing side, float x, float y, float z) {

    BlockPos otherPos = thisState.getValue(TOP) ?
      thisPos.down() : thisPos.up();
    IBlockState otherState = world.getBlockState(otherPos);

    if (otherState.getBlock() != this || world.isRemote) {

      return false;
    }

    thisState = thisState.cycleProperty(OPEN);
    world.setBlockState(thisPos, thisState);
    world.setBlockState(otherPos, otherState
                        .withProperty(OPEN, thisState.getValue(OPEN)));
    world.playEvent(player, thisState.getValue(OPEN) ?
                    1006 : 1012, thisPos, 0);

    return true;
}

 

I was under the impression that setBlockState by default synchronises the state change with the client - and I've stepped through in the debugger and seen that it does reach notifyBlockUpdate. So I don't understand why it doesn't seem to be updating properly? The whole class is here (along with the rest of my code).

Edited by Jay Avery

  • Author

Well, I found the foolishly obvious solution. I had screwed up my getMetaFromState/getStateFromMeta so the state wasn't being stored or sent server->client correctly.

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.