Jump to content

NBT Usage Help [Solved]


wookiederk

Recommended Posts

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Yeah, I'll start with the ones I added last night.  Wasn't crashing until today and wasn't crashing at all yesterday (+past few days since removing Cupboard), so deductive reasoning says it's likeliest to be one of the new ones.  A few horse armor mods and a corn-based add-on to Farmer's Delight, the latter which I hope to keep - I could do without the horse armor mods if necessary.  Let me try a few things and we'll see. 
    • Add crash-reports with sites like https://mclo.gs/ Add this mod: https://www.curseforge.com/minecraft/mc-mods/packet-fixer/files/5416165
    • Maybe - remove recently added mods one by one
    • Temu, a popular online shopping platform, is currently offering an exclusive coupon code for Australian customers that can unlock significant savings. If you want to save money on your next purchase, the coupon code {act892435} is your key to unlocking AU$100 off your order, along with additional discounts on select items. How to Use the Coupon Code {act892435} Using the coupon code is straightforward. Follow these simple steps to maximize your savings: Download or Open the Temu App: If you haven't already, download the Temu app from your app store or visit the Temu website. Add Items to Your Cart: Browse through Temu’s vast selection of products and add your desired items to your shopping cart. Proceed to Checkout: Once you have finished shopping, go to your cart and click on the checkout button. Enter the Coupon Code: Look for the "Promo Code" or "Coupon Code" field on the checkout page. Enter {act892435} into this field and click “apply.” Enjoy Your Savings: After applying the code, you will see a deduction of AU$100 from your total order amount, plus you may receive an additional discount of 30% to 70% off on select items. Benefits of Using {act892435} The coupon code {act892435} is particularly beneficial for several reasons: Significant Savings: The AU$100 discount applies to your entire order, making it a great opportunity for larger purchases. Additional Discounts: In addition to the AU$100 off, you can stack this coupon with other promotions that offer up to 70% off select items, maximizing your savings potential. No Minimum Purchase Requirement: There’s no minimum spend required to use this coupon, allowing you to use it on any size order. Tips for Maximizing Your Savings To get the most out of the {act892435} coupon code, consider these tips: Shop Strategically: Since the AU$100 discount applies to your total order, consider purchasing multiple items or higher-priced products to maximize your savings. Check Eligible Items: Make sure to add items that qualify for additional discounts (30% to 70% off) to benefit from both offers. Stay Updated on Promotions: Keep an eye on Temu’s app and website for flash sales and limited-time offers that can further enhance your savings. Additional Ways to Save on Temu While using the coupon code {act892435} is one of the best ways to save right now, there are other strategies you can employ: Explore the Deals Section: Regularly check Temu's "Deals" section in the app for time-sensitive offers and sales. Follow Social Media Accounts: By following Temu’s Australian social media pages, you may gain access to exclusive promo codes not available elsewhere. Sign Up for Newsletters: Subscribe to Temu’s email newsletter for updates on new deals and additional discount codes delivered directly to your inbox. Conclusion The exclusive coupon code {act892435} offers Australian shoppers a fantastic opportunity to save AU$100 on their next Temu purchase while also enjoying extra discounts on select items. By following simple steps during checkout and employing strategic shopping techniques, you can maximize your savings significantly. Don’t miss out on this limited-time offer—head over to Temu today and start shopping! Share
    • No, I have both of those on.  Are they triggering as potential crash errors, even though suspected mods are "none"?  Apologies, I'm relatively new at modding Minecraft.   Edit: What's odd to me is that I've had both of those on literally from world inception (over three weeks real-world time, I think?) and never had issue with either.  I wonder if something added afterwards is causing incompatibilities.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.