Permalink
Browse files

FlatGenerator shouldn't be a BiomeGenerator. Made VanillaGenerator an…

… interface extending WorldGenerator too
  • Loading branch information...
1 parent f917af1 commit 8c2185dc29843dc26a4741ee6801636414351644 @zml2008 zml2008 committed May 11, 2012
@@ -135,7 +135,7 @@ public void onLoad() {
private void setupWorlds() {
//Initialize generators.
NormalGenerator normGen = new NormalGenerator();
- FlatGenerator flatGen = new FlatGenerator();
+ FlatGenerator flatGen = new FlatGenerator(50);
NetherGenerator netherGen = new NetherGenerator();
TheEndGenerator endGen = new TheEndGenerator();
@@ -26,7 +26,6 @@
*/
package org.spout.vanilla.world.generator;
-import org.spout.vanilla.world.generator.flat.biome.FlatGrassBiome;
import org.spout.vanilla.world.generator.nether.biome.NetherrackBiome;
import org.spout.vanilla.world.generator.normal.biome.BeachBiome;
import org.spout.vanilla.world.generator.normal.biome.DesertBiome;
@@ -60,5 +59,4 @@
public static final VanillaBiome SMALL_MOUNTAINS = new SmallMountainsBiome(20);
public static final VanillaBiome JUNGLE = new JungleBiome(21);
public static final VanillaBiome ENDSTONE = new EndStoneBiome(22);
- public static final VanillaBiome FLATGRASS = new FlatGrassBiome(23);
}
@@ -26,16 +26,12 @@
*/
package org.spout.vanilla.world.generator;
-import org.spout.api.generator.biome.BiomeGenerator;
+import org.spout.api.generator.WorldGenerator;
import org.spout.api.geo.World;
import org.spout.api.geo.discrete.Point;
-import org.spout.api.util.cuboid.CuboidShortBuffer;
-public abstract class VanillaGenerator extends BiomeGenerator {
- @Override
- public void generate(CuboidShortBuffer blockData, int chunkX, int chunkY, int chunkZ) {
- super.generate(blockData, chunkX, chunkY, chunkZ);
- }
+public interface VanillaGenerator extends WorldGenerator {
+
public abstract Point getSafeSpawn(World world);
}
@@ -26,18 +26,48 @@
*/
package org.spout.vanilla.world.generator.flat;
+import org.spout.api.generator.Populator;
+import org.spout.api.generator.WorldGenerator;
import org.spout.api.geo.World;
+import org.spout.api.geo.cuboid.Chunk;
import org.spout.api.geo.discrete.Point;
+import org.spout.api.util.cuboid.CuboidShortBuffer;
+import org.spout.vanilla.material.VanillaMaterials;
import org.spout.vanilla.world.generator.VanillaBiomes;
import org.spout.vanilla.world.generator.VanillaGenerator;
import org.spout.vanilla.world.selector.NoiseSelector;
-public class FlatGenerator extends VanillaGenerator {
+public class FlatGenerator implements WorldGenerator, VanillaGenerator {
+ private final int height;
+
+ public FlatGenerator(int height) {
+ this.height = height;
+ }
+
+ @Override
+ public void generate(CuboidShortBuffer blockData, int chunkX, int chunkY, int chunkZ) {
+ int x = chunkX << 4, z = chunkZ << 4;
+ for (int dx = x; dx < x + 16; ++dx) {
+ for (int dz = z; dz < z + 16; ++dz) {
+ final int startY = chunkY * Chunk.CHUNK_SIZE;
+ final int endY = Math.min(Chunk.CHUNK_SIZE + startY, height);
+ for (int y = startY; y < endY; y++) {
+ if (y <= 0) {
+ blockData.set(dx, y, dz, VanillaMaterials.BEDROCK.getId());
+ } else if (y == height - 1) {
+ blockData.set(dx, y, dz, VanillaMaterials.GRASS.getId());
+ } else {
+ blockData.set(dx, y, dz, VanillaMaterials.DIRT.getId());
+ }
+ }
+ }
+ }
+ }
+
@Override
- public void registerBiomes() {
- setSelector(new NoiseSelector(1, 1, 1, 1, 1));
- register(VanillaBiomes.FLATGRASS);
+ public Populator[] getPopulators() {
+ return new Populator[0];
}
@Override
@@ -26,14 +26,15 @@
*/
package org.spout.vanilla.world.generator.nether;
+import org.spout.api.generator.biome.BiomeGenerator;
import org.spout.api.geo.World;
import org.spout.api.geo.discrete.Point;
import org.spout.vanilla.world.generator.VanillaBiomes;
import org.spout.vanilla.world.generator.VanillaGenerator;
import org.spout.vanilla.world.selector.WhittakerNoiseSelector;
-public class NetherGenerator extends VanillaGenerator {
+public class NetherGenerator extends BiomeGenerator implements VanillaGenerator {
@Override
public void registerBiomes() {
setSelector(new WhittakerNoiseSelector(2));
@@ -26,6 +26,7 @@
*/
package org.spout.vanilla.world.generator.normal;
+import org.spout.api.generator.biome.BiomeGenerator;
import org.spout.api.geo.World;
import org.spout.api.geo.discrete.Point;
@@ -34,7 +35,7 @@
import org.spout.vanilla.world.populator.SmoothPopulator;
import org.spout.vanilla.world.selector.WhittakerNoiseSelector;
-public class NormalGenerator extends VanillaGenerator {
+public class NormalGenerator extends BiomeGenerator implements VanillaGenerator {
@Override
public void registerBiomes() {
setSelector(new WhittakerNoiseSelector(2.0));
@@ -26,14 +26,15 @@
*/
package org.spout.vanilla.world.generator.theend;
+import org.spout.api.generator.biome.BiomeGenerator;
import org.spout.api.geo.World;
import org.spout.api.geo.discrete.Point;
import org.spout.vanilla.world.generator.VanillaBiomes;
import org.spout.vanilla.world.generator.VanillaGenerator;
import org.spout.vanilla.world.selector.NoiseSelector;
-public class TheEndGenerator extends VanillaGenerator {
+public class TheEndGenerator extends BiomeGenerator implements VanillaGenerator {
@Override
public void registerBiomes() {
setSelector(new NoiseSelector(0.9, 1.5, 5, 0.9, 1.5));

0 comments on commit 8c2185d

Please sign in to comment.