Jump to content

Recommended Posts

Posted

At first I was thinking that's maybe beacuse Server is running in the background, or maybe it's just bug, but now it started to bother me.

WTF.jpg

I am using this code:

@Override
public void onBlockDestroyedByPlayer(World par1World, int x, int y, int z, int m)
{
	Random generator = new Random(); 
	int X = generator.nextInt(10000) + 1;

	System.out.println(X);
}

It gives me 2x random numbers every time I destroy block - WHY?! And will it cause problems on MP?

Note that no matter if I use Random or not, all the System.out will run twice.

 

1.7.10 is no longer supported by forge, you are on your own.

Posted

Yes it's because of the server and client threads. If you only want it called on one side use an if statement, with world.isRemote which returns true on the client and false on the server. This shouldn't cause a problem, normally you want to do things on both, but sometimes you will only want t do it on the server, and very very rarely you may want to do something only on the client (although i'm not sure why)

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.