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

Hi, I'm doing a little experimenting with NBT Tags. I'm  trying to save and load data player specific but I do not know how to access it correctly. It just results in a crash when I try to save/load to the tag. The additional properties attach to the player in my main file. Here is my code for the extended properties and Item class that call it:

Both Save and Load NBT arent working.

Extended Properties Class:

public static boolean[] recipes;
public static String[] recipeNames;

@Override
public void saveNBTData(NBTTagCompound compound) {
	NBTTagList cookValues = new NBTTagList();
	for (int i = 0; i < recipes.length; i++) {
		compound.setBoolean(recipeNames[i], recipes[i]);
		cookValues.appendTag(compound);
	}
	compound.setTag("Cookbook", cookValues);
}

@Override
public void loadNBTData(NBTTagCompound compound) {
	NBTTagList cookValues = compound.getTagList("Cookbook");
	for (int i = 0; i < cookValues.tagCount(); i++) {
		this.recipes[i] = compound.getBoolean(recipeNames[i]);
		System.out.println(recipes[i]);
	}
}

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

}

public void writeRecipe(boolean par1, int par2, String par3) {
	recipes[par2] = par1;
	this.recipeNames[par2] = par3;
} 

 

Food Class:

@Override
public void onFoodEaten(ItemStack itemstack, World world,
		EntityPlayer player) {
	player.getFoodStats().addStats(this);
	world.playSoundAtEntity(player, "random.burp", 0.5F,
			world.rand.nextFloat() * 0.1F + 0.9F);
	this.addPotionEffects(itemstack, world, player);
	((EventCookbook) player.getExtendedProperties("Cookbook")).writeRecipe(
			true, 0);
} 

 

Any help appreciated

 

Edit: Fixed it on my own

Guest
This topic is now closed to further replies.

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.