Jump to content

Recommended Posts

Posted

I'm defining custom logic for an item via onItemUse. While debugging I'm noticing that the method is actually called twice - once from the main thread and once from the server thread. This wasn't noticeable until I sent a message to the player - it shows twice.

 

player.sendMessage(new TextComponentTranslation("text.scroll.backfire_poison"));

 

I'm not sure what to do - I'm making block changes (right click a block to change it...) so this needs to run on the server but setting @SideOnly(Side.SERVER) doesn't work here. I need to find a way to prevent this from running twice.

Posted

I will, but the side aspect now seems unrelated to my issue, unless I have to get way more complex and split these up into logical client/server methods and have them communicate, which I hope is unnecessary..

Posted

No, but the side is important here. You see 2 messages because one is from the client and one from the server. The solution is in the "Performing Side-Specific Operations" portion.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Ok, I'm new to this so it took me a while to understand it all but the example they spelled out solved my issue.

 

Quote

For example, if you want to damage the player every time they click your block, or have your machine process dirt into diamonds, you should only do so after ensuring world.isRemote is false. Applying game logic to the logical client can cause desynchronization (ghost entities, desynchronized stats, etc.) in the lightest case, and crashes in the worst case.

 

Thanks for pointing me in the right direction.

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.