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

I used this tutorial from CoolAlias, taht one with the Extended Player Properties, but it seems like the event is fired, but it doesn't save the NBT, and I can't figure out why

 

public class PlayerProperties implements IExtendedEntityProperties
{

public final static String EXT_PROP_NAME = "IntektorsProperties";

private final EntityPlayer player;

public int researchState;

public PlayerProperties(EntityPlayer player)
{
	this.player = player;
}

public static final void register(EntityPlayer player)
{
	player.registerExtendedProperties(PlayerProperties.EXT_PROP_NAME, new PlayerProperties(player));
}

public static final PlayerProperties get(EntityPlayer player)
{
	return (PlayerProperties) player.getExtendedProperties(EXT_PROP_NAME);
}

@Override
public void saveNBTData(NBTTagCompound compound)
{
	NBTTagCompound properties = new NBTTagCompound();
	properties.getInteger("Research");
	compound.setTag(EXT_PROP_NAME, properties);
}

@Override
public void loadNBTData(NBTTagCompound compound)
{
	NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
	this.researchState = properties.getInteger("Research");
}

@Override
public void init(Entity entity, World world)
{

}

}

 

The event is fireds, I checked this, but it creates the Properties every time again

 

@SubscribeEvent
public void onEntityContructionEvent(EntityConstructing event){
	if(event.entity instanceof EntityPlayer && PlayerProperties.get((EntityPlayer) event.entity) == null){
		PlayerProperties.register((EntityPlayer) event.entity);
	}
}

 

 

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

@Override
public void saveNBTData(NBTTagCompound compound)
{
	NBTTagCompound properties = new NBTTagCompound();
	properties.getInteger("Research");
	compound.setTag(EXT_PROP_NAME, properties);
}

@Override
public void loadNBTData(NBTTagCompound compound)
{
	NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
	this.researchState = properties.getInteger("Research");
}
}

 

properties.getInteger("Research");

VVV

properties.setInteger("Research", this.researchState);

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

  • Author

What exactly makes you think it is not saved? How do you check it? Also how is "researchState modified?

 

First of all, this line of code

 

PlayerProperties.get((EntityPlayer) event.entity) == null

 

should make sure to only create a new instance of the properties, if there isn't already one, shouldn't it?

 

Also, when I use my update method

 

@Override
public void updateEntity() {
	if(theUser != null){
		finishedNBT.setBoolean(theUser.getDisplayName(), true);
		System.out.println(PlayerProperties.get(theUser).researchState + "" + FMLCommonHandler.instance().getEffectiveSide());
	}
}

 

it prints 0 on both Client and Server, although

 

PlayerProperties.get(theUser).researchState++;
			ModArmMod.network.sendToServer(new ClientToServerMessage(7, new int[]{tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord}));

in my gui

 

if(message.ID == 7){
			TileEntityArmorModifier tileEntity = (TileEntityArmorModifier) ctx.getServerHandler().playerEntity.getEntityWorld().getTileEntity(message.extra[0], message.extra[1], message.extra[2]);
			PlayerProperties.get(tileEntity.theUser).researchState++;
		}

 

and thats it

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

  • Author

@Override
public void saveNBTData(NBTTagCompound compound)
{
	NBTTagCompound properties = new NBTTagCompound();
	properties.getInteger("Research");
	compound.setTag(EXT_PROP_NAME, properties);
}

@Override
public void loadNBTData(NBTTagCompound compound)
{
	NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
	this.researchState = properties.getInteger("Research");
}
}

 

properties.getInteger("Research");

 

#setInteger

 

 

thanks, but it won't cfhange anything if there is every time a new instance created

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

  • Author

There is a new instance created when the player is created, there is nothing wrong with that.

 

hm ok, but why the hell is it 0 then

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

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.