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.

[1.12.2] World.setBlockState() work in physical server side and not show correctly in client

Featured Replies

Posted

Hi there, I'm new one to try write forge mods find some problems and search some topics may not help for this question...

 

I write a test project about this:

https://github.com/IceLitty/forge-1.12.2-14.23.1.2555-mod-test-project

And problem lines:

https://github.com/IceLitty/forge-1.12.2-14.23.1.2555-mod-test-project/blob/master/src/main/java/com/gmail/litalways/icykingdoms/growBlock.java#L77

 

When I run client and into client world, I use Bone Meal to change this block states 'stage', it can cycle from 0 to 1.

And I start server, join client into it, IDE log can output correctly cycle 0 and 1, but client shows not changed..

 

Even if I not write world.isRemote, or tried this update function, they all not help:

this.requiresUpdates();
worldIn.updateObservingBlocksAt(pos, this);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
worldIn.notifyBlockUpdate(pos, state, state.withProperty(STAGE, 1), 4);
worldIn.scheduleUpdate(pos, this, 0);
worldIn.scheduleBlockUpdate(pos, this, 0, 1);
worldIn.markAndNotifyBlock(pos, worldIn.getChunkFromBlockCoords(pos), state, state.withProperty(STAGE, 1), 4);
worldIn.markBlocksDirtyVertical(pos.getX(), pos.getZ(), pos.getY(), pos.getY());
worldIn.updateBlockTick(pos, this, 0, 1);

 

  • Author
12 minutes ago, Alexiy said:

Try 'setBlockState' without a flag or with a flag 2.

Yes I tried from 1 to 16, as same had problem..

Ok, let's try this - after the line worldIn.setBlockState(pos, state.cycleProperty(STAGE), 4) add following:

 

IBlockState blockState=worldIn.getBlockState(pos);

worldIn.notifyBlockUpdate(pos,blockState,blockState,2);

  • Author
1 hour ago, Alexiy said:

Ok, let's try this - after the line worldIn.setBlockState(pos, state.cycleProperty(STAGE), 4) add following:

 

IBlockState blockState=worldIn.getBlockState(pos);

worldIn.notifyBlockUpdate(pos,blockState,blockState,2);

hmm... and still no changes by client, server still can cycle it _(:з)∠)_

Oh, I've noticed you haven't overridden getStateFromMeta method. You have to override it and return appropriate state from the given metadata. And in getMetaFromState you have to return appropriate metadata, I guess in your case it will be just state.getValue(STAGE).

  • Author
20 hours ago, Alexiy said:

Oh, I've noticed you haven't overridden getStateFromMeta method. You have to override it and return appropriate state from the given metadata. And in getMetaFromState you have to return appropriate metadata, I guess in your case it will be just state.getValue(STAGE).

 

16 hours ago, diesieben07 said:

This.

The world only remembers block states by their metadata. Properties which are not encoded as metadata are forgotten by the world.

 

It works!

Is actually when server changed, server push the meta id to client not push the state?! But I look forge document It have special state, it not effect metadata id, but still work..

And 1.13 will remove metadata id, if I using 1.12, it still need overwrite getStateFromMeta and getMetaFromState function?

  • 3 weeks later...
  • Author
On 2018/1/10 at 10:23 PM, diesieben07 said:

Yes, the server sends the metadata to the client.

1.13 will still use some kind of ID for every state. Sending full serialized states to the client (or saving them in the world) is madness, the save size and network traffic would explode.

Err.. Another simple question..

In this https://github.com/IceLitty/forge-1.12.2-14.23.1.2555-mod-test-project/blob/master/src/main/java/com/gmail/litalways/icykingdoms/RegistryFunc.java#L22

I register this blockitem's localname is "gb", whole id is "tile.gb.name" by block and "item.gb.name" by item, then I add en_US.lang file in assets/icykingdoms/lang folder, they still show local id in game..

And I try put lang file to assets/minecraft/lang, still doesn't work.

*icykingdoms is mod id, defined https://github.com/IceLitty/forge-1.12.2-14.23.1.2555-mod-test-project/blob/master/src/main/java/com/gmail/litalways/icykingdoms/IcyKingdomsMod.java#L14

And I determine it's can't find lang file, because any string like item name, string on UI.. they all just show id

Assets must be all lower case.

 

en_us.lang

not

en_US.lang

 

Also, you should include your mod ID in your unlocalized names to avoid conflicts with other mods ("gb"? really?)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author
11 hours ago, Draco18s said:

Assets must be all lower case.

 

en_us.lang

not

en_US.lang

 

Also, you should include your mod ID in your unlocalized names to avoid conflicts with other mods ("gb"? really?)

I think it will use lang folder under assets/modid? So it could be anything string?

Or it will get together and .. oh I know

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.