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

Hey, guys, it's me again!

 

The issue I am having this time is that I need an item to be able to store the player entity, and how I do that is by storing the name. That works well and everything, works perfectly while in SSP, but for some reason it does NOT work when I am testing this while on a server.

 

Below is the code that I use to get the EntityPlayer from the string.

EntityPlayer owner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(tag.getString("ownerName"));

 

(There is some null checking before and after this line)

 

From what I understand, seeing as when the client uses this on a server receives a NPE, the client is unable to get the server (or config manager, etc) from this line of code, and thus can not obtain the EntityPlayer from this. I either need a method that will return the EntityPlayer from a string representation, or be able to instead get the .dat file instead, since I am mainly interested in the stored data of the player's .dat file.

 

Second part, a separate matter, is that when the player dies any custom information that I add to the Entity data is erased. What I use is this:

NBTTagCompound playerTag = owner.getEntityData();
if(playerTag.getInteger("currentEssence")>=this.getEnergyUsed())
    	{
    		return true;
    	}

 

I suppose that when I save/access the information to/from the Entity, I am not saving it in an area that persists. I suppose the main issue with this is that I am not directly accessing the player's .dat file, and thus am not able to write persistent information.

 

I think that both of these issues relate to the need of directly getting the player's .dat information from a string, so if anyone has a method to do this for a server, that would be greatly appreciated!

use a class that extends IExtendedEntityProperties

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

  • Author

use a class that extends IExtendedEntityProperties

 

I suppose that will work for the second issue, but it doesn't help with the first. Basically I'd need to get the NBTTagCompound (the one returned by .getEntityData()) by a different method.

well if the data is stored in the ItemStack extra nbt compound (idk what its exactly called) the server should automaticly sync itself to the client

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.