Jump to content

[1.7.10] attackEntityFrom called only on client side


VulcanForge

Recommended Posts

To start off, here's my code:

 

@Override
public boolean attackEntityFrom(DamageSource damage, float damageLevel)
{
	if(!(damage.getEntity() instanceof EntityPlayer)) return false;

	FMLLog.getLogger().info("In method");

	if(!worldObj.isRemote)
	{
		this.dropItem(STItem.phaserDrill, 1);
		FMLLog.getLogger().info("Item dropped");
		setDead();
		return true;
	}

	return false;
}

 

As you would expect, "In method" is logged whenever I hit the entity, but "Item dropped" is only logged when it's called server-side. But for some reason, I have to hit the entity many many times before it's called server-side. Here's an excerpt from my logs:

 

[19:00:51] [Client thread/INFO] [FML]: In method
[19:00:51] [server thread/INFO] [FML]: In method
[19:00:51] [server thread/INFO] [FML]: Item dropped
[19:01:00] [Client thread/INFO] [FML]: In method
[19:01:03] [Client thread/INFO] [FML]: In method
[19:01:06] [Client thread/INFO] [FML]: In method
[19:01:07] [Client thread/INFO] [FML]: In method
[19:01:08] [Client thread/INFO] [FML]: In method
[19:01:09] [Client thread/INFO] [FML]: In method
[19:01:15] [Client thread/INFO] [FML]: In method
[19:01:15] [Client thread/INFO] [FML]: In method
[19:01:15] [server thread/INFO] [FML]: In method
[19:01:15] [server thread/INFO] [FML]: Item dropped
[19:01:18] [Client thread/INFO] [FML]: In method
[19:01:18] [server thread/INFO] [FML]: In method
[19:01:18] [server thread/INFO] [FML]: Item dropped

 

As you can see, the server is hit and miss on calling attackEntityFrom(). Is attackEntityFrom() not supposed to be called on both sides all the time or what? And one more question. What's the significance of the Boolean value I'm returning? I assume that it returns true if the method actually does something, but maybe my problem has something to do with my return statement?

Link to comment
Share on other sites

Update: I know what's going on. I'm not in range to the entity from the server's perspective. Earlier, I had been calling setDead() outside of the if(!world.isRemote) block and the client would remove my copy but the server would retain its. I finally fixed that, but then I assumed that this problem had something to do with the same thing. But I'm guessing that my client is being optimistic that I'm in range to the entity, but the server is ignoring the packet because it calculates my range too high. Sorry to bother you guys, but it may be worthwhile to know that the client can be a bit out of sync even on an SP world.

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.