Copyright ? 2014 PEMapModder
This software is open-source and everyone is welcome to share redistributions or modifications,
as long as it is clearly specified that this project's original source is ...
If you think the Android project Spidermine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package pemapmodder.old_spidermine.world.populator;
//www.java2s.comimport java.util.Random;
import pemapmodder.old_spidermine.utils.math.MathUtils;
import pemapmodder.old_spidermine.utils.math.Position;
import pemapmodder.old_spidermine.world.Block;
import pemapmodder.old_spidermine.world.World;
publicclass WorldPopulator {
publicstaticvoid populate(World world, Object seed, short type) {
new WorldPopulator(world, seed, type);
}
private Random random;
private WorldPopulator(World world, Object seed, short type){
this.random=new Random(MathUtils.myHash(seed)/*+world.hashCode()*/);
for(int x=0;x<256;x++){//populate bedrock
for(int z=0;z<256;z++){
world.setBlock(new Position(x, 0, z), new Block(7), false);
int height=random.nextInt()%4;
if(height==0)height=4;
for(int i=1;i<=height;i++)
world.setBlock(new Position(x, i, z), new Block(7), false);
}
}
}
publicfinalstaticshort TYPE_SUPERFLAT=0x0;
publicfinalstaticshort TYPE_NORMAL=0x1;
publicfinalstaticshort TYPE_MEGA=0x2;
//public final static short TYPE_PRE_INFINITE=0xFF;
}