Posted February 24, 201312 yr How can i make a structure generate only once? i want to make a structure which generates only once and not everytime a new chunk is beeing generated. i got the code to work but the problem is i used a variable to check if the structure is already generated. but when i exit the game it resets the variable and the structure is beeing generated again. so can i write the variable to NBT or something? or is there another way to save variables in for example in my baseclass or CommonProxy? http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
February 24, 201312 yr Author I tried to make a new WorldSavedData class but i cant firgure out how it works. can someone explain it to me pls? i can't find anything about it on the internet to. http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
February 25, 201312 yr perhaps make a file??? Also, I should have you know that you are reading my signature.
February 25, 201312 yr Author the world save data way looks a lot easier to me then making a file. and since it is already implemented into minecraft i think im gonna go with that one. but do i need to register it or something? i cant find anything about it. http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
February 26, 201312 yr Author i did that but it wont save. i set my variable to true and when i restart the game it is false again. if(world.loadItemData(WorldSaveData.class, "LegendzWorldSaveData") == null){ WorldSavedData data = new WorldSaveData("LegendzWorldSaveData"); world.setItemData("LegendzWorldSaveData", data); } WorldSaveData worldSaveData = (WorldSaveData) world.loadItemData(WorldSaveData.class, "LegendzWorldSaveData"); System.out.println(worldSaveData.alreadyGenerated[0]); i put this in the generate method in my WorldGenerator. and here is my WorldSaveData Class package legendz.common; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import net.minecraft.world.storage.MapStorage; public class WorldSaveData extends WorldSavedData { public static boolean[] alreadyGenerated = new boolean[8]; public WorldSaveData(String par1Str) { super(par1Str); } @Override public void readFromNBT(NBTTagCompound nbt) { for(int i = 0; i < alreadyGenerated.length; i++){ alreadyGenerated[i] = nbt.getBoolean("generated"+i); } } @Override public void writeToNBT(NBTTagCompound nbt) { for(int i = 0; i < alreadyGenerated.length; i++){ nbt.setBoolean("generated"+i, alreadyGenerated[i]); } } } http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
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.