Jump to content

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


IceLitty

Recommended Posts

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

 

Link to comment
Share on other sites

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 _(:з)∠)_

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • 3 weeks later...
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.