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

Edit: Initial issue not actually an issue as there were more than 1 entity in the world which I overlooked. New issue is this:

 

If I am to send a packet during the readEntityFromNBT method, the client won't update, however if I am to send packets during the update method it will update. Could you explain the reason behind this?

 

------------------------------------------------------------------------------------------------------------------------------------------

 

Whenever I reload a world, the readEntityFromNBT method is called a total of 4 times for one entity.

 

- The first time it is called, when I use compound.getInt("skin") it returns a default value of 0, which is not the one I want.

- Then the second time it is called it returns 5, the actual value I want my skin field to be and the one it was set to before reloading.

- Then the next to two times it is called it again returns 0, which is again not what I am looking for.

 

So when logging this information in the console I end up with this:

 

[iNFO] 0
[iNFO] 5
[iNFO] 0
[iNFO] 0

 

I cannot for the life of my figure out why this is happening and don't know what code to provide that could be of help apart from the NBT methods:

 

@Override
public void writeEntityToNBT(NBTTagCompound compound) 
{
super.writeEntityToNBT(compound);

compound.setInteger("level", level);
compound.setInteger("xp", xp);
compound.setDouble("health", health);
compound.setDouble("damage", damage);
compound.setDouble("speed", speed);
compound.setInteger("type", type);
compound.setInteger("skin", skin);
}

@Override
public void readEntityFromNBT(NBTTagCompound compound) 
{
super.readEntityFromNBT(compound);

setLevel(compound.getInteger("level"));
setXP(compound.getInteger("xp"));
setMaximumHealth(compound.getDouble("health"));
setDamage(compound.getDouble("damage"));
setSpeed(compound.getDouble("speed"));
setType(compound.getInteger("type"));
setSkin(compound.getInteger("skin"));

Log.info(compound.getInteger("skin"));
}

 

Any ideas would be much appreciated, thanks.

  • Author

As it turns out, no there were more than one in the world, so I managed to overlook that. New issue though regarding packets.

 

If I am to send a packet during the readEntityFromNBT method, the client won't update, however if I am to send packets during the update method it will update. Could you explain the reason behind this?

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.