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.

Featured Replies

Posted

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?

  • Author

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.

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.