I was wondering if there was a way to modify a world's seed. Obviously, this would not effect old chunks, but I only need it to affect new ones. I'd like to be able to do this because I'm creating a plugin that will be used for a very specific type of survival minigame server. It will use the standard Minecraft chunk generator, but I've created a BlockPopulator to create a "fenced in" area out of bedrock. The problem is, I want the terrain to change every game, so I think the simplest way would be to change the world's seed and regenerate the chunks. I know that such a method would take a bit of time to do, but that is not a problem in my case. Unfortunately, as far as I can tell, Bukkit provides no methods for actually modifying a World's seed. The only method I could think of would be deleting the world and generating a new one, but this causes a lot of problems that seem unnecessary when a simple seed modification would be sufficient. Does anyone know if this is possible?
@imjake9 Use the WorldCreator interface. I'm not too familiar with this but it looks like: Code: WorldCreator.seed((long) seednumber); http://jd.bukkit.org/doxygen/d3/d60/classorg_1_1bukkit_1_1WorldCreator.html
That's all well and good, but I don't see how that allows me to change the seed of an existing world. Unless I'm missing something...?
@imjake9 The seed is stored here: https://github.com/Bukkit/CraftBukk...n/java/net/minecraft/server/WorldData.java#L7 - It's private and there doesn't seem to be a setSeed, so you have to use reflections: Code:java World world = theBukkitWorld;long newSeed = theNewSeed; net.minectaft.server.WorldData data = ((CraftWorld)world).getHandle().worldData;Field f = data.getClass().getDeclaredField("seed");f.setAccessible(true);f.setLong(worldData, newSeed);f.setAccessible(false); world.save();
@caldabeast http://en.wikipedia.org/wiki/Reflection_(computer_programming) http://java.sun.com/developer/technicalArticles/ALT/Reflection/
Sorry to be a noob, but how would i use this code to change the seed? i know little or nothing about programming or the way minecraft is programmed, but i have an issue which can be fixed by changing my server seed. can you help me use this to change it?
Final isn't final with reflection, as far as I am aware. If it is, it would still be achievable with AspectJ... EDIT: Yep. http://stackoverflow.com/questions/3301635/change-private-static-final-field-using-java-reflection
Simply copy&paste it? Code:java World world = theBukkitWorld; //theBukkitWorld is the World object.long newSeed = theNewSeed; //theNewSeed is the new seed you want to have. net.minectaft.server.WorldData data = ((CraftWorld)world).getHandle().worldData; //Now we get the WorldData (notch code)Field f = data.getClass().getDeclaredField("seed"); //We get the private field named seed...f.setAccessible(true); //...set it accessitble so we can modify it...f.setLong(worldData, newSeed); //...and set the new seed to it.f.setAccessible(false); //Then we set if non-accessible again. world.save(); //And finally we save the world with he new seed. But as other stated bukkit seems to have changed the codes. I didn't look at them but maybe the code won't work anymore.