Posted December 16, 201212 yr Hey Guys, I want, that you have to eat a plant to discover what it does. That works quite good, but everytime I start the map new, all discovered informations are resteted. Furthermore it would be nice, if it also works for every single player in multiplayer... So I think I've to save the vars to a file, but how can I do it? So here are the relevant parts of the Code: ItemFoodLantanaBerries.java : public class ItemFoodLantanaBerries extends ItemFood { public boolean discovered = false; // This var says if you know the plant or not. At start you don't know what this plant does. /... public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { discovered = true; // <-- If you've eaten the plant, you know the properties of it. /... } @SideOnly(Side.CLIENT) public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if(discovered == false) // If you don't know the plant, you will have an other information. { par3List.add("Some blue berries."); } else { par3List.add("There is a medium posion inside."); } } }
December 16, 201212 yr By "start the map new," do you mean when you make a new map, or when you quit then come back? http://i.imgur.com/ivK3J.png[/img] I'm a little surprised that I am still ranked as a "Forge Modder," having not posted a single mod since my animals mod... I have to complete Digging Deeper!, fast!
December 17, 201212 yr Author By "start the map new," do you mean when you make a new map, or when you quit then come back? I mean when I quit and come back, all my discovered informations are away. If you create a new map, it's ok, that you will loose your informations...
December 19, 201212 yr Add information to player.getEntityData(), hopefully it's pretty self-explanatory. Protip: try and find answers yourself before asking on the forum. It's pretty likely that there is an answer. Was I helpful? Give me a thank you! http://bit.ly/HZ03zy[/img] Tired of waiting for mods to port to bukkit? use BukkitForge! (now with a working version of WorldEdit!)
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.