diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 172dd0b7..91a20138 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -99,6 +99,7 @@ import client.window.WindowEvent; import client.world.ChunkClient; import client.world.WorldClient; import common.Version; +import common.biome.Biome; import common.block.Block; import common.collect.Lists; import common.collect.Maps; @@ -522,6 +523,7 @@ public class Client implements IThreadListener { Window.init(); ModelBlock.setAsProvider(); Registry.register(); + UniverseRegistry.register(); Log.setSync(CLIENT); CLIENT.run(time); Window.end(); @@ -1719,13 +1721,15 @@ public class Client implements IThreadListener { break; } + Biome biome = null; String bline; String lline; if(this.world.isBlockLoaded(blockpos)) { ChunkClient chunk = this.world.getChunk(blockpos); - bline = String.format("Biom: %.2f K, N: %.2f K, D: %s (%s)", chunk.getTemperature(blockpos), chunk.getOffset(blockpos), - TextColor.stripCodes(this.world.dimension.getDisplay()), - this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName); + biome = chunk.getBiome(blockpos); + bline = "Biom: " + biome.display + " (" + biome.name + "), D: " + + TextColor.stripCodes(this.world.dimension.getDisplay()) + + " (" + (this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName) + ")"; lline = "Licht: " + chunk.getLightSub(blockpos, 0) + " (" + chunk.getLight(LightType.SKY, blockpos) + " Himmel, " + chunk.getLight(LightType.BLOCK, blockpos) + " Blöcke, " + String.format( "%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt), A: " @@ -1740,6 +1744,7 @@ public class Client implements IThreadListener { + String.format("%.1f °", this.world.getCelestialAngle(1.0f)); } + float temp = Math.max(this.world.getTempOffset() + (biome != null ? biome.getTemperature(blockpos) : 0.0f), 0.0f); long ticked = System.currentTimeMillis() - this.lastTicked; return @@ -1775,7 +1780,7 @@ public class Client implements IThreadListener { String.format("Laub: %s%s, T: %.2f K / %.2f °C, %s (R %.1f, %.1f)", !this.world.dimension.hasSeasons() ? "*" : "", this.world.getLeavesGen(blockpos).getDisplayName(), - this.world.getTemperatureK(blockpos), this.world.getTemperatureC(blockpos), + temp, World.ABSOLUTE_ZERO + temp, this.world.getWeather().getDisplay(), this.world.getRainStrength(), this.world.getDarkness() ) + "\n" + diff --git a/client/src/main/java/client/gui/ingame/GuiCreateDimension.java b/client/src/main/java/client/gui/ingame/GuiCreateDimension.java index 6b14262d..f2734c4d 100644 --- a/client/src/main/java/client/gui/ingame/GuiCreateDimension.java +++ b/client/src/main/java/client/gui/ingame/GuiCreateDimension.java @@ -3,6 +3,7 @@ package client.gui.ingame; import java.util.List; import client.gui.Gui; +import common.biome.Biome; import common.block.foliage.LeavesType; import common.collect.Lists; import common.dimension.Dimension; @@ -11,6 +12,7 @@ import common.dimension.Dimension.ReplacerType; import common.init.Blocks; import common.init.UniverseRegistry; import common.tags.TagObject; +import common.world.State; public class GuiCreateDimension extends Gui { public static final GuiCreateDimension INSTANCE = new GuiCreateDimension(); @@ -59,7 +61,7 @@ public class GuiCreateDimension extends Gui { dtag.setInt("SeaRarity", 50); dtag.setInt("AddRarity", 50); dtag.setInt("SeaLevel", 0); -// dtag.setString("DefaultBiome", Biome.NONE.name.toLowerCase()); // TODO fix everything + dtag.setString("DefaultBiome", Biome.NONE.name.toLowerCase()); dtag.setBool("SemiFixed", false); // dtag.setString("DefaultWeather", Weather.CLEAR.getName()); dtag.setString("DefaultLeaves", LeavesType.SPRING.getName()); @@ -82,17 +84,17 @@ public class GuiCreateDimension extends Gui { return addPreset(display, "terra", data); } -// private static Dimension addFlatPreset(String display, Biome biome, boolean populate, State main, Object ... layers) { -// return addFlatPreset(display, "terra", biome, populate, main, layers); -// } -// -// private static Dimension addFlatPreset(String display, String base, Biome biome, boolean populate, State main, Object ... layers) { -// Dimension dim = addPreset("Flach - " + display, base, "ClearGenerator:1b" + (populate ? "" : ",NoPopulation:1b")); -//// dim.setBiome(biome); // TODO: populator -// if(main != null) -// dim.setFlatGen(main, layers); -// return dim; -// } + private static Dimension addFlatPreset(String display, Biome biome, boolean populate, State main, Object ... layers) { + return addFlatPreset(display, "terra", biome, populate, main, layers); + } + + private static Dimension addFlatPreset(String display, String base, Biome biome, boolean populate, State main, Object ... layers) { + Dimension dim = addPreset("Flach - " + display, base, "ClearGenerator:1b" + (populate ? "" : ",NoPopulation:1b")); + dim.setBiome(biome); + if(main != null) + dim.setFlatGen(main, layers); + return dim; + } static { @@ -109,34 +111,34 @@ public class GuiCreateDimension extends Gui { addPreset("Chaotische Höhlen", "UpperLmtScale:2.0,LowerLmtScale:64.0,SeaLevel:6"); addPreset("Viel Glück", "LiquidBlock:lava,SeaLevel:40"); -// addFlatPreset("Klassisch", Biome.PLAIN, false, Blocks.dirt.getState(), Blocks.bedrock.getState(), 2, Blocks.dirt.getState(), -// Blocks.grass.getState()).enableVillages(); -// -// addFlatPreset("Abbauwelt", Biome.HILLS, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 230, Blocks.stone.getState(), -// 5, Blocks.dirt.getState(), Blocks.grass.getState()).enableStrongholds().enableMineshafts().setDungeons(8); -// -// addFlatPreset("Wasserwelt", Biome.SEA, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 5, Blocks.stone.getState(), -// 52, Blocks.dirt.getState(), 5, Blocks.sand.getState(), 90, Blocks.water.getState()); -// -// addFlatPreset("Oberfläche", Biome.PLAIN, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(), -// 3, Blocks.dirt.getState(), Blocks.grass.getState()).setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()).enableVillages().enableStrongholds().enableMineshafts().setDungeons(8) -// .addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false).addLake(Blocks.lava.getState(), Blocks.stone.getState(), null, 8, 8, 255, true); -// -// addFlatPreset("Verschneites Königreich", Biome.ICE, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(), -// 3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).enableVillages(); -// -// addFlatPreset("Verschneites Königreich +", Biome.ICE, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(), -// 3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()).enableVillages() -// .addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false); -// -// addFlatPreset("Unendliche Grube", Biome.PLAIN, false, Blocks.dirt.getState(), 2, Blocks.cobblestone.getState(), 3, Blocks.dirt.getState(), Blocks.grass.getState()) -// .setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()).enableVillages(); -// -// addFlatPreset("Wüste", Biome.DESERT, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 3, Blocks.stone.getState(), 52, Blocks.sandstone.getState()) -// .enableVillages().enableScattered(); -// -// addFlatPreset("Sandsteinwelt", Biome.DESERT, false, Blocks.sandstone.getState(), Blocks.bedrock.getState(), 3, Blocks.stone.getState(), -// 52, Blocks.sandstone.getState()); + addFlatPreset("Klassisch", Biome.PLAIN, false, Blocks.dirt.getState(), Blocks.bedrock.getState(), 2, Blocks.dirt.getState(), + Blocks.grass.getState()).enableVillages(); + + addFlatPreset("Abbauwelt", Biome.HILLS, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 230, Blocks.stone.getState(), + 5, Blocks.dirt.getState(), Blocks.grass.getState()).enableStrongholds().enableMineshafts().setDungeons(8); + + addFlatPreset("Wasserwelt", Biome.SEA, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 5, Blocks.stone.getState(), + 52, Blocks.dirt.getState(), 5, Blocks.sand.getState(), 90, Blocks.water.getState()); + + addFlatPreset("Oberfläche", Biome.PLAIN, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(), + 3, Blocks.dirt.getState(), Blocks.grass.getState()).setBiomeReplacer(Blocks.gravel.getState()).enableVillages().enableStrongholds().enableMineshafts().setDungeons(8) + .addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false).addLake(Blocks.lava.getState(), Blocks.stone.getState(), null, 8, 8, 255, true); + + addFlatPreset("Verschneites Königreich", Biome.ICE, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(), + 3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).enableVillages(); + + addFlatPreset("Verschneites Königreich +", Biome.ICE, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(), + 3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).setBiomeReplacer(Blocks.gravel.getState()).enableVillages() + .addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false); + + addFlatPreset("Unendliche Grube", Biome.PLAIN, false, Blocks.dirt.getState(), 2, Blocks.cobblestone.getState(), 3, Blocks.dirt.getState(), Blocks.grass.getState()) + .setBiomeReplacer(Blocks.gravel.getState()).enableVillages(); + + addFlatPreset("Wüste", Biome.DESERT, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 3, Blocks.stone.getState(), 52, Blocks.sandstone.getState()) + .enableVillages().enableScattered(); + + addFlatPreset("Sandsteinwelt", Biome.DESERT, false, Blocks.sandstone.getState(), Blocks.bedrock.getState(), 3, Blocks.stone.getState(), + 52, Blocks.sandstone.getState()); addPreset("Leer", "ClearGenerator:1b"); addPreset("Alpha 1.2", "Strongholds:0b,Villages:0b,MineShafts:0b,Scattered:0b,Generator:simple,Replacer:simple,Ravines:0b,SeaLevel:64,AltBlock2:sand"); diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index 27524803..0bd8dc79 100755 --- a/client/src/main/java/client/network/ClientPlayer.java +++ b/client/src/main/java/client/network/ClientPlayer.java @@ -90,6 +90,7 @@ import common.packet.SPacketPlayerAbilities; import common.packet.SPacketTabComplete; import common.packet.SPacketUpdateEntityTags; import common.packet.SPacketAnimation; +import common.packet.SPacketBiome; import common.packet.SPacketBlockBreakAnim; import common.packet.SPacketBlockChange; import common.packet.SPacketCamera; @@ -767,6 +768,14 @@ public class ClientPlayer implements IClientPlayer } } + public void handleBiomes(SPacketBiome packetIn) + { + NetHandler.checkThread(packetIn, this, this.gm, this.world); + ChunkClient chunk = this.world.getChunk(packetIn.getChunkX(), packetIn.getChunkZ()); + chunk.setBiome(packetIn.getPos(), packetIn.getBiome()); + this.world.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15); + } + /** * Updates the block and metadata and generates a blockupdate (and notify the clients) */ diff --git a/client/src/main/java/client/renderer/EntityRenderer.java b/client/src/main/java/client/renderer/EntityRenderer.java index 830b9eff..4663864b 100755 --- a/client/src/main/java/client/renderer/EntityRenderer.java +++ b/client/src/main/java/client/renderer/EntityRenderer.java @@ -13,6 +13,7 @@ import client.Client; import client.renderer.texture.DynamicTexture; import client.renderer.texture.TextureMap; import client.world.WorldClient; +import common.biome.Biome; import common.block.Block; import common.block.Material; import common.effect.Effect; @@ -1139,9 +1140,10 @@ public class EntityRenderer { for (int l = 0; l < k; ++l) { BlockPos blockpos1 = world.getPrecipitationHeight(blockpos.add(this.random.zrange(i) - this.random.zrange(i), 0, this.random.zrange(i) - this.random.zrange(i))); + Biome biomegenbase = world.getBiomeGenForCoords(blockpos1); BlockPos blockpos2 = blockpos1.down(); Block block = world.getState(blockpos2).getBlock(); - float temp = world.getTemperatureC(blockpos1); + float temp = World.ABSOLUTE_ZERO + world.getTempOffset() + biomegenbase.getTemperature(blockpos1); if (blockpos1.getY() <= blockpos.getY() + i && blockpos1.getY() >= blockpos.getY() - i && /* biomegenbase.canRain() && */ temp > 0.0F) { @@ -1233,6 +1235,7 @@ public class EntityRenderer { double rx = (double)this.rainXCoords[idx] * 0.5D; double rz = (double)this.rainZCoords[idx] * 0.5D; pos.set(x, 0, z); + Biome biome = world.getBiomeGenForCoords(pos); int prec = world.getPrecipitationHeight(pos).getY(); int miny = ey - hrange; @@ -1255,7 +1258,7 @@ public class EntityRenderer { if(miny != maxy) { this.random.setSeed((long)(x * x * 3121 + x * 45238971 ^ z * z * 418711 + z * 13761)); pos.set(x, miny, z); - float temp = world.getTemperatureC(pos); + float temp = World.ABSOLUTE_ZERO + world.getTempOffset() + biome.getTemperature(pos); if(temp > 0.0F) { if(mode != (temp >= 194.0f ? 2 : (temp <= 5.0f ? 3 : 0))) { diff --git a/client/src/main/java/client/renderer/RegionRenderCache.java b/client/src/main/java/client/renderer/RegionRenderCache.java index 9d811e2a..b29b7f08 100755 --- a/client/src/main/java/client/renderer/RegionRenderCache.java +++ b/client/src/main/java/client/renderer/RegionRenderCache.java @@ -4,6 +4,7 @@ import java.util.Arrays; import client.world.ChunkClient; import client.world.WorldClient; +import common.biome.Biome; import common.init.Blocks; import common.tileentity.TileEntity; import common.util.BlockPos; @@ -138,6 +139,11 @@ public class RegionRenderCache implements IWorldAccess return i << 20 | j << 4; } + public Biome getBiomeGenForCoords(BlockPos pos) + { + return this.world.getBiomeGenForCoords(pos); + } + private int getLightForExt(LightType p_175629_1_, BlockPos pos) { if (p_175629_1_ == LightType.SKY && !this.world.dimension.hasSkyLight()) diff --git a/client/src/main/java/client/world/ChunkClient.java b/client/src/main/java/client/world/ChunkClient.java index a6420192..8a7bb6c2 100644 --- a/client/src/main/java/client/world/ChunkClient.java +++ b/client/src/main/java/client/world/ChunkClient.java @@ -1,5 +1,6 @@ package client.world; +import common.biome.Biome; import common.block.Block; import common.init.Blocks; import common.tileentity.TileEntity; @@ -10,9 +11,6 @@ import common.world.Chunk; import common.world.World; public class ChunkClient extends Chunk { - private final float[] temperatures = new float[256]; - private final float[] offsets = new float[256]; - public ChunkClient(World world, int x, int z) { super(world, x, z); } @@ -107,11 +105,9 @@ public class ChunkClient extends Chunk { } if(biomes) { - for(int k = 0; k < this.temperatures.length; ++k) { - this.temperatures[k] = Float.intBitsToFloat((int)((data[pos + 3] & 255) << 24 | (data[pos + 2] & 255) << 16 | (data[pos + 1] & 255) << 8 | data[pos] & 255)); - pos += 4; - this.offsets[k] = Float.intBitsToFloat((int)((data[pos + 3] & 255) << 24 | (data[pos + 2] & 255) << 16 | (data[pos + 1] & 255) << 8 | data[pos] & 255)); - pos += 4; + for(int k = 0; k < this.biomes.length; ++k) { + this.biomes[k] = (char)((data[pos + 1] & 255) << 8 | data[pos] & 255); + pos += 2; } } @@ -134,20 +130,12 @@ public class ChunkClient extends Chunk { public void setLoaded() { this.loaded = true; } + + public void setBiome(BlockPos pos, Biome biome) { + this.biomes[((pos.getZ() & 15) << 4 | pos.getX() & 15)] = (char)biome.id; + } public boolean isDummy() { return false; } - - public float getTemperature(BlockPos pos) { - int x = pos.getX() & 15; - int z = pos.getZ() & 15; - return this.temperatures[z << 4 | x]; - } - - public float getOffset(BlockPos pos) { - int x = pos.getX() & 15; - int z = pos.getZ() & 15; - return this.offsets[z << 4 | x]; - } } diff --git a/client/src/main/java/client/world/ChunkEmpty.java b/client/src/main/java/client/world/ChunkEmpty.java index 102c9851..f1be89c2 100755 --- a/client/src/main/java/client/world/ChunkEmpty.java +++ b/client/src/main/java/client/world/ChunkEmpty.java @@ -3,6 +3,7 @@ package client.world; import java.util.List; import java.util.function.Predicate; +import common.biome.Biome; import common.block.Block; import common.block.natural.BlockFire; import common.collect.Lists; @@ -145,13 +146,12 @@ public class ChunkEmpty extends ChunkClient { public void setData(byte[] data, int[] extend, boolean biomes) { } - - public float getTemperature(BlockPos pos) { - return 0.0f; + + public Biome getBiome(BlockPos pos) { + return Biome.DEF_BIOME; } - - public float getOffset(BlockPos pos) { - return 0.0f; + + public void setBiome(BlockPos pos, Biome biome) { } public void resetRelight() { diff --git a/client/src/main/java/client/world/WorldClient.java b/client/src/main/java/client/world/WorldClient.java index adac6884..045dee5e 100755 --- a/client/src/main/java/client/world/WorldClient.java +++ b/client/src/main/java/client/world/WorldClient.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Set; import client.Client; +import common.biome.Biome; import common.collect.Lists; import common.collect.Sets; import common.dimension.Dimension; @@ -410,11 +411,11 @@ public class WorldClient extends AWorldClient return this.getChunk(pos.getX() >> 4, pos.getZ() >> 4); } - protected float getTemperature(BlockPos pos) { - if(!this.isBlockLoaded(pos)) - return 0.0f; - ChunkClient chunk = this.getChunk(pos); - return pos.getY() > 64 ? chunk.getTemperature(pos) - (chunk.getOffset(pos) + (float)pos.getY() - 64.0F) / 15.0f : chunk.getTemperature(pos); + public Biome getBiomeGenForCoords(BlockPos pos) { + if(this.isBlockLoaded(pos)) + return this.getChunk(pos).getBiome(pos); + else + return Biome.DEF_BIOME; } protected boolean isLoaded(int x, int z, boolean allowEmpty) { @@ -768,14 +769,24 @@ public class WorldClient extends AWorldClient public Vec3 getSkyColor(Entity entity, float partial) { BlockPos pos = new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY), ExtMath.floord(entity.posZ)); + Biome biome = this.getBiomeGenForCoords(pos); Vec3 vec; if(this.dimension.isExterminated()) vec = new Vec3(0x101010); else vec = new Vec3(this.dimension.getSkyColor()); if(this.dimension.hasDaylight()) { - float mult = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F); - vec = new Vec3(vec.xCoord * mult, vec.yCoord * mult, vec.zCoord * mult); + float mult = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partial)) * 2.0F + 0.5F, + 0.0F, 1.0F); + if(this.dimension.getSkyColor() == 0xffffffff) { + float temp = ExtMath.clampf(((biome.getTemperature(pos) + 14.0f) / 40.0f + 0.15f) / 3.0F, + -1.0F, 1.0F); + Vec3 sky = new Vec3(hsvToRGB(0.62222224F - temp * 0.05F, 0.5F + temp * 0.1F, 1.0F)); + vec = new Vec3(vec.xCoord * sky.xCoord * mult, vec.yCoord * sky.yCoord * mult, vec.zCoord * sky.zCoord * mult); + } + else { + vec = new Vec3(vec.xCoord * mult, vec.yCoord * mult, vec.zCoord * mult); + } } float r = (float)vec.xCoord; float g = (float)vec.yCoord; diff --git a/common/src/main/java/common/biome/Biome.java b/common/src/main/java/common/biome/Biome.java index bb994953..d16d9ad5 100644 --- a/common/src/main/java/common/biome/Biome.java +++ b/common/src/main/java/common/biome/Biome.java @@ -1,27 +1,194 @@ package common.biome; -public final class Biome { +import java.util.List; +import java.util.Map; + +import common.collect.Lists; +import common.collect.Maps; +import common.log.Log; +import common.rng.PerlinGen; +import common.rng.Random; +import common.util.BlockPos; +import common.util.Displayable; +import common.util.Identifyable; + +public enum Biome implements Identifyable, Displayable { + NONE("none", "", 0x000000), + PLAIN("plain", "Ebene", 0x8db360, 12.0f, 40.0f), + DESERT("desert", "Wüste", 0xfa9418, 60.0f, 0.0f), + HILLS("hills", "Bergland", 0x606060, -12.0f, 30.0f), + FOREST("forest", "Wald", 0x056621, 8.0f, 80.0f), + TAIGA("taiga", "Taiga", 0x0b6659, -10.0f, 80.0f), + SWAMP("swamp", "Sumpf", 0x07f9b2, 12.0f, 90.0f), + RIVER("river", "Fluss", 0x0000ff), + EXTERMINATED("exterminated", "Ausgelöscht", 0x000000, 150.0f, 0.0f), + SPACE("space", "Leere des Weltraums", 0x000000, 0.0f, 0.0f), + ICE_SEA("ice_sea", "Vereister See", 0x9090a0, -20.0f), + ICE_RIVER("ice_river", "Vereister Fluss", 0xa0a0ff, -20.0f), + ICE("ice", "Eisebene", 0xffffff, -20.0f), + ICE_HILLS("ice_hills", "Vereistes Bergland", 0xa0a0a0, -20.0f), + MUSHROOM("mushroom", "Pilzland", 0xff00ff, 16.0f, 100.0f), + BLACKENED("blackened", "Schwarz", 0x000000, 0.0f, 0.0f), + BEACH("beach", "Strand", 0xfade55, 12.0f, 40.0f), + DESERT_HILLS("desert_hills", "Wüsten-Bergland", 0xd25f12, 60.0f, 0.0f), + FOREST_HILLS("forest_hills", "Wald-Bergland", 0x22551c, 8.0f, 80.0f), + TAIGA_HILLS("taiga_hills", "Taiga-Bergland", 0x163933, -10.0f, 80.0f), + HILLS_EDGE("hills_edge", "Bergland-Grenze", 0x72789a, -12.0f, 30.0f), + TROPIC("tropic", "Urwald", 0x537b09, 18.0f, 90.0f), + TROPIC_HILLS("tropic_hills", "Urwald-Bergland", 0x2c4205, 18.0f, 90.0f), + TROPIC_EDGE("tropic_edge", "Urwald-Grenze", 0x628b17, 18.0f, 80.0f), + SEA("sea", "See", 0x000070), + STONE_BEACH("stone_beach", "Steinstrand", 0xa2a284, -12.0f, 30.0f), + ICE_BEACH("ice_beach", "Vereister Strand", 0xfaf0c0, -18.0f, 30.0f), + BIRCH_FOREST("birch_forest", "Birkenwald", 0x307444, 4.0f, 60.0f), + BIRCH_HILLS("birch_hills", "Birken-Bergland", 0x1f5f32, 4.0f, 60.0f), + DARK_FOREST("dark_forest", "Dichter Wald", 0x40511a, 8.0f, 80.0f), + ICE_TAIGA("ice_taiga", "Vereiste Taiga", 0x31554a, -40.0f, 40.0f), + ICE_TAIGA_HILLS("ice_taiga_hills", "Vereistes Taiga-Bergland", 0x243f36, -40.0f, 40.0f), + LARGE_TAIGA("large_taiga", "Hohe Taiga", 0x596651, -8.0f, 80.0f), + LARGE_TAIGA_HILLS("large_taiga_hills", "Hohes Taiga-Bergland", 0x454f3e, -8.0f, 80.0f), + LARGE_HILLS("large_hills", "Hohes Bergland", 0x507050, -12.0f, 30.0f), + SAVANNA("savanna", "Savanne", 0xbdb25f, 28.0f, 0.0f), + SAVANNA_PLATEAU("savanna_plateau", "Savannen-Plateau", 0xa79d64, 20.0f, 0.0f), + MESA("mesa", "Mesa", 0xd94515, 0.0f, 0.0f), + MESA_FOREST("mesa_forest", "Mesa-Wald", 0xb09765, 0.0f, 0.0f), + MESA_PLATEAU("mesa_plateau", "Mesa-Plateau", 0xca8c65, 0.0f, 0.0f), + SNOW("snow", "Eisland", 0xffffff, 0.0f, 100.0f), + TIAN("tian", "Tian", 0x808080, 0.0f, 80.0f), + ELVEN_FOREST("elven_forest", "Elbenwald", 0x059821, 8.0f, 90.0f), + UPPER_HELL("upper_hell", "Übergang in die Hölle", 0xff0000, 0.0f, 0.0f), + LOWER_HELL("lower_hell", "Abgrund der Hölle", 0xff0000, 0.0f, 0.0f), + HELL_HILLS("hell_hills", "Bergland der Hölle", 0xff0000, 0.0f, 0.0f), + SOUL_PLAINS("soul_plains", "Seelenland", 0xff0000, 0.0f, 0.0f), + ASH("ash", "Verbrannt", 0xff0000, 0.0f, 0.0f), + MOON("moon", "Mondoberfläche", 0xa0a0a0, 0.0f, 0.0f), + CHAOS("chaos", "Chaos", 0xff00ff), + + DESERT_MOD("desert_mod", "Wüste M", 0xfa9418, 60.0f, 0.0f), + HILLS_MOD("hills_mod", "Bergland M", 0x606060, -12.0f, 30.0f), + FLOWER_FOREST("flower_forest", "Blumenwald", 0x6a7425, 8.0f, 80.0f), + TAIGA_MOD("taiga_mod", "Taiga M", 0x0b6659, -10.0f, 80.0f), + SWAMP_MOD("swamp_mod", "Sumpf M", 0x07f9b2, 12.0f, 90.0f), + ICE_SPIKES("ice_spikes", "Eisebene mit Spitzen", 0xd2ffff, -20.0f), + TROPIC_MOD("tropic_mod", "Urwald M", 0x537b09, 18.0f, 90.0f), + TROPIC_EDGE_MOD("propic_edge_mod", "Urwald-Grenze M", 0x628b17, 18.0f, 80.0f), + BIRCH_FOREST_MOD("birch_forest_mod", "Birkenwald M", 0x307444, 4.0f, 60.0f), + BIRCH_HILLS_MOD("birch_hills_mod", "Birken-Bergland M", 0x1f5f32, 4.0f, 60.0f), + DARK_FOREST_MOD("dark_forest_mod", "Dichter Wald M", 0x40511a, 8.0f, 80.0f), + ICE_TAIGA_MOD("ice_taiga_mod", "Vereiste Taiga M", 0x31554a, -40.0f, 40.0f), + SPRUCE_TAIGA("spruce_taiga", "Fichtentaiga", 0x596651, -10.0f, 80.0f), + REDWOOD_TAIGA("redwood_taiga", "Mammutbaumtaiga", 0x596651, -10.0f, 80.0f), + LARGE_HILLS_MOD("large_hills_mod", "Hohes Bergland M", 0x507050, -12.0f, 30.0f), + SAVANNA_MOD("savanna_mod", "Savanne M", 0xbdb25f, 24.0f, 0.0f), + SAVANNA_PLATEAU_MOD("savanna_plateau_mod", "Savannen-Plateau M", 0xa79d64, 20.0f, 0.0f), + MESA_PEAK("mesa_peak", "Mesa-Spitze", 0xd94515, 0.0f, 0.0f), + MESA_FOREST_MOD("mesa_forest_mod", "Mesa-Wald M", 0xb09765, 0.0f, 0.0f), + MESA_PLATEAU_MOD("mesa_plateau_mod", "Mesa-Plateau M", 0xca8c65, 0.0f, 0.0f); + + public static final Biome DEF_BIOME = FOREST; + private static final PerlinGen TEMP_NOISE = new PerlinGen(new Random(836430928262265276L), 1); + private static final Biome[] BIOMES = new Biome[256]; + private static final Map LOOKUP = Maps.newTreeMap(); + + public final int id; + public final String name; + public final String display; + public final int color; public final float temperature; public final float humidity; - public final float depth; - public final float scale; - public final float factor; - - public int id; - - public Biome(float temperature, float humidity, float depth, float scale) { - this.temperature = temperature; - this.humidity = humidity; - this.depth = depth; - this.scale = scale; - this.factor = Math.min(humidity * 0.01f * ((temperature + 14.0f) / 40.0f + 0.15f), 1.0f); - } - - public Biome(float temperature, float humidity, Scaling scaling) { - this(temperature, humidity, scaling.depth, scaling.scale); + + static { + for(Biome biome : values()) { + BIOMES[biome.id] = biome; + if(LOOKUP.containsKey(biome.name)) + throw new IllegalStateException("Biom \"" + biome.name + "\" ist als ID " + LOOKUP.get(biome.name).id + " und " + biome.id + " definiert"); + LOOKUP.put(biome.name, biome); + } } - public Biome(float temperature, float humidity) { - this(temperature, humidity, Scaling.VARYING_LOW); + public static Biome getBiome(int id) + { + if (id >= 0 && id < BIOMES.length) + { + return BIOMES[id]; + } + else + { + Log.TICK.warn("Biom-ID ist nicht im Bereich: " + id + ", verwende " + DEF_BIOME.id + " (" + DEF_BIOME.name + ")"); + return DEF_BIOME; + } } + + public static Biome getBiomeDef(int id) + { + if (id >= 0 && id < BIOMES.length) + { + Biome biome = BIOMES[id]; + return biome == null ? DEF_BIOME : biome; + } + else + { + Log.TICK.warn("Biom-ID ist nicht im Bereich: " + id + ", verwende " + DEF_BIOME.id + " (" + DEF_BIOME.name + ")"); + return DEF_BIOME; + } + } + + public static List getBiomeNames() { + return Lists.newArrayList(LOOKUP.keySet()); + } + + public static Biome findByName(String name) { + Biome biome = LOOKUP.get(name.toLowerCase().replace(" ", "").replace("_", "")); + if(biome == null) { + int z; + try { + z = Integer.parseInt(name); + } + catch(NumberFormatException e) { + return DEF_BIOME; + } + return z < 0 || z >= BIOMES.length || BIOMES[z] == null ? DEF_BIOME : BIOMES[z]; + } + return biome; + } + + private Biome(String name, String display, int color, float temperature, float humidity) { + this.id = this.ordinal(); + this.name = name; + this.display = display; + this.temperature = temperature; + this.humidity = humidity; + this.color = color; + } + + private Biome(String name, String display, int color, float temperature) { + this(name, display, color, temperature, 50.0f); + } + + private Biome(String name, String display, int color) { + this(name, display, color, 0.0f, 50.0f); + } + + public final float getTemperature(BlockPos pos) { + if(pos.getY() > 64) { + float f = (float)(TEMP_NOISE.generate((double)pos.getX() * 1.0D / 8.0D, (double)pos.getZ() * 1.0D / 8.0D) * 4.0D); + return this.temperature - (f + (float)pos.getY() - 64.0F) / 15.0f; + } + return this.temperature; + } + + public float getFactor() { + float f = this.humidity * 0.01f * ((this.temperature + 14.0f) / 40.0f + 0.15f); + return f > 1.0f ? 1.0f : f; + } + + // skycolor = ((temp + 14) / 40 + 0.15) / 3 + + public String getName() { + return this.name; + } + + public String getDisplay() { + return this.display; + } } diff --git a/common/src/main/java/common/biome/IBiome.java b/common/src/main/java/common/biome/IBiome.java new file mode 100644 index 00000000..31fd8184 --- /dev/null +++ b/common/src/main/java/common/biome/IBiome.java @@ -0,0 +1,47 @@ +package common.biome; + +import common.init.BlockRegistry; +import common.rng.Random; +import common.util.BlockPos; +import common.world.AWorldServer; +import common.world.State; + +public interface IBiome { + public static abstract class BiomeProvider { + private static BiomeProvider provider = new BiomeProvider() { + public IBiome getBiome(Biome base) { + return new IBiome() { + public State getFiller() { + return BlockRegistry.byName("air").getState(); + } + public State getTop() { + return BlockRegistry.byName("air").getState(); + } + public void growGrass(AWorldServer worldIn, BlockPos pos, State state, Random rand) { + } + public boolean generateBigMushroom(AWorldServer worldIn, BlockPos pos, State state, Random rand) { + return false; + } + public void generateTree(AWorldServer worldIn, BlockPos pos, State state, Random rand) { + } + }; + } + }; + + public abstract IBiome getBiome(Biome base); + } + + public static void setProvider(BiomeProvider provider) { + BiomeProvider.provider = provider; + } + + public static IBiome getBiome(Biome base) { + return BiomeProvider.provider.getBiome(base); + } + + void growGrass(AWorldServer worldIn, BlockPos pos, State state, Random rand); + boolean generateBigMushroom(AWorldServer worldIn, BlockPos pos, State state, Random rand); + void generateTree(AWorldServer worldIn, BlockPos pos, State state, Random rand); + State getFiller(); + State getTop(); +} \ No newline at end of file diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index 0fab7ccc..07159065 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -15,6 +15,7 @@ import java.util.function.Function; import common.attributes.Attribute; import common.attributes.UsageSlot; +import common.biome.Biome; import common.block.artificial.BlockSlab; import common.block.natural.BlockSnow; import common.collect.ImmutableList; @@ -45,6 +46,7 @@ import common.rng.Random; import common.tileentity.TileEntity; import common.util.BlockPos; import common.util.BoundingBox; +import common.util.ExtMath; import common.util.Facing; import common.util.HitPosition; import common.util.Vec3; diff --git a/common/src/main/java/common/block/foliage/BlockBlackenedSoil.java b/common/src/main/java/common/block/foliage/BlockBlackenedSoil.java index 75859faa..aded0dd8 100644 --- a/common/src/main/java/common/block/foliage/BlockBlackenedSoil.java +++ b/common/src/main/java/common/block/foliage/BlockBlackenedSoil.java @@ -1,5 +1,6 @@ package common.block.foliage; +import common.biome.Biome; import common.block.Block; import common.block.Material; import common.init.Blocks; @@ -40,6 +41,7 @@ public class BlockBlackenedSoil extends Block if ((iblockstate.getBlock() == Blocks.dirt || iblockstate.getBlock() == Blocks.grass || iblockstate.getBlock() == Blocks.swamp || iblockstate.getBlock() == Blocks.blackened_dirt) && worldIn.getLightFromNeighbors(blockpos.up()) >= 2 && block.getLightOpacity() <= 6) { worldIn.setState(blockpos, Blocks.blackened_soil.getState()); + worldIn.setBiome(blockpos, Biome.BLACKENED); } } } diff --git a/common/src/main/java/common/block/foliage/BlockDoublePlant.java b/common/src/main/java/common/block/foliage/BlockDoublePlant.java index e6585fbd..9e47b265 100755 --- a/common/src/main/java/common/block/foliage/BlockDoublePlant.java +++ b/common/src/main/java/common/block/foliage/BlockDoublePlant.java @@ -1,5 +1,6 @@ package common.block.foliage; +import common.biome.Biome; import common.block.Block; import common.block.Material; import common.block.SoundType; diff --git a/common/src/main/java/common/block/foliage/BlockFlower.java b/common/src/main/java/common/block/foliage/BlockFlower.java index c218e609..10a12c49 100755 --- a/common/src/main/java/common/block/foliage/BlockFlower.java +++ b/common/src/main/java/common/block/foliage/BlockFlower.java @@ -69,7 +69,7 @@ public class BlockFlower extends BlockBush ORANGE_TULIP("orange_tulip", "Orange Tulpe"), WHITE_TULIP("white_tulip", "Weiße Tulpe"), PINK_TULIP("pink_tulip", "Rosa Tulpe"), - DAISY("daisy", "Margerite"), + OXEYE_DAISY("daisy", "Margerite"), BLACK_LOTUS("black_lotus", "Schwarzer Lotus"); private final String name; diff --git a/common/src/main/java/common/block/foliage/BlockGrass.java b/common/src/main/java/common/block/foliage/BlockGrass.java index 84e3e7e0..c08174b5 100755 --- a/common/src/main/java/common/block/foliage/BlockGrass.java +++ b/common/src/main/java/common/block/foliage/BlockGrass.java @@ -1,5 +1,7 @@ package common.block.foliage; +import common.biome.Biome; +import common.biome.IBiome; import common.block.Block; import common.block.Material; import common.init.Blocks; @@ -84,7 +86,7 @@ public class BlockGrass extends Block implements IGrowable public void grow(AWorldServer worldIn, Random rand, BlockPos pos, State state) { - worldIn.growGrass(pos, state, rand); + IBiome.getBiome(worldIn.getBiomeGenForCoords(pos)).growGrass(worldIn, pos, state, rand); } protected Property[] getProperties() diff --git a/common/src/main/java/common/block/foliage/BlockLeaves.java b/common/src/main/java/common/block/foliage/BlockLeaves.java index 12b3ec24..54a377b5 100755 --- a/common/src/main/java/common/block/foliage/BlockLeaves.java +++ b/common/src/main/java/common/block/foliage/BlockLeaves.java @@ -2,6 +2,7 @@ package common.block.foliage; import java.util.List; +import common.biome.Biome; import common.block.Block; import common.block.Material; import common.block.SoundType; @@ -15,6 +16,8 @@ import common.item.CheatTab; import common.item.Item; import common.item.ItemStack; import common.item.tool.ItemShears; +import common.model.Model; +import common.model.ModelProvider; import common.properties.Property; import common.properties.PropertyBool; import common.rng.Random; @@ -22,6 +25,7 @@ import common.tileentity.TileEntity; import common.util.BlockPos; import common.util.Facing; import common.vars.Vars; +import common.world.IWorldAccess; import common.world.State; import common.world.World; import common.world.AWorldServer; diff --git a/common/src/main/java/common/block/foliage/BlockMushroom.java b/common/src/main/java/common/block/foliage/BlockMushroom.java index 87e4f250..dce8c08c 100755 --- a/common/src/main/java/common/block/foliage/BlockMushroom.java +++ b/common/src/main/java/common/block/foliage/BlockMushroom.java @@ -1,5 +1,6 @@ package common.block.foliage; +import common.biome.IBiome; import common.block.Block; import common.init.Blocks; import common.model.Model; @@ -101,7 +102,7 @@ public class BlockMushroom extends BlockBush implements IGrowable public void grow(AWorldServer worldIn, Random rand, BlockPos pos, State state) { - worldIn.generateBigMushroom(pos, state, rand); + IBiome.getBiome(worldIn.getBiomeGenForCoords(pos)).generateBigMushroom(worldIn, pos, state, rand); } public Model getModel(ModelProvider provider, String name, State state) { diff --git a/common/src/main/java/common/block/foliage/BlockSapling.java b/common/src/main/java/common/block/foliage/BlockSapling.java index 6ff24706..7c1c1407 100755 --- a/common/src/main/java/common/block/foliage/BlockSapling.java +++ b/common/src/main/java/common/block/foliage/BlockSapling.java @@ -2,7 +2,9 @@ package common.block.foliage; import java.util.List; +import common.biome.IBiome; import common.block.Block; +import common.block.foliage.BlockTallGrass.EnumType; import common.collect.Lists; import common.init.Blocks; import common.init.WoodType; @@ -78,7 +80,7 @@ public class BlockSapling extends BlockBush implements IGrowable } else { - worldIn.generateTree(pos, state, rand); + IBiome.getBiome(worldIn.getBiomeGenForCoords(pos)).generateTree(worldIn, pos, state, rand); } } diff --git a/common/src/main/java/common/block/foliage/BlockTallGrass.java b/common/src/main/java/common/block/foliage/BlockTallGrass.java index 3164e8f0..e2d1b422 100755 --- a/common/src/main/java/common/block/foliage/BlockTallGrass.java +++ b/common/src/main/java/common/block/foliage/BlockTallGrass.java @@ -1,5 +1,6 @@ package common.block.foliage; +import common.biome.Biome; import common.block.Block; import common.block.Material; import common.entity.npc.EntityNPC; @@ -16,6 +17,7 @@ import common.tileentity.TileEntity; import common.util.BlockPos; import common.util.Identifyable; import common.vars.Vars; +import common.world.IWorldAccess; import common.world.State; import common.world.World; import common.world.AWorldServer; diff --git a/common/src/main/java/common/block/foliage/BlockVine.java b/common/src/main/java/common/block/foliage/BlockVine.java index fc7f7e76..1d8a6e90 100755 --- a/common/src/main/java/common/block/foliage/BlockVine.java +++ b/common/src/main/java/common/block/foliage/BlockVine.java @@ -1,10 +1,12 @@ package common.block.foliage; +import common.biome.Biome; import common.block.Block; import common.block.Material; import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; import common.init.Blocks; +import common.init.Items; import common.item.CheatTab; import common.item.Item; import common.item.ItemStack; diff --git a/common/src/main/java/common/block/natural/BlockBlackenedDirt.java b/common/src/main/java/common/block/natural/BlockBlackenedDirt.java index 14177319..4ac6d947 100644 --- a/common/src/main/java/common/block/natural/BlockBlackenedDirt.java +++ b/common/src/main/java/common/block/natural/BlockBlackenedDirt.java @@ -1,5 +1,6 @@ package common.block.natural; +import common.biome.Biome; import common.block.Block; import common.block.Material; import common.init.Blocks; @@ -36,6 +37,7 @@ public class BlockBlackenedDirt extends Block else if ((iblockstate.getBlock() == Blocks.grass || iblockstate.getBlock() == Blocks.swamp) && worldIn.getLightFromNeighbors(blockpos.up()) >= 2 && block.getLightOpacity() <= 6) { worldIn.setState(blockpos, Blocks.blackened_soil.getState()); + worldIn.setBiome(blockpos, Biome.BLACKENED); } else if (iblockstate.getBlock() == Blocks.stone && rand.chance(25)) { diff --git a/common/src/main/java/common/dimension/Dimension.java b/common/src/main/java/common/dimension/Dimension.java index b0c04609..1ffd79d7 100755 --- a/common/src/main/java/common/dimension/Dimension.java +++ b/common/src/main/java/common/dimension/Dimension.java @@ -3,19 +3,15 @@ package common.dimension; import java.util.List; import java.util.Map; import common.biome.Biome; +import common.biome.IBiome; import common.block.foliage.LeavesType; import common.collect.Lists; import common.collect.Maps; -import common.entity.Entity; -import common.entity.animal.EntityChicken; -import common.entity.types.EntityLiving; import common.init.BlockRegistry; import common.init.Blocks; -import common.init.EntityRegistry; import common.init.MetalType; import common.init.UniverseRegistry; import common.rng.Random; -import common.rng.WeightedList; import common.tags.TagObject; import common.util.ExtMath; import common.util.Vec3; @@ -61,7 +57,7 @@ public abstract class Dimension extends Section { public static GeneratorType getByName(String name) { GeneratorType type = LOOKUP.get(name.toLowerCase()); - return type == null ? FLAT : type; + return type == null ? PERLIN : type; } static { @@ -72,7 +68,7 @@ public abstract class Dimension extends Section { } public static enum ReplacerType { - NONE("none"), TERRANIAN("terranian"), MESARIAN("mesarian"), ALT_SIMPLE("alt_simple"), SIMPLE("simple"), ALTERNATE("alternate"), TOPLAYER("toplayer"); + NONE("none"), BIOMES("biomes"), SIMPLE("simple"), ALTERNATE("alternate"), TOPLAYER("toplayer"); private static final Map LOOKUP = Maps.newHashMap(); @@ -88,7 +84,7 @@ public abstract class Dimension extends Section { public static ReplacerType getByName(String name) { ReplacerType type = LOOKUP.get(name.toLowerCase()); - return type == null ? NONE : type; + return type == null ? BIOMES : type; } static { @@ -98,33 +94,6 @@ public abstract class Dimension extends Section { } } - public static enum PopulatorType { - NONE("none"), TERRANIAN("terranian"), MESARIAN("mesarian"); - - private static final Map LOOKUP = Maps.newHashMap(); - - private final String name; - - private PopulatorType(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - public static PopulatorType getByName(String name) { - PopulatorType type = LOOKUP.get(name.toLowerCase()); - return type == null ? NONE : type; - } - - static { - for(PopulatorType type : values()) { - LOOKUP.put(type.name, type); - } - } - } - public static interface ColorGenerator { int getColor(long time); } @@ -211,8 +180,9 @@ public abstract class Dimension extends Section { private GeneratorType generatorType = GeneratorType.FLAT; private ReplacerType replacerType = ReplacerType.NONE; - private PopulatorType populatorType = PopulatorType.NONE; - + + private boolean populated = true; + private boolean mobs = false; // mobgen+spawn private boolean snow = false; // snowgen+update private boolean caves = false; private boolean ravines = false; @@ -231,10 +201,8 @@ public abstract class Dimension extends Section { private int seaRarity = 50; // b.layered private int addRarity = 50; // b.layered private int seaLevel = 0; // g.perlin, g.cavern, g.simple, g.destroyed, lake (r), r.biome, r.simple, r.alternate, ... - private float depth = 0.1f; // g.perlin - private float scale = 0.2f; // g.perlin - private Biome defaultBiome = null; // biomegen + private Biome defaultBiome = Biome.NONE; // biomegen private State filler = Blocks.air.getState(); // caves+rav, liquid, ore, g.perlin, g.cavern, g.island, // g.simple, g.flat (sealevel), r.biome, r.simple, r.alternate, r.toplayer @@ -255,7 +223,6 @@ public abstract class Dimension extends Section { private final List ores = Lists.newArrayList(); private final List lakes = Lists.newArrayList(); private final List liquids = Lists.newArrayList(); - private final WeightedList spawns = new WeightedList(); private long seed = 0L; private boolean exterminated = false; @@ -279,26 +246,6 @@ public abstract class Dimension extends Section { return readState(tag, "Block", def); } - public static void writeType(TagObject tag, String name, Class type) { - if(type != null) - tag.setString(name, EntityRegistry.getEntityString(type)); - } - - public static void writeType(TagObject tag, Class type) { - writeType(tag, "Type", type); - } - - public static Class readType(TagObject tag, String name, Class def) { - if(!tag.hasString(name)) - return def; - Class type = EntityRegistry.getEntityClass(tag.getString(name)); - return type != null && EntityLiving.class.isAssignableFrom(type) ? (Class)type : def; - } - - public static Class readType(TagObject tag, Class def) { - return readType(tag, "Type", def); - } - protected Dimension(boolean custom) { super(custom); } @@ -425,54 +372,9 @@ public abstract class Dimension extends Section { return this; } - public final Dimension setPerlinGen(State filler, State liquid, int seaLevel, float depth, float scale) { - this.depth = depth; // TODO: save - this.scale = scale; - return this.setPerlinGen(filler, liquid, seaLevel); - } - - public final Dimension setTerranianReplacer(State surface, State top, State alt1, State alt2) { - this.surface = surface; - this.top = top; + public final Dimension setBiomeReplacer(State alt1) { this.alt1 = alt1; - this.alt2 = alt2; - this.replacerType = ReplacerType.TERRANIAN; - return this; - } - - public final Dimension setMesarianReplacer(State surface) { - this.surface = surface; - this.replacerType = ReplacerType.MESARIAN; - return this; - } - - public final Dimension setSimpleAltReplacer(State surface, State top, State alt1) { - this.surface = surface; - this.top = top; - this.alt1 = alt1; - this.replacerType = ReplacerType.ALT_SIMPLE; - return this; - } - - public final Dimension setSimpleAltReplacer(State surface, State top) { - this.surface = surface; - this.top = top; - this.replacerType = ReplacerType.ALT_SIMPLE; - return this; - } - - public final Dimension setSimpleAltReplacer(State alt1) { - this.alt1 = alt1; - this.replacerType = ReplacerType.ALT_SIMPLE; - return this; - } - - public final Dimension setSimpleReplacer(State surface, State top, State alt1, State alt2) { - this.surface = surface; - this.top = top; - this.alt1 = alt1; - this.alt2 = alt2; - this.replacerType = ReplacerType.SIMPLE; + this.replacerType = ReplacerType.BIOMES; return this; } @@ -495,11 +397,6 @@ public abstract class Dimension extends Section { this.replacerType = ReplacerType.TOPLAYER; return this; } - - public final Dimension setPopulator(PopulatorType type) { - this.populatorType = type; - return this; - } public final Dimension setBiomeGen(Biome mainBiome, boolean semiFixed, int biomeSize, int riverSize, int snowRarity, int seaRarity) { return this.setBiomeGen(mainBiome, semiFixed, biomeSize, riverSize, snowRarity, seaRarity, 1); @@ -507,7 +404,10 @@ public abstract class Dimension extends Section { public final Dimension setBiomeGen(Biome mainBiome, boolean semiFixed, int biomeSize, int riverSize, int snowRarity, int seaRarity, int addRarity, Biome ... add) { - this.defaultBiome = mainBiome; //TODO: save + this.defaultBiome = mainBiome; + IBiome biome = IBiome.getBiome(mainBiome); + this.top = biome.getFiller(); + this.surface = biome.getTop(); this.semiFixed = semiFixed; this.biomeSize = biomeSize; this.riverSize = riverSize; @@ -537,6 +437,19 @@ public abstract class Dimension extends Section { this.hotBiomes = biomes; return this; } + + public final Dimension setBiome(Biome value) { + this.defaultBiome = value; + IBiome biome = IBiome.getBiome(value); + this.top = biome.getFiller(); + this.surface = biome.getTop(); + return this; + } + + public final Dimension enableMobs() { + this.mobs = true; + return this; + } public final Dimension enableSnow() { this.snow = true; @@ -631,11 +544,6 @@ public abstract class Dimension extends Section { return this; } - public final Dimension addSpawn(Class type, int weight, int min, int max) { - this.spawns.add(new RngSpawn(type, weight, min, max)); - return this; - } - protected final Dimension setPhysics(int size, long orbitalPeriod, long rotationPeriod, float orbitOffset, float gravity, float temperature, @@ -926,6 +834,10 @@ public abstract class Dimension extends Section { return this.top; } + public final State getAltFiller1() { + return this.alt1; + } + public final State getLiquid() { return this.liquid; } @@ -934,6 +846,10 @@ public abstract class Dimension extends Section { return this.defaultLeaves; } + public final boolean hasMobs() { + return this.mobs; + } + public final boolean hasSnow() { return this.snow; } @@ -965,13 +881,9 @@ public abstract class Dimension extends Section { public final boolean hasFortresses() { return this.useFortresses; } - - public float getDepth() { - return this.depth; - } - - public float getScale() { - return this.scale; + + public final boolean hasPopulator() { + return this.populated; } @@ -1111,7 +1023,7 @@ public abstract class Dimension extends Section { this.noiseGen.biomeScaleOffset = tag.getFloat("BScaleOffset"); this.generatorType = GeneratorType.getByName(tag.getString("Generator")); this.replacerType = ReplacerType.getByName(tag.getString("Replacer")); - this.populatorType = PopulatorType.getByName(tag.getString("Populator")); + this.mobs = tag.getBool("MobGen"); this.snow = tag.getBool("SnowGen"); this.ceiling = tag.getBool("Ceiling"); this.caves = tag.getBool("Caves"); @@ -1128,7 +1040,7 @@ public abstract class Dimension extends Section { this.snowRarity = tag.getInt("SnowRarity"); this.seaRarity = tag.getInt("SeaRarity"); this.addRarity = tag.getInt("AddRarity"); -// this.defaultBiome = Biome.findByName(tag.getString("DefaultBiome")); + this.defaultBiome = Biome.findByName(tag.getString("DefaultBiome")); this.semiFixed = tag.getBool("SemiFixed"); this.defaultWeather = Weather.getByName(tag.getString("DefaultWeather")); this.defaultWeather = this.weather = this.defaultWeather == null ? Weather.CLEAR : this.defaultWeather; @@ -1149,81 +1061,81 @@ public abstract class Dimension extends Section { else { this.layers = null; } -// if(tag.hasStringArray("AddBiomes")) { -// String[] list = tag.getStringArray("AddBiomes"); -// if(list.length == 0) { -// this.addBiomes = null; -// } -// else { -// this.addBiomes = new Biome[list.length]; -// for(int z = 0; z < this.addBiomes.length; z++) { -// this.addBiomes[z] = Biome.findByName(list[z]); -// } -// } -// } -// else { -// this.addBiomes = null; -// } -// if(tag.hasStringArray("FrostBiomes")) { -// String[] list = tag.getStringArray("FrostBiomes"); -// if(list.length == 0) { -// this.frostBiomes = null; -// } -// else { -// this.frostBiomes = new Biome[list.length]; -// for(int z = 0; z < this.frostBiomes.length; z++) { -// this.frostBiomes[z] = Biome.findByName(list[z]); -// } -// } -// } -// else { -// this.frostBiomes = null; -// } -// if(tag.hasStringArray("ColdBiomes")) { -// String[] list = tag.getStringArray("ColdBiomes"); -// if(list.length == 0) { -// this.coldBiomes = null; -// } -// else { -// this.coldBiomes = new Biome[list.length]; -// for(int z = 0; z < this.coldBiomes.length; z++) { -// this.coldBiomes[z] = Biome.findByName(list[z]); -// } -// } -// } -// else { -// this.coldBiomes = null; -// } -// if(tag.hasStringArray("MediumBiomes")) { -// String[] list = tag.getStringArray("MediumBiomes"); -// if(list.length == 0) { -// this.mediumBiomes = null; -// } -// else { -// this.mediumBiomes = new Biome[list.length]; -// for(int z = 0; z < this.mediumBiomes.length; z++) { -// this.mediumBiomes[z] = Biome.findByName(list[z]); -// } -// } -// } -// else { -// this.mediumBiomes = null; -// } -// if(tag.hasStringArray("HotBiomes")) { -// String[] list = tag.getStringArray("HotBiomes"); -// if(list.length == 0) { -// this.hotBiomes = null; -// } -// else { -// this.hotBiomes = new Biome[list.length]; -// for(int z = 0; z < this.hotBiomes.length; z++) { -// this.hotBiomes[z] = Biome.findByName(list[z]); -// } -// } -// } -// else { -// this.hotBiomes = null; -// } + if(tag.hasStringArray("AddBiomes")) { + String[] list = tag.getStringArray("AddBiomes"); + if(list.length == 0) { + this.addBiomes = null; + } + else { + this.addBiomes = new Biome[list.length]; + for(int z = 0; z < this.addBiomes.length; z++) { + this.addBiomes[z] = Biome.findByName(list[z]); + } + } + } + else { + this.addBiomes = null; + } + if(tag.hasStringArray("FrostBiomes")) { + String[] list = tag.getStringArray("FrostBiomes"); + if(list.length == 0) { + this.frostBiomes = null; + } + else { + this.frostBiomes = new Biome[list.length]; + for(int z = 0; z < this.frostBiomes.length; z++) { + this.frostBiomes[z] = Biome.findByName(list[z]); + } + } + } + else { + this.frostBiomes = null; + } + if(tag.hasStringArray("ColdBiomes")) { + String[] list = tag.getStringArray("ColdBiomes"); + if(list.length == 0) { + this.coldBiomes = null; + } + else { + this.coldBiomes = new Biome[list.length]; + for(int z = 0; z < this.coldBiomes.length; z++) { + this.coldBiomes[z] = Biome.findByName(list[z]); + } + } + } + else { + this.coldBiomes = null; + } + if(tag.hasStringArray("MediumBiomes")) { + String[] list = tag.getStringArray("MediumBiomes"); + if(list.length == 0) { + this.mediumBiomes = null; + } + else { + this.mediumBiomes = new Biome[list.length]; + for(int z = 0; z < this.mediumBiomes.length; z++) { + this.mediumBiomes[z] = Biome.findByName(list[z]); + } + } + } + else { + this.mediumBiomes = null; + } + if(tag.hasStringArray("HotBiomes")) { + String[] list = tag.getStringArray("HotBiomes"); + if(list.length == 0) { + this.hotBiomes = null; + } + else { + this.hotBiomes = new Biome[list.length]; + for(int z = 0; z < this.hotBiomes.length; z++) { + this.hotBiomes[z] = Biome.findByName(list[z]); + } + } + } + else { + this.hotBiomes = null; + } this.ores.clear(); if(tag.hasList("Ores")) { List list = tag.getList("Ores"); @@ -1255,16 +1167,7 @@ public abstract class Dimension extends Section { gen.getInt("Chance"), gen.getInt("Min"), gen.getInt("Max"), gen.getBool("Lower"))); } } - this.spawns.clear(); - if(tag.hasList("Spawns")) { - List list = tag.getList("Spawns"); - for(int z = 0; z < list.size(); z++) { - TagObject gen = list.get(z); - this.spawns.add(new RngSpawn( - readType(gen, EntityChicken.class), - gen.getInt("Weight"), gen.getInt("Min"), gen.getInt("Max"))); - } - } + this.populated = !tag.hasBool("NoPopulation") || !tag.getBool("NoPopulation"); this.denseFog = tag.getBool("DenseFog"); this.brightness = tag.getInt("Brightness"); this.skyColor = tag.getInt("SkyColor"); @@ -1331,7 +1234,7 @@ public abstract class Dimension extends Section { tag.setFloat("BScaleOffset", this.noiseGen.biomeScaleOffset); tag.setString("Generator", this.generatorType.getName()); tag.setString("Replacer", this.replacerType.getName()); - tag.setString("Populator", this.populatorType.getName()); + tag.setBool("MobGen", this.mobs); tag.setBool("SnowGen", this.snow); tag.setBool("Ceiling", this.ceiling); tag.setBool("Caves", this.caves); @@ -1348,7 +1251,7 @@ public abstract class Dimension extends Section { tag.setInt("SnowRarity", this.snowRarity); tag.setInt("SeaRarity", this.seaRarity); tag.setInt("AddRarity", this.addRarity); -// tag.setString("DefaultBiome", this.defaultBiome.getName()); + tag.setString("DefaultBiome", this.defaultBiome.name.toLowerCase()); tag.setBool("SemiFixed", this.semiFixed); tag.setString("DefaultWeather", this.defaultWeather.getName()); tag.setString("DefaultLeaves", this.defaultLeaves.getName()); @@ -1364,41 +1267,41 @@ public abstract class Dimension extends Section { } tag.setStringArray("Layers", list); } -// if(this.addBiomes != null) { -// String[] list = new String[this.addBiomes.length]; -// for(int z = 0; z < this.addBiomes.length; z++) { -// list[z] = this.addBiomes[z].getName(); -// } -// tag.setStringArray("AddBiomes", list); -// } -// if(this.frostBiomes != null) { -// String[] list = new String[this.frostBiomes.length]; -// for(int z = 0; z < this.frostBiomes.length; z++) { -// list[z] = this.frostBiomes[z].getName(); -// } -// tag.setStringArray("FrostBiomes", list); -// } -// if(this.coldBiomes != null) { -// String[] list = new String[this.coldBiomes.length]; -// for(int z = 0; z < this.coldBiomes.length; z++) { -// list[z] = this.coldBiomes[z].getName(); -// } -// tag.setStringArray("ColdBiomes", list); -// } -// if(this.mediumBiomes != null) { -// String[] list = new String[this.mediumBiomes.length]; -// for(int z = 0; z < this.mediumBiomes.length; z++) { -// list[z] = this.mediumBiomes[z].getName(); -// } -// tag.setStringArray("MediumBiomes", list); -// } -// if(this.hotBiomes != null) { -// String[] list = new String[this.hotBiomes.length]; -// for(int z = 0; z < this.hotBiomes.length; z++) { -// list[z] = this.hotBiomes[z].getName(); -// } -// tag.setStringArray("HotBiomes", list); -// } + if(this.addBiomes != null) { + String[] list = new String[this.addBiomes.length]; + for(int z = 0; z < this.addBiomes.length; z++) { + list[z] = this.addBiomes[z].name.toLowerCase(); + } + tag.setStringArray("AddBiomes", list); + } + if(this.frostBiomes != null) { + String[] list = new String[this.frostBiomes.length]; + for(int z = 0; z < this.frostBiomes.length; z++) { + list[z] = this.frostBiomes[z].name.toLowerCase(); + } + tag.setStringArray("FrostBiomes", list); + } + if(this.coldBiomes != null) { + String[] list = new String[this.coldBiomes.length]; + for(int z = 0; z < this.coldBiomes.length; z++) { + list[z] = this.coldBiomes[z].name.toLowerCase(); + } + tag.setStringArray("ColdBiomes", list); + } + if(this.mediumBiomes != null) { + String[] list = new String[this.mediumBiomes.length]; + for(int z = 0; z < this.mediumBiomes.length; z++) { + list[z] = this.mediumBiomes[z].name.toLowerCase(); + } + tag.setStringArray("MediumBiomes", list); + } + if(this.hotBiomes != null) { + String[] list = new String[this.hotBiomes.length]; + for(int z = 0; z < this.hotBiomes.length; z++) { + list[z] = this.hotBiomes[z].name.toLowerCase(); + } + tag.setStringArray("HotBiomes", list); + } if(!this.ores.isEmpty()) { List list = Lists.newArrayList(); for(Ore gen : this.ores) { @@ -1442,18 +1345,8 @@ public abstract class Dimension extends Section { } tag.setList("Liquids", list); } - if(!this.spawns.isEmpty()) { - List list = Lists.newArrayList(); - for(RngSpawn gen : this.spawns) { - TagObject spawn = new TagObject(); - writeType(spawn, gen.type); - spawn.setInt("Weight", gen.weight); - spawn.setInt("Min", gen.min); - spawn.setInt("Max", gen.max); - list.add(spawn); - } - tag.setList("Spawns", list); - } + if(!this.populated) + tag.setBool("NoPopulation", true); tag.setBool("DenseFog", this.denseFog); tag.setInt("Brightness", this.brightness); tag.setInt("SkyColor", this.skyColor); @@ -1566,10 +1459,6 @@ public abstract class Dimension extends Section { return this.replacerType; } - public PopulatorType getPopulatorType() { - return this.populatorType; - } - public State getAlt1() { return this.alt1; } @@ -1613,8 +1502,4 @@ public abstract class Dimension extends Section { public List getLiquids() { return this.liquids; } - - public WeightedList getSpawns() { - return this.spawns; - } } diff --git a/common/src/main/java/common/dimension/Moon.java b/common/src/main/java/common/dimension/Moon.java index 4c8301aa..4556b5ce 100755 --- a/common/src/main/java/common/dimension/Moon.java +++ b/common/src/main/java/common/dimension/Moon.java @@ -1,5 +1,6 @@ package common.dimension; +import common.biome.Biome; import common.block.Block; import common.init.Blocks; import common.init.UniverseRegistry; @@ -9,20 +10,21 @@ public final class Moon extends Dimension { super(true); } - public Moon(int sky, int fog, int radius, long orbit, long rotation, float gravity, float temperature, int brightness, Block surface, Block liquid, float depth, float scale) { + public Moon(int sky, int fog, int radius, long orbit, long rotation, float gravity, float temperature, int brightness, Block surface, Block liquid) { super(false); this.setPhysics(Planet.radiusToSize(Math.min(radius, 26000000)), orbit, rotation, 0.0f, gravity, temperature, brightness); this.setStarBrightness(0.75f).setDeepStarBrightness(0.75f); this.setSkyColor(sky).setFogColor(fog); - this.setPerlinGen(surface.getState(), liquid.getState(), 63, depth, scale); + this.setPerlinGen(surface.getState(), liquid.getState(), 63); + this.setBiome(Biome.MOON); } - public Moon(int color, int radius, long orbit, long rotation, float gravity, float temperature, Block surface, Block liquid, float depth, float scale) { - this(color, color, radius, orbit, rotation, gravity, temperature, 8, surface, liquid, depth, scale); + public Moon(int color, int radius, long orbit, long rotation, float gravity, float temperature, Block surface, Block liquid) { + this(color, color, radius, orbit, rotation, gravity, temperature, 8, surface, liquid); } public Moon(int radius, long orbit, long rotation, float gravity, float temperature) { - this(0x333333, radius, orbit, rotation, gravity, temperature, Blocks.moon_rock, Blocks.air, 0.125F, 0.05F); + this(0x333333, radius, orbit, rotation, gravity, temperature, Blocks.moon_rock, Blocks.air); } public Moon(int radius, long orbitRotation, float gravity, float temperature) { diff --git a/common/src/main/java/common/dimension/Planet.java b/common/src/main/java/common/dimension/Planet.java index ab676341..213950d1 100755 --- a/common/src/main/java/common/dimension/Planet.java +++ b/common/src/main/java/common/dimension/Planet.java @@ -24,7 +24,7 @@ public final class Planet extends Dimension { } public Planet(int radius, long orbit, long rotation, float offset, float gravity, float temperature) { - this(0x7aa7ff, 0xc0d8ff, 0xffffff, radius, orbit, rotation, offset, gravity, temperature, 0); + this(0xffffffff, 0xc0d8ff, 0xffffff, radius, orbit, rotation, offset, gravity, temperature, 0); } public Planet(int sky, int fog, int clouds, int radius, long orbit, long rotation, float gravity, float temperature) { diff --git a/common/src/main/java/common/dimension/Space.java b/common/src/main/java/common/dimension/Space.java index 66858652..9656d671 100755 --- a/common/src/main/java/common/dimension/Space.java +++ b/common/src/main/java/common/dimension/Space.java @@ -1,5 +1,6 @@ package common.dimension; +import common.biome.Biome; import common.world.World; public final class Space extends Dimension { @@ -8,7 +9,7 @@ public final class Space extends Dimension { private Space() { super(false); this.setPhysics(World.MAX_SIZE, 1L, 1L, 0.0f, 0.0f, 2.7f, 15); - this.setStarBrightness(1.0f).setDeepStarBrightness(1.0f); + this.setBiome(Biome.SPACE).setStarBrightness(1.0f).setDeepStarBrightness(1.0f); } public final DimType getType() { diff --git a/common/src/main/java/common/entity/animal/EntityHorse.java b/common/src/main/java/common/entity/animal/EntityHorse.java index 2648f7cf..96099311 100755 --- a/common/src/main/java/common/entity/animal/EntityHorse.java +++ b/common/src/main/java/common/entity/animal/EntityHorse.java @@ -356,6 +356,14 @@ public class EntityHorse extends EntityAnimal implements IInvBasic return this.passenger == null; } + public boolean prepareChunkForSpawn() + { + int i = ExtMath.floord(this.posX); + int j = ExtMath.floord(this.posZ); + this.worldObj.getBiomeGenForCoords(new BlockPos(i, 0, j)); + return true; + } + public void dropChests() { if (!this.worldObj.client && this.isChested()) @@ -484,6 +492,15 @@ public class EntityHorse extends EntityAnimal implements IInvBasic // } } + /** + * Checks if the entity's current position is a valid location to spawn this entity. + */ + public boolean getCanSpawnHere() + { + this.prepareChunkForSpawn(); + return super.getCanSpawnHere(); + } + protected EntityHorse getClosestHorse(Entity entityIn, double distance) { double d0 = Double.MAX_VALUE; diff --git a/common/src/main/java/common/entity/animal/EntitySheep.java b/common/src/main/java/common/entity/animal/EntitySheep.java index 49d67776..7aeaaf82 100755 --- a/common/src/main/java/common/entity/animal/EntitySheep.java +++ b/common/src/main/java/common/entity/animal/EntitySheep.java @@ -11,6 +11,7 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; +import common.biome.Biome; import common.block.artificial.BlockWool; import common.collect.Maps; import common.color.DyeColor; @@ -285,9 +286,9 @@ public class EntitySheep extends EntityAnimal DyeColor.MAGENTA, DyeColor.ORANGE, DyeColor.PINK, DyeColor.PURPLE, DyeColor.RED }; - public static DyeColor getRandomSheepColor(Random random, float temp) + public static DyeColor getRandomSheepColor(Random random, Biome biome) { - if(temp <= 0.0f) + if(biome == Biome.SNOW) return DyeColor.WHITE; int i = random.zrange(140); return i < 20 ? DyeColor.BLACK : @@ -325,7 +326,7 @@ public class EntitySheep extends EntityAnimal public Object onInitialSpawn(Object livingdata) { livingdata = super.onInitialSpawn(livingdata); - this.setFleeceColor(getRandomSheepColor(this.worldObj.rand, this.worldObj.getTemperatureC(this.getPosition()))); + this.setFleeceColor(getRandomSheepColor(this.worldObj.rand, this.worldObj.getBiomeGenForCoords(this.getPosition()))); return livingdata; } diff --git a/common/src/main/java/common/entity/npc/EntitySlime.java b/common/src/main/java/common/entity/npc/EntitySlime.java index 7cee9f60..c1dc448d 100755 --- a/common/src/main/java/common/entity/npc/EntitySlime.java +++ b/common/src/main/java/common/entity/npc/EntitySlime.java @@ -2,10 +2,10 @@ package common.entity.npc; import common.ai.EntityAIBase; import common.ai.EntityMoveHelper; +import common.biome.Biome; import common.entity.DamageSource; import common.entity.Entity; import common.entity.types.EntityLiving; -import common.init.Blocks; import common.init.ItemRegistry; import common.init.Items; import common.init.SoundEvent; @@ -383,7 +383,9 @@ public class EntitySlime extends EntityNPC // { // if (this.worldObj.getDifficulty() != Difficulty.PEACEFUL) // { - if (this.worldObj.getState(new BlockPos(this.posX, this.getEntityBoundingBox().minY - 1.0, this.posZ)).getBlock() == Blocks.swamp && this.posY > 50.0D && this.posY < 70.0D && this.rand.floatv() < 0.5F && this.rand.floatv() < this.worldObj.getMoonPhase() && this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.zrange(8)) + Biome biomegenbase = this.worldObj.getBiomeGenForCoords(blockpos); + + if (biomegenbase == Biome.SWAMP && this.posY > 50.0D && this.posY < 70.0D && this.rand.floatv() < 0.5F && this.rand.floatv() < this.worldObj.getMoonPhase() && this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.zrange(8)) { return super.getCanSpawnHere(); } diff --git a/common/src/main/java/common/init/Registry.java b/common/src/main/java/common/init/Registry.java index 2cac6753..d855fdee 100755 --- a/common/src/main/java/common/init/Registry.java +++ b/common/src/main/java/common/init/Registry.java @@ -10,6 +10,5 @@ public abstract class Registry { CraftingRegistry.register(); SmeltingRegistry.register(); EntityRegistry.register(); - UniverseRegistry.register(); } } diff --git a/common/src/main/java/common/init/UniverseRegistry.java b/common/src/main/java/common/init/UniverseRegistry.java index 1f956ca0..0a5ae0f1 100755 --- a/common/src/main/java/common/init/UniverseRegistry.java +++ b/common/src/main/java/common/init/UniverseRegistry.java @@ -5,7 +5,6 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; import common.biome.Biome; -import common.biome.Scaling; import common.collect.Lists; import common.collect.Maps; import common.collect.Sets; @@ -22,36 +21,7 @@ import common.dimension.Sector; import common.dimension.Semi; import common.dimension.Space; import common.dimension.Star; -import common.entity.Entity; -import common.entity.animal.EntityBat; -import common.entity.animal.EntityCat; -import common.entity.animal.EntityChicken; -import common.entity.animal.EntityCow; -import common.entity.animal.EntityFox; -import common.entity.animal.EntityHorse; -import common.entity.animal.EntityMouse; -import common.entity.animal.EntityPig; -import common.entity.animal.EntityRabbit; -import common.entity.animal.EntitySheep; -import common.entity.animal.EntityWolf; -import common.entity.npc.EntityArachnoid; -import common.entity.npc.EntityBloodElf; -import common.entity.npc.EntityCultivator; -import common.entity.npc.EntityElf; -import common.entity.npc.EntityFireDemon; -import common.entity.npc.EntityHaunter; -import common.entity.npc.EntityMage; -import common.entity.npc.EntityMerfolk; -import common.entity.npc.EntityMetalhead; -import common.entity.npc.EntitySlime; -import common.entity.npc.EntitySpirit; -import common.entity.npc.EntityTiefling; -import common.entity.npc.EntityUndead; -import common.entity.npc.EntityWoodElf; -import common.entity.npc.EntityZombie; -import common.entity.types.EntityLiving; import common.world.Weather; - import java.util.Set; public abstract class UniverseRegistry { @@ -427,61 +397,7 @@ public abstract class UniverseRegistry { registerMoon(display, new Moon(radius, orbitRotation, gravity, temperature)); } -// public static final Biome PLAIN = new Biome(12.0f, 40.0f, Scaling.PLAINS_LOW); -// public static final Biome DESERT = new Biome(60.0f, 0.0f, Scaling.PLAINS_LOW); -// public static final Biome HILLS = new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE); -// public static final Biome FOREST = new Biome(8.0f, 80.0f); -// public static final Biome TAIGA = new Biome(-10.0f, 80.0f, Scaling.PLAINS_MEDIUM); -// public static final Biome SWAMP = new Biome(12.0f, 90.0f, Scaling.SEA_POND); -// public static final Biome ICE = new Biome(-20.0f, 50.0f, Scaling.PLAINS_LOW); -// public static final Biome ICE_HILLS = new Biome(-20.0f, 50.0f, Scaling.HILLS_LOW); -// public static final Biome BEACH = new Biome(12.0f, 40.0f, Scaling.SEA_SHORE); -// public static final Biome DESERT_HILLS = new Biome(60.0f, 0.0f, Scaling.HILLS_LOW); -// public static final Biome FOREST_HILLS = new Biome(8.0f, 80.0f, Scaling.HILLS_LOW); -// public static final Biome TAIGA_HILLS = new Biome(-10.0f, 80.0f, Scaling.HILLS_LOW); -// public static final Biome HILLS_EDGE = new Biome(-12.0f, 30.0f, Scaling.HILLS_MEDIUM); -// public static final Biome TROPIC = new Biome(18.0f, 90.0f); -// public static final Biome TROPIC_HILLS = new Biome(18.0f, 90.0f, Scaling.HILLS_LOW); -// public static final Biome TROPIC_EDGE = new Biome(18.0f, 80.0f); -// public static final Biome STONE_BEACH = new Biome(-12.0f, 30.0f, Scaling.SEA_VARYING); -// public static final Biome ICE_BEACH = new Biome(-18.0f, 30.0f, Scaling.SEA_SHORE); -// public static final Biome BIRCH_FOREST = new Biome(4.0f, 60.0f); -// public static final Biome BIRCH_HILLS = new Biome(4.0f, 60.0f, Scaling.HILLS_LOW); -// public static final Biome DARK_FOREST = new Biome(8.0f, 80.0f); -// public static final Biome ICE_TAIGA = new Biome(-40.0f, 40.0f, Scaling.PLAINS_MEDIUM); -// public static final Biome ICE_TAIGA_HILLS = new Biome(-40.0f, 40.0f, Scaling.HILLS_LOW); -// public static final Biome LARGE_TAIGA = new Biome(-8.0f, 80.0f, Scaling.PLAINS_MEDIUM); -// public static final Biome LARGE_TAIGA_HILLS = new Biome(-8.0f, 80.0f, Scaling.HILLS_LOW); -// public static final Biome LARGE_HILLS = new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE); -// public static final Biome SAVANNA = new Biome(28.0f, 0.0f, Scaling.PLAINS_LOW); -// public static final Biome SAVANNA_PLATEAU = new Biome(20.0f, 0.0f, Scaling.HILLS_PLATEAU); -// -// public static final Biome DESERT_MOD = new Biome(60.0f, 0.0f, 0.225F, 0.25F); -// public static final Biome HILLS_MOD = new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE); -// public static final Biome FLOWER_FOREST = new Biome(8.0f, 80.0f, 0.1F, 0.4F); -// public static final Biome TAIGA_MOD = new Biome(-10.0f, 80.0f, 0.3F, 0.4F); -// public static final Biome SWAMP_MOD = new Biome(12.0f, 90.0f, -0.1F, 0.3F); -// public static final Biome ICE_SPIKES = new Biome(-20.0f, 50.0f, 0.425F, 0.45F); -// public static final Biome TROPIC_MOD = new Biome(18.0f, 90.0f, 0.2F, 0.4F); -// public static final Biome TROPIC_EDGE_MOD = new Biome(18.0f, 80.0f, 0.2F, 0.4F); -// public static final Biome BIRCH_FOREST_MOD = new Biome(4.0f, 60.0f, 0.2F, 0.4F); -// public static final Biome BIRCH_HILLS_MOD = new Biome(4.0f, 60.0f, 0.55F, 0.5F); -// public static final Biome DARK_FOREST_MOD = new Biome(8.0f, 80.0f, 0.2F, 0.4F); -// public static final Biome ICE_TAIGA_MOD = new Biome(-40.0f, 40.0f, 0.3F, 0.4F); -// public static final Biome SPRUCE_TAIGA = new Biome(-10.0f, 80.0f, Scaling.PLAINS_MEDIUM); -// public static final Biome REDWOOD_TAIGA = new Biome(-10.0f, 80.0f, 0.3F, 0.4F); -// public static final Biome LARGE_HILLS_MOD = new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE); -// public static final Biome SAVANNA_MOD = new Biome(24.0f, 0.0f, 0.3625F, 1.225F); -// public static final Biome SAVANNA_PLATEAU_MOD = new Biome(20.0f, 0.0f, 1.05F, 1.2125F); -// -// .setBiomeGen(Biome.FOREST, false, 4, 4, 6, 50).enableMobs().enableSnow() -// .setFrostBiomes(Biome.ICE, Biome.ICE, Biome.ICE, Biome.ICE_TAIGA, Biome.LARGE_TAIGA) -// .setColdBiomes(Biome.FOREST, Biome.HILLS, Biome.TAIGA, Biome.PLAIN) -// .setMediumBiomes(Biome.FOREST, Biome.DARK_FOREST, Biome.HILLS, Biome.PLAIN, Biome.BIRCH_FOREST, -// Biome.SWAMP, Biome.TROPIC) -// .setHotBiomes(Biome.DESERT, Biome.DESERT, Biome.DESERT, Biome.SAVANNA, Biome.SAVANNA, Biome.PLAIN) - - static void register() { // TODO: add mushroom 0.2F, 0.3F .addSpawn(EntityDwarf.class, 8, 4, 8) + public static void register() { register("space", "Der Weltraum", Space.INSTANCE); registerGalaxy("milkyway", "Galaxie Milchstraße", () -> { @@ -489,13 +405,13 @@ public abstract class UniverseRegistry { registerStar("Sol", 695508000, 274.0f, 5778.0f, () -> { registerPlanet("Terra", new Planet(6378136, 8766144L, 24000L, 28.0f, 9.81f, 259.15f) .setPerlinGen(Blocks.stone.getState(), Blocks.water.getState(), 63) - .setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()) - .setBiomeGen(new Biome(8.0f, 80.0f), false, 4, 4, 6, 50).enableSnow() - .setFrostBiomes(new Biome(-20.0f, 50.0f, Scaling.PLAINS_LOW), new Biome(-20.0f, 50.0f, Scaling.PLAINS_LOW), new Biome(-20.0f, 50.0f, Scaling.PLAINS_LOW), new Biome(-40.0f, 40.0f, Scaling.PLAINS_MEDIUM), new Biome(-8.0f, 80.0f, Scaling.PLAINS_MEDIUM)) - .setColdBiomes(new Biome(8.0f, 80.0f), new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE), new Biome(-10.0f, 80.0f, Scaling.PLAINS_MEDIUM), new Biome(12.0f, 40.0f, Scaling.PLAINS_LOW)) - .setMediumBiomes(new Biome(8.0f, 80.0f), new Biome(8.0f, 80.0f, 0.1F, 0.4F), new Biome(8.0f, 80.0f), new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE), new Biome(12.0f, 40.0f, Scaling.PLAINS_LOW), new Biome(4.0f, 60.0f), - new Biome(12.0f, 90.0f, Scaling.SEA_POND), new Biome(18.0f, 90.0f)) - .setHotBiomes(new Biome(60.0f, 0.0f, Scaling.PLAINS_LOW), new Biome(60.0f, 0.0f, Scaling.PLAINS_LOW), new Biome(60.0f, 0.0f, Scaling.HILLS_LOW), new Biome(28.0f, 0.0f, Scaling.PLAINS_LOW), new Biome(20.0f, 0.0f, Scaling.HILLS_PLATEAU), new Biome(12.0f, 40.0f, Scaling.PLAINS_LOW)) + .setBiomeReplacer(Blocks.gravel.getState()) + .setBiomeGen(Biome.FOREST, false, 4, 4, 6, 50, 50, Biome.MUSHROOM).enableMobs().enableSnow() + .setFrostBiomes(Biome.ICE, Biome.ICE, Biome.ICE, Biome.ICE_TAIGA, Biome.LARGE_TAIGA) + .setColdBiomes(Biome.FOREST, Biome.HILLS, Biome.TAIGA, Biome.PLAIN) + .setMediumBiomes(Biome.FOREST, Biome.DARK_FOREST, Biome.HILLS, Biome.PLAIN, Biome.BIRCH_FOREST, + Biome.SWAMP, Biome.TROPIC) + .setHotBiomes(Biome.DESERT, Biome.DESERT, Biome.DESERT, Biome.SAVANNA, Biome.SAVANNA, Biome.PLAIN) .enableCavesRavines(Blocks.lava.getState()).setDungeons(8) .addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false) .addLake(Blocks.lava.getState(), Blocks.stone.getState(), null, 8, 8, 255, true) @@ -511,26 +427,6 @@ public abstract class UniverseRegistry { .addOre(Blocks.diamond_ore.getState(), 1, 0, 8, 0, 16, false) .addOre(Blocks.ruby_ore.getState(), 1, 0, 4, 12, 8, true) .addOre(Blocks.cinnabar_ore.getState(), 1, 0, 11, 0, 24, false) - .addSpawn(EntitySheep.class, 12, 4, 4) - .addSpawn(EntityRabbit.class, 10, 3, 10) - .addSpawn(EntityPig.class, 10, 4, 4) - .addSpawn(EntityChicken.class, 10, 4, 4) - .addSpawn(EntityCow.class, 8, 4, 4) - .addSpawn(EntityArachnoid.class, 100, 4, 4) - .addSpawn(EntityZombie.class, 100, 4, 4) - .addSpawn(EntityUndead.class, 100, 4, 4) - .addSpawn(EntityHaunter.class, 100, 4, 4) - .addSpawn(EntitySlime.class, 100, 4, 4) - .addSpawn(EntityMage.class, 5, 1, 1) - .addSpawn(EntityBat.class, 10, 8, 8) - .addSpawn(EntityMouse.class, 10, 8, 8) - .addSpawn(EntityWolf.class, 5, 2, 4) - .addSpawn(EntityFox.class, 4, 2, 6) - .addSpawn(EntityWoodElf.class, 100, 4, 16) - .addSpawn(EntityElf.class, 12, 4, 16) - .addSpawn(EntityMerfolk.class, 10, 4, 4) - .addSpawn(EntityHorse.class, 5, 2, 6) - .addSpawn(EntityCat.class, 2, 1, 1) .enableVillages().enableMineshafts().enableScattered().enableStrongholds(), () -> { registerMoon("Luna", 1737100, 655728L, 1.62f, 210.0f); }); @@ -592,27 +488,20 @@ public abstract class UniverseRegistry { .setPerlinGen(Blocks.moon_rock.getState(), Blocks.air.getState(), 63)); }); registerStar("Gi'rok", 603421976, 232.0f, 5220.0f, () -> { - registerPlanet("gharoth", "Elbenplanet Gharoth", new Planet(2806382, 4837386L, 52960L, 30.0f, 10.0f, 257.3f + 8.0f) //TODO: check temp + registerPlanet("gharoth", "Elbenplanet Gharoth", new Planet(2806382, 4837386L, 52960L, 30.0f, 10.0f, 257.3f) .setSimpleGen(Blocks.dirt.getState(), Blocks.water.getState(), 64) - .setSimpleReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()) - .enableCaves(Blocks.air.getState()).setDungeons(4).enableSnow() + .setSimpleReplacer(Blocks.gravel.getState(), Blocks.sand.getState()).setBiome(Biome.ELVEN_FOREST) + .enableCaves(Blocks.air.getState()).setDungeons(4).enableMobs().enableSnow() .addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false) .addLake(Blocks.lava.getState(), null, null, 8, 8, 255, true) .addLiquid(Blocks.flowing_water.getState(), 50, 8, 255, false) .addLiquid(Blocks.flowing_lava.getState(), 20, 8, 255, true) .addOre(Blocks.thetium_ore.getState(), 1, 0, 3, 0, 14, false) - .addOre(Blocks.gyriyn_ore.getState(), 0, 2, 3, 0, 12, false) - .addSpawn(EntitySheep.class, 12, 4, 4) - .addSpawn(EntityRabbit.class, 10, 3, 10) - .addSpawn(EntityChicken.class, 10, 4, 4) - .addSpawn(EntityMouse.class, 10, 8, 8) - .addSpawn(EntityWoodElf.class, 100, 4, 16) - .addSpawn(EntityElf.class, 12, 4, 16) - .addSpawn(EntityFox.class, 3, 2, 5)); + .addOre(Blocks.gyriyn_ore.getState(), 0, 2, 3, 0, 12, false)); registerPlanet("transylvania", "Vampirplanet Transsylvanien", new Planet(8374921, 33850466L, 49760L, 20.0f, 10.0f, 255.5f) .setPerlinGen(Blocks.rock.getState(), Blocks.water.getState(), 63) - .setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()).setBiomeGen(new Biome(8.0f, 80.0f), true, 5, 3, 3, 30) - .enableCavesRavines(Blocks.lava.getState()).setDungeons(10).enableSnow() + .setBiomeReplacer(Blocks.gravel.getState()).setBiomeGen(Biome.FOREST, true, 5, 3, 3, 30) + .enableCavesRavines(Blocks.lava.getState()).setDungeons(10).enableMobs().enableSnow() .addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false) .addLake(Blocks.lava.getState(), null, null, 8, 8, 255, true) .addLiquid(Blocks.flowing_water.getState(), 50, 8, 255, false) @@ -620,30 +509,17 @@ public abstract class UniverseRegistry { .addOre(Blocks.coal_ore.getState(), 12, 0, 14, 4, 28, false) .addOre(Blocks.lead_ore.getState(), 2, 0, 8, 0, 8, false) .addOre(Blocks.ardite_ore.getState(), 0, 2, 3, 0, 12, false) - .addOre(Blocks.nichun_ore.getState(), 0, 10, 1, 0, 10, false) - .addSpawn(EntitySheep.class, 12, 4, 4) - .addSpawn(EntityCow.class, 8, 4, 4) - .addSpawn(EntityArachnoid.class, 100, 4, 4) - .addSpawn(EntityZombie.class, 100, 4, 4) - .addSpawn(EntityUndead.class, 100, 4, 4) - .addSpawn(EntitySlime.class, 100, 4, 4) - .addSpawn(EntityBat.class, 10, 8, 8) - .addSpawn(EntityMouse.class, 10, 8, 8) - .addSpawn(EntityWolf.class, 5, 2, 4) - .addSpawn(EntityHorse.class, 5, 2, 6), () -> { - registerMoon("yrdinath", "Eismond Yrdinath", new Moon(0xccccff, 2503812, 46743637L, 17460L, 2.5f, 239.15f, Blocks.snow, Blocks.ice, 0.1F, 0.2F) //TODO: check height - .enableSnow().setDefaultWeather(Weather.SNOW) - .addSpawn(EntitySheep.class, 50, 4, 4) - .addSpawn(EntitySpirit.class, 10, 1, 1)); - registerMoon("mythril", "Eismond Mythril", new Moon(0xbbbbff, 2213749, 42659432L, 15330L, 2.25f, 221.65f, Blocks.snow, Blocks.ice, 0.1F, 0.2F) - .enableSnow().setDefaultWeather(Weather.SNOW) - .addSpawn(EntitySheep.class, 50, 4, 4) - .addSpawn(EntitySpirit.class, 10, 1, 1)); + .addOre(Blocks.nichun_ore.getState(), 0, 10, 1, 0, 10, false), () -> { + registerMoon("yrdinath", "Eismond Yrdinath", new Moon(0xccccff, 2503812, 46743637L, 17460L, 2.5f, 239.15f, Blocks.snow, Blocks.ice) + .setBiome(Biome.SNOW).enableMobs().enableSnow().setDefaultWeather(Weather.SNOW)); + registerMoon("mythril", "Eismond Mythril", new Moon(0xbbbbff, 2213749, 42659432L, 15330L, 2.25f, 221.65f, Blocks.snow, Blocks.ice) + .setBiome(Biome.SNOW).enableMobs().enableSnow().setDefaultWeather(Weather.SNOW)); }); registerPlanet("mesar", "Wüstenplanet Me'sar", new Planet(0xff7f3f, 0xff6022, 0xff6f00, 9823183, 56643366L, 87340L, 11.0f, 333.15f) - .setPerlinGen(Blocks.rock.getState(), Blocks.air.getState(), 63, 0.2f, 0.4f) - .setMesarianReplacer(Blocks.red_sand.getState()) - .enableCavesRavines(Blocks.lava.getState()) + .setPerlinGen(Blocks.rock.getState(), Blocks.air.getState(), 63) + .setBiomeReplacer(Blocks.red_sand.getState()) + .setBiomeGen(Biome.MESA, true, 3, 1000, 100000, 100000) + .enableCavesRavines(Blocks.lava.getState()).enableMobs() .addLake(Blocks.lava.getState(), null, null, 8, 8, 255, true) .addLiquid(Blocks.flowing_lava.getState(), 20, 8, 255, true) .addOre(Blocks.iron_ore.getState(), 6, 2, 24, 0, 64, false) @@ -660,97 +536,65 @@ public abstract class UniverseRegistry { registerStar("Ov'rol", new Star(0x000000, 832718528, 302.0f, 12666.0f, Blocks.goo), () -> { registerPlanet("blackplanet", "Der Schwarze Planet", new Planet(0x000000, 0x000000, 0x000000, 13038204, 4632918508L, 204556L, 12.0f, 0.0f) .setPerlinGen(Blocks.blackened_stone.getState(), Blocks.goo.getState(), 63) - .setSimpleAltReplacer(Blocks.blackened_soil.getState(), Blocks.blackened_dirt.getState(), Blocks.blackened_cobble.getState()) - .enableCaves(Blocks.air.getState()).setDungeons(4) + .setBiomeReplacer(Blocks.blackened_cobble.getState()).setBiome(Biome.BLACKENED) + .enableCaves(Blocks.air.getState()).setDungeons(4).enableMobs() .addLake(Blocks.goo.getState(), null, null, 8, 8, 255, true) // .addOre(Blocks.PLACEHOLDER_ore.getState(), 0, 2, 3, 0, 12, false) - .addSpawn(EntityMetalhead.class, 50, 1, 1) ); }); }); }); - Dimension warp = new Semi(0x0c001f, 0x190033, 124072917, 285.0f, 3).setCloudTexture(CloudType.DENSE).setCloudHeight(238.0f) - .setPerlinGen(Blocks.obsidian.getState(), Blocks.lava.getState(), 63, 1.0F, 2.0F) - .enableCavesRavines(Blocks.air.getState()).enableLongCaves().enableSnow() - .addLake(Blocks.water.getState(), null, Blocks.obsidian.getState(), 8, 0, 255, false) - .addLake(Blocks.lava.getState(), null, null, 1, 8, 255, false) - .addLiquid(Blocks.flowing_water.getState(), 1, 8, 255, false) - .addLiquid(Blocks.flowing_lava.getState(), 40, 8, 255, true) - .setStarBrightness(0.9f).setDeepStarBrightness(0.6f) - .setStarColorSin(25.0f, 0.1f, 0.25f, 0xff00ff, 1, 4).setDeepStarColorSin(25.0f, 0.1f, 0.5f, 0xff00ff, 1, 4); - for(Class clazz : EntityRegistry.getAllClasses()) { - if(EntityLiving.class.isAssignableFrom(clazz)) - warp.addSpawn((Class)clazz, 1, 1, 8); - } - registerSemi("warp", "Der Warp", warp); + registerSemi("warp", "Der Warp", new Semi(0x0c001f, 0x190033, 124072917, 285.0f, 3).setCloudTexture(CloudType.DENSE).setCloudHeight(238.0f) + .setPerlinGen(Blocks.obsidian.getState(), Blocks.lava.getState(), 63) + .setBiome(Biome.CHAOS).enableCavesRavines(Blocks.air.getState()).enableLongCaves().enableMobs().enableSnow() + .addLake(Blocks.water.getState(), null, Blocks.obsidian.getState(), 8, 0, 255, false) + .addLake(Blocks.lava.getState(), null, null, 1, 8, 255, false) + .addLiquid(Blocks.flowing_water.getState(), 1, 8, 255, false) + .addLiquid(Blocks.flowing_lava.getState(), 40, 8, 255, true) + .setStarBrightness(0.9f).setDeepStarBrightness(0.6f) + .setStarColorSin(25.0f, 0.1f, 0.25f, 0xff00ff, 1, 4).setDeepStarColorSin(25.0f, 0.1f, 0.5f, 0xff00ff, 1, 4)); registerDomain("Tian'Xin", () -> { registerArea("Ni'enrath", new Area(0x7f00ff, 532109, 276.15f, 1).setLightColor(0x07000f).setBlockColor(0xcf6fff) - .setPerlinGen(Blocks.tian.getState(), Blocks.spring_water.getState(), 63, 0.1F, 1.0F) - .setSimpleAltReplacer(Blocks.tian_soil.getState(), Blocks.tian.getState()).enableLongCaves().enableSnow() + .setPerlinGen(Blocks.tian.getState(), Blocks.spring_water.getState(), 63).setBiome(Biome.TIAN) + .setBiomeReplacer(Blocks.tian.getState()).enableLongCaves().enableMobs().enableSnow() .addLake(Blocks.spring_water.getState(), Blocks.tian.getState(), Blocks.tian.getState(), 4, 0, 255, false) - .addLiquid(Blocks.flowing_spring_water.getState(), 50, 8, 255, false) - .addSpawn(EntityCultivator.class, 50, 1, 1) - .addSpawn(EntityMerfolk.class, 10, 4, 4) - .addSpawn(EntityRabbit.class, 10, 3, 10) - .addSpawn(EntityBat.class, 10, 8, 8) - .addSpawn(EntityMouse.class, 10, 8, 8)); + .addLiquid(Blocks.flowing_spring_water.getState(), 50, 8, 255, false)); }); registerDomain("Digital", () -> { registerArea("Cyberspace", new Area(0x000000, 16777216, 293.15f, 15).setLightColor(0x00ff00).setBlockColor(0xff0000).enableBlockLightSubtraction() - .setFlatGen(Blocks.green_clay.getState(), 2)); + .setFlatGen(Blocks.green_clay.getState(), 2) + .enableMobs()); }); registerDomain("hell", "Hölle", () -> { - registerArea("thedric", "Kreis Thedric", new Area(0x330707, 105639735, 347.15f, 2).enableLongCaves().enableFortresses() + registerArea("thedric", "Kreis Thedric", new Area(0x330707, 105639735, 347.15f, 2).enableLongCaves().enableMobs().enableFortresses() .enableWorldCeiling().enableDenseFog() .setCavernGen(Blocks.hellrock.getState(), Blocks.lava.getState(), 63) .setSurfaceReplacer(Blocks.gravel.getState(), Blocks.soul_sand.getState()) - .addSpawn(EntityFireDemon.class, 50, 4, 4) - .addSpawn(EntityTiefling.class, 100, 4, 4) - .addSpawn(EntityBloodElf.class, 10, 1, 2) - .addSpawn(EntityMetalhead.class, 1, 1, 1)); - registerArea("kyroth", "Kreis Kyroth", new Area(0x990000, 86742970, 387.15f, 3).enableLongCaves() + .setBiome(Biome.UPPER_HELL)); + registerArea("kyroth", "Kreis Kyroth", new Area(0x990000, 86742970, 387.15f, 3).enableLongCaves().enableMobs() .setSimpleGen(Blocks.hellrock.getState(), Blocks.lava.getState(), 64) .setSimpleReplacer(Blocks.obsidian.getState(), Blocks.soul_sand.getState()) + .setBiome(Biome.LOWER_HELL) .addLake(Blocks.lava.getState(), null, null, 4, 8, 255, false) - .addLiquid(Blocks.flowing_lava.getState(), 40, 8, 255, true) - .addSpawn(EntityFireDemon.class, 50, 4, 4) - .addSpawn(EntityTiefling.class, 100, 4, 4) - .addSpawn(EntityBloodElf.class, 50, 2, 10) - .addSpawn(EntityCultivator.class, 10, 1, 1)); - registerArea("ahrd", "Kreis Ahrd", new Area(0xcc0000, 67028432, 467.15f, 15).enableLongCaves() - .setPerlinGen(Blocks.hellrock.getState(), Blocks.lava.getState(), 63, 1.0F, 0.5F) - .setSimpleAltReplacer(Blocks.soul_sand.getState()) + .addLiquid(Blocks.flowing_lava.getState(), 40, 8, 255, true)); + registerArea("ahrd", "Kreis Ahrd", new Area(0xcc0000, 67028432, 467.15f, 15).enableLongCaves().enableMobs() + .setPerlinGen(Blocks.hellrock.getState(), Blocks.lava.getState(), 63) + .setBiomeReplacer(Blocks.soul_sand.getState()).setBiome(Biome.HELL_HILLS) .addLake(Blocks.lava.getState(), Blocks.soul_sand.getState(), Blocks.soul_sand.getState(), - 2, 8, 255, false).addLiquid(Blocks.flowing_lava.getState(), 80, 8, 255, true) - .addSpawn(EntityFireDemon.class, 50, 4, 4) - .addSpawn(EntityTiefling.class, 100, 4, 4) - .addSpawn(EntityBloodElf.class, 50, 2, 10) - .addSpawn(EntityCultivator.class, 10, 1, 1)); - registerArea("mizorath", "Kreis Mizorath", new Area(0xff0000, 54029584, 1067.15f, 15) - .setPerlinGen(Blocks.hellrock.getState(), Blocks.blood.getState(), 63, -0.2F, 0.1F) - .setSimpleAltReplacer(Blocks.soul_sand.getState()) - .addSpawn(EntityFireDemon.class, 50, 4, 4) - .addSpawn(EntityTiefling.class, 100, 4, 4) - .addSpawn(EntityBloodElf.class, 50, 2, 10) - .addSpawn(EntityCultivator.class, 10, 1, 1)); - registerArea("dargoth", "Kreis Dargoth", new Area(0xff3f0c, 43293629, 1707.15f, 15) - .setPerlinGen(Blocks.hellrock.getState(), Blocks.magma.getState(), 63, -0.2F, 0.1F) - .setSimpleAltReplacer(Blocks.soul_sand.getState()) - .addSpawn(EntityFireDemon.class, 50, 4, 4) - .addSpawn(EntityTiefling.class, 100, 4, 4) - .addSpawn(EntityBloodElf.class, 50, 2, 10) - .addSpawn(EntityCultivator.class, 10, 1, 1)); - registerArea("aasirith", "Kreis Aasirith", new Area(0x191919, 36291872, 2482.0f, 1).enableLongCaves() - .setPerlinGen(Blocks.rock.getState(), Blocks.magma.getState(), 63, 0.125F, 0.05F) - .setSimpleAltReplacer(Blocks.ash.getState(), Blocks.rock.getState(), Blocks.ash.getState()) + 2, 8, 255, false).addLiquid(Blocks.flowing_lava.getState(), 80, 8, 255, true)); + registerArea("mizorath", "Kreis Mizorath", new Area(0xff0000, 54029584, 1067.15f, 15).enableMobs() + .setPerlinGen(Blocks.hellrock.getState(), Blocks.blood.getState(), 63) + .setBiomeReplacer(Blocks.soul_sand.getState()).setBiome(Biome.SOUL_PLAINS)); + registerArea("dargoth", "Kreis Dargoth", new Area(0xff3f0c, 43293629, 1707.15f, 15).enableMobs() + .setPerlinGen(Blocks.hellrock.getState(), Blocks.magma.getState(), 63) + .setBiomeReplacer(Blocks.soul_sand.getState()).setBiome(Biome.SOUL_PLAINS)); + registerArea("aasirith", "Kreis Aasirith", new Area(0x191919, 36291872, 2482.0f, 1).enableLongCaves().enableMobs() + .setPerlinGen(Blocks.rock.getState(), Blocks.magma.getState(), 63) + .setBiomeReplacer(Blocks.ash.getState()).setBiome(Biome.ASH) .addLake(Blocks.lava.getState(), Blocks.rock.getState(), Blocks.rock.getState(), - 2, 8, 255, false).addLiquid(Blocks.flowing_lava.getState(), 80, 8, 255, true) - .addSpawn(EntityFireDemon.class, 50, 4, 4) - .addSpawn(EntityTiefling.class, 100, 4, 4) - .addSpawn(EntityBloodElf.class, 50, 2, 10) - .addSpawn(EntityCultivator.class, 10, 1, 1)); + 2, 8, 255, false).addLiquid(Blocks.flowing_lava.getState(), 80, 8, 255, true)); }); } } diff --git a/common/src/main/java/common/item/tool/ItemScanner.java b/common/src/main/java/common/item/tool/ItemScanner.java index eadcdcfa..af56a4b6 100755 --- a/common/src/main/java/common/item/tool/ItemScanner.java +++ b/common/src/main/java/common/item/tool/ItemScanner.java @@ -1,5 +1,6 @@ package common.item.tool; +import common.biome.Biome; import common.color.TextColor; import common.entity.npc.EntityNPC; import common.item.ItemStack; @@ -15,10 +16,10 @@ public class ItemScanner extends ItemWand { public void onUse(ItemStack stack, EntityNPC player, AWorldServer world, Vec3 vec) { - BlockPos pos = new BlockPos(vec); - player.connection.addHotbar(TextColor.NEON + "* Position in %s: %.1f %.1f %.1f, %.1f K, %.1f °C, G: %.1f °C, %.1f %%", world.dimension.getDisplay(), + Biome biome = world.getBiomeGenForCoords(new BlockPos(vec.xCoord, 0, vec.zCoord)); + player.connection.addHotbar(TextColor.NEON + "* Position in %s: %.3f %.3f %.3f, %s, %.2f °C", world.dimension.getDisplay(), vec.xCoord, vec.yCoord, vec.zCoord, - world.getTemperatureK(pos), world.getTemperatureC(pos), world.getGenTemperature(pos.getX(), pos.getZ()), world.getGenHumidity(pos.getX(), pos.getZ())); + biome.display, world.getTemperatureC(new BlockPos(vec))); } public int getRange(ItemStack stack, EntityNPC player) { diff --git a/common/src/main/java/common/network/IClientPlayer.java b/common/src/main/java/common/network/IClientPlayer.java index 43a68671..d04ae379 100644 --- a/common/src/main/java/common/network/IClientPlayer.java +++ b/common/src/main/java/common/network/IClientPlayer.java @@ -29,6 +29,7 @@ import common.packet.SPacketPlayerAbilities; import common.packet.SPacketTabComplete; import common.packet.SPacketUpdateEntityTags; import common.packet.SPacketAnimation; +import common.packet.SPacketBiome; import common.packet.SPacketBlockBreakAnim; import common.packet.SPacketBlockChange; import common.packet.SPacketCamera; @@ -92,6 +93,7 @@ public interface IClientPlayer extends NetHandler { void handlePlayerPosLook(SPacketPlayerPosLook packet); void handleMultiBlockChange(SPacketMultiBlockChange packet); void handleChunkData(SPacketChunkData packet); + void handleBiomes(SPacketBiome packet); void handleBlockChange(SPacketBlockChange packet); void handleDisconnect(SPacketDisconnect packet); void handleCollectItem(SPacketCollectItem packet); diff --git a/common/src/main/java/common/network/PacketRegistry.java b/common/src/main/java/common/network/PacketRegistry.java index 128dd719..f29cabbe 100755 --- a/common/src/main/java/common/network/PacketRegistry.java +++ b/common/src/main/java/common/network/PacketRegistry.java @@ -66,6 +66,7 @@ import common.packet.SPacketPlayerAbilities; import common.packet.SPacketTabComplete; import common.packet.SPacketUpdateEntityTags; import common.packet.SPacketAnimation; +import common.packet.SPacketBiome; import common.packet.SPacketBlockBreakAnim; import common.packet.SPacketBlockChange; import common.packet.SPacketCamera; @@ -175,6 +176,7 @@ public enum PacketRegistry { this.server(SPacketSkin.class); this.server(SPacketDisconnect.class); this.server(SPacketCamera.class); + this.server(SPacketBiome.class); this.server(SPacketUpdateEntityTags.class); this.server(SPacketTrades.class); this.server(SPacketDimensionName.class); diff --git a/common/src/main/java/common/packet/SPacketBiome.java b/common/src/main/java/common/packet/SPacketBiome.java new file mode 100755 index 00000000..99915453 --- /dev/null +++ b/common/src/main/java/common/packet/SPacketBiome.java @@ -0,0 +1,56 @@ +package common.packet; + +import java.io.IOException; + +import common.biome.Biome; +import common.network.IClientPlayer; +import common.network.Packet; +import common.network.PacketBuffer; +import common.util.BlockPos; + +public class SPacketBiome implements Packet { + private int posX; + private int posZ; + private Biome biome; + + public SPacketBiome() { + } + + public SPacketBiome(BlockPos pos, Biome biome) { + this.posX = pos.getX(); + this.posZ = pos.getZ(); + this.biome = biome; + } + + public void readPacketData(PacketBuffer buf) throws IOException { + this.posX = buf.readInt(); + this.posZ = buf.readInt(); + this.biome = buf.readEnumValue(Biome.class); + } + + public void writePacketData(PacketBuffer buf) throws IOException { + buf.writeInt(this.posX); + buf.writeInt(this.posZ); + buf.writeEnumValue(this.biome); + } + + public void processPacket(IClientPlayer handler) { + handler.handleBiomes(this); + } + + public int getChunkX() { + return this.posX >> 4; + } + + public int getChunkZ() { + return this.posZ >> 4; + } + + public BlockPos getPos() { + return new BlockPos(this.posX, 0, this.posZ); + } + + public Biome getBiome() { + return this.biome; + } +} diff --git a/common/src/main/java/common/packet/SPacketChunkData.java b/common/src/main/java/common/packet/SPacketChunkData.java index 69ddf527..01e2bb12 100755 --- a/common/src/main/java/common/packet/SPacketChunkData.java +++ b/common/src/main/java/common/packet/SPacketChunkData.java @@ -73,7 +73,7 @@ public class SPacketChunkData implements Packet int i = segments * 2 * 16 * 16 * 16; int j = segments * 16 * 16 * 16 / 2; int k = overworld ? segments * 16 * 16 * 16 / 2 : 0; - int l = biomes ? 256 * 8 : 0; + int l = biomes ? 256 * 2 : 0; return i + j + k + l; } diff --git a/common/src/main/java/common/world/AWorldServer.java b/common/src/main/java/common/world/AWorldServer.java index fcad3723..b0a1a1ce 100644 --- a/common/src/main/java/common/world/AWorldServer.java +++ b/common/src/main/java/common/world/AWorldServer.java @@ -2,6 +2,7 @@ package common.world; import java.util.List; +import common.biome.Biome; import common.block.Block; import common.dimension.Dimension; import common.entity.Entity; @@ -9,7 +10,6 @@ import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; import common.network.IPlayer; import common.network.Packet; -import common.rng.Random; import common.util.BlockPos; import common.util.BoundingBox; import common.util.ParticleType; @@ -46,10 +46,6 @@ public abstract class AWorldServer extends World { public abstract boolean isDaytime(); public abstract int getSkylightSubtracted(); public abstract T findNearestEntityWithinAABB(Class entityType, BoundingBox aabb, T closestTo); + public abstract void setBiome(BlockPos pos, Biome biome); public abstract void markChunkDirty(BlockPos pos); - public abstract void growGrass(BlockPos pos, State state, Random rand); - public abstract boolean generateBigMushroom(BlockPos pos, State state, Random rand); - public abstract void generateTree(BlockPos pos, State state, Random rand); - public abstract float getGenTemperature(int x, int z); - public abstract float getGenHumidity(int x, int z); } diff --git a/common/src/main/java/common/world/Chunk.java b/common/src/main/java/common/world/Chunk.java index 69d92f24..7b6005b1 100755 --- a/common/src/main/java/common/world/Chunk.java +++ b/common/src/main/java/common/world/Chunk.java @@ -7,6 +7,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.function.Predicate; +import common.biome.Biome; import common.block.Block; import common.block.ITileEntityProvider; import common.block.Material; @@ -31,6 +32,7 @@ public abstract class Chunk { protected final Block fillerBlock; protected final IntHashMap blocks = new IntHashMap(); protected final Set blockList = Sets.newHashSet(); + protected final char[] biomes = new char[256]; protected final int[] precHeight = new int[256]; protected final boolean[] updateSky = new boolean[256]; protected final int[] height = new int[256]; @@ -839,4 +841,10 @@ public abstract class Chunk { public int getLowest() { return this.minHeight; } + + public Biome getBiome(BlockPos pos) { + int x = pos.getX() & 15; + int z = pos.getZ() & 15; + return Biome.getBiomeDef(this.biomes[z << 4 | x]); + } } diff --git a/common/src/main/java/common/world/IWorldAccess.java b/common/src/main/java/common/world/IWorldAccess.java index 3986e79f..b798152b 100755 --- a/common/src/main/java/common/world/IWorldAccess.java +++ b/common/src/main/java/common/world/IWorldAccess.java @@ -1,5 +1,6 @@ package common.world; +import common.biome.Biome; import common.tileentity.TileEntity; import common.util.BlockPos; @@ -7,4 +8,5 @@ public interface IWorldAccess extends IBlockAccess { TileEntity getTileEntity(BlockPos pos); int getCombinedLight(BlockPos pos, int lightValue); + Biome getBiomeGenForCoords(BlockPos pos); } diff --git a/common/src/main/java/common/world/World.java b/common/src/main/java/common/world/World.java index 5f028982..10d92064 100755 --- a/common/src/main/java/common/world/World.java +++ b/common/src/main/java/common/world/World.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Set; import java.util.function.Predicate; +import common.biome.Biome; import common.block.Block; import common.block.Material; import common.block.artificial.BlockSlab; @@ -19,6 +20,7 @@ import common.collect.Lists; import common.collect.Sets; import common.dimension.DimType; import common.dimension.Dimension; +import common.dimension.Galaxy; import common.dimension.Moon; import common.dimension.Planet; import common.dimension.Sector; @@ -187,7 +189,7 @@ public abstract class World implements IWorldAccess { return this.formatTime(player == null ? null : player.getOrigin().getDimension(), days); } - protected abstract float getTemperature(BlockPos pos); + public abstract Biome getBiomeGenForCoords(BlockPos pos); public boolean isAirBlock(BlockPos pos) { return this.getState(pos).getBlock() == Blocks.air; @@ -1596,7 +1598,7 @@ public abstract class World implements IWorldAccess { } public float getTemperatureK(BlockPos pos) { - return this.dimension.isExterminated() ? World.ABSOLUTE_ZERO + 150.0f : Math.max(this.temp + this.getTemperature(pos), 0.0f); + return Math.max(this.temp + this.getBiomeGenForCoords(pos).getTemperature(pos), 0.0f); } public float getTemperatureC(BlockPos pos) { diff --git a/server/src/main/java/server/Server.java b/server/src/main/java/server/Server.java index d1f13776..961b9381 100755 --- a/server/src/main/java/server/Server.java +++ b/server/src/main/java/server/Server.java @@ -108,6 +108,7 @@ import server.vars.SVar; import server.vars.SVars; import server.world.Region; import server.world.WorldServer; +import server.worldgen.biome.GenBiome; public final class Server implements IThreadListener, Executor { private final Thread thread = Thread.currentThread(); @@ -164,6 +165,8 @@ public final class Server implements IThreadListener, Executor { if(Util.DEVMODE) Log.SYSTEM.warn("Entwicklungsmodus aktiv - Debugging-Features sind verfügbar"); Registry.register(); + GenBiome.setAsProvider(); + UniverseRegistry.register(); TeleportRegistry.register(); RotationRegistry.register(); ReorderRegistry.register(); diff --git a/server/src/main/java/server/command/commands/CommandLoad.java b/server/src/main/java/server/command/commands/CommandLoad.java index 1547ac3b..c85bf1d0 100644 --- a/server/src/main/java/server/command/commands/CommandLoad.java +++ b/server/src/main/java/server/command/commands/CommandLoad.java @@ -3,6 +3,7 @@ package server.command.commands; import java.io.File; import java.util.Arrays; +import common.biome.Biome; import common.collect.Iterables; import common.collect.Lists; import common.color.TextColor; @@ -14,6 +15,7 @@ import common.dimension.Star; import common.init.NameRegistry; import common.init.UniverseRegistry; import common.rng.Random; +import common.world.World; import server.command.ArgumentParser; import server.command.Command; import server.command.CommandEnvironment; @@ -79,6 +81,7 @@ public class CommandLoad extends Command { this.addString("display", false); this.setParamsOptional(); this.addString("star", false); + this.addEnum("biome", Biome.DEF_BIOME, Biome.class, Biome.values()); this.addString("convert", 'c', false, (env, last) -> { File[] list = IMPORTS_DIR.listFiles(file -> file.isDirectory()); if(list != null) @@ -86,18 +89,18 @@ public class CommandLoad extends Command { return list == null ? Lists.newArrayList() : Lists.newArrayList(Iterables.transform(Lists.newArrayList(list), file -> ArgumentParser.escape(file.getName()))); }); this.addFlag("teleport", 't'); - this.addColor("sky", 's', 0x7aa7ff); + this.addColor("sky", 's', 0xffffffff); this.addColor("fog", 'f', 0xc0d8ff); this.addColor("clouds", 'w', 0xffffff); this.addLong("orbit", 'o', 1L, 1000000000000L, 8000000L); - this.addLong("rotation", 'r', 1L, 1000000000000L, 25000L); + this.addLong("rotation", 'r', 1L, 1000000000000L, 24000L); this.addDouble("offset", 'm', 0.0, 100000.0, 0.0); - this.addDouble("gravity", 'g', 0.0, 100000.0, 10.0); - this.addDouble("temperature", 'k', 0.0, 100000.0, 260.0); + this.addDouble("gravity", 'g', 0.0, 100000.0, 9.81); + this.addDouble("temperature", 'k', 0.0, 100000.0, 259.15); this.addInt("brightness", 'b', 0, 15, 0); } - public void exec(CommandEnvironment env, Executor exec, String name, String display, String star, String convert, boolean teleport, int sky, int fog, int clouds, + public void exec(CommandEnvironment env, Executor exec, String name, String display, String star, Biome biome, String convert, boolean teleport, int sky, int fog, int clouds, long orbit, long rotation, double offset, double gravity, double temperature, int brightness) { if(teleport && !exec.isPlayer()) throw new RunException("Nur Spieler können teleportiert werden"); @@ -118,6 +121,7 @@ public class CommandLoad extends Command { this.loadingDim = name; if(Converter.convert(dir, name, pos -> env.getServer().schedule(() -> { Planet planet = registerPlanet(star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness); + planet.setBiome(biome); this.loadingDim = null; exec.log(TextColor.GREEN + "Welt %s wurde erfolgreich in Dimension '%s' konvertiert", dir, display); if(teleport && pos != null) { @@ -135,6 +139,7 @@ public class CommandLoad extends Command { return; } Planet planet = registerPlanet(star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness); + planet.setBiome(biome); exec.log(TextColor.GREEN + "Dimension '%s' wurde registriert", display); if(teleport && ((Player)exec).getPresentEntity() != null) ((Player)exec).getPresentEntity().teleport(CommandWorld.adjust(env.getServer().getWorld(planet), ((Player)exec).getPresentEntity().getPosition()), planet); diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 3537e519..1ac39724 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -135,7 +135,6 @@ import server.vars.SVars; import server.world.ChunkServer; import server.world.Region; import server.world.WorldServer; -import server.worldgen.BiomeGenerator; public class Player extends User implements Executor, IPlayer { @@ -828,10 +827,10 @@ public class Player extends User implements Executor, IPlayer - public static SPacketChunkData.Extracted getExtractedData(WorldServer world, ChunkServer chunk, boolean biomes, boolean overworld, int[] extend) + public static SPacketChunkData.Extracted getExtractedData(ChunkServer chunk, boolean biomes, boolean overworld, int[] extend) { Set aextendedblockstorage = chunk.getStorage(); - SPacketChunkData.Extracted dataset = new SPacketChunkData.Extracted(); + SPacketChunkData.Extracted s21packetchunkdata$extracted = new SPacketChunkData.Extracted(); List list = Lists.newArrayList(); if(extend == null) { @@ -852,8 +851,8 @@ public class Player extends User implements Executor, IPlayer extend[z] = list.get(z).getY() >> 4; } - dataset.extend = extend; - dataset.data = new byte[SPacketChunkData.getSize(extend.length, overworld, biomes)]; + s21packetchunkdata$extracted.extend = extend; + s21packetchunkdata$extracted.data = new byte[SPacketChunkData.getSize(extend.length, overworld, biomes)]; int j = 0; for (BlockArray extendedblockstorage1 : list) @@ -862,45 +861,36 @@ public class Player extends User implements Executor, IPlayer for (char c0 : achar) { - dataset.data[j++] = (byte)(c0 & 255); - dataset.data[j++] = (byte)(c0 >> 8 & 255); + s21packetchunkdata$extracted.data[j++] = (byte)(c0 & 255); + s21packetchunkdata$extracted.data[j++] = (byte)(c0 >> 8 & 255); } } for (BlockArray extendedblockstorage2 : list) { - j = copyTo(extendedblockstorage2.getBlocklight().getData(), dataset.data, j); + j = copyTo(extendedblockstorage2.getBlocklight().getData(), s21packetchunkdata$extracted.data, j); } if (overworld) { for (BlockArray extendedblockstorage3 : list) { - j = copyTo(extendedblockstorage3.getSkylight().getData(), dataset.data, j); + j = copyTo(extendedblockstorage3.getSkylight().getData(), s21packetchunkdata$extracted.data, j); } } if (biomes) { - BiomeGenerator gen = world.getBiomeGenerator(); - for (int n = 0; n < 256; n++) + char[] achar = chunk.getBiomes(); + + for (char c0 : achar) { - int x = (chunk.xPos << 4) | (n >> 4); - int z = (chunk.zPos << 4) | (n & 15); - int temp = Float.floatToIntBits(gen == null ? 0.0f : gen.getBiomeAt(new BlockPos(x, 0, z)).temperature); - int off = Float.floatToIntBits(world.getTempNoise(x, z)); - dataset.data[j++] = (byte)(temp & 255); - dataset.data[j++] = (byte)(temp >> 8 & 255); - dataset.data[j++] = (byte)(temp >> 16 & 255); - dataset.data[j++] = (byte)(temp >> 24 & 255); - dataset.data[j++] = (byte)(off & 255); - dataset.data[j++] = (byte)(off >> 8 & 255); - dataset.data[j++] = (byte)(off >> 16 & 255); - dataset.data[j++] = (byte)(off >> 24 & 255); + s21packetchunkdata$extracted.data[j++] = (byte)(c0 & 255); + s21packetchunkdata$extracted.data[j++] = (byte)(c0 >> 8 & 255); } } - return dataset; + return s21packetchunkdata$extracted; } private static int copyTo(byte[] src, byte[] dest, int offset) @@ -909,12 +899,12 @@ public class Player extends User implements Executor, IPlayer return offset + src.length; } - public static SPacketChunkData getPacket(WorldServer world, ChunkServer chunkIn, boolean biomes, int[] extend, boolean sky) + public static SPacketChunkData getPacket(ChunkServer chunkIn, boolean biomes, int[] extend, boolean sky) { - return new SPacketChunkData(chunkIn.xPos, chunkIn.zPos, biomes, getExtractedData(world, chunkIn, biomes, sky, extend)); + return new SPacketChunkData(chunkIn.xPos, chunkIn.zPos, biomes, getExtractedData(chunkIn, biomes, sky, extend)); } - private static SPacketMapChunkBulk getPacket(WorldServer world, List chunks, boolean sky) + private static SPacketMapChunkBulk getPacket(List chunks, boolean sky) { int i = chunks.size(); int[] xPositions = new int[i]; @@ -924,7 +914,7 @@ public class Player extends User implements Executor, IPlayer for (int j = 0; j < i; ++j) { ChunkServer chunk = chunks.get(j); - SPacketChunkData.Extracted s21packetchunkdata$extracted = getExtractedData(world, chunk, true, sky, null); + SPacketChunkData.Extracted s21packetchunkdata$extracted = getExtractedData(chunk, true, sky, null); xPositions[j] = chunk.xPos; zPositions[j] = chunk.zPos; chunksData[j] = s21packetchunkdata$extracted; @@ -971,7 +961,6 @@ public class Player extends User implements Executor, IPlayer List list = Lists.newArrayList(); Iterator iterator1 = this.loadedChunks.iterator(); List list1 = Lists.newArrayList(); - WorldServer world = this.getEntityWorld(); int n = 10; // TODO: this.local ? 1024 : 10; @@ -981,14 +970,14 @@ public class Player extends User implements Executor, IPlayer if (chunkcoordintpair != null) { - if (world.isBlockLoaded(new BlockPos(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4))) + if (this.entity.worldObj.isBlockLoaded(new BlockPos(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4))) { - ChunkServer chunk = world.getChunk(chunkcoordintpair.x, chunkcoordintpair.z); + ChunkServer chunk = this.getEntityWorld().getChunk(chunkcoordintpair.x, chunkcoordintpair.z); if (chunk.isPopulated()) { list.add(chunk); - list1.addAll(world.getTileEntitiesIn(chunkcoordintpair.x * 16, -World.MAX_SIZE_Y, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, World.MAX_SIZE_Y, chunkcoordintpair.z * 16 + 16)); + list1.addAll(((WorldServer)this.entity.worldObj).getTileEntitiesIn(chunkcoordintpair.x * 16, -World.MAX_SIZE_Y, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, World.MAX_SIZE_Y, chunkcoordintpair.z * 16 + 16)); iterator1.remove(); } } @@ -1003,11 +992,11 @@ public class Player extends User implements Executor, IPlayer { if (list.size() == 1) { - this.sendPacket(getPacket(world, list.get(0), true, null, this.entity.worldObj.dimension.hasSkyLight())); + this.sendPacket(getPacket(list.get(0), true, null, this.entity.worldObj.dimension.hasSkyLight())); } else { - this.sendPacket(getPacket(world, list, this.entity.worldObj.dimension.hasSkyLight())); + this.sendPacket(getPacket(list, this.entity.worldObj.dimension.hasSkyLight())); } for (TileEntity tileentity : list1) diff --git a/server/src/main/java/server/world/ChunkServer.java b/server/src/main/java/server/world/ChunkServer.java index 99c7f023..7f7e46e7 100644 --- a/server/src/main/java/server/world/ChunkServer.java +++ b/server/src/main/java/server/world/ChunkServer.java @@ -1,7 +1,9 @@ package server.world; +import java.util.Arrays; import java.util.Map; import java.util.Set; +import common.biome.Biome; import common.block.Block; import common.entity.Entity; import common.init.BlockRegistry; @@ -23,7 +25,7 @@ public class ChunkServer extends Chunk { super(world, x, z); } - public ChunkServer(World world, char[] data, int height, boolean base, boolean ceil, Random rand, int x, int z) { + public ChunkServer(World world, char[] data, int height, boolean base, boolean ceil, Random rand, Biome[] biomes, int x, int z) { this(world, x, z); boolean sky = world.dimension.hasSkyLight(); for(int bx = 0; bx < 16; ++bx) { @@ -83,11 +85,20 @@ public class ChunkServer extends Chunk { } } } + for(int n = 0; n < this.biomes.length; ++n) { + this.biomes[n] = (char)biomes[n].id; + } if(ceil) this.resetRelight(); else this.genSkyLight(); } + + public ChunkServer(World world, Biome biome, int x, int z) { + this(world, x, z); + Arrays.fill(this.biomes, (char)biome.id); + this.genSkyLight(); + } public int getTopSegment() { return this.top; @@ -135,6 +146,22 @@ public class ChunkServer extends Chunk { } } + public char[] getBiomes() { + return this.biomes; + } + + public void setBiomes(char[] biomes) { + if(this.biomes.length != biomes.length) { + Log.IO.warn("Konnte Biome des Chunks nicht setzen, Länge des Arrays ist " + biomes.length + " statt " + this.biomes.length); + Arrays.fill(this.biomes, (char)Biome.DEF_BIOME.id); + } + else { + for(int n = 0; n < this.biomes.length; ++n) { + this.biomes[n] = biomes[n]; + } + } + } + public int[] getHeights() { return this.height; } diff --git a/server/src/main/java/server/world/Region.java b/server/src/main/java/server/world/Region.java index 75f88bc6..63d47e2c 100755 --- a/server/src/main/java/server/world/Region.java +++ b/server/src/main/java/server/world/Region.java @@ -10,6 +10,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.RandomAccessFile; +import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -19,6 +20,7 @@ import java.util.Set; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; +import common.biome.Biome; import common.block.Block; import common.collect.Lists; import common.collect.Maps; @@ -117,6 +119,71 @@ public class Region { return false; } + private static boolean makeBiomeMap(TagObject tag) { + Map biomes = Maps.newTreeMap(); + Map assign = Maps.newHashMap(); + if(tag.hasStringArray("biomes")) { + String[] ids = tag.getStringArray("biomes"); + for(char bid = 1; bid < ids.length; bid++) { + String id = ids[bid]; + if(!id.isEmpty()) { + biomes.put(bid, id); + assign.put(id, bid); + } + } + } + Map mapping = Maps.newHashMap(); + List missing = Lists.newArrayList(); + char highest = 0; + for(Biome state : Biome.values()) { + if(state == Biome.NONE) + continue; + String id = state.getName(); + if(assign.containsKey(id)) { + char bid = assign.get(id); + if(bid == 0) { + missing.add(id); + continue; + } + mapping.put(bid, id); + highest = bid > highest ? bid : highest; + biomes.remove(bid); + Log.IO.debug("Bestehende Biom-ID %d = %s", (int)bid, id); + } + else { + missing.add(id); + } + } + for(Entry entry : biomes.entrySet()) { + Log.IO.debug("Entfernte Biom-ID %d = %s", (int)entry.getKey(), entry.getValue()); + } + char bid = 1; + for(String id : missing) { + while(mapping.containsKey(bid)) { + ++bid; + } + mapping.put(bid, id); + highest = bid > highest ? bid : highest; + Log.IO.debug("Neue Biom-ID %d = %s", (int)bid, id); + } + for(Entry entry : mapping.entrySet()) { + bid = entry.getKey(); + char ids = (char)Biome.findByName(entry.getValue()).id; + BDECODE_MAP[bid] = ids; + BENCODE_MAP[ids] = bid; + } + if(!missing.isEmpty() || !biomes.isEmpty()) { + String[] ids = new String[highest + 1]; + ids[0] = Biome.NONE.getName(); + for(bid = 1; bid < ids.length; bid++) { + ids[bid] = mapping.getOrDefault(bid, ""); + } + tag.setStringArray("biomes", ids); + return true; + } + return false; + } + public static void loadMap() { File mapFile = new File("datamap.cdt"); TagObject tag; @@ -132,8 +199,10 @@ public class Region { else { tag = new TagObject(); } - if(makeMap(tag)) { - Log.IO.info("Block-IDs haben sich geändert, schreibe %s", mapFile); + boolean states = makeMap(tag); + boolean biomes = makeBiomeMap(tag); + if(states || biomes) { + Log.IO.info((states ? "Block-IDs" : "") + (states && biomes ? " und " : "") + (biomes ? "Biom-IDs" : "") + " haben sich geändert, schreibe %s", mapFile); try { TagObject.writeGZip(tag, mapFile); } @@ -173,6 +242,8 @@ public class Region { private static final List QUEUE = Collections.synchronizedList(Lists.newArrayList()); private static final char[] DECODE_MAP = new char[65536]; private static final char[] ENCODE_MAP = new char[65536]; + private static final char[] BDECODE_MAP = new char[65536]; + private static final char[] BENCODE_MAP = new char[65536]; private static volatile long queued; private static volatile long saved; @@ -522,6 +593,18 @@ public class Region { chunk.setStorage(sections); + if(tag.hasByteArray("Biomes")) { + byte[] bdata = tag.getByteArray("Biomes"); + char[] biomes = new char[bdata.length / 2]; + for(int n = 0; n < biomes.length; n++) { + biomes[n] = BDECODE_MAP[(char)((bdata[n * 2] & 255) << 8 | bdata[n * 2 + 1] & 255)]; + } + chunk.setBiomes(biomes); + } + else { + Arrays.fill(chunk.getBiomes(), (char)Biome.DEF_BIOME.id); + } + List entities = tag.getList("Entities"); if(entities != null) { @@ -651,6 +734,14 @@ public class Region { } tag.setList("Sections", sects); + char[] biomes = chunk.getBiomes(); + byte[] bdata = new byte[biomes.length * 2]; + for(int n = 0; n < biomes.length; n++) { + char biome = BENCODE_MAP[biomes[n]]; + bdata[n * 2] = (byte)(biome >> 8 & 255); + bdata[n * 2 + 1] = (byte)(biome & 255); + } + tag.setByteArray("Biomes", bdata); chunk.setHasEntities(false); List entities = Lists.newArrayList(); diff --git a/server/src/main/java/server/world/Spawner.java b/server/src/main/java/server/world/Spawner.java index 01e5d380..6e650221 100755 --- a/server/src/main/java/server/world/Spawner.java +++ b/server/src/main/java/server/world/Spawner.java @@ -4,7 +4,6 @@ import java.util.Set; import common.block.Block; import common.collect.Sets; -import common.dimension.RngSpawn; import common.entity.npc.EntityNPC; import common.entity.npc.EntityWaterNPC; import common.entity.types.EntityLiving; @@ -16,6 +15,8 @@ import common.util.ChunkPos; import common.util.ExtMath; import common.world.World; import server.vars.SVars; +import server.worldgen.biome.GenBiome; +import server.worldgen.biome.RngSpawn; public abstract class Spawner { private static final int MOB_COUNT_DIV = (int)Math.pow(17.0D, 2.0D); @@ -157,11 +158,15 @@ public abstract class Spawner { return spawned; } - public static void generate(WorldServer world, WeightedList list, int x, int z, int sx, int sz, Random rand) { + public static void generate(WorldServer world, GenBiome biome, int x, int z, int sx, int sz, Random rand) { int iters = 0; - while(rand.floatv() < 0.1f) { + while(rand.floatv() < biome.getMobGenChance()) { if(iters++ == 10) break; + WeightedList list = biome.getMobs(); + if(list.isEmpty()) { + continue; + } RngSpawn entry = list.pick(world.rand); int count = entry.min + rand.zrange(1 + entry.max - entry.min); Object data = null; diff --git a/server/src/main/java/server/world/WorldServer.java b/server/src/main/java/server/world/WorldServer.java index e479134e..368fc3c0 100755 --- a/server/src/main/java/server/world/WorldServer.java +++ b/server/src/main/java/server/world/WorldServer.java @@ -18,8 +18,6 @@ import common.block.BlockFalling; import common.block.ITileEntityProvider; import common.block.Material; import common.block.artificial.BlockDoor; -import common.block.foliage.BlockFlower; -import common.block.foliage.BlockSapling; import common.block.liquid.BlockLiquid; import common.block.natural.BlockSnow; import common.collect.Lists; @@ -30,7 +28,6 @@ import common.dimension.Dimension.GeneratorType; import common.dimension.Lake; import common.dimension.Liquid; import common.dimension.Ore; -import common.dimension.RngSpawn; import common.entity.DamageSource; import common.entity.Entity; import common.entity.EntityTrackerEntry; @@ -40,7 +37,6 @@ import common.entity.types.EntityLiving; import common.init.Blocks; import common.init.SoundEvent; import common.init.UniverseRegistry; -import common.init.WoodType; import common.log.Log; import common.network.IPlayer; import common.network.Packet; @@ -51,11 +47,11 @@ import common.packet.SPacketSoundEffect; import common.packet.SPacketParticles; import common.packet.SPacketChangeGameState; import common.packet.SPacketSpawnGlobalEntity; +import common.packet.SPacketBiome; import common.packet.SPacketBlockBreakAnim; import common.packet.SPacketBlockChange; import common.packet.SPacketCelestials; import common.packet.SPacketMultiBlockChange; -import common.rng.PerlinGen; import common.rng.Random; import common.rng.WeightedList; import common.tags.TagObject; @@ -85,13 +81,14 @@ import server.init.TeleportRegistry; import server.network.Player; import server.vars.SVars; import server.village.VillageCollection; +import server.worldgen.BiomeGenLayered; import server.worldgen.BiomeGenPerlin; +import server.worldgen.BiomeGenSingle; import server.worldgen.BiomeGenerator; import server.worldgen.BlockReplacer; import server.worldgen.ChunkGenerator; import server.worldgen.ChunkPrimer; import server.worldgen.FeatureDungeons; -import server.worldgen.FeatureGenerator; import server.worldgen.FeatureLakes; import server.worldgen.FeatureLiquids; import server.worldgen.FeatureOres; @@ -102,31 +99,20 @@ import server.worldgen.GeneratorIsland; import server.worldgen.GeneratorPerlin; import server.worldgen.GeneratorSimple; import server.worldgen.MobConstants; -import server.worldgen.ReplacerAltSimple; import server.worldgen.ReplacerAltBiome; import server.worldgen.ReplacerAltSurface; -import server.worldgen.ReplacerMesa; -import server.worldgen.ReplacerTerranian; +import server.worldgen.ReplacerBiome; import server.worldgen.ReplacerTopLayer; +import server.worldgen.biome.GenBiome; +import server.worldgen.biome.RngSpawn; import server.worldgen.caves.MapGenBigCaves; import server.worldgen.caves.MapGenCaves; import server.worldgen.caves.MapGenRavine; -import server.worldgen.foliage.WorldGenBigMushroom; -import server.worldgen.populator.Populator; -import server.worldgen.populator.PopulatorMesa; import server.worldgen.structure.MapGenBridge; import server.worldgen.structure.MapGenMineshaft; import server.worldgen.structure.MapGenScatteredFeature; import server.worldgen.structure.MapGenStronghold; import server.worldgen.structure.MapGenVillage; -import server.worldgen.tree.WorldGenBaseTree; -import server.worldgen.tree.WorldGenBigTree; -import server.worldgen.tree.WorldGenBirch; -import server.worldgen.tree.WorldGenDarkOak; -import server.worldgen.tree.WorldGenJungle; -import server.worldgen.tree.WorldGenPine; -import server.worldgen.tree.WorldGenSavanna; -import server.worldgen.tree.WorldGenTaiga2; public final class WorldServer extends AWorldServer { private static final int[][] XZ_DIRS = new int[][] {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; @@ -153,7 +139,7 @@ public final class WorldServer extends AWorldServer { private final Map dataMap = Maps.newHashMap(); private final List dataList = Lists.newArrayList(); private final List toTick = Lists.newArrayList(); - private final PerlinGen tempGen; + private final Biome[] biomes = new Biome[256]; private MapGenCaves caveGen; private MapGenBigCaves bigCaveGen; @@ -168,8 +154,6 @@ public final class WorldServer extends AWorldServer { private BiomeGenerator biomeGen; private BlockReplacer replacer; private FeatureDungeons dungeons; - private Populator populator; - private WeightedList mobs; private State liquid; private boolean base; private boolean ceil; @@ -180,7 +164,9 @@ public final class WorldServer extends AWorldServer { private int height; private int size; private int seaLevel; + private boolean mobs; private boolean snow; + private boolean populate; private int updatesForced; private boolean loadersModified; @@ -218,12 +204,12 @@ public final class WorldServer extends AWorldServer { } private BiomeGenerator createBiomeGenerator(Random rand) { - return this.dimension.getBiomeSize() > 0 ? new BiomeGenerator(rand.longv(), this.dimension.getDefaultBiome(), this.dimension.isSemiFixed(), this.dimension.getBiomeSize(), this.dimension.getRiverSize(), + return this.dimension.getBiomeSize() > 0 ? new BiomeGenLayered(rand.longv(), this.dimension.getDefaultBiome(), this.dimension.isSemiFixed(), this.dimension.getBiomeSize(), this.dimension.getRiverSize(), this.dimension.getSnowRarity(), this.dimension.getSeaRarity(), this.dimension.getAddBiomes() == null ? new Biome[0] : this.dimension.getAddBiomes(), this.dimension.getAddRarity(), this.dimension.getHotBiomes() == null ? new Biome[] {this.dimension.getDefaultBiome()} : this.dimension.getHotBiomes(), this.dimension.getMediumBiomes() == null ? new Biome[] {this.dimension.getDefaultBiome()} : this.dimension.getMediumBiomes(), this.dimension.getColdBiomes() == null ? new Biome[] {this.dimension.getDefaultBiome()} : this.dimension.getColdBiomes(), - this.dimension.getFrostBiomes() == null ? new Biome[] {this.dimension.getDefaultBiome()} : this.dimension.getFrostBiomes()) : null; + this.dimension.getFrostBiomes() == null ? new Biome[] {this.dimension.getDefaultBiome()} : this.dimension.getFrostBiomes()) : new BiomeGenSingle(this.dimension.getDefaultBiome()); } private ChunkGenerator createChunkGenerator(Random rand) { @@ -232,11 +218,10 @@ public final class WorldServer extends AWorldServer { return this.dimension.getLayers() == null ? new GeneratorFlat(this.dimension.getSeaLevel(), this.dimension.getFiller()) : new GeneratorFlat(this.dimension.getLayers()); case PERLIN: default: - return this.biomeGen == null ? new GeneratorPerlin(rand, this.dimension.getFiller(), this.dimension.getLiquid(), this.dimension.getNoiseGen(), this.dimension.getDepth(), this.dimension.getScale()) : - new GeneratorPerlin(rand, this.dimension.getFiller(), this.dimension.getLiquid(), this.dimension.getNoiseGen()); + return new GeneratorPerlin(rand, this.dimension.getFiller(), this.dimension.getLiquid(), this.dimension.getNoiseGen()); case SIMPLE: return new GeneratorSimple(rand, this.dimension.getFiller(), this.dimension.getLiquid(), - this.biomeGen != null ? null : new BiomeGenPerlin(rand.longv())); + this.dimension.getBiomeSize() > 0 ? null : new BiomeGenPerlin(rand.longv())); case ISLAND: return new GeneratorIsland(rand, this.dimension.getFiller()); case CAVERN: @@ -248,15 +233,11 @@ public final class WorldServer extends AWorldServer { private BlockReplacer createBlockReplacer(Random rand) { switch(this.dimension.getReplacerType()) { - case TERRANIAN: + case BIOMES: default: - return new ReplacerTerranian(rand, this.dimension.getSurface(), this.dimension.getTop(), this.dimension.getFiller(), this.dimension.getAlt1(), this.dimension.getAlt2(), this.dimension.getLiquid(), this.dimension.getSeaLevel()); - case MESARIAN: - return new ReplacerMesa(rand, this.dimension.getFiller(), this.dimension.getLiquid(), this.dimension.getSeaLevel(), this.dimension.getSurface()); - case ALT_SIMPLE: - return new ReplacerAltSimple(rand, this.dimension.getSurface(), this.dimension.getTop(), this.dimension.getFiller(), this.dimension.getAlt1(), this.dimension.getLiquid(), this.dimension.getSeaLevel()); + return new ReplacerBiome(rand); case SIMPLE: - return new ReplacerAltBiome(rand, this.dimension.getSurface(), this.dimension.getTop(), this.dimension.getFiller(), this.dimension.getLiquid(), this.dimension.getAlt2(), this.dimension.getAlt1()); + return new ReplacerAltBiome(rand, this.dimension.getFiller(), this.dimension.getLiquid(), this.dimension.getAlt2(), this.dimension.getAlt1()); case ALTERNATE: return new ReplacerAltSurface(rand, this.dimension.getFiller(), this.dimension.getAlt1(), this.dimension.getAlt2(), this.dimension.getLiquid()); case TOPLAYER: @@ -266,18 +247,6 @@ public final class WorldServer extends AWorldServer { } } - private Populator createPopulator() { - switch(this.dimension.getPopulatorType()) { - case NONE: - return null; - case MESARIAN: - return new PopulatorMesa(true); - case TERRANIAN: - default: - return null; - } - } - private FeatureDungeons createDungeonGenerator() { return this.dimension.getDungeons() > 0 ? new FeatureDungeons(this.dimension.getDungeons()) : null; } @@ -285,13 +254,13 @@ public final class WorldServer extends AWorldServer { private MapGenCaves createCaveGenerator() { return this.dimension.hasCaves() ? (new MapGenCaves(this.dimension.getCaveFiller(), this.dimension.getFiller().getBlock(), this.dimension.getTop().getBlock(), - this.dimension.getSurface(), this.dimension.getAlt1().getBlock())) : null; + this.dimension.getSurface().getBlock(), this.dimension.getAlt1().getBlock())) : null; } private MapGenRavine createRavineGenerator() { return this.dimension.hasRavines() ? (new MapGenRavine(this.dimension.getCaveFiller(), this.dimension.getFiller().getBlock(), - this.dimension.getTop().getBlock(), this.dimension.getSurface())) : null; + this.dimension.getTop().getBlock(), this.dimension.getSurface().getBlock())) : null; } private MapGenBigCaves createBigCaveGenerator() { @@ -345,8 +314,7 @@ public final class WorldServer extends AWorldServer { this.seed = this.dimension.getSeed(); this.time = this.dimension.getTimeExisted(); - this.grng = new Random(this.seed ^ 836430928262265276L); - this.tempGen = new PerlinGen(this.grng, 1); + this.grng = new Random(this.seed); this.initGenerator(this.dimension.isExterminated()); this.calculateInitialSkylight(); this.calculateInitialWeather(); @@ -377,10 +345,9 @@ public final class WorldServer extends AWorldServer { public void tick() { this.updatePhysics(); this.updateWeather(false); - if(this.biomeGen != null) - this.biomeGen.cleanupCache(); + this.biomeGen.cleanupCache(); // this.profiler.start("mobSpawner"); - if((this.mobs != null || this.bridgeGen != null || this.scatteredGen != null) && Vars.mobs && SVars.tickSpawn) { + if(this.mobs && Vars.mobs && SVars.tickSpawn) { Spawner.spawn(this); } // this.profiler.next("chunkSource"); @@ -467,12 +434,13 @@ public final class WorldServer extends AWorldServer { } private WeightedList getSpawnTypes(BlockPos pos) { + Biome biome = this.getBiomeGenForCoords(pos); if(this.bridgeGen != null && (this.bridgeGen.isPresent(pos) || (this.bridgeGen.isPositionInStructure(this, pos) && this.getState(pos.down()).getBlock() == Blocks.blood_brick))) return MobConstants.FORTRESS_MOBS; else if(this.scatteredGen != null && this.scatteredGen.hasMageHut(pos)) return MobConstants.MAGEHUT_MOBS; - return this.mobs; + return GenBiome.BIOMES[biome.id].getMobs(); } public RngSpawn getSpawnListEntryForTypeAt(BlockPos pos) { @@ -493,6 +461,13 @@ public final class WorldServer extends AWorldServer { return this.biomeGen; } + public Biome getBiomeGenForCoords(final BlockPos pos) { + if(this.isBlockLoaded(pos)) + return this.getChunk(pos).getBiome(pos); + else + return this.biomeGen.getBiomeGenerator(pos, Biome.DEF_BIOME); + } + public void setItemData(String dataID, WorldSavedData worldSavedDataIn) { this.setData(dataID, worldSavedDataIn); } @@ -1358,6 +1333,7 @@ public final class WorldServer extends AWorldServer { int bx = x * 16; int bz = z * 16; BlockPos pos = new BlockPos(bx, 0, bz); + GenBiome biome = GenBiome.BIOMES[this.getBiomeGenForCoords(pos.add(16, 0, 16)).id]; this.grng.setSeed(this.seed); long sx = this.grng.longv() / 2L * 2L + 1L; long sz = this.grng.longv() / 2L * 2L + 1L; @@ -1379,7 +1355,7 @@ public final class WorldServer extends AWorldServer { if(this.scatteredGen != null) { this.scatteredGen.generateStructure(this, this.grng, coord); } - if(lakes && this.lakes != null && (this.populator == null || this.populator.canGenerateLakes())) { + if(lakes && this.lakes != null && biome.generateLakes) { for(FeatureLakes lake : this.lakes) { lake.generate(this, this.grng, pos); } @@ -1392,16 +1368,16 @@ public final class WorldServer extends AWorldServer { ore.generate(this, this.grng, pos); } } - if(this.populator != null) { - this.populator.decorate(this, this.grng, pos); + if(this.populate) { + biome.decorate(this, this.grng, pos); } - if(this.liquids != null && (this.populator == null || this.populator.canGenerateLiquids())) { + if(this.liquids != null && biome.generateLiquids) { for(FeatureLiquids liquid : this.liquids) { liquid.generate(this, this.grng, pos); } } - if(this.mobs != null && Vars.mobs && SVars.genSpawn) { - Spawner.generate(this, this.mobs, bx + 8, bz + 8, 16, 16, this.grng); + if(this.mobs && Vars.mobs && SVars.genSpawn) { + Spawner.generate(this, biome, bx + 8, bz + 8, 16, 16, this.grng); } // if(this.snow) { pos = pos.add(8, 0, 8); @@ -1424,16 +1400,14 @@ public final class WorldServer extends AWorldServer { } private ChunkServer generate(int x, int z) { - if(x < -this.size || z < -this.size || x >= this.size || z >= this.size) { - ChunkServer chunk = new ChunkServer(this, x, z); - chunk.genSkyLight(); - return chunk; - } + if(x < -this.size || z < -this.size || x >= this.size || z >= this.size) + return new ChunkServer(this, Biome.SPACE, x, z); this.grng.setSeed((long)x * 341873128712L + (long)z * 132897987541L); ChunkPrimer primer = new ChunkPrimer(this.height); this.generator.generateChunk(this, x, z, primer); + this.biomeGen.getChunkBiomes(this.biomes, x * 16, z * 16, 16, 16); if(this.replacer != null) { - this.replacer.replaceBlocks(this, x, z, primer, this.grng); + this.replacer.replaceBlocks(this, x, z, primer, this.grng, this.biomes); } if(this.caveGen != null) { this.caveGen.generate(this, x, z, primer); @@ -1459,7 +1433,7 @@ public final class WorldServer extends AWorldServer { if(this.scatteredGen != null) { this.scatteredGen.generate(this, x, z, primer); } - return new ChunkServer(this, primer.getData(), primer.height, this.base, this.ceil, this.grng, x, z); + return new ChunkServer(this, primer.getData(), primer.height, this.base, this.ceil, this.grng, this.biomes, x, z); } public boolean isExterminated() { @@ -1591,16 +1565,16 @@ public final class WorldServer extends AWorldServer { private void initGenerator(boolean exterminated) { this.grng.setSeed(this.seed); this.liquid = exterminated ? Blocks.air.getState() : this.dimension.getLiquid(); - this.biomeGen = exterminated ? null : this.createBiomeGenerator(this.grng); + this.biomeGen = exterminated ? new BiomeGenSingle(Biome.EXTERMINATED) : this.createBiomeGenerator(this.grng); this.generator = exterminated ? new GeneratorDestroyed(this.dimension.getSeaLevel()) : this.createChunkGenerator(this.grng); this.replacer = exterminated ? null : this.createBlockReplacer(this.grng); - this.populator = exterminated ? null : this.createPopulator(); + this.populate = !exterminated && this.dimension.hasPopulator(); this.caveGen = exterminated ? null : this.createCaveGenerator(); this.bigCaveGen = exterminated ? null : this.createBigCaveGenerator(); this.ravineGen = exterminated ? null : this.createRavineGenerator(); this.base = !exterminated && this.dimension.getFiller().getBlock() != Blocks.air && this.dimension.getGeneratorType() != GeneratorType.FLAT; this.ceil = !exterminated && this.dimension.hasWorldCeiling(); - this.mobs = exterminated || this.dimension.getSpawns().isEmpty() ? null : this.dimension.getSpawns(); + this.mobs = !exterminated && this.dimension.hasMobs(); this.snow = !exterminated && this.dimension.hasSnow(); this.strongholdGen = !exterminated && this.dimension.hasStrongholds() ? new MapGenStronghold() : null; this.villageGen = !exterminated && this.dimension.hasVillages() ? new MapGenVillage() : null; @@ -1745,6 +1719,22 @@ public final class WorldServer extends AWorldServer { return this.instances.getValueByKey(v) != null; } + public void setBiome(BlockPos pos, Biome biome) { + if(this.dimension.isExterminated()) + return; + ChunkServer chunk = this.getChunk(pos); + if(chunk == null || !chunk.isLoaded()) + return; + chunk.getBiomes()[((pos.getZ() & 0xF) << 4 | pos.getX() & 0xF)] = (char)biome.id; + chunk.setModified(true); + int chunkX = pos.getX() >> 4; + int chunkZ = pos.getZ() >> 4; + long v = (long)chunkX + 2147483647L | (long)chunkZ + 2147483647L << 32; + PlayerInstance ins = this.instances.getValueByKey(v); + if(ins != null) + ins.sendToAllPlayersWatchingChunk(new SPacketBiome(pos, biome)); + } + private PlayerInstance getPlayerInstance(int chunkX, int chunkZ, boolean create) { long v = (long)chunkX + 2147483647L | (long)chunkZ + 2147483647L << 32; PlayerInstance inst = this.instances.getValueByKey(v); @@ -2342,23 +2332,6 @@ public final class WorldServer extends AWorldServer { e.printStackTrace(); } } - - protected float getTemperature(BlockPos pos) { - float temperature = this.biomeGen == null ? 0.0f : this.biomeGen.getBiomeAt(pos).temperature; - return pos.getY() > 64 ? temperature - (this.getTempNoise(pos.getX(), pos.getZ()) + (float)pos.getY() - 64.0F) / 15.0f : temperature; - } - - public float getTempNoise(int x, int z) { - return (float)(this.tempGen.generate((double)x * 1.0D / 8.0D, (double)z * 1.0D / 8.0D) * 4.0D); - } - - public float getGenTemperature(int x, int z) { - return World.ABSOLUTE_ZERO + this.dimension.getTemperature() + this.dimension.getOrbitOffset() * 0.5f + (this.biomeGen == null ? 0.0f : this.biomeGen.getBiomeAt(x, z).temperature); - } - - public float getGenHumidity(int x, int z) { - return this.biomeGen == null ? 50.0f : this.biomeGen.getBiomeAt(x, z).humidity; - } // public boolean canBlockSeeSky(BlockPos pos) { // if(pos.getY() >= this.getSeaLevel()) { @@ -2633,227 +2606,6 @@ public final class WorldServer extends AWorldServer { } return new SPacketMultiBlockChange(pos, changes); } - - public boolean generateBigMushroom(BlockPos pos, State state, Random rand) - { - this.setBlockToAir(pos); - FeatureGenerator worldgenerator = null; - - if (state.getBlock() == Blocks.brown_mushroom) - { - worldgenerator = new WorldGenBigMushroom(Blocks.brown_mushroom_block); - } - else if (state.getBlock() == Blocks.red_mushroom) - { - worldgenerator = new WorldGenBigMushroom(Blocks.red_mushroom_block); - } - - if (worldgenerator != null && worldgenerator.generate(this, rand, pos)) - { - return true; - } - else - { - this.setState(pos, state, 3); - return false; - } - } - - private boolean isTypeAt(BlockPos pos, WoodType type) - { - State iblockstate = this.getState(pos); - return iblockstate.getBlock() instanceof BlockSapling && ((BlockSapling)iblockstate.getBlock()).getWoodType() == type; - } - - private boolean isSameSaplingTypeIn(BlockPos pos, int xOff, int yOff, WoodType type) - { - return this.isTypeAt(pos.add(xOff, 0, yOff), type) && this.isTypeAt(pos.add(xOff + 1, 0, yOff), type) && this.isTypeAt(pos.add(xOff, 0, yOff + 1), type) && this.isTypeAt(pos.add(xOff + 1, 0, yOff + 1), type); - } - - public void generateTree(BlockPos pos, State state, Random rand) - { - WoodType type = state.getBlock() instanceof BlockSapling ? ((BlockSapling)state.getBlock()).getWoodType() : WoodType.OAK; - State log = type == WoodType.CHERRY ? Blocks.cherry_log.getState() : // .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.CHERRY) : - (type == WoodType.MAPLE ? Blocks.maple_log.getState() /* .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.MAPLE) */ : Blocks.oak_log.getState()); - WoodType leaves = type == WoodType.CHERRY || type == WoodType.MAPLE ? type : WoodType.OAK; - FeatureGenerator worldgenerator = (FeatureGenerator)(rand.chance(10) ? new WorldGenBigTree(true, log, leaves) : new WorldGenBaseTree(true, log, leaves)); - int i = 0; - int j = 0; - boolean flag = false; -// leaves = leaves.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()); - - switch (type) - { - case SPRUCE: - label114: - for (i = 0; i >= -1; --i) - { - for (j = 0; j >= -1; --j) - { - if (this.isSameSaplingTypeIn(pos, i, j, WoodType.SPRUCE)) - { - worldgenerator = new WorldGenPine(false, rand.chance()); - flag = true; - break label114; - } - } - } - - if (!flag) - { - j = 0; - i = 0; - worldgenerator = new WorldGenTaiga2(true); - } - - break; - - case BIRCH: - worldgenerator = new WorldGenBirch(true, false); - break; - - case TIAN: - worldgenerator = new WorldGenBigTree(true, Blocks.tian_log.getState(), WoodType.TIAN) - .setHeightLimit(6, 20); - break; - - case JUNGLE: - State iblockstate = Blocks.jungle_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE); - WoodType iblockstate1 = WoodType.JUNGLE; // .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE); // .withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); - label269: - - for (i = 0; i >= -1; --i) - { - for (j = 0; j >= -1; --j) - { - if (this.isSameSaplingTypeIn(pos, i, j, WoodType.JUNGLE)) - { - worldgenerator = new WorldGenJungle(true, 10, 20, iblockstate, iblockstate1); - flag = true; - break label269; - } - } - } - - if (!flag) - { - j = 0; - i = 0; - worldgenerator = new WorldGenBaseTree(true, rand.range(4, 10), iblockstate, iblockstate1, false); - } - - break; - - case ACACIA: - worldgenerator = new WorldGenSavanna(true); - break; - - case DARK_OAK: - label390: - for (i = 0; i >= -1; --i) - { - for (j = 0; j >= -1; --j) - { - if (this.isSameSaplingTypeIn(pos, i, j, WoodType.DARK_OAK)) - { - worldgenerator = new WorldGenDarkOak(true); - flag = true; - break label390; - } - } - } - - if (!flag) - { - return; - } - - case OAK: - case CHERRY: - case MAPLE: - } - - State iblockstate2 = Blocks.air.getState(); - - if (flag) - { - this.setState(pos.add(i, 0, j), iblockstate2, 4); - this.setState(pos.add(i + 1, 0, j), iblockstate2, 4); - this.setState(pos.add(i, 0, j + 1), iblockstate2, 4); - this.setState(pos.add(i + 1, 0, j + 1), iblockstate2, 4); - } - else - { - this.setState(pos, iblockstate2, 4); - } - - if (!worldgenerator.generate(this, rand, pos.add(i, 0, j))) - { - if (flag) - { - this.setState(pos.add(i, 0, j), state, 4); - this.setState(pos.add(i + 1, 0, j), state, 4); - this.setState(pos.add(i, 0, j + 1), state, 4); - this.setState(pos.add(i + 1, 0, j + 1), state, 4); - } - else - { - this.setState(pos, state, 4); - } - } - } - - public void growGrass(BlockPos pos, State state, Random rand) - { - BlockPos blockpos = pos.up(); - - for (int i = 0; i < 128; ++i) - { - BlockPos blockpos1 = blockpos; - int j = 0; - - while (true) - { - if (j >= i / 16) - { - if (this.getState(blockpos1).getBlock() == Blocks.air) - { - if (rand.chance(8)) - { - BlockFlower.EnumFlowerType blockflower$enumflowertype = rand.pick(BlockFlower.EnumFlowerType.ROSE, BlockFlower.EnumFlowerType.DANDELION, BlockFlower.EnumFlowerType.POPPY, BlockFlower.EnumFlowerType.DAISY); - BlockFlower blockflower = BlockFlower.getByType(blockflower$enumflowertype); - State iblockstate = blockflower.getState(); - - if (blockflower.canBlockStay(this, blockpos1, iblockstate)) - { - this.setState(blockpos1, iblockstate, 3); - } - } - else - { - State iblockstate1 = Blocks.tallgrass.getState(); - - if (Blocks.tallgrass.canBlockStay(this, blockpos1, iblockstate1)) - { - this.setState(blockpos1, iblockstate1, 3); - } - } - } - - break; - } - - blockpos1 = blockpos1.add(rand.zrange(3) - 1, (rand.zrange(3) - 1) * rand.zrange(3) / 2, rand.zrange(3) - 1); - - if (this.getState(blockpos1.down()).getBlock() != Blocks.grass || this.getState(blockpos1).getBlock().isNormalCube()) - { - break; - } - - ++j; - } - } - } private class PlayerInstance { private final List watching = Lists.newArrayList(); @@ -2890,7 +2642,7 @@ public final class WorldServer extends AWorldServer { ChunkServer chunk = WorldServer.this.getChunk(this.position.x, this.position.z); if(chunk.isPopulated()) { - player.connection.sendPacket(Player.getPacket(WorldServer.this, chunk, true, new int[0], WorldServer.this.dimension.hasSkyLight())); + player.connection.sendPacket(Player.getPacket(chunk, true, new int[0], WorldServer.this.dimension.hasSkyLight())); } this.watching.remove(player); @@ -2981,7 +2733,7 @@ public final class WorldServer extends AWorldServer { extend[n++] = i; } } - this.sendToAllPlayersWatchingChunk(Player.getPacket(WorldServer.this, WorldServer.this.getChunk(this.position.x, this.position.z), + this.sendToAllPlayersWatchingChunk(Player.getPacket(WorldServer.this.getChunk(this.position.x, this.position.z), this.biomes, extend, WorldServer.this.dimension.hasSkyLight())); if(this.biomes) { diff --git a/server/src/main/java/server/worldgen/BiomeGenLayered.java b/server/src/main/java/server/worldgen/BiomeGenLayered.java new file mode 100755 index 00000000..7c03681a --- /dev/null +++ b/server/src/main/java/server/worldgen/BiomeGenLayered.java @@ -0,0 +1,276 @@ +package server.worldgen; + +import java.util.List; +import java.util.Set; + +import common.biome.Biome; +import common.collect.Lists; +import common.util.BlockPos; +import common.util.LongHashMap; +import server.worldgen.layer.GenLayer; +import server.worldgen.layer.GenLayerAddAreas; +import server.worldgen.layer.GenLayerAddExtra; +import server.worldgen.layer.GenLayerAddSea; +import server.worldgen.layer.GenLayerAddSnow; +import server.worldgen.layer.GenLayerBase; +import server.worldgen.layer.GenLayerBiome; +import server.worldgen.layer.GenLayerBiomeEdge; +import server.worldgen.layer.GenLayerEdge; +import server.worldgen.layer.GenLayerFuzzyZoom; +import server.worldgen.layer.GenLayerHills; +import server.worldgen.layer.GenLayerRemoveEmpty; +import server.worldgen.layer.GenLayerRiver; +import server.worldgen.layer.GenLayerRiverInit; +import server.worldgen.layer.GenLayerRiverMix; +import server.worldgen.layer.GenLayerShore; +import server.worldgen.layer.GenLayerSmooth; +import server.worldgen.layer.GenLayerVoronoiZoom; +import server.worldgen.layer.GenLayerZoom; +import server.worldgen.layer.IntCache; + +public class BiomeGenLayered implements BiomeGenerator { + private class CacheBlock + { + public final double[] factors = new double[256]; + public final Biome[] biomes = new Biome[256]; + public int xPosition; + public int zPosition; + public long lastAccessTime; + + public CacheBlock(int x, int z) + { + this.xPosition = x; + this.zPosition = z; + BiomeGenLayered.this.getFactors(this.factors, x << 4, z << 4, 16, 16); + BiomeGenLayered.this.getBiomes(this.biomes, x << 4, z << 4, 16, 16, false); + } + + public Biome getBiomeGenAt(int x, int z) + { + return this.biomes[x & 15 | (z & 15) << 4]; + } + } + + private final GenLayer genBiomes; + private final GenLayer biomeIndexLayer; + private final LongHashMap cacheMap = new LongHashMap(); + private final List cache = Lists.newArrayList(); + private long lastCleanupTime; + +// public BiomeGenNew(long seed, GeneratorSettings options) { +// this(seed, options.biomeMode, options.fixedBiome, options.genMode == 2, options.biomeSize, +// options.riverSize, options.snowRarity, options.seaRarity, options.shroomRarity, options.biomeRarity); +// } + +// public BiomeGenLayered(Dimension dim, Random rand) { +// this(); +// } + + public BiomeGenLayered(long seed, Biome def, boolean fixed, int biomeSize, int riverSize, int snowRarity, int seaRarity, + Biome[] add, int addRarity, Biome[] hot, Biome[] medium, Biome[] cold, Biome[] frost) { +// GenLayer[] layers = GenLayer.getLayers(seed, fixedBiome, biomeSize, riverSize, snowRarity, seaRarity, shroomRarity, biomeRarity); + GenLayer layer0t1 = new GenLayerBase(1L); + layer0t1 = new GenLayerFuzzyZoom(2000L, layer0t1); + GenLayerAddAreas layer2 = new GenLayerAddAreas(1L, layer0t1); + GenLayerZoom layer3 = new GenLayerZoom(2001L, layer2); + GenLayerAddAreas layer4t6 = new GenLayerAddAreas(2L, layer3); + layer4t6 = new GenLayerAddAreas(50L, layer4t6); + layer4t6 = new GenLayerAddAreas(70L, layer4t6); + GenLayerRemoveEmpty layer7 = new GenLayerRemoveEmpty(2L, layer4t6); + GenLayerAddSnow layer8 = new GenLayerAddSnow(2L, layer7, snowRarity); + GenLayerAddAreas layer9 = new GenLayerAddAreas(3L, layer8); + GenLayerEdge layer10t12 = new GenLayerEdge(2L, layer9, GenLayerEdge.Mode.COOL_WARM); + layer10t12 = new GenLayerEdge(2L, layer10t12, GenLayerEdge.Mode.HEAT_ICE); +// layer10t12 = new GenLayerEdge(3L, layer10t12, GenLayerEdge.Mode.SPECIAL); + GenLayerZoom layer13t14 = new GenLayerZoom(2002L, layer10t12); + layer13t14 = new GenLayerZoom(2003L, layer13t14); + GenLayerAddAreas layer15 = new GenLayerAddAreas(4L, layer13t14); + GenLayerAddExtra layer16 = new GenLayerAddExtra(5L, layer15, add, addRarity); + GenLayerAddSea layer17 = new GenLayerAddSea(4L, layer16, seaRarity); + GenLayer layer18 = GenLayerZoom.magnify(1000L, layer17, 0); + GenLayer layer19 = GenLayerZoom.magnify(1000L, layer18, 0); + GenLayerRiverInit layer20 = new GenLayerRiverInit(100L, layer19); + GenLayerBiome layer21n = new GenLayerBiome(200L, layer18, hot, medium, cold, frost, def, fixed); + GenLayer layer22n = GenLayerZoom.magnify(1000L, layer21n, 2); + GenLayerBiomeEdge layer23n = new GenLayerBiomeEdge(1000L, layer22n); + GenLayer layer21l = GenLayerZoom.magnify(1000L, layer20, 2); + GenLayer layer24n = new GenLayerHills(1000L, layer23n, layer21l, def); + GenLayer layer21t22a = GenLayerZoom.magnify(1000L, layer20, 2); + layer21t22a = GenLayerZoom.magnify(1000L, layer21t22a, riverSize); + GenLayerRiver layer23a = new GenLayerRiver(1L, layer21t22a); + GenLayerSmooth layer24a = new GenLayerSmooth(1000L, layer23a); +// layer24n = new GenLayerRareBiome(1001L, layer24n, biomeRarity); + for(int k = 0; k < biomeSize; ++k) { + layer24n = new GenLayerZoom((long)(1000 + k), layer24n); + if(k == 0) { + layer24n = new GenLayerAddAreas(3L, layer24n); + } + if(k == 1 || biomeSize == 1) { + layer24n = new GenLayerShore(1000L, layer24n); + } + } + GenLayerSmooth layer25n = new GenLayerSmooth(1000L, layer24n); + GenLayerRiverMix layerOut = new GenLayerRiverMix(100L, layer25n, layer24a, def); + GenLayer layerIndex = // perlinGen ? new GenLayerRiverMix(100L, layer25n, layer24a) : + new GenLayerVoronoiZoom(10L, layerOut); + layerOut.initWorldGenSeed(seed); + layerIndex.initWorldGenSeed(seed); +// return new GenLayer[] {layerOut, layerIndex}; + this.genBiomes = layerOut; + this.biomeIndexLayer = layerIndex; + } + + private CacheBlock getBiomeCacheBlock(int x, int z) + { + x = x >> 4; + z = z >> 4; + long i = LongHashMap.packInt(x, z); // (long)x & 4294967295L | ((long)z & 4294967295L) << 32; + CacheBlock blk = this.cacheMap.getValueByKey(i); + + if (blk == null) + { + blk = new CacheBlock(x, z); + this.cacheMap.add(i, blk); + this.cache.add(blk); + } + + blk.lastAccessTime = System.currentTimeMillis(); + return blk; + } + + public void cleanupCache() + { + long i = System.currentTimeMillis(); + long j = i - this.lastCleanupTime; + + if (j > 7500L || j < 0L) + { + this.lastCleanupTime = i; + + for (int k = 0; k < this.cache.size(); ++k) + { + CacheBlock blk = this.cache.get(k); + long l = i - blk.lastAccessTime; + + if (l > 30000L || l < 0L) + { + this.cache.remove(k--); + long i1 = LongHashMap.packInt(blk.xPosition, blk.zPosition) ; // (long)biomecache$block.xPosition & 4294967295L | ((long)biomecache$block.zPosition & 4294967295L) << 32; + this.cacheMap.remove(i1); + } + } + } + } + + public Biome getBiomeGenerator(BlockPos pos, Biome def) { + int x = pos.getX(); + int z = pos.getZ(); + Biome biome = this.getBiomeCacheBlock(x, z).getBiomeGenAt(x, z); + return biome == null ? def : biome; + } + + public void getFactors(double[] listToReuse, int x, int z, int width, int length) { + IntCache.resetIntCache(); + + int[] aint = this.biomeIndexLayer.getInts(x, z, width, length); + + for(int i = 0; i < width * length; ++i) { + Biome biome = Biome.getBiomeDef(aint[i]); + listToReuse[i] = (double)biome.getFactor(); + } + } + + public void genFactors(double[] factors, int xPos, int zPos, int sizeX, int sizeZ) { + IntCache.resetIntCache(); + + if(sizeX == 16 && sizeZ == 16 && (xPos & 15) == 0 && (zPos & 15) == 0) { + double[] cachedFacts = this.getBiomeCacheBlock(xPos, zPos).factors; + System.arraycopy(cachedFacts, 0, factors, 0, sizeX * sizeZ); + } + else { + int[] aint = this.biomeIndexLayer.getInts(xPos, zPos, sizeX, sizeZ); + + for(int i = 0; i < sizeX * sizeZ; ++i) { + Biome biome = Biome.getBiomeDef(aint[i]); + factors[i] = (double)biome.getFactor(); + } + } + } + + public void getGenBiomes(Biome[] biomes, int x, int z, int width, int height) { + IntCache.resetIntCache(); + + int[] aint = this.genBiomes.getInts(x, z, width, height); + + for(int i = 0; i < width * height; ++i) { + biomes[i] = Biome.getBiomeDef(aint[i]); + } + } + + public void getChunkBiomes(Biome[] oldBiomeList, int x, int z, int width, int depth) { + this.getBiomes(oldBiomeList, x, z, width, depth, true); + } + + public void getBiomes(Biome[] listToReuse, int x, int z, int width, int length, boolean cache) { + IntCache.resetIntCache(); + + if(cache && width == 16 && length == 16 && (x & 15) == 0 && (z & 15) == 0) { + Biome[] biomes = this.getBiomeCacheBlock(x, z).biomes; + System.arraycopy(biomes, 0, listToReuse, 0, width * length); + } + else { + int[] aint = this.biomeIndexLayer.getInts(x, z, width, length); + + for(int i = 0; i < width * length; ++i) { + listToReuse[i] = Biome.getBiomeDef(aint[i]); + } + } + } + + public boolean areBiomesViable(int x, int z, int size, Set allowed) { + IntCache.resetIntCache(); + int i = x - size >> 2; + int j = z - size >> 2; + int k = x + size >> 2; + int l = z + size >> 2; + int i1 = k - i + 1; + int j1 = l - j + 1; + int[] aint = this.genBiomes.getInts(i, j, i1, j1); + + for(int k1 = 0; k1 < i1 * j1; ++k1) { + Biome biome = Biome.getBiome(aint[k1]); + + if(!allowed.contains(biome)) { + return false; + } + } + + return true; + } + +// public BlockPos findBiomePosition(int x, int z, int range, Set biomes, Random rand) { +// IntCache.resetIntCache(); +// int x1 = x - range >> 2; +// int z1 = z - range >> 2; +// int x2 = x + range >> 2; +// int z2 = z + range >> 2; +// int xs = x2 - x1 + 1; +// int zs = z2 - z1 + 1; +// int[] ints = this.genBiomes.getInts(x1, z1, xs, zs); +// BlockPos pos = null; +// int count = 0; +// +// for(int n = 0; n < xs * zs; ++n) { +// int bx = x1 + n % xs << 2; +// int bz = z1 + n / xs << 2; +// Biome biome = Biome.getBiome(ints[n]); +// +// if(biomes.contains(biome) && (pos == null || rand.zrange(count + 1) == 0)) { +// pos = new BlockPos(bx, 0, bz); +// ++count; +// } +// } +// +// return pos; +// } +} diff --git a/server/src/main/java/server/worldgen/BiomeGenSingle.java b/server/src/main/java/server/worldgen/BiomeGenSingle.java new file mode 100755 index 00000000..cd5bade8 --- /dev/null +++ b/server/src/main/java/server/worldgen/BiomeGenSingle.java @@ -0,0 +1,47 @@ +package server.worldgen; + +import java.util.Arrays; +import java.util.Set; + +import common.biome.Biome; +import common.util.BlockPos; + +public class BiomeGenSingle implements BiomeGenerator { + private final Biome biome; + + public BiomeGenSingle(Biome biome) { + this.biome = biome; + } + + public Biome getBiomeGenerator(BlockPos pos, Biome def) { + return this.biome; + } + + public void getGenBiomes(Biome[] biomes, int x, int z, int width, int height) { + Arrays.fill(biomes, 0, width * height, this.biome); + } + + public void getChunkBiomes(Biome[] oldBiomeList, int x, int z, int width, int depth) { + Arrays.fill(oldBiomeList, 0, width * depth, this.biome); + } + + public void getBiomes(Biome[] listToReuse, int x, int z, int width, int length, boolean cache) { + Arrays.fill(listToReuse, 0, width * length, this.biome); + } + +// public BlockPos findBiomePosition(int x, int z, int range, Set biomes, Random random) { +// return biomes.contains(this.biome) ? new BlockPos(x - range + random.zrange(range * 2 + 1), 0, z - range + random.zrange(range * 2 + 1)) +// : null; +// } + + public boolean areBiomesViable(int x, int z, int size, Set allowed) { + return allowed.contains(this.biome); + } + + public void cleanupCache() { + } + + public void genFactors(double[] factors, int xPos, int zPos, int sizeX, int sizeZ) { + Arrays.fill(factors, 0, sizeX * sizeZ, this.biome.getFactor()); + } +} diff --git a/server/src/main/java/server/worldgen/BiomeGenerator.java b/server/src/main/java/server/worldgen/BiomeGenerator.java index 663b1a7e..6d755688 100755 --- a/server/src/main/java/server/worldgen/BiomeGenerator.java +++ b/server/src/main/java/server/worldgen/BiomeGenerator.java @@ -1,243 +1,16 @@ package server.worldgen; -import java.util.List; +import java.util.Set; + import common.biome.Biome; -import common.biome.Scaling; -import common.collect.Lists; import common.util.BlockPos; -import common.util.LongHashMap; -import server.worldgen.layer.GenLayer; -import server.worldgen.layer.GenLayerAddAreas; -import server.worldgen.layer.GenLayerAddExtra; -import server.worldgen.layer.GenLayerAddSea; -import server.worldgen.layer.GenLayerAddSnow; -import server.worldgen.layer.GenLayerBase; -import server.worldgen.layer.GenLayerBiome; -import server.worldgen.layer.GenLayerEdge; -import server.worldgen.layer.GenLayerFuzzyZoom; -import server.worldgen.layer.GenLayerRemoveEmpty; -import server.worldgen.layer.GenLayerRiver; -import server.worldgen.layer.GenLayerRiverInit; -import server.worldgen.layer.GenLayerRiverMix; -import server.worldgen.layer.GenLayerSmooth; -import server.worldgen.layer.GenLayerVoronoiZoom; -import server.worldgen.layer.GenLayerZoom; -import server.worldgen.layer.IntCache; -public class BiomeGenerator { - private class CacheBlock - { - public final double[] factors = new double[256]; - public final Biome[] biomes = new Biome[256]; - public int xPosition; - public int zPosition; - public long lastAccessTime; - - public CacheBlock(int x, int z) - { - this.xPosition = x; - this.zPosition = z; - BiomeGenerator.this.getFactors(this.factors, x << 4, z << 4, 16, 16); - BiomeGenerator.this.getBiomes(this.biomes, x << 4, z << 4, 16, 16, false); - } - - public Biome getBiomeGenAt(int x, int z) - { - return this.biomes[x & 15 | (z & 15) << 4]; - } - } - - private final GenLayer genBiomes; - private final GenLayer biomeIndexLayer; - private final LongHashMap cacheMap = new LongHashMap(); - private final List cache = Lists.newArrayList(); - private final Biome[] biomes; - private final Biome defBiome; - private long lastCleanupTime; - - public BiomeGenerator(long seed, Biome def, boolean fixed, int biomeSize, int riverSize, int snowRarity, int seaRarity, - Biome[] add, int addRarity, Biome[] hot, Biome[] medium, Biome[] cold, Biome[] frost) { - this.biomes = new Biome[5 + hot.length + medium.length + cold.length + frost.length + add.length]; - this.defBiome = this.biomes[GenLayer.NONE] = def; - this.biomes[GenLayer.RIVER] = new Biome(0.0f, 50.0f, Scaling.SEA_SHALLOW); - this.biomes[GenLayer.SEA] = new Biome(0.0f, 50.0f, Scaling.SEA_MEDIUM); - this.biomes[GenLayer.ICE_RIVER] = new Biome(-20.0f, 50.0f, Scaling.SEA_SHALLOW); - this.biomes[GenLayer.ICE_SEA] = new Biome(-20.0f, 50.0f, Scaling.SEA_MEDIUM); - int n = 5; - for(Biome biome : frost) { - this.biomes[n++] = biome; - } - for(Biome biome : cold) { - this.biomes[n++] = biome; - } - for(Biome biome : medium) { - this.biomes[n++] = biome; - } - for(Biome biome : hot) { - this.biomes[n++] = biome; - } - for(Biome biome : add) { - this.biomes[n++] = biome; - } - for(int z = 0; z < this.biomes.length; z++) { - this.biomes[z].id = z; - } - - GenLayer layer0t1 = new GenLayerBase(1L); - layer0t1 = new GenLayerFuzzyZoom(2000L, layer0t1); - GenLayerAddAreas layer2 = new GenLayerAddAreas(1L, layer0t1); - GenLayerZoom layer3 = new GenLayerZoom(2001L, layer2); - GenLayerAddAreas layer4t6 = new GenLayerAddAreas(2L, layer3); - layer4t6 = new GenLayerAddAreas(50L, layer4t6); - layer4t6 = new GenLayerAddAreas(70L, layer4t6); - GenLayerRemoveEmpty layer7 = new GenLayerRemoveEmpty(2L, layer4t6); - GenLayerAddSnow layer8 = new GenLayerAddSnow(2L, layer7, snowRarity); - GenLayerAddAreas layer9 = new GenLayerAddAreas(3L, layer8); - GenLayerEdge layer10t12 = new GenLayerEdge(2L, layer9, GenLayerEdge.Mode.COOL_WARM); - layer10t12 = new GenLayerEdge(2L, layer10t12, GenLayerEdge.Mode.HEAT_ICE); -// layer10t12 = new GenLayerEdge(3L, layer10t12, GenLayerEdge.Mode.SPECIAL); - GenLayerZoom layer13t14 = new GenLayerZoom(2002L, layer10t12); - layer13t14 = new GenLayerZoom(2003L, layer13t14); - GenLayerAddAreas layer15 = new GenLayerAddAreas(4L, layer13t14); - GenLayerAddExtra layer16 = new GenLayerAddExtra(5L, layer15, add, addRarity); - GenLayerAddSea layer17 = new GenLayerAddSea(4L, layer16, seaRarity); - GenLayer layer18 = GenLayerZoom.magnify(1000L, layer17, 0); - GenLayer layer19 = GenLayerZoom.magnify(1000L, layer18, 0); - GenLayerRiverInit layer20 = new GenLayerRiverInit(100L, layer19); - GenLayerBiome layer21n = new GenLayerBiome(200L, layer18, hot, medium, cold, frost, def, fixed); - GenLayer layer22n = GenLayerZoom.magnify(1000L, layer21n, 2); - GenLayer layer21t22a = GenLayerZoom.magnify(1000L, layer20, 2); - layer21t22a = GenLayerZoom.magnify(1000L, layer21t22a, riverSize); - GenLayerRiver layer23a = new GenLayerRiver(1L, layer21t22a); - GenLayerSmooth layer24a = new GenLayerSmooth(1000L, layer23a); -// layer24n = new GenLayerRareBiome(1001L, layer24n, biomeRarity); - for(int k = 0; k < biomeSize; ++k) { - layer22n = new GenLayerZoom((long)(1000 + k), layer22n); - if(k == 0) { - layer22n = new GenLayerAddAreas(3L, layer22n); - } - } - GenLayerSmooth layer25n = new GenLayerSmooth(1000L, layer22n); - GenLayerRiverMix layerOut = new GenLayerRiverMix(100L, layer25n, layer24a, def, frost); - GenLayer layerIndex = // perlinGen ? new GenLayerRiverMix(100L, layer25n, layer24a) : - new GenLayerVoronoiZoom(10L, layerOut); - layerOut.initWorldGenSeed(seed); - layerIndex.initWorldGenSeed(seed); -// return new GenLayer[] {layerOut, layerIndex}; - this.genBiomes = layerOut; - this.biomeIndexLayer = layerIndex; - } - - private CacheBlock getBiomeCacheBlock(int x, int z) - { - x = x >> 4; - z = z >> 4; - long i = LongHashMap.packInt(x, z); // (long)x & 4294967295L | ((long)z & 4294967295L) << 32; - CacheBlock blk = this.cacheMap.getValueByKey(i); - - if (blk == null) - { - blk = new CacheBlock(x, z); - this.cacheMap.add(i, blk); - this.cache.add(blk); - } - - blk.lastAccessTime = System.currentTimeMillis(); - return blk; - } - - public void cleanupCache() - { - long i = System.currentTimeMillis(); - long j = i - this.lastCleanupTime; - - if (j > 7500L || j < 0L) - { - this.lastCleanupTime = i; - - for (int k = 0; k < this.cache.size(); ++k) - { - CacheBlock blk = this.cache.get(k); - long l = i - blk.lastAccessTime; - - if (l > 30000L || l < 0L) - { - this.cache.remove(k--); - long i1 = LongHashMap.packInt(blk.xPosition, blk.zPosition) ; // (long)biomecache$block.xPosition & 4294967295L | ((long)biomecache$block.zPosition & 4294967295L) << 32; - this.cacheMap.remove(i1); - } - } - } - } - - private Biome getBiome(int id) - { - return id < 0 || id >= this.biomes.length || this.biomes[id] == null ? this.defBiome : this.biomes[id]; - } - - public Biome getBiomeAt(BlockPos pos) { - int x = pos.getX(); - int z = pos.getZ(); - Biome biome = this.getBiomeCacheBlock(x, z).getBiomeGenAt(x, z); - return biome == null ? this.defBiome : biome; - } - - public Biome getBiomeAt(int x, int z) { - Biome biome = this.getBiomeCacheBlock(x, z).getBiomeGenAt(x, z); - return biome == null ? this.defBiome : biome; - } - - private void getFactors(double[] listToReuse, int x, int z, int width, int length) { - IntCache.resetIntCache(); - - int[] aint = this.biomeIndexLayer.getInts(x, z, width, length); - - for(int i = 0; i < width * length; ++i) { - listToReuse[i] = (double)this.getBiome(aint[i]).factor; - } - } - - public void genFactors(double[] factors, int xPos, int zPos, int sizeX, int sizeZ) { - IntCache.resetIntCache(); - - if(sizeX == 16 && sizeZ == 16 && (xPos & 15) == 0 && (zPos & 15) == 0) { - double[] cachedFacts = this.getBiomeCacheBlock(xPos, zPos).factors; - System.arraycopy(cachedFacts, 0, factors, 0, sizeX * sizeZ); - } - else { - int[] aint = this.biomeIndexLayer.getInts(xPos, zPos, sizeX, sizeZ); - - for(int i = 0; i < sizeX * sizeZ; ++i) { - factors[i] = (double)this.getBiome(aint[i]).factor; - } - } - } - - public void genScaling(float[] depths, float[] scales, int x, int z, int width, int height) { - IntCache.resetIntCache(); - - int[] aint = this.genBiomes.getInts(x, z, width, height); - - for(int i = 0; i < width * height; ++i) { - Biome biome = this.getBiome(aint[i]); - depths[i] = biome.depth; - scales[i] = biome.scale; - } - } - - private void getBiomes(Biome[] listToReuse, int x, int z, int width, int length, boolean cache) { - IntCache.resetIntCache(); - - if(cache && width == 16 && length == 16 && (x & 15) == 0 && (z & 15) == 0) { - Biome[] biomes = this.getBiomeCacheBlock(x, z).biomes; - System.arraycopy(biomes, 0, listToReuse, 0, width * length); - } - else { - int[] aint = this.biomeIndexLayer.getInts(x, z, width, length); - - for(int i = 0; i < width * length; ++i) { - listToReuse[i] = this.getBiome(aint[i]); - } - } - } +public interface BiomeGenerator { + public void genFactors(double[] factors, int xPos, int zPos, int sizeX, int sizeZ); + public Biome getBiomeGenerator(BlockPos pos, Biome def); + public void getGenBiomes(Biome[] biomes, int x, int z, int width, int height); + public void getChunkBiomes(Biome[] oldBiomeList, int x, int z, int width, int depth); + public void getBiomes(Biome[] listToReuse, int x, int z, int width, int length, boolean cacheFlag); + public boolean areBiomesViable(int x, int z, int size, Set allowed); + public void cleanupCache(); } diff --git a/server/src/main/java/server/worldgen/BlockReplacer.java b/server/src/main/java/server/worldgen/BlockReplacer.java index b51db465..ab5cb4e3 100755 --- a/server/src/main/java/server/worldgen/BlockReplacer.java +++ b/server/src/main/java/server/worldgen/BlockReplacer.java @@ -1,8 +1,9 @@ package server.worldgen; +import common.biome.Biome; import common.rng.Random; import server.world.WorldServer; public interface BlockReplacer { - public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand); + public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes); } diff --git a/server/src/main/java/server/worldgen/FeatureLakes.java b/server/src/main/java/server/worldgen/FeatureLakes.java index bb94eb1f..e641cf41 100755 --- a/server/src/main/java/server/worldgen/FeatureLakes.java +++ b/server/src/main/java/server/worldgen/FeatureLakes.java @@ -8,6 +8,7 @@ import common.util.BlockPos; import common.world.LightType; import common.world.State; import server.world.WorldServer; +import server.worldgen.biome.GenBiome; public class FeatureLakes { @@ -108,9 +109,6 @@ public class FeatureLakes } } - Block replace = this.top != null ? worldIn.dimension.getSurface().getBlock() : null; - boolean useTop = false; - for (int k1 = 0; k1 < 16; ++k1) { for (int l2 = 0; l2 < 16; ++l2) @@ -121,21 +119,17 @@ public class FeatureLakes if (flag) { - State state = worldIn.getState(position.add(k1, k, l2)); - Material material = state.getBlock().getMaterial(); + Material material = worldIn.getState(position.add(k1, k, l2)).getBlock().getMaterial(); if (k >= 4 && material.isLiquid()) { return false; } - if (k < 4 && !material.isSolid() && state.getBlock() != this.block) + if (k < 4 && !material.isSolid() && worldIn.getState(position.add(k1, k, l2)).getBlock() != this.block) { return false; } - - if(replace != null && !useTop && state.getBlock() == replace) - useTop = true; } } } @@ -155,8 +149,8 @@ public class FeatureLakes } } - if(useTop) { - replace = worldIn.dimension.getTop().getBlock(); + if(this.top != null) { + Block replace = worldIn.dimension.getTop().getBlock(); for (int i2 = 0; i2 < 16; ++i2) { for (int j3 = 0; j3 < 16; ++j3) @@ -169,7 +163,16 @@ public class FeatureLakes if (worldIn.getState(blockpos).getBlock() == replace && worldIn.getLightFor(LightType.SKY, position.add(i2, j4, j3)) > 0) { - worldIn.setState(blockpos, this.top, 2); + GenBiome biomegenbase = GenBiome.BIOMES[worldIn.getBiomeGenForCoords(blockpos).id]; + + if (biomegenbase.topBlock.getBlock() == Blocks.mycelium) + { + worldIn.setState(blockpos, Blocks.mycelium.getState(), 2); + } + else + { + worldIn.setState(blockpos, this.top, 2); + } } } } diff --git a/server/src/main/java/server/worldgen/GeneratorPerlin.java b/server/src/main/java/server/worldgen/GeneratorPerlin.java index c916cc77..1a4bd0e8 100755 --- a/server/src/main/java/server/worldgen/GeneratorPerlin.java +++ b/server/src/main/java/server/worldgen/GeneratorPerlin.java @@ -1,7 +1,6 @@ package server.worldgen; -import java.util.Arrays; - +import common.biome.Biome; import common.dimension.Dimension; import common.rng.NoiseGen; import common.rng.OctaveGen; @@ -9,6 +8,7 @@ import common.rng.Random; import common.util.ExtMath; import common.world.State; import server.world.WorldServer; +import server.worldgen.biome.GenBiome; public class GeneratorPerlin implements ChunkGenerator { @@ -52,8 +52,7 @@ public class GeneratorPerlin implements ChunkGenerator private final double[] lowerNoise = new double[825]; private final double[] upperNoise = new double[825]; private final double[] depthNoise = new double[25]; - private final float[] depths = new float[100]; - private final float[] scales = new float[100]; + private final Biome[] biomes = new Biome[100]; // public GeneratorNew(Random rand, GeneratorSettings settings) // { @@ -64,12 +63,6 @@ public class GeneratorPerlin implements ChunkGenerator // settings.mainNoiseScaleY, settings.mainNoiseScaleZ, settings.baseSize, settings.stretchY, settings.biomeDepthWeight, // settings.biomeDepthOffset, settings.biomeScaleWeight, settings.biomeScaleOffset); // } - - public GeneratorPerlin(Random rand, State block, State liquid, Dimension.GeneratorSettings settings, float depth, float scale) { - this(rand, block, liquid, settings); - Arrays.fill(this.depths, depth); - Arrays.fill(this.scales, scale); - } public GeneratorPerlin(Random rand, State block, State liquid, Dimension.GeneratorSettings settings) { this(rand, /* dim.hasFarLands(), dim.getSeaLevel(), */ block, liquid, @@ -115,9 +108,8 @@ public class GeneratorPerlin implements ChunkGenerator public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer) { - int sea = world.getSeaLevel(); - if(world.getBiomeGenerator() != null) - world.getBiomeGenerator().genScaling(this.depths, this.scales, x * 4 - 2, z * 4 - 2, 10, 10); + int sea = world.getSeaLevel(); + world.getBiomeGenerator().getGenBiomes(this.biomes, x * 4 - 2, z * 4 - 2, 10, 10); this.genNoisemap(x * 4, 0, z * 4); for (int xb = 0; xb < 4; ++xb) @@ -204,18 +196,16 @@ public class GeneratorPerlin implements ChunkGenerator float max = 0.0F; float min = 0.0F; float sum = 0.0F; - int range = 2; - float depth1 = this.depths[u + 2 + (v + 2) * 10]; - float scale1 = this.scales[u + 2 + (v + 2) * 10]; + int range = 2; + GenBiome biome = GenBiome.BIOMES[this.biomes[u + 2 + (v + 2) * 10].id]; for (int a = -range; a <= range; ++a) { for (int b = -range; b <= range; ++b) - { - float depth2 = this.depths[u + a + 2 + (v + b + 2) * 10]; - float scale2 = this.scales[u + a + 2 + (v + b + 2) * 10]; - float bmin = this.biomeDepthOffset + depth2 * this.biomeDepthWeight; - float bmax = this.biomeScaleOffset + scale2 * this.biomeScaleWeight; + { + GenBiome biome2 = GenBiome.BIOMES[this.biomes[u + a + 2 + (v + b + 2) * 10].id]; + float bmin = this.biomeDepthOffset + biome2.depth * this.biomeDepthWeight; + float bmax = this.biomeScaleOffset + biome2.scale * this.biomeScaleWeight; if (this.amplification > 0.0F && bmin > 0.0F) { @@ -225,7 +215,7 @@ public class GeneratorPerlin implements ChunkGenerator float fact = PARABOLIC[a + 2 + (b + 2) * 5] / (bmin + 2.0F); - if (depth2 > depth1) + if (biome2.depth > biome.depth) { fact /= 2.0F; } diff --git a/server/src/main/java/server/worldgen/GeneratorSimple.java b/server/src/main/java/server/worldgen/GeneratorSimple.java index 8f51cdfa..0f842012 100755 --- a/server/src/main/java/server/worldgen/GeneratorSimple.java +++ b/server/src/main/java/server/worldgen/GeneratorSimple.java @@ -1,7 +1,5 @@ package server.worldgen; -import java.util.Arrays; - import common.rng.NoiseGen; import common.rng.OctaveGen; import common.rng.Random; @@ -58,10 +56,10 @@ public class GeneratorSimple implements ChunkGenerator public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer) { - if(this.biomeGen != null) - this.biomeGen.generate(this.factors, x, z); - else if(world.getBiomeGenerator() != null) + if(this.biomeGen == null) world.getBiomeGenerator().genFactors(this.factors, x * 16, z * 16, 16, 16); + else + this.biomeGen.generate(this.factors, x, z); byte range = 4; int sea = world.getSeaLevel(); int xr = range + 1; diff --git a/server/src/main/java/server/worldgen/MobConstants.java b/server/src/main/java/server/worldgen/MobConstants.java index cccc71ce..fdf88815 100644 --- a/server/src/main/java/server/worldgen/MobConstants.java +++ b/server/src/main/java/server/worldgen/MobConstants.java @@ -1,11 +1,11 @@ package server.worldgen; -import common.dimension.RngSpawn; import common.entity.npc.EntityDarkMage; import common.entity.npc.EntityMage; import common.entity.npc.EntityTiefling; import common.entity.npc.EntityUndead; import common.rng.WeightedList; +import server.worldgen.biome.RngSpawn; public abstract class MobConstants { public static final WeightedList MAGEHUT_MOBS = new WeightedList(new RngSpawn(EntityMage.class, 1, 1, 1)); diff --git a/server/src/main/java/server/worldgen/ReplacerAltBiome.java b/server/src/main/java/server/worldgen/ReplacerAltBiome.java index 2321318d..66549f0f 100755 --- a/server/src/main/java/server/worldgen/ReplacerAltBiome.java +++ b/server/src/main/java/server/worldgen/ReplacerAltBiome.java @@ -1,5 +1,6 @@ package server.worldgen; +import common.biome.Biome; import common.block.Block; import common.init.Blocks; import common.rng.NoiseGen; @@ -7,6 +8,7 @@ import common.rng.OctaveGen; import common.rng.Random; import common.world.State; import server.world.WorldServer; +import server.worldgen.biome.GenBiome; public class ReplacerAltBiome implements BlockReplacer { @@ -14,8 +16,6 @@ public class ReplacerAltBiome implements BlockReplacer private final NoiseGen exclNoiseGen; private final State filler; - private final State top; - private final State surface; private final State liquid; private final State alt1; private final State alt2; @@ -36,7 +36,7 @@ public class ReplacerAltBiome implements BlockReplacer // this(rand, /* dim.hasFarLands(), */ dim.getFiller(), dim.getLiquid(), dim.getAltFiller2(), dim.getAltFiller1()); // } - public ReplacerAltBiome(Random rand, /* boolean farlands, */ State surface, State top, State filler, State liquid, State alt1, State alt2) + public ReplacerAltBiome(Random rand, /* boolean farlands, */ State filler, State liquid, State alt1, State alt2) { this.altNoiseGen = /* farlands ? new OctaveGenOld(rand, 4) : */ new OctaveGen(rand, 4); this.exclNoiseGen = /* farlands ? new OctaveGenOld(rand, 4) : */ new OctaveGen(rand, 4); @@ -45,11 +45,9 @@ public class ReplacerAltBiome implements BlockReplacer this.alt1 = alt1; this.alt2 = alt2; this.block = filler.getBlock(); - this.surface = surface; - this.top = top; } - public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand) + public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes) { int seaLevel = world.getSeaLevel(); double scale = 0.03125D; @@ -60,12 +58,13 @@ public class ReplacerAltBiome implements BlockReplacer { for(int px = 0; px < 16; px++) { + GenBiome biome = GenBiome.BIOMES[biomes[pz * 16 + px].id]; boolean alt2 = this.alt2Noise[pz + px * 16] + rand.doublev() * 0.20000000000000001D > 0.0D; boolean alt1 = this.alt1Noise[px + pz * 16] + rand.doublev() * 0.20000000000000001D > 3D; int excl = (int)(this.exclNoise[pz + px * 16] / 3D + 3D + rand.doublev() * 0.25D); int rockHeight = -1; - State topBlock = this.surface; - State fillerBlock = this.top; + State topBlock = biome.topBlock; + State fillerBlock = biome.fillerBlock; for(int py = primer.height - 1; py >= 0; py--) { Block currentBlock = primer.get(px, py, pz).getBlock(); @@ -87,8 +86,8 @@ public class ReplacerAltBiome implements BlockReplacer } else if(py >= seaLevel - 4 && py <= seaLevel + 1) { - topBlock = this.surface; - fillerBlock = this.top; + topBlock = biome.topBlock; + fillerBlock = biome.fillerBlock; if(alt1) { topBlock = Blocks.air.getState(); diff --git a/server/src/main/java/server/worldgen/ReplacerAltSimple.java b/server/src/main/java/server/worldgen/ReplacerAltSimple.java deleted file mode 100644 index 06874629..00000000 --- a/server/src/main/java/server/worldgen/ReplacerAltSimple.java +++ /dev/null @@ -1,108 +0,0 @@ -package server.worldgen; - -import common.init.Blocks; -import common.rng.Random; -import common.util.BlockPos; -import common.world.State; -import common.world.World; -import server.world.WorldServer; - -public class ReplacerAltSimple extends ReplacerBiome -{ - protected final State alt; - protected final State surface; - protected final State top; - - public ReplacerAltSimple(Random rand, State surface, State top, State filler, State alt, State liquid, int seaLevel) - { - super(rand, filler, liquid, seaLevel); - this.alt = alt; - this.surface = surface; - this.top = top; - } - - public void genTerrainBlocks(WorldServer world, Random rand, ChunkPrimer primer, int x, int z, double noise) { - this.genTerrainBlocks(world, rand, primer, x, z, noise, this.surface, this.top); - } - - protected State adjust(State current) { - return current; - } - - protected final void genTerrainBlocks(WorldServer world, Random rand, ChunkPrimer primer, int x, int z, double noise, State baseSurface, State baseTop) - { - State surface = baseSurface; - State top = baseTop; - State adjusted; - int sel = -1; - int rng = (int)(noise / 3.0D + 3.0D + rand.doublev() * 0.25D); - int bx = x & 15; - int bz = z & 15; - BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); - - for (int by = primer.height - 1; by >= 0; by--) - { - State current = primer.get(bz, by, bx); - - if (current.getBlock() == Blocks.air) - { - sel = -1; - } - else if (current.getBlock() == this.fillerBlock) - { - if (sel == -1) - { - if (rng <= 0) - { - surface = null; - top = this.filler; - } - else if (by >= this.seaLevel - 4 && by <= this.seaLevel + 1) - { - surface = baseSurface; - top = baseTop; - } - - if (by < this.seaLevel && (surface == null || surface.getBlock() == Blocks.air)) - { - if (this.freeze && world.getTemperatureC(pos.set((x & ~15) | bz, by, (z & ~15) | bx)) <= 0.0F) - { - surface = Blocks.ice.getState(); - } - else - { - surface = this.liquid; - } - } - - sel = rng; - - if (by >= this.seaLevel - 1) - { - primer.set(bz, by, bx, surface); - } - else if (by < this.seaLevel - 7 - rng) - { - surface = null; - top = this.filler; - primer.set(bz, by, bx, this.alt); - } - else - { - primer.set(bz, by, bx, top); - } - } - else if (sel > 0) - { - --sel; - primer.set(bz, by, bx, top); - if (sel == 0 && (adjusted = this.adjust(top)) != top) - { - sel = rand.zrange(4) + Math.max(0, by - 63); - top = adjusted; - } - } - } - } - } -} diff --git a/server/src/main/java/server/worldgen/ReplacerAltSurface.java b/server/src/main/java/server/worldgen/ReplacerAltSurface.java index 0c107a22..e3daac10 100755 --- a/server/src/main/java/server/worldgen/ReplacerAltSurface.java +++ b/server/src/main/java/server/worldgen/ReplacerAltSurface.java @@ -1,5 +1,6 @@ package server.worldgen; +import common.biome.Biome; import common.block.Block; import common.init.Blocks; import common.rng.OctaveGen; @@ -37,7 +38,7 @@ public class ReplacerAltSurface implements BlockReplacer this.fillerBlock = filler.getBlock(); } - public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand) + public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes) { int i = world.getSeaLevel() + 1; double d0 = 0.03125D; diff --git a/server/src/main/java/server/worldgen/ReplacerBiome.java b/server/src/main/java/server/worldgen/ReplacerBiome.java index e0d140ed..945755b4 100755 --- a/server/src/main/java/server/worldgen/ReplacerBiome.java +++ b/server/src/main/java/server/worldgen/ReplacerBiome.java @@ -1,45 +1,33 @@ package server.worldgen; -import common.block.Block; -import common.block.Material; +import common.biome.Biome; import common.rng.PerlinGen; import common.rng.Random; -import common.world.State; import server.world.WorldServer; +import server.worldgen.biome.GenBiome; -public abstract class ReplacerBiome implements BlockReplacer +public class ReplacerBiome implements BlockReplacer { private final PerlinGen stoneNoiseGen; - private final double[] stoneNoise = new double[256]; - protected final int seaLevel; - protected final State filler; - protected final Block fillerBlock; - protected final State liquid; - protected final boolean freeze; + private final double[] stoneNoise = new double[256]; - public ReplacerBiome(Random rand, State filler, State liquid, int seaLevel) + public ReplacerBiome(Random rand) { this.stoneNoiseGen = new PerlinGen(rand, 4); - this.seaLevel = seaLevel; - this.filler = filler; - this.fillerBlock = filler.getBlock(); - this.liquid = liquid; - this.freeze = liquid.getBlock().getMaterial() == Material.WATER; } - public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand) + public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes) { - double m = 0.03125D; - this.stoneNoiseGen.generate(this.stoneNoise, (double)(x * 16), (double)(z * 16), 16, 16, m * 2.0D, m * 2.0D, 1.0D); + double d0 = 0.03125D; + this.stoneNoiseGen.generate(this.stoneNoise, (double)(x * 16), (double)(z * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); - for (int px = 0; px < 16; ++px) + for (int i = 0; i < 16; ++i) { - for (int pz = 0; pz < 16; ++pz) + for (int j = 0; j < 16; ++j) { - this.genTerrainBlocks(world, rand, primer, x * 16 + px, z * 16 + pz, this.stoneNoise[pz + px * 16]); + GenBiome biome = GenBiome.BIOMES[biomes[j + i * 16].id]; + biome.genTerrainBlocks(world, rand, primer, x * 16 + i, z * 16 + j, this.stoneNoise[j + i * 16]); } } } - - protected abstract void genTerrainBlocks(WorldServer world, Random rand, ChunkPrimer primer, int x, int z, double noise); } diff --git a/server/src/main/java/server/worldgen/ReplacerMesa.java b/server/src/main/java/server/worldgen/ReplacerMesa.java deleted file mode 100644 index 53c966dc..00000000 --- a/server/src/main/java/server/worldgen/ReplacerMesa.java +++ /dev/null @@ -1,257 +0,0 @@ -package server.worldgen; - -import java.util.Arrays; - -import common.block.natural.BlockColoredClay; -import common.init.Blocks; -import common.rng.PerlinGen; -import common.rng.Random; -import common.world.State; -import server.world.WorldServer; - -public class ReplacerMesa extends ReplacerBiome -{ - private final State[] layers; - private final PerlinGen baseBryceGen; - private final PerlinGen highBryceGen; - private final PerlinGen clayColorGen; - private final PerlinGen soilGen; - private final PerlinGen peakGen; - private final State surface; - - public ReplacerMesa(Random rand, State filler, State liquid, int seaLevel, State surface) { - super(rand, filler, liquid, seaLevel); - this.layers = new State[64]; - Arrays.fill(this.layers, Blocks.hardened_clay.getState()); - this.clayColorGen = new PerlinGen(rand, 1); - this.baseBryceGen = new PerlinGen(rand, 4); - this.highBryceGen = new PerlinGen(rand, 1); - this.soilGen = new PerlinGen(rand, 8); - this.peakGen = new PerlinGen(rand, 8); - this.setupLayers(rand); - this.surface = surface; - } - - private State getBlockAt(int x, int y, int z) - { - int i = (int)Math.round(this.clayColorGen.generate((double)x * 1.0D / 512.0D, (double)x * 1.0D / 512.0D) * 2.0D); - return this.layers[(y + i + 64) % 64]; - } - - public void genTerrainBlocks(WorldServer world, Random rand, ChunkPrimer primer, int x, int z, double noise) - { - boolean soil = this.soilGen.generate((double)x * 0.5D, (double)z * 0.5D) > 0.1; - boolean peak = this.peakGen.generate((double)x * 0.5D, (double)z * 0.5D) > 0.1; - - double d4 = 0.0D; - - if (peak) - { - int i = (x & -16) + (z & 15); - int j = (z & -16) + (x & 15); - double d0 = Math.min(Math.abs(noise), this.baseBryceGen.generate((double)i * 0.25D, (double)j * 0.25D)); - - if (d0 > 0.0D) - { - double d1 = 0.001953125D; - double d2 = Math.abs(this.highBryceGen.generate((double)i * d1, (double)j * d1)); - d4 = d0 * d0 * 2.5D; - double d3 = Math.ceil(d2 * 50.0D) + 14.0D; - - if (d4 > d3) - { - d4 = d3; - } - - d4 = d4 + 64.0D; - } - } - - int bx = x & 15; - int by = z & 15; - State surface = Blocks.white_clay.getState(); - State top = Blocks.white_clay.getState(); - int rng = (int)(noise / 3.0D + 3.0D + rand.doublev() * 0.25D); - boolean hard = Math.cos(noise / 3.0D * Math.PI) > 0.0D; - int sel = -1; - boolean base = false; - - for (int i1 = primer.height - 1; i1 >= 0; --i1) - { - if (primer.get(by, i1, bx).getBlock() == Blocks.air && i1 < (int)d4) - { - primer.set(by, i1, bx, this.filler); - } - - State iblockstate1 = primer.get(by, i1, bx); - - if (iblockstate1.getBlock() == Blocks.air) - { - sel = -1; - } - else if (iblockstate1.getBlock() == this.fillerBlock) - { - if (sel == -1) - { - base = false; - - if (rng <= 0) - { - surface = null; - top = this.filler; - } - else if (i1 >= this.seaLevel - 4 && i1 <= this.seaLevel + 1) - { - surface = Blocks.white_clay.getState(); - top = Blocks.white_clay.getState(); - } - - if (i1 < this.seaLevel && (surface == null || surface.getBlock() == Blocks.air)) - { - surface = this.liquid; - } - - sel = rng + Math.max(0, i1 - this.seaLevel); - - if (i1 < this.seaLevel - 1) - { - primer.set(by, i1, bx, top); - - if (top.getBlock() instanceof BlockColoredClay) - { - primer.set(by, i1, bx, Blocks.orange_clay.getState()); - } - } - else if (soil && i1 > 86 + rng * 2) - { - if (hard) - { - primer.set(by, i1, bx, Blocks.coarse_dirt.getState()); - } - else - { - primer.set(by, i1, bx, Blocks.grass.getState()); - } - } - else if (i1 <= this.seaLevel + 3 + rng) - { - primer.set(by, i1, bx, this.surface); - base = true; - } - else - { - State iblockstate4; - - if (i1 >= 64 && i1 <= 127) - { - if (hard) - { - iblockstate4 = Blocks.hardened_clay.getState(); - } - else - { - iblockstate4 = this.getBlockAt(x, i1, z); - } - } - else - { - iblockstate4 = Blocks.orange_clay.getState(); - } - - primer.set(by, i1, bx, iblockstate4); - } - } - else if (sel > 0) - { - --sel; - - if (base) - { - primer.set(by, i1, bx, Blocks.orange_clay.getState()); - } - else - { - State iblockstate2 = this.getBlockAt(x, i1, z); - primer.set(by, i1, bx, iblockstate2); - } - } - } - } - } - - private void setupLayers(Random random) - { - for (int l1 = 0; l1 < 64; ++l1) - { - l1 += random.roll(5); - - if (l1 < 64) - { - this.layers[l1] = Blocks.orange_clay.getState(); - } - } - - int i2 = random.range(2, 5); - - for (int i = 0; i < i2; ++i) - { - int j = random.roll(3); - int k = random.zrange(64); - - for (int l = 0; k + l < 64 && l < j; ++l) - { - this.layers[k + l] = Blocks.yellow_clay.getState(); - } - } - - int j2 = random.range(2, 5); - - for (int k2 = 0; k2 < j2; ++k2) - { - int i3 = random.range(2, 4); - int l3 = random.zrange(64); - - for (int i1 = 0; l3 + i1 < 64 && i1 < i3; ++i1) - { - this.layers[l3 + i1] = Blocks.brown_clay.getState(); - } - } - - int l2 = random.range(2, 5); - - for (int j3 = 0; j3 < l2; ++j3) - { - int i4 = random.roll(3); - int k4 = random.zrange(64); - - for (int j1 = 0; k4 + j1 < 64 && j1 < i4; ++j1) - { - this.layers[k4 + j1] = Blocks.red_clay.getState(); - } - } - - int k3 = random.range(3, 5); - int j4 = 0; - - for (int l4 = 0; l4 < k3; ++l4) - { - int i5 = 1; - j4 += random.range(4, 19); - - for (int k1 = 0; j4 + k1 < 64 && k1 < i5; ++k1) - { - this.layers[j4 + k1] = Blocks.white_clay.getState(); - - if (j4 + k1 > 1 && random.chance()) - { - this.layers[j4 + k1 - 1] = Blocks.silver_clay.getState(); - } - - if (j4 + k1 < 63 && random.chance()) - { - this.layers[j4 + k1 + 1] = Blocks.silver_clay.getState(); - } - } - } - } -} diff --git a/server/src/main/java/server/worldgen/ReplacerTerranian.java b/server/src/main/java/server/worldgen/ReplacerTerranian.java deleted file mode 100644 index 4120d4c7..00000000 --- a/server/src/main/java/server/worldgen/ReplacerTerranian.java +++ /dev/null @@ -1,107 +0,0 @@ -package server.worldgen; - -import common.block.foliage.BlockLilyPad; -import common.init.Blocks; -import common.rng.PerlinGen; -import common.rng.Random; -import common.util.Facing; -import common.world.State; -import server.world.WorldServer; - -public class ReplacerTerranian extends ReplacerAltSimple { - private final PerlinGen grassNoiseGen; - private final State dry; - - public ReplacerTerranian(Random rand, State surface, State top, State filler, State alt, State dry, State liquid, int seaLevel) { - super(rand, surface, top, filler, alt, liquid, seaLevel); - this.grassNoiseGen = new PerlinGen(rand, 1); - this.dry = dry; - } - - protected State adjust(State current) { - return current.getBlock() == Blocks.sand ? Blocks.sandstone.getState() : current; - } - - public void genTerrainBlocks(WorldServer world, Random rand, ChunkPrimer primer, int x, int z, double noise) - { - float absTemp = world.getGenTemperature((x & ~15) | (z & 15), (z & ~15) | (x & 15)); - float humidity = world.getGenHumidity((x & ~15) | (z & 15), (z & ~15) | (x & 15)); - - State topBlock = this.surface; - State fillerBlock = this.top; - - if(absTemp >= 50.0f) { - topBlock = this.dry; - fillerBlock = this.dry; - } - else if(absTemp >= 38.0f && humidity < 50.0f) { - if (noise > 1.75D) - { - topBlock = this.filler; - fillerBlock = this.filler; - } - else if (noise > -0.5D) - { - topBlock = Blocks.coarse_dirt.getState(); - } - } - else if(absTemp <= 10.0f && humidity <= 10.0f) { - topBlock = this.filler; - fillerBlock = this.filler; - } - else if(absTemp <= 10.0f && humidity < 60.0f) { - if (noise < -1.0D || noise > 2.0D) - { - topBlock = this.alt; - fillerBlock = this.alt; - } - else if (humidity < 40.0f && noise > 1.0D) - { - topBlock = this.filler; - fillerBlock = this.filler; - } - } - else if (absTemp >= 25.0f && humidity >= 70.0f) - { - if (noise > 1.75D) - { - topBlock = Blocks.coarse_dirt.getState(); - } - else if (noise > -0.95D) - { - topBlock = Blocks.podzol.getState(); - } - } - else if(absTemp < 22.0f && humidity >= 65.0f) { - topBlock = Blocks.swamp.getState(); - int sea = world.getSeaLevel() - 1; - double d0 = grassNoiseGen.generate((double)x * 0.25D, (double)z * 0.25D); - if (d0 > 0.0D) - { - int i = x & 15; - int j = z & 15; - - for (int k = primer.height - 1; k >= 0; --k) - { - if (primer.get(j, k, i).getBlock() != Blocks.air) - { - if (k == sea) - { - if(!primer.get(j, k, i).getBlock().getMaterial().isLiquid() || k <= 0 || !primer.get(j, k - 1, i).getBlock().getMaterial().isLiquid()) - primer.set(j, k, i, Blocks.swamp_water.getState()); - - if (d0 < 0.12D) - { - primer.set(j, k + 1, i, Blocks.waterlily.getState().withProperty(BlockLilyPad.FACING, Facing.randHorizontal(rand))); - } - } - - break; - } - } - } - } - - this.genTerrainBlocks(world, rand, primer, x, z, noise, topBlock, fillerBlock); - } -} diff --git a/server/src/main/java/server/worldgen/ReplacerTopLayer.java b/server/src/main/java/server/worldgen/ReplacerTopLayer.java index 681f3d00..5f2a52c3 100755 --- a/server/src/main/java/server/worldgen/ReplacerTopLayer.java +++ b/server/src/main/java/server/worldgen/ReplacerTopLayer.java @@ -1,5 +1,6 @@ package server.worldgen; +import common.biome.Biome; import common.block.Block; import common.init.Blocks; import common.rng.Random; @@ -20,7 +21,7 @@ public class ReplacerTopLayer implements BlockReplacer this.replace = replace; } - public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand) + public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes) { for (int i = 0; i < 16; ++i) { diff --git a/server/src/main/java/server/worldgen/biome/BiomeBeach.java b/server/src/main/java/server/worldgen/biome/BiomeBeach.java new file mode 100755 index 00000000..751fc627 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeBeach.java @@ -0,0 +1,22 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.init.Blocks; +import common.rng.WeightedList; + +public class BiomeBeach extends GenBiome +{ + public BiomeBeach(boolean cold) + { + super(cold ? Biome.ICE_BEACH : Biome.BEACH); + this.topBlock = Blocks.sand.getState(); + this.fillerBlock = Blocks.sand.getState(); + this.treesPerChunk = -999; + this.deadBushPerChunk = 0; + this.reedsPerChunk = 0; + this.cactiPerChunk = 0; + } + + protected void addMobs(WeightedList mobs) { + } +} diff --git a/server/src/main/java/server/worldgen/biome/BiomeBlackened.java b/server/src/main/java/server/worldgen/biome/BiomeBlackened.java new file mode 100644 index 00000000..45c4c826 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeBlackened.java @@ -0,0 +1,36 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.block.foliage.BlockFlower; +import common.entity.npc.EntityMetalhead; +import common.init.Blocks; +import common.init.WoodType; +import common.rng.Random; +import common.rng.WeightedList; +import common.util.BlockPos; +import server.worldgen.tree.WorldGenBaseTree; +import server.worldgen.tree.WorldGenTree; + +public class BiomeBlackened extends GenBiome { + protected final WorldGenTree treeGen = new WorldGenBaseTree(false, Blocks.blackwood_log.getState(), WoodType.BLACKWOOD); + + public BiomeBlackened() { + super(Biome.BLACKENED); + this.topBlock = Blocks.blackened_soil.getState(); + this.fillerBlock = Blocks.blackened_dirt.getState(); + this.treesPerChunk = 3; + this.generateLakes = false; + } + + protected void addMobs(WeightedList mobs) { + mobs.add(new RngSpawn(EntityMetalhead.class, 50, 1, 1)); + } + + public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) { + return BlockFlower.EnumFlowerType.BLACK_LOTUS; + } + + public WorldGenTree genBigTreeChance(Random rand) { + return this.treeGen; + } +} diff --git a/server/src/main/java/server/worldgen/biome/BiomeChaos.java b/server/src/main/java/server/worldgen/biome/BiomeChaos.java new file mode 100755 index 00000000..df4cfe53 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeChaos.java @@ -0,0 +1,45 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.entity.Entity; +import common.entity.types.EntityLiving; +import common.init.Blocks; +import common.init.EntityRegistry; +import common.rng.Random; +import common.rng.WeightedList; +import common.util.BlockPos; +import server.world.WorldServer; +import server.worldgen.FeatureGenerator; +import server.worldgen.foliage.WorldGenMushroom; + +public class BiomeChaos extends GenBiome +{ + protected FeatureGenerator mushroomBlueGen = new WorldGenMushroom(Blocks.blue_mushroom); + + public BiomeChaos() + { + super(Biome.CHAOS); + this.topBlock = Blocks.obsidian.getState(); + this.fillerBlock = Blocks.obsidian.getState(); + } + + protected void addMobs(WeightedList mobs) { + for(Class clazz : EntityRegistry.getAllClasses()) { + if(EntityLiving.class.isAssignableFrom(clazz)) + mobs.add(new RngSpawn((Class)clazz, 1, 1, 8)); + } + } + + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) + { + super.decorate(worldIn, rand, pos); + + if (rand.chance(10)) + { + int i8 = rand.chOffset(); + int l11 = rand.chOffset(); + BlockPos blockpos2 = worldIn.getHeight(pos.add(i8, 0, l11)); + this.mushroomBlueGen.generate(worldIn, rand, blockpos2); + } + } +} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorDesert.java b/server/src/main/java/server/worldgen/biome/BiomeDesert.java similarity index 60% rename from server/src/main/java/server/worldgen/populator/PopulatorDesert.java rename to server/src/main/java/server/worldgen/biome/BiomeDesert.java index e147f466..1b680803 100755 --- a/server/src/main/java/server/worldgen/populator/PopulatorDesert.java +++ b/server/src/main/java/server/worldgen/biome/BiomeDesert.java @@ -1,23 +1,29 @@ -package server.worldgen.populator; +package server.worldgen.biome; +import common.biome.Biome; +import common.init.Blocks; import common.rng.Random; +import common.rng.WeightedList; import common.util.BlockPos; import server.world.WorldServer; import server.worldgen.feature.WorldGenDesertWells; -public class PopulatorDesert extends PopulatorBasic +public class BiomeDesert extends GenBiome { - public PopulatorDesert() + public BiomeDesert(boolean hills) { + super(hills ? Biome.DESERT_HILLS : Biome.DESERT); + this.topBlock = Blocks.sand.getState(); + this.fillerBlock = Blocks.sand.getState(); this.treesPerChunk = -999; this.deadBushPerChunk = 2; this.reedsPerChunk = 50; this.cactiPerChunk = 10; + this.generateLakes = false; } - public boolean canGenerateLakes() { - return false; - } + protected void addMobs(WeightedList mobs) { + } public void decorate(WorldServer worldIn, Random rand, BlockPos pos) { diff --git a/server/src/main/java/server/worldgen/biome/BiomeExterminated.java b/server/src/main/java/server/worldgen/biome/BiomeExterminated.java new file mode 100755 index 00000000..dec157ed --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeExterminated.java @@ -0,0 +1,22 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.init.Blocks; +import common.rng.Random; +import common.rng.WeightedList; +import common.util.BlockPos; +import server.world.WorldServer; + +public class BiomeExterminated extends GenBiome { + public BiomeExterminated() { + super(Biome.EXTERMINATED); + this.topBlock = Blocks.air.getState(); + this.fillerBlock = Blocks.air.getState(); + } + + protected void addMobs(WeightedList mobs) { + } + + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) { + } +} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorForest.java b/server/src/main/java/server/worldgen/biome/BiomeForest.java similarity index 79% rename from server/src/main/java/server/worldgen/populator/PopulatorForest.java rename to server/src/main/java/server/worldgen/biome/BiomeForest.java index d3e915ec..ee8f3469 100755 --- a/server/src/main/java/server/worldgen/populator/PopulatorForest.java +++ b/server/src/main/java/server/worldgen/biome/BiomeForest.java @@ -1,7 +1,12 @@ -package server.worldgen.populator; +package server.worldgen.biome; +import common.biome.Biome; import common.block.foliage.BlockDoublePlant; import common.block.foliage.BlockFlower; +import common.entity.animal.EntityFox; +import common.entity.animal.EntityWolf; +import common.entity.npc.EntityElf; +import common.entity.npc.EntityWoodElf; import common.init.Blocks; import common.init.WoodType; import common.rng.Random; @@ -15,7 +20,7 @@ import server.worldgen.tree.WorldGenBirch; import server.worldgen.tree.WorldGenDarkOak; import server.worldgen.tree.WorldGenTree; -public class PopulatorForest extends PopulatorBasic +public class BiomeForest extends GenBiome { private static final BlockDoublePlant[] FLOWER_TYPES = new BlockDoublePlant[] { Blocks.syringa, Blocks.rose_bush, Blocks.paeonia @@ -39,8 +44,9 @@ public class PopulatorForest extends PopulatorBasic protected WorldGenBigTree mapleBig = new WorldGenBigTree(false, Blocks.maple_log.getState(), // .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.MAPLE), WoodType.MAPLE); // .withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen())); - public PopulatorForest(int type) + public BiomeForest(Biome base, int type) { + super(base); this.subType = type; this.treesPerChunk = 10; this.grassPerChunk = 2; @@ -60,17 +66,31 @@ public class PopulatorForest extends PopulatorBasic this.reedsPerChunk = 50; this.waterlilyPerChunk = 4; } + + if (this.subType == 0) + { + this.mobs.add(new RngSpawn(EntityWolf.class, 5, 2, 4)); + this.mobs.add(new RngSpawn(EntityFox.class, 1, 2, 6)); + } if (this.subType == 3) { this.treesPerChunk = -999; + this.mobs.add(new RngSpawn(EntityFox.class, 1, 2, 4)); + } + + if(this.subType != 4) { + this.mobs.add(new RngSpawn(EntityWoodElf.class, 3, 2, 6)); + } + else { + this.mobs.add(new RngSpawn(EntityWoodElf.class, 100, 4, 16)); + this.mobs.add(new RngSpawn(EntityElf.class, 12, 4, 16)); + this.mobs.add(new RngSpawn(EntityFox.class, 3, 2, 5)); } } - protected WorldGenTree genBigTreeChance(Random rand) + public WorldGenTree genBigTreeChance(Random rand) { - if(this.subType == 5) - return rand.chance() ? PopulatorForest.tallBirch : PopulatorForest.normalBirch; return (WorldGenTree) (this.subType == 3 && rand.rarity(3) ? darkOak : (this.subType != 2 && rand.rarity(5) ? (this.subType != 3 && this.subType != 4 && rand.chance(this.subType == 1 ? 2 : 30) ? (rand.chance(25) ? this.cherryBig : this.cherry) : @@ -78,7 +98,7 @@ public class PopulatorForest extends PopulatorBasic (this.subType == 4 || rand.chance(this.subType == 2 ? 30 : 2) ? (rand.chance(this.subType == 4 ? 32 : 5) ? this.mapleBig : this.maple) : normalBirch))); } - protected BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) + public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) { if (this.subType == 1) { @@ -179,4 +199,30 @@ public class PopulatorForest extends PopulatorBasic super.decorate(worldIn, rand, pos); } + + protected GenBiome createMutatedBiome(Biome base) + { + if (this.base == Biome.FOREST) + { + BiomeForest biomegenforest = new BiomeForest(base, 1); + biomegenforest.setScaling(this.depth, this.scale + 0.2F); + return biomegenforest; + } + else + { + return this.base != Biome.BIRCH_FOREST && this.base != Biome.BIRCH_HILLS ? new BiomeMutated(base, this) + { + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) + { + this.baseBiome.decorate(worldIn, rand, pos); + } + }: new BiomeMutated(base, this) + { + public WorldGenTree genBigTreeChance(Random rand) + { + return rand.chance() ? BiomeForest.tallBirch : BiomeForest.normalBirch; + } + }; + } + } } diff --git a/server/src/main/java/server/worldgen/biome/BiomeHell.java b/server/src/main/java/server/worldgen/biome/BiomeHell.java new file mode 100755 index 00000000..65d3ad8c --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeHell.java @@ -0,0 +1,127 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.entity.npc.EntityBloodElf; +import common.entity.npc.EntityCultivator; +import common.entity.npc.EntityFireDemon; +import common.entity.npc.EntityMetalhead; +import common.entity.npc.EntityTiefling; +import common.init.Blocks; +import common.rng.Random; +import common.rng.WeightedList; +import common.util.BlockPos; +import server.world.WorldServer; +import server.worldgen.FeatureOres; +import server.worldgen.feature.WorldGenFire; +import server.worldgen.feature.WorldGenGlowStone; +import server.worldgen.feature.WorldGenHellLava; +import server.worldgen.foliage.WorldGenMushroom; + +public class BiomeHell extends GenBiome +{ + private final int subtype; + private final WorldGenFire fireGen; + private final WorldGenGlowStone glowStoneGen1; + private final WorldGenGlowStone glowStoneGen2; + private final FeatureOres quartzGen; + private final WorldGenHellLava lavaGen1; + private final WorldGenHellLava lavaGen2; + private final WorldGenMushroom brownMushroomGen; + private final WorldGenMushroom redMushroomGen; + + public BiomeHell(Biome base, int subtype) + { + super(base); + this.subtype = subtype; + if(this.subtype == 0) { + this.mobs.add(new RngSpawn(EntityBloodElf.class, 10, 1, 2)); + this.mobs.add(new RngSpawn(EntityMetalhead.class, 1, 1, 1)); + this.fireGen = new WorldGenFire(); + this.glowStoneGen1 = new WorldGenGlowStone(); + this.glowStoneGen2 = new WorldGenGlowStone(); + this.quartzGen = new FeatureOres(Blocks.quartz_ore.getState(), 16, 0, 14, 10, 118, false); + this.lavaGen1 = new WorldGenHellLava(Blocks.flowing_lava, true); + this.lavaGen2 = new WorldGenHellLava(Blocks.flowing_lava, false); + this.brownMushroomGen = new WorldGenMushroom(Blocks.brown_mushroom); + this.redMushroomGen = new WorldGenMushroom(Blocks.red_mushroom); + } + else { + this.mobs.add(new RngSpawn(EntityBloodElf.class, 50, 2, 10)); + this.mobs.add(new RngSpawn(EntityCultivator.class, 10, 1, 1)); + this.fireGen = null; + this.glowStoneGen1 = null; + this.glowStoneGen2 = null; + this.quartzGen = null; + this.lavaGen1 = null; + this.lavaGen2 = null; + this.brownMushroomGen = null; + this.redMushroomGen = null; + } + if(this.subtype == 2) { + this.topBlock = Blocks.ash.getState(); + this.fillerBlock = Blocks.rock.getState(); + } + else { + this.topBlock = Blocks.hellrock.getState(); + this.fillerBlock = Blocks.hellrock.getState(); + } + } + + protected void addMobs(WeightedList mobs) { + mobs.add(new RngSpawn(EntityFireDemon.class, 50, 4, 4)); + mobs.add(new RngSpawn(EntityTiefling.class, 100, 4, 4)); + } + + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) + { + if(this.subtype == 0) { + for (int i = 0; i < 8; ++i) + { + this.lavaGen2.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(120) + 4, rand.zrange(16) + 8)); + } + + for (int j = 0; j < rand.zrange(rand.zrange(10) + 1) + 1; ++j) + { + this.fireGen.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(120) + 4, rand.zrange(16) + 8)); + } + + for (int k = 0; k < rand.zrange(rand.zrange(10) + 1); ++k) + { + this.glowStoneGen1.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(120) + 4, rand.zrange(16) + 8)); + } + + for (int l = 0; l < 10; ++l) + { + this.glowStoneGen2.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(128), rand.zrange(16) + 8)); + } + + if (rand.chance()) + { + this.brownMushroomGen.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(128), rand.zrange(16) + 8)); + } + + if (rand.chance()) + { + this.redMushroomGen.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(128), rand.zrange(16) + 8)); + } + +// for (int i1 = 0; i1 < 16; ++i1) +// { + this.quartzGen.generate(worldIn, rand, pos); // .add(rand.nextInt(16), rand.nextInt(108) + 10, rand.nextInt(16))); +// } + + for (int j1 = 0; j1 < 16; ++j1) + { + this.lavaGen1.generate(worldIn, rand, pos.add(rand.zrange(16), rand.zrange(108) + 10, rand.zrange(16))); + } + } + else { + super.decorate(worldIn, rand, pos); + } + } + +// protected Decorator createBiomeDecorator() +// { +// return this.subtype == 0 ? new DecoratorHell() : super.createBiomeDecorator(); +// } +} diff --git a/server/src/main/java/server/worldgen/biome/BiomeHills.java b/server/src/main/java/server/worldgen/biome/BiomeHills.java new file mode 100755 index 00000000..ee65713f --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeHills.java @@ -0,0 +1,101 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.init.Blocks; +import common.rng.Random; +import common.util.BlockPos; +import server.world.WorldServer; +import server.worldgen.ChunkPrimer; +import server.worldgen.FeatureOres; +import server.worldgen.tree.WorldGenTaiga2; +import server.worldgen.tree.WorldGenTree; + +public class BiomeHills extends GenBiome +{ +// private FeatureGenerator theWorldGenerator = new FeatureOres(Blocks.monster_egg.getDefaultState().withProperty(BlockSilverfish.VARIANT, BlockSilverfish.EnumType.STONE), false, 7, 9, 0, 64); + private FeatureOres theEmeraldGenerator = new FeatureOres(Blocks.emerald_ore.getState(), 3, 5, 1, 4, 32, false); + private WorldGenTaiga2 field_150634_aD = new WorldGenTaiga2(false); + private int field_150635_aE = 0; + private int field_150636_aF = 1; + private int field_150637_aG = 2; + private int field_150638_aH; + + protected BiomeHills(Biome base, boolean large) + { + super(base); + this.field_150638_aH = this.field_150635_aE; + + if (large) + { + this.treesPerChunk = 3; + this.field_150638_aH = this.field_150636_aF; + } + } + + public WorldGenTree genBigTreeChance(Random rand) + { + return (WorldGenTree)(rand.rarity(3) ? this.field_150634_aD : super.genBigTreeChance(rand)); + } + + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) + { + super.decorate(worldIn, rand, pos); +// int i = 3 + rand.nextInt(6); +// +// for (int j = 0; j < i; ++j) +// { +// int k = rand.nextInt(16); +// int l = rand.nextInt(28) + 4; +// int i1 = rand.nextInt(16); +// BlockPos blockpos = pos.add(k, l, i1); +// +// if (worldIn.getBlockState(blockpos).getBlock() == Blocks.stone) +// { +// worldIn.setBlockState(blockpos, Blocks.emerald_ore.getDefaultState(), 2); +// } +// } + this.theEmeraldGenerator.generate(worldIn, rand, pos); + +// for (i = 0; i < 7; ++i) +// { +// int j1 = rand.nextInt(16); +// int k1 = rand.nextInt(64); +// int l1 = rand.nextInt(16); +// this.theWorldGenerator.generate(worldIn, rand, pos); // .add(j1, k1, l1)); +// } + } + + public void genTerrainBlocks(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) + { + this.topBlock = Blocks.grass.getState(); + this.fillerBlock = Blocks.dirt.getState(); + + if ((noiseVal < -1.0D || noiseVal > 2.0D) && this.field_150638_aH == this.field_150637_aG) + { + this.topBlock = Blocks.gravel.getState(); + this.fillerBlock = Blocks.gravel.getState(); + } + else if (noiseVal > 1.0D && this.field_150638_aH != this.field_150636_aF) + { + this.topBlock = Blocks.stone.getState(); + this.fillerBlock = Blocks.stone.getState(); + } + + this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); + } + + /** + * this creates a mutation specific to Hills biomes + */ + private BiomeHills mutateHills(GenBiome p_150633_1_) + { + this.field_150638_aH = this.field_150637_aG; + this.setScaling(p_150633_1_.depth, p_150633_1_.scale); + return this; + } + + protected GenBiome createMutatedBiome(Biome base) + { + return (new BiomeHills(base, false)).mutateHills(this); + } +} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorTropical.java b/server/src/main/java/server/worldgen/biome/BiomeJungle.java similarity index 79% rename from server/src/main/java/server/worldgen/populator/PopulatorTropical.java rename to server/src/main/java/server/worldgen/biome/BiomeJungle.java index 3f47e7d6..4697daa2 100755 --- a/server/src/main/java/server/worldgen/populator/PopulatorTropical.java +++ b/server/src/main/java/server/worldgen/biome/BiomeJungle.java @@ -1,5 +1,8 @@ -package server.worldgen.populator; +package server.worldgen.biome; +import common.biome.Biome; +import common.entity.animal.EntityChicken; +import common.entity.animal.EntityCat; import common.init.Blocks; import common.init.WoodType; import common.rng.Random; @@ -15,7 +18,7 @@ import server.worldgen.tree.WorldGenBaseTree; import server.worldgen.tree.WorldGenJungle; import server.worldgen.tree.WorldGenTree; -public class PopulatorTropical extends PopulatorBasic +public class BiomeJungle extends GenBiome { private static final State LOG = Blocks.jungle_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE); private static final WoodType LEAVES = WoodType.JUNGLE; // .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE); // .withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); @@ -23,8 +26,9 @@ public class PopulatorTropical extends PopulatorBasic private final boolean edge; - public PopulatorTropical(boolean edge) + public BiomeJungle(Biome base, boolean edge) { + super(base); this.edge = edge; if (edge) @@ -38,14 +42,24 @@ public class PopulatorTropical extends PopulatorBasic this.grassPerChunk = 25; this.flowersPerChunk = 4; + + if (!edge) + { + this.mobs.add(new RngSpawn(EntityCat.class, 2, 1, 1)); + } + + this.mobs.add(new RngSpawn(EntityChicken.class, 10, 4, 4)); } - protected WorldGenTree genBigTreeChance(Random rand) + public WorldGenTree genBigTreeChance(Random rand) { return (WorldGenTree)(rand.chance(10) ? this.worldGeneratorBigTree : (rand.chance(2) ? new WorldGenShrub(LOG, BUSH) : (!this.edge && rand.chance(3) ? new WorldGenJungle(false, 10, 20, LOG, LEAVES) : new WorldGenBaseTree(false, rand.range(4, 10), LOG, LEAVES, true)))); } - protected FeatureGenerator getRandomWorldGenForGrass(Random rand) + /** + * Gets a WorldGen appropriate for this biome. + */ + public FeatureGenerator getRandomWorldGenForGrass(Random rand) { return rand.chance(4) ? new WorldGenTallGrass(Blocks.fern) : new WorldGenTallGrass(Blocks.tallgrass); } diff --git a/server/src/main/java/server/worldgen/biome/BiomeMesa.java b/server/src/main/java/server/worldgen/biome/BiomeMesa.java new file mode 100755 index 00000000..0d1fb243 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeMesa.java @@ -0,0 +1,328 @@ +package server.worldgen.biome; + +import java.util.Arrays; + +import common.biome.Biome; +import common.block.Block; +import common.block.natural.BlockColoredClay; +import common.init.Blocks; +import common.rng.PerlinGen; +import common.rng.Random; +import common.rng.WeightedList; +import common.util.BlockPos; +import common.world.State; +import server.world.WorldServer; +import server.worldgen.ChunkPrimer; +import server.worldgen.tree.WorldGenTree; + +public class BiomeMesa extends GenBiome +{ + private final boolean bryce; + private final boolean soil; + + private State[] layers; + private long layerSeed; + private PerlinGen baseBryceGen; + private PerlinGen highBryceGen; + private PerlinGen clayColorGen; + + public BiomeMesa(Biome base, boolean bryce, boolean soil) + { + super(base); + this.bryce = bryce; + this.soil = soil; +// this.setDisableRain(); +// this.setTemperatureLegacy(2.0F).setHumidity(0.0F); +// this.mobs.clear(); + this.topBlock = Blocks.red_sand.getState(); + this.fillerBlock = Blocks.white_clay.getState(); + this.treesPerChunk = -999; + this.deadBushPerChunk = 20; + this.reedsPerChunk = 3; + this.cactiPerChunk = 5; + this.flowersPerChunk = 0; +// this.mobs.clear(); + + if (soil) + { + this.treesPerChunk = 5; + } + } + + protected void addMobs(WeightedList mobs) { + } + + public WorldGenTree genBigTreeChance(Random rand) + { + return this.worldGeneratorTrees; + } + + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) + { + super.decorate(worldIn, rand, pos); + } + + public void genTerrainBlocks(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) + { + if (this.layers == null || this.layerSeed != worldIn.getSeed()) + { + this.setupLayers(worldIn.getSeed()); + } + + if (this.baseBryceGen == null || this.highBryceGen == null || this.layerSeed != worldIn.getSeed()) + { + Random random = new Random(this.layerSeed); + this.baseBryceGen = new PerlinGen(random, 4); + this.highBryceGen = new PerlinGen(random, 1); + } + + this.layerSeed = worldIn.getSeed(); + double d4 = 0.0D; + + if (this.bryce) + { + int i = (x & -16) + (z & 15); + int j = (z & -16) + (x & 15); + double d0 = Math.min(Math.abs(noiseVal), this.baseBryceGen.generate((double)i * 0.25D, (double)j * 0.25D)); + + if (d0 > 0.0D) + { + double d1 = 0.001953125D; + double d2 = Math.abs(this.highBryceGen.generate((double)i * d1, (double)j * d1)); + d4 = d0 * d0 * 2.5D; + double d3 = Math.ceil(d2 * 50.0D) + 14.0D; + + if (d4 > d3) + { + d4 = d3; + } + + d4 = d4 + 64.0D; + } + } + + int j1 = x & 15; + int k1 = z & 15; + int l1 = worldIn.getSeaLevel(); + State iblockstate = Blocks.white_clay.getState(); + State iblockstate3 = this.fillerBlock; + int k = (int)(noiseVal / 3.0D + 3.0D + rand.doublev() * 0.25D); + boolean flag = Math.cos(noiseVal / 3.0D * Math.PI) > 0.0D; + int l = -1; + boolean flag1 = false; + State worldState = worldIn.dimension.getFiller(); + Block worldBlock = worldState.getBlock(); + State worldAlt = worldIn.dimension.getAltFiller1(); + State liquid = worldIn.getSurfaceLiquid(); +// IBlockState bottom = worldIn.dimension.hasBedrock() ? Blocks.bedrock.getDefaultState() : Blocks.air.getDefaultState(); + + for (int i1 = chunkPrimerIn.height - 1; i1 >= 0; --i1) + { + if (chunkPrimerIn.get(k1, i1, j1).getBlock() == Blocks.air && i1 < (int)d4) + { + chunkPrimerIn.set(k1, i1, j1, worldState); + } + +// if (i1 <= rand.zrange(5) && bedrock) +// { +// chunkPrimerIn.set(k1, i1, j1, bottom); +// } +// else +// { + State iblockstate1 = chunkPrimerIn.get(k1, i1, j1); + + if (iblockstate1.getBlock() == Blocks.air) + { + l = -1; + } + else if (iblockstate1.getBlock() == worldBlock) + { + if (l == -1) + { + flag1 = false; + + if (k <= 0) + { + iblockstate = null; + iblockstate3 = worldState; + } + else if (i1 >= l1 - 4 && i1 <= l1 + 1) + { + iblockstate = Blocks.white_clay.getState(); + iblockstate3 = this.fillerBlock; + } + + if (i1 < l1 && (iblockstate == null || iblockstate.getBlock() == Blocks.air)) + { + iblockstate = liquid; + } + + l = k + Math.max(0, i1 - l1); + + if (i1 < l1 - 1) + { + chunkPrimerIn.set(k1, i1, j1, iblockstate3); + + if (iblockstate3.getBlock() instanceof BlockColoredClay) + { + chunkPrimerIn.set(k1, i1, j1, Blocks.orange_clay.getState()); + } + } + else if (this.soil && i1 > 86 + k * 2) + { + if (flag) + { + chunkPrimerIn.set(k1, i1, j1, Blocks.coarse_dirt.getState()); + } + else + { + chunkPrimerIn.set(k1, i1, j1, Blocks.grass.getState()); + } + } + else if (i1 <= l1 + 3 + k) + { + chunkPrimerIn.set(k1, i1, j1, this.topBlock); + flag1 = true; + } + else + { + State iblockstate4; + + if (i1 >= 64 && i1 <= 127) + { + if (flag) + { + iblockstate4 = Blocks.hardened_clay.getState(); + } + else + { + iblockstate4 = this.getBlockAt(x, i1, z); + } + } + else + { + iblockstate4 = Blocks.orange_clay.getState(); + } + + chunkPrimerIn.set(k1, i1, j1, iblockstate4); + } + } + else if (l > 0) + { + --l; + + if (flag1) + { + chunkPrimerIn.set(k1, i1, j1, Blocks.orange_clay.getState()); + } + else + { + State iblockstate2 = this.getBlockAt(x, i1, z); + chunkPrimerIn.set(k1, i1, j1, iblockstate2); + } + } + } + } +// } + } + + private void setupLayers(long seed) + { + this.layers = new State[64]; + Arrays.fill(this.layers, Blocks.hardened_clay.getState()); + Random random = new Random(seed); + this.clayColorGen = new PerlinGen(random, 1); + + for (int l1 = 0; l1 < 64; ++l1) + { + l1 += random.roll(5); + + if (l1 < 64) + { + this.layers[l1] = Blocks.orange_clay.getState(); + } + } + + int i2 = random.range(2, 5); + + for (int i = 0; i < i2; ++i) + { + int j = random.roll(3); + int k = random.zrange(64); + + for (int l = 0; k + l < 64 && l < j; ++l) + { + this.layers[k + l] = Blocks.yellow_clay.getState(); + } + } + + int j2 = random.range(2, 5); + + for (int k2 = 0; k2 < j2; ++k2) + { + int i3 = random.range(2, 4); + int l3 = random.zrange(64); + + for (int i1 = 0; l3 + i1 < 64 && i1 < i3; ++i1) + { + this.layers[l3 + i1] = Blocks.brown_clay.getState(); + } + } + + int l2 = random.range(2, 5); + + for (int j3 = 0; j3 < l2; ++j3) + { + int i4 = random.roll(3); + int k4 = random.zrange(64); + + for (int j1 = 0; k4 + j1 < 64 && j1 < i4; ++j1) + { + this.layers[k4 + j1] = Blocks.red_clay.getState(); + } + } + + int k3 = random.range(3, 5); + int j4 = 0; + + for (int l4 = 0; l4 < k3; ++l4) + { + int i5 = 1; + j4 += random.range(4, 19); + + for (int k1 = 0; j4 + k1 < 64 && k1 < i5; ++k1) + { + this.layers[j4 + k1] = Blocks.white_clay.getState(); + + if (j4 + k1 > 1 && random.chance()) + { + this.layers[j4 + k1 - 1] = Blocks.silver_clay.getState(); + } + + if (j4 + k1 < 63 && random.chance()) + { + this.layers[j4 + k1 + 1] = Blocks.silver_clay.getState(); + } + } + } + } + + private State getBlockAt(int x, int y, int z) + { + int i = (int)Math.round(this.clayColorGen.generate((double)x * 1.0D / 512.0D, (double)x * 1.0D / 512.0D) * 2.0D); + return this.layers[(y + i + 64) % 64]; + } + + protected GenBiome createMutatedBiome(Biome base) + { + boolean bryce = this.base == Biome.MESA; + BiomeMesa mesa = new BiomeMesa(base, bryce, this.soil); + + if (!bryce) + { + mesa.setScaling(Scaling.HILLS_LOW); + } + + return mesa; + } +} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorCheese.java b/server/src/main/java/server/worldgen/biome/BiomeMoon.java similarity index 53% rename from server/src/main/java/server/worldgen/populator/PopulatorCheese.java rename to server/src/main/java/server/worldgen/biome/BiomeMoon.java index 391b65f2..3a970da0 100755 --- a/server/src/main/java/server/worldgen/populator/PopulatorCheese.java +++ b/server/src/main/java/server/worldgen/biome/BiomeMoon.java @@ -1,14 +1,25 @@ -package server.worldgen.populator; +package server.worldgen.biome; +import common.biome.Biome; import common.init.Blocks; import common.rng.Random; +import common.rng.WeightedList; import common.util.BlockPos; import server.world.WorldServer; import server.worldgen.FeatureOres; -public class PopulatorCheese extends PopulatorBasic { +public class BiomeMoon extends GenBiome { private FeatureOres cheeseGenerator = new FeatureOres(Blocks.moon_cheese.getState(), 8, 8, 12, 24, 52, false); + public BiomeMoon() { + super(Biome.MOON); + this.topBlock = Blocks.moon_rock.getState(); + this.fillerBlock = Blocks.moon_rock.getState(); + } + + protected void addMobs(WeightedList mobs) { + } + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) { this.cheeseGenerator.generate(worldIn, rand, pos); } diff --git a/server/src/main/java/server/worldgen/biome/BiomeMushroom.java b/server/src/main/java/server/worldgen/biome/BiomeMushroom.java new file mode 100755 index 00000000..bcae4661 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeMushroom.java @@ -0,0 +1,22 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.entity.npc.EntityDwarf; +import common.init.Blocks; +import common.rng.WeightedList; + +public class BiomeMushroom extends GenBiome { + public BiomeMushroom() { + super(Biome.MUSHROOM); + this.treesPerChunk = -100; + this.flowersPerChunk = -100; + this.grassPerChunk = -100; + this.mushroomsPerChunk = 1; + this.bigMushroomsPerChunk = 1; + this.topBlock = Blocks.mycelium.getState(); + } + + protected void addMobs(WeightedList mobs) { + mobs.add(new RngSpawn(EntityDwarf.class, 8, 4, 8)); + } +} diff --git a/server/src/main/java/server/worldgen/biome/BiomeMutated.java b/server/src/main/java/server/worldgen/biome/BiomeMutated.java new file mode 100755 index 00000000..5534dda8 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeMutated.java @@ -0,0 +1,83 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.rng.Random; +import common.rng.WeightedList; +import common.util.BlockPos; +import server.world.WorldServer; +import server.worldgen.ChunkPrimer; +import server.worldgen.tree.WorldGenTree; + +public class BiomeMutated extends GenBiome +{ + protected GenBiome baseBiome; + + public BiomeMutated(Biome base, GenBiome biome) + { + super(base); + this.baseBiome = biome; + this.topBlock = biome.topBlock; + this.fillerBlock = biome.fillerBlock; +// this.minHeight = biome.minHeight; +// this.maxHeight = biome.maxHeight; + this.allowColdBeach = biome.allowColdBeach; +// this.enableRain = biome.enableRain; +// this.mobs.clear(); + this.mobs.addAll(biome.mobs); +// this.mobs = new WeightedList(biome.mobs); +// this.monsters = new WeightedList(biome.monsters); +// this.caveMobs = new WeightedList(biome.caveMobs); +// this.waterMobs = new WeightedList(biome.waterMobs); +// this.npcs = new WeightedList(biome.npcs); +// this.temperature = biome.temperature; +// this.humidity = biome.humidity; + this.depth = biome.depth + 0.1F; + this.scale = biome.scale + 0.2F; + } + + protected void addMobs(WeightedList mobs) { + } + + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) + { + this.baseBiome.decorate(worldIn, rand, pos); // TODO: check + } + + public void decorateNormal(WorldServer worldIn, Random rand, BlockPos pos) + { + super.decorate(worldIn, rand, pos); + } + + public void genTerrainBlocks(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) + { + this.baseBiome.genTerrainBlocks(worldIn, rand, chunkPrimerIn, x, z, noiseVal); + } + + public float getMobGenChance() + { + return this.baseBiome.getMobGenChance(); + } + + public WorldGenTree genBigTreeChance(Random rand) + { + return this.baseBiome.genBigTreeChance(rand); + } + + public Class getBiomeClass() + { + return this.baseBiome.getBiomeClass(); + } + + /** + * returns true if the biome specified is equal to this biome + */ + public boolean isEqualTo(GenBiome biome) + { + return this.baseBiome.isEqualTo(biome); + } + + public Temperature getTempCategory() + { + return this.baseBiome.getTempCategory(); + } +} diff --git a/server/src/main/java/server/worldgen/biome/BiomeNone.java b/server/src/main/java/server/worldgen/biome/BiomeNone.java new file mode 100755 index 00000000..9f1278e4 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeNone.java @@ -0,0 +1,30 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.init.Blocks; +import common.rng.Random; +import common.rng.WeightedList; +import common.util.BlockPos; +import server.world.WorldServer; +import server.worldgen.ChunkPrimer; + +public class BiomeNone extends GenBiome { + public BiomeNone() { + super(Biome.NONE); + this.topBlock = Blocks.air.getState(); + this.fillerBlock = Blocks.air.getState(); + } + + protected void addMobs(WeightedList mobs) { + } + + public void genTerrainBlocks(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { + } + + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) { + } + + public Temperature getTempCategory() { + return Temperature.SEA; + } +} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorPlains.java b/server/src/main/java/server/worldgen/biome/BiomePlains.java similarity index 88% rename from server/src/main/java/server/worldgen/populator/PopulatorPlains.java rename to server/src/main/java/server/worldgen/biome/BiomePlains.java index 2d1e4d58..5c2d60ad 100755 --- a/server/src/main/java/server/worldgen/populator/PopulatorPlains.java +++ b/server/src/main/java/server/worldgen/biome/BiomePlains.java @@ -1,12 +1,14 @@ -package server.worldgen.populator; +package server.worldgen.biome; +import common.biome.Biome; import common.block.foliage.BlockFlower; +import common.entity.animal.EntityHorse; import common.init.Blocks; import common.rng.Random; import common.util.BlockPos; import server.world.WorldServer; -public class PopulatorPlains extends PopulatorBasic +public class BiomePlains extends GenBiome { private static final BlockFlower.EnumFlowerType[] TULIP_TYPES = new BlockFlower.EnumFlowerType[] { BlockFlower.EnumFlowerType.ORANGE_TULIP, BlockFlower.EnumFlowerType.RED_TULIP, @@ -14,19 +16,22 @@ public class PopulatorPlains extends PopulatorBasic }; private static final BlockFlower.EnumFlowerType[] FLOWER_TYPES = new BlockFlower.EnumFlowerType[] { - BlockFlower.EnumFlowerType.POPPY, BlockFlower.EnumFlowerType.HOUSTONIA, BlockFlower.EnumFlowerType.DAISY + BlockFlower.EnumFlowerType.POPPY, BlockFlower.EnumFlowerType.HOUSTONIA, BlockFlower.EnumFlowerType.OXEYE_DAISY }; // protected boolean field_150628_aC; - protected PopulatorPlains() + protected BiomePlains() { + super(Biome.PLAIN); + this.setScaling(Scaling.PLAINS_LOW); + this.mobs.add(new RngSpawn(EntityHorse.class, 5, 2, 6)); this.treesPerChunk = -999; this.flowersPerChunk = 4; this.grassPerChunk = 10; } - protected BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) + public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) { double d0 = GRASS_NOISE.generate((double)pos.getX() / 200.0D, (double)pos.getZ() / 200.0D); diff --git a/server/src/main/java/server/worldgen/biome/BiomeSavanna.java b/server/src/main/java/server/worldgen/biome/BiomeSavanna.java new file mode 100755 index 00000000..7b2b5583 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeSavanna.java @@ -0,0 +1,87 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.entity.animal.EntityHorse; +import common.init.Blocks; +import common.rng.Random; +import common.util.BlockPos; +import server.world.WorldServer; +import server.worldgen.ChunkPrimer; +import server.worldgen.tree.WorldGenSavanna; +import server.worldgen.tree.WorldGenTree; + +public class BiomeSavanna extends GenBiome +{ + private static final WorldGenSavanna field_150627_aC = new WorldGenSavanna(false); + + protected BiomeSavanna(boolean plateau) + { + super(plateau ? Biome.SAVANNA_PLATEAU : Biome.SAVANNA); + this.mobs.add(new RngSpawn(EntityHorse.class, 1, 2, 6)); + this.treesPerChunk = 1; + this.flowersPerChunk = 4; + this.grassPerChunk = 20; + } + + public WorldGenTree genBigTreeChance(Random rand) + { + return (WorldGenTree)(rand.rarity(5) ? field_150627_aC : this.worldGeneratorTrees); + } + + protected GenBiome createMutatedBiome(Biome base) + { + GenBiome biomegenbase = new BiomeSavanna.Mutated(base, this); + biomegenbase.depth = this.depth * 0.5F + 0.3F; + biomegenbase.scale = this.scale * 0.5F + 1.2F; + return biomegenbase; + } + + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) + { + DOUBLE_PLANT_GEN.setPlantType(Blocks.large_tallgrass); + + for (int i = 0; i < 7; ++i) + { + int j = rand.chOffset(); + int k = rand.chOffset(); + int l = rand.zrange(worldIn.getHeight(pos.add(j, 0, k)).getY() + 32); + DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j, l, k)); + } + + super.decorate(worldIn, rand, pos); + } + + public static class Mutated extends BiomeMutated + { + public Mutated(Biome base, GenBiome p_i45382_2_) + { + super(base, p_i45382_2_); + this.treesPerChunk = 2; + this.flowersPerChunk = 2; + this.grassPerChunk = 5; + } + + public void genTerrainBlocks(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) + { + this.topBlock = Blocks.grass.getState(); + this.fillerBlock = Blocks.dirt.getState(); + + if (noiseVal > 1.75D) + { + this.topBlock = Blocks.stone.getState(); + this.fillerBlock = Blocks.stone.getState(); + } + else if (noiseVal > -0.5D) + { + this.topBlock = Blocks.coarse_dirt.getState(); + } + + this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); + } + + public void decorate(WorldServer worldIn, Random rand, BlockPos pos) + { + this.decorateNormal(worldIn, rand, pos); + } + } +} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorSnow.java b/server/src/main/java/server/worldgen/biome/BiomeSnow.java similarity index 62% rename from server/src/main/java/server/worldgen/populator/PopulatorSnow.java rename to server/src/main/java/server/worldgen/biome/BiomeSnow.java index 3abca16d..91adb979 100755 --- a/server/src/main/java/server/worldgen/populator/PopulatorSnow.java +++ b/server/src/main/java/server/worldgen/biome/BiomeSnow.java @@ -1,6 +1,9 @@ -package server.worldgen.populator; +package server.worldgen.biome; +import common.biome.Biome; +import common.init.Blocks; import common.rng.Random; +import common.rng.WeightedList; import common.util.BlockPos; import server.world.WorldServer; import server.worldgen.feature.WorldGenIcePath; @@ -8,15 +11,21 @@ import server.worldgen.feature.WorldGenIceSpike; import server.worldgen.tree.WorldGenTaiga2; import server.worldgen.tree.WorldGenTree; -public class PopulatorSnow extends PopulatorBasic +public class BiomeSnow extends GenBiome { private final WorldGenIceSpike spikeGen = new WorldGenIceSpike(); private final WorldGenIcePath pathGen = new WorldGenIcePath(4); private final boolean spiky; - public PopulatorSnow(boolean spiky) + public BiomeSnow(Biome base, boolean spiky) { + super(base); this.spiky = spiky; + if(spiky) + this.topBlock = Blocks.snow.getState(); + } + + protected void addMobs(WeightedList mobs) { } public void decorate(WorldServer worldIn, Random rand, BlockPos pos) @@ -41,8 +50,16 @@ public class PopulatorSnow extends PopulatorBasic super.decorate(worldIn, rand, pos); } - protected WorldGenTree genBigTreeChance(Random rand) + public WorldGenTree genBigTreeChance(Random rand) { return new WorldGenTaiga2(false); } + + protected GenBiome createMutatedBiome(Biome base) + { + GenBiome biomegenbase = (new BiomeSnow(base, true)).enableColdBeach().setScaling(this.depth + 0.1F, this.scale + 0.1F); + biomegenbase.depth = this.depth + 0.3F; + biomegenbase.scale = this.scale + 0.4F; + return biomegenbase; + } } diff --git a/server/src/main/java/server/worldgen/biome/BiomeSnowLand.java b/server/src/main/java/server/worldgen/biome/BiomeSnowLand.java new file mode 100755 index 00000000..e9c3903f --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeSnowLand.java @@ -0,0 +1,23 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.entity.animal.EntitySheep; +import common.entity.npc.EntitySpirit; +import common.init.Blocks; +import common.rng.WeightedList; + +public class BiomeSnowLand extends GenBiome +{ + public BiomeSnowLand() + { + super(Biome.SNOW); + this.topBlock = Blocks.snow.getState(); + this.fillerBlock = Blocks.snow.getState(); + this.mushroomsPerChunk = -1; + } + + protected void addMobs(WeightedList mobs) { + mobs.add(new RngSpawn(EntitySheep.class, 50, 4, 4)); + mobs.add(new RngSpawn(EntitySpirit.class, 10, 1, 1)); + } +} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorAsteroids.java b/server/src/main/java/server/worldgen/biome/BiomeSpace.java similarity index 67% rename from server/src/main/java/server/worldgen/populator/PopulatorAsteroids.java rename to server/src/main/java/server/worldgen/biome/BiomeSpace.java index a3885866..925b1fe5 100755 --- a/server/src/main/java/server/worldgen/populator/PopulatorAsteroids.java +++ b/server/src/main/java/server/worldgen/biome/BiomeSpace.java @@ -1,18 +1,30 @@ -package server.worldgen.populator; +package server.worldgen.biome; +import common.biome.Biome; import common.init.Blocks; import common.rng.Random; +import common.rng.WeightedList; import common.util.BlockPos; import server.world.WorldServer; import server.worldgen.FeatureGenerator; import server.worldgen.feature.WorldGenAsteroid; -public class PopulatorAsteroids extends PopulatorBasic +public class BiomeSpace extends GenBiome { protected FeatureGenerator asteroidGen1 = new WorldGenAsteroid(Blocks.stone.getState(), Blocks.rock.getState()); protected FeatureGenerator asteroidGen2 = new WorldGenAsteroid(Blocks.dirt.getState(), Blocks.coarse_dirt.getState()); + + public BiomeSpace() + { + super(Biome.SPACE); + this.topBlock = Blocks.air.getState(); + this.fillerBlock = Blocks.air.getState(); + } + + protected void addMobs(WeightedList mobs) { + } public void decorate(WorldServer worldIn, Random rand, BlockPos pos) { diff --git a/server/src/main/java/server/worldgen/biome/BiomeStoneBeach.java b/server/src/main/java/server/worldgen/biome/BiomeStoneBeach.java new file mode 100755 index 00000000..0734b434 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeStoneBeach.java @@ -0,0 +1,23 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.init.Blocks; +import common.rng.WeightedList; + +public class BiomeStoneBeach extends GenBiome +{ + public BiomeStoneBeach() + { + super(Biome.STONE_BEACH); +// this.mobs.clear(); + this.topBlock = Blocks.stone.getState(); + this.fillerBlock = Blocks.stone.getState(); + this.treesPerChunk = -999; + this.deadBushPerChunk = 0; + this.reedsPerChunk = 0; + this.cactiPerChunk = 0; + } + + protected void addMobs(WeightedList mobs) { + } +} diff --git a/server/src/main/java/server/worldgen/biome/BiomeSwamp.java b/server/src/main/java/server/worldgen/biome/BiomeSwamp.java new file mode 100755 index 00000000..066615ab --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeSwamp.java @@ -0,0 +1,87 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.block.foliage.BlockFlower; +import common.block.foliage.BlockLilyPad; +import common.entity.npc.EntitySlime; +import common.init.Blocks; +import common.rng.Random; +import common.util.BlockPos; +import common.util.Facing; +import server.world.WorldServer; +import server.worldgen.ChunkPrimer; +import server.worldgen.FeatureGenerator; +import server.worldgen.foliage.WorldGenTallGrass; +import server.worldgen.tree.WorldGenSwamp; +import server.worldgen.tree.WorldGenTree; + +public class BiomeSwamp extends GenBiome +{ + protected final WorldGenSwamp worldGeneratorSwamp = new WorldGenSwamp(); + + protected BiomeSwamp() + { + super(Biome.SWAMP); + this.topBlock = Blocks.swamp.getState(); + this.treesPerChunk = 2; + this.flowersPerChunk = 1; + this.deadBushPerChunk = 1; + this.mushroomsPerChunk = 8; + this.reedsPerChunk = 10; + this.clayPerChunk = 1; + this.waterlilyPerChunk = 4; + this.sandPerChunk2 = 0; + this.sandPerChunk = 0; + this.grassPerChunk = 5; + this.mobs.add(new RngSpawn(EntitySlime.class, 1, 1, 1)); + this.disableBeach(); + } + + public WorldGenTree genBigTreeChance(Random rand) + { + return this.worldGeneratorSwamp; + } + + public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) + { + return BlockFlower.EnumFlowerType.BLUE_ORCHID; + } + + public FeatureGenerator getRandomWorldGenForGrass(Random rand) + { + return new WorldGenTallGrass(Blocks.swamp_grass); + } + + public void genTerrainBlocks(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) + { + int sea = worldIn.getSeaLevel() - 1; + double d0 = GRASS_NOISE.generate((double)x * 0.25D, (double)z * 0.25D); + + if (d0 > 0.0D) + { + int i = x & 15; + int j = z & 15; + + for (int k = chunkPrimerIn.height - 1; k >= 0; --k) + { + if (chunkPrimerIn.get(j, k, i).getBlock() != Blocks.air) + { + if (k == sea) + { + if(!chunkPrimerIn.get(j, k, i).getBlock().getMaterial().isLiquid() || k <= 0 || !chunkPrimerIn.get(j, k - 1, i).getBlock().getMaterial().isLiquid()) + chunkPrimerIn.set(j, k, i, Blocks.swamp_water.getState()); + + if (d0 < 0.12D) + { + chunkPrimerIn.set(j, k + 1, i, Blocks.waterlily.getState().withProperty(BlockLilyPad.FACING, Facing.randHorizontal(rand))); + } + } + + break; + } + } + } + + this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); + } +} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorTaiga.java b/server/src/main/java/server/worldgen/biome/BiomeTaiga.java similarity index 54% rename from server/src/main/java/server/worldgen/populator/PopulatorTaiga.java rename to server/src/main/java/server/worldgen/biome/BiomeTaiga.java index a31de061..ca604fe1 100755 --- a/server/src/main/java/server/worldgen/populator/PopulatorTaiga.java +++ b/server/src/main/java/server/worldgen/biome/BiomeTaiga.java @@ -1,9 +1,12 @@ -package server.worldgen.populator; +package server.worldgen.biome; +import common.biome.Biome; +import common.entity.animal.EntityWolf; import common.init.Blocks; import common.rng.Random; import common.util.BlockPos; import server.world.WorldServer; +import server.worldgen.ChunkPrimer; import server.worldgen.FeatureGenerator; import server.worldgen.feature.WorldGenBlockBlob; import server.worldgen.foliage.WorldGenTallGrass; @@ -12,21 +15,23 @@ import server.worldgen.tree.WorldGenTaiga1; import server.worldgen.tree.WorldGenTaiga2; import server.worldgen.tree.WorldGenTree; -public class PopulatorTaiga extends PopulatorBasic +public class BiomeTaiga extends GenBiome { private static final WorldGenTaiga1 field_150639_aC = new WorldGenTaiga1(); private static final WorldGenTaiga2 field_150640_aD = new WorldGenTaiga2(false); private static final WorldGenPine field_150641_aE = new WorldGenPine(false, false); private static final WorldGenPine field_150642_aF = new WorldGenPine(false, true); private static final WorldGenBlockBlob field_150643_aG = new WorldGenBlockBlob(Blocks.mossy_cobblestone, 0); - private final int subType; + private int field_150644_aH; - public PopulatorTaiga(int subType) + public BiomeTaiga(Biome base, int p_i45385_2_) { - this.subType = subType; + super(base); + this.field_150644_aH = p_i45385_2_; + this.mobs.add(new RngSpawn(EntityWolf.class, 8, 4, 4)); this.treesPerChunk = 10; - if (subType != 1 && subType != 2) + if (p_i45385_2_ != 1 && p_i45385_2_ != 2) { this.grassPerChunk = 1; this.mushroomsPerChunk = 1; @@ -39,19 +44,22 @@ public class PopulatorTaiga extends PopulatorBasic } } - protected WorldGenTree genBigTreeChance(Random rand) + public WorldGenTree genBigTreeChance(Random rand) { - return (WorldGenTree)((this.subType == 1 || this.subType == 2) && rand.chance(3) ? (this.subType != 2 && rand.rarity(13) ? field_150641_aE : field_150642_aF) : (rand.chance(3) ? field_150639_aC : field_150640_aD)); + return (WorldGenTree)((this.field_150644_aH == 1 || this.field_150644_aH == 2) && rand.chance(3) ? (this.field_150644_aH != 2 && rand.rarity(13) ? field_150641_aE : field_150642_aF) : (rand.chance(3) ? field_150639_aC : field_150640_aD)); } - protected FeatureGenerator getRandomWorldGenForGrass(Random rand) + /** + * Gets a WorldGen appropriate for this biome. + */ + public FeatureGenerator getRandomWorldGenForGrass(Random rand) { return rand.rarity(5) ? new WorldGenTallGrass(Blocks.fern) : new WorldGenTallGrass(Blocks.tallgrass); } public void decorate(WorldServer worldIn, Random rand, BlockPos pos) { - if (this.subType == 1 || this.subType == 2) + if (this.field_150644_aH == 1 || this.field_150644_aH == 2) { int i = rand.zrange(3); @@ -76,4 +84,29 @@ public class PopulatorTaiga extends PopulatorBasic super.decorate(worldIn, rand, pos); } + + public void genTerrainBlocks(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) + { + if (this.field_150644_aH == 1 || this.field_150644_aH == 2) + { + this.topBlock = Blocks.grass.getState(); + this.fillerBlock = Blocks.dirt.getState(); + + if (noiseVal > 1.75D) + { + this.topBlock = Blocks.coarse_dirt.getState(); + } + else if (noiseVal > -0.95D) + { + this.topBlock = Blocks.podzol.getState(); + } + } + + this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); + } + + protected GenBiome createMutatedBiome(Biome base) + { + return this.base == Biome.LARGE_TAIGA ? (new BiomeTaiga(base, 2)).setScaling(this.depth, this.scale) : super.createMutatedBiome(base); + } } diff --git a/server/src/main/java/server/worldgen/populator/PopulatorTian.java b/server/src/main/java/server/worldgen/biome/BiomeTian.java similarity index 68% rename from server/src/main/java/server/worldgen/populator/PopulatorTian.java rename to server/src/main/java/server/worldgen/biome/BiomeTian.java index 7fea4646..a2ff2485 100755 --- a/server/src/main/java/server/worldgen/populator/PopulatorTian.java +++ b/server/src/main/java/server/worldgen/biome/BiomeTian.java @@ -1,9 +1,16 @@ -package server.worldgen.populator; +package server.worldgen.biome; +import common.biome.Biome; import common.block.foliage.BlockFlower; +import common.entity.animal.EntityBat; +import common.entity.animal.EntityMouse; +import common.entity.animal.EntityRabbit; +import common.entity.npc.EntityCultivator; +import common.entity.npc.EntityMerfolk; import common.init.Blocks; import common.init.WoodType; import common.rng.Random; +import common.rng.WeightedList; import common.util.BlockPos; import server.world.WorldServer; import server.worldgen.FeatureGenerator; @@ -13,7 +20,7 @@ import server.worldgen.tree.WorldGenBaseTree; import server.worldgen.tree.WorldGenBigTree; import server.worldgen.tree.WorldGenTree; -public class PopulatorTian extends PopulatorBasic +public class BiomeTian extends GenBiome { protected FeatureGenerator spikeGen = new WorldGenSpikes(Blocks.tian_soil, 128, 2, 3, Blocks.obsidian.getState(), true); protected FeatureGenerator mushroomBlueGen = new WorldGenMushroom(Blocks.blue_mushroom); @@ -25,19 +32,30 @@ public class PopulatorTian extends PopulatorBasic protected WorldGenTree treeGen4 = new WorldGenBigTree(false, Blocks.tian_log.getState(), WoodType.TIAN) .setHeightLimit(12, 15); - public PopulatorTian() + public BiomeTian() { + super(Biome.TIAN); + this.topBlock = Blocks.tian_soil.getState(); + this.fillerBlock = Blocks.tian.getState(); this.mushroomsPerChunk = -1; this.grassPerChunk = 0; this.treesPerChunk = 1; } + + protected void addMobs(WeightedList mobs) { + mobs.add(new RngSpawn(EntityCultivator.class, 50, 1, 1)); + mobs.add(new RngSpawn(EntityMerfolk.class, 10, 4, 4)); + mobs.add(new RngSpawn(EntityRabbit.class, 10, 3, 10)); + mobs.add(new RngSpawn(EntityBat.class, 10, 8, 8)); + mobs.add(new RngSpawn(EntityMouse.class, 10, 8, 8)); + } - protected BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) + public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) { return BlockFlower.EnumFlowerType.BLACK_LOTUS; } - protected WorldGenTree genBigTreeChance(Random rand) + public WorldGenTree genBigTreeChance(Random rand) { return rand.pick(rand.chance(this.treeGen2, this.treeGen1, 4), rand.chance(this.treeGen3, this.treeGen4, 15)); } diff --git a/server/src/main/java/server/worldgen/biome/BiomeWater.java b/server/src/main/java/server/worldgen/biome/BiomeWater.java new file mode 100755 index 00000000..141bcc3f --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/BiomeWater.java @@ -0,0 +1,24 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.entity.npc.EntityMerfolk; +import common.rng.WeightedList; + +public class BiomeWater extends GenBiome { + private final boolean river; + + public BiomeWater(Biome base, boolean river) { + super(base); + this.river = river; + this.disableBeach(); + if(!this.river) + this.mobs.add(new RngSpawn(EntityMerfolk.class, 10, 4, 4)); + } + + protected void addMobs(WeightedList mobs) { + } + + public Temperature getTempCategory() { + return this.river ? super.getTempCategory() : Temperature.SEA; + } +} diff --git a/server/src/main/java/server/worldgen/biome/GenBiome.java b/server/src/main/java/server/worldgen/biome/GenBiome.java new file mode 100755 index 00000000..31b162e8 --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/GenBiome.java @@ -0,0 +1,873 @@ +package server.worldgen.biome; + +import common.biome.Biome; +import common.biome.IBiome; +import common.block.Block; +import common.block.Material; +import common.block.foliage.BlockFlower; +import common.block.foliage.BlockSapling; +import common.entity.animal.EntityBat; +import common.entity.animal.EntityChicken; +import common.entity.animal.EntityCow; +import common.entity.animal.EntityMouse; +import common.entity.animal.EntityPig; +import common.entity.animal.EntityRabbit; +import common.entity.animal.EntitySheep; +import common.entity.npc.EntityArachnoid; +import common.entity.npc.EntityHaunter; +import common.entity.npc.EntityMage; +import common.entity.npc.EntitySlime; +import common.entity.npc.EntityUndead; +import common.entity.npc.EntityZombie; +import common.init.Blocks; +import common.init.WoodType; +import common.log.Log; +import common.rng.PerlinGen; +import common.rng.Random; +import common.rng.WeightedList; +import common.util.BlockPos; +import common.world.AWorldServer; +import common.world.State; +import common.world.World; +import server.world.WorldServer; +import server.worldgen.ChunkPrimer; +import server.worldgen.FeatureGenerator; +import server.worldgen.feature.WorldGenClay; +import server.worldgen.feature.WorldGenClayExt; +import server.worldgen.feature.WorldGenSand; +import server.worldgen.foliage.FeatureDoublePlant; +import server.worldgen.foliage.WorldGenBigMushroom; +import server.worldgen.foliage.WorldGenCactus; +import server.worldgen.foliage.WorldGenDeadBush; +import server.worldgen.foliage.WorldGenFlowers; +import server.worldgen.foliage.WorldGenMushroom; +import server.worldgen.foliage.WorldGenPumpkin; +import server.worldgen.foliage.WorldGenReed; +import server.worldgen.foliage.WorldGenTallGrass; +import server.worldgen.foliage.WorldGenWaterlily; +import server.worldgen.tree.WorldGenBaseTree; +import server.worldgen.tree.WorldGenBigTree; +import server.worldgen.tree.WorldGenBirch; +import server.worldgen.tree.WorldGenDarkOak; +import server.worldgen.tree.WorldGenJungle; +import server.worldgen.tree.WorldGenPine; +import server.worldgen.tree.WorldGenSavanna; +import server.worldgen.tree.WorldGenSwamp; +import server.worldgen.tree.WorldGenTaiga2; +import server.worldgen.tree.WorldGenTree; + +public abstract class GenBiome implements IBiome { + public static final GenBiome[] BIOMES = new GenBiome[256]; + + public static final GenBiome none = (new BiomeNone()); + + public static final GenBiome plains = (new BiomePlains()); + public static final GenBiome desert = (new BiomeDesert(false)).setScaling(Scaling.PLAINS_LOW); + public static final GenBiome extremeHills = (new BiomeHills(Biome.HILLS, false)).setScaling(Scaling.HILLS_LARGE); + public static final GenBiome forest = (new BiomeForest(Biome.FOREST, 0)); + public static final GenBiome taiga = (new BiomeTaiga(Biome.TAIGA, 0)).setScaling(Scaling.PLAINS_MEDIUM); + public static final GenBiome swampland = (new BiomeSwamp()).setScaling(Scaling.SEA_POND); + public static final GenBiome river = (new BiomeWater(Biome.RIVER, true)).setScaling(Scaling.SEA_SHALLOW); + + public static final GenBiome exterminated = (new BiomeExterminated()); + public static final GenBiome space = (new BiomeSpace()); + + public static final GenBiome frozenSea = (new BiomeWater(Biome.ICE_SEA, false)).enableColdBeach().setScaling(Scaling.SEA_MEDIUM); + public static final GenBiome frozenRiver = (new BiomeWater(Biome.ICE_RIVER, true)).enableColdBeach().setScaling(Scaling.SEA_SHALLOW); + public static final GenBiome icePlains = (new BiomeSnow(Biome.ICE, false)).enableColdBeach().setScaling(Scaling.PLAINS_LOW); + public static final GenBiome iceMountains = (new BiomeSnow(Biome.ICE_HILLS, false)).enableColdBeach().setScaling(Scaling.HILLS_LOW); + public static final GenBiome mushroomPlains = (new BiomeMushroom()).setScaling(Scaling.PLAINS_VARYING); + public static final GenBiome blackened = (new BiomeBlackened()); + public static final GenBiome beach = (new BiomeBeach(false)).setScaling(Scaling.SEA_SHORE); + public static final GenBiome desertHills = (new BiomeDesert(true)).setScaling(Scaling.HILLS_LOW); + public static final GenBiome forestHills = (new BiomeForest(Biome.FOREST_HILLS, 0)).setScaling(Scaling.HILLS_LOW); + public static final GenBiome taigaHills = (new BiomeTaiga(Biome.TAIGA_HILLS, 0)).setScaling(Scaling.HILLS_LOW); + public static final GenBiome extremeHillsEdge = (new BiomeHills(Biome.HILLS_EDGE, true)).setScaling(Scaling.HILLS_MEDIUM); + public static final GenBiome jungle = (new BiomeJungle(Biome.TROPIC, false)); + public static final GenBiome jungleHills = (new BiomeJungle(Biome.TROPIC_HILLS, false)).setScaling(Scaling.HILLS_LOW); + public static final GenBiome jungleEdge = (new BiomeJungle(Biome.TROPIC_EDGE, true)); + public static final GenBiome sea = (new BiomeWater(Biome.SEA, false)).setScaling(Scaling.SEA_MEDIUM); + public static final GenBiome stoneBeach = (new BiomeStoneBeach()).setScaling(Scaling.SEA_VARYING); + public static final GenBiome coldBeach = (new BiomeBeach(true)).setScaling(Scaling.SEA_SHORE).enableColdBeach(); + public static final GenBiome birchForest = (new BiomeForest(Biome.BIRCH_FOREST, 2)); + public static final GenBiome birchForestHills = (new BiomeForest(Biome.BIRCH_HILLS, 2)).setScaling(Scaling.HILLS_LOW); + public static final GenBiome roofedForest = (new BiomeForest(Biome.DARK_FOREST, 3)); + public static final GenBiome coldTaiga = (new BiomeTaiga(Biome.ICE_TAIGA, 0)).enableColdBeach().setScaling(Scaling.PLAINS_MEDIUM); + public static final GenBiome coldTaigaHills = (new BiomeTaiga(Biome.ICE_TAIGA_HILLS, 0)).enableColdBeach().setScaling(Scaling.HILLS_LOW); + public static final GenBiome megaTaiga = (new BiomeTaiga(Biome.LARGE_TAIGA, 1)).setScaling(Scaling.PLAINS_MEDIUM); + public static final GenBiome megaTaigaHills = (new BiomeTaiga(Biome.LARGE_TAIGA_HILLS, 1)).setScaling(Scaling.HILLS_LOW); + public static final GenBiome extremeHillsPlus = (new BiomeHills(Biome.LARGE_HILLS, true)).setScaling(Scaling.HILLS_LARGE); + public static final GenBiome savanna = (new BiomeSavanna(false)).setScaling(Scaling.PLAINS_LOW); + public static final GenBiome savannaPlateau = (new BiomeSavanna(true)).setScaling(Scaling.HILLS_PLATEAU); + + public static final GenBiome mesa = (new BiomeMesa(Biome.MESA, false, false)); + public static final GenBiome mesaPlateau_F = (new BiomeMesa(Biome.MESA_FOREST, false, true)).setScaling(Scaling.HILLS_PLATEAU); + public static final GenBiome mesaPlateau = (new BiomeMesa(Biome.MESA_PLATEAU, false, false)).setScaling(Scaling.HILLS_PLATEAU); + + public static final GenBiome snowLand = (new BiomeSnowLand()).enableColdBeach(); + public static final GenBiome tian = (new BiomeTian()).setScaling(Scaling.VARYING_MEDIUM); + public static final GenBiome elvenForest = (new BiomeForest(Biome.ELVEN_FOREST, 4)); + public static final GenBiome upperHell = (new BiomeHell(Biome.UPPER_HELL, 0)); + public static final GenBiome lowerHell = (new BiomeHell(Biome.LOWER_HELL, 1)); + public static final GenBiome hellHills = (new BiomeHell(Biome.HELL_HILLS, 1)).setScaling(Scaling.HILLS_LARGE); + public static final GenBiome soulPlains = (new BiomeHell(Biome.SOUL_PLAINS, 1)).setScaling(Scaling.SEA_POND); + public static final GenBiome ashLand = (new BiomeHell(Biome.ASH, 2)).setScaling(Scaling.PLAINS_LOW); + public static final GenBiome moon = (new BiomeMoon()).setScaling(Scaling.PLAINS_LOW); + public static final GenBiome chaos = (new BiomeChaos()).setScaling(Scaling.VARYING_CHAOTIC); + + protected static final PerlinGen TREE_NOISE = new PerlinGen(new Random(726528729282625L), 8); + protected static final PerlinGen GRASS_NOISE = new PerlinGen(new Random(297363826225L), 1); + protected static final FeatureDoublePlant DOUBLE_PLANT_GEN = new FeatureDoublePlant(); + + public final Biome base; + + protected final WeightedList mobs = new WeightedList(); + protected final WorldGenBaseTree worldGeneratorTrees = new WorldGenBaseTree(false); + protected final WorldGenBigTree worldGeneratorBigTree = new WorldGenBigTree(false); + private final FeatureGenerator clayGen = new WorldGenClay(4); + private final FeatureGenerator sandGen = new WorldGenSand(Blocks.sand, 7); + private final FeatureGenerator gravelAsSandGen = new WorldGenSand(Blocks.gravel, 6); + private final WorldGenFlowers yellowFlowerGen = new WorldGenFlowers(Blocks.dandelion); + private final FeatureGenerator mushroomBrownGen = new WorldGenMushroom(Blocks.brown_mushroom); + private final FeatureGenerator mushroomRedGen = new WorldGenMushroom(Blocks.red_mushroom); + private final FeatureGenerator bigMushroomGen = new WorldGenBigMushroom(); + private final FeatureGenerator reedGen = new WorldGenReed(); + private final FeatureGenerator cactusGen = new WorldGenCactus(); + private final FeatureGenerator waterlilyGen = new WorldGenWaterlily(); + private final FeatureGenerator clayGenExt = new WorldGenClayExt(32); + + public Biome mutated = null; + public State topBlock = Blocks.grass.getState(); + public State fillerBlock = Blocks.dirt.getState(); + public float depth = Scaling.VARYING_LOW.depth; + public float scale = Scaling.VARYING_LOW.scale; + public boolean generateLakes = true; + public boolean generateLiquids = true; + public boolean allowColdBeach = false; + public boolean disallowBeach = false; + + protected int waterlilyPerChunk = 0; + protected int treesPerChunk = 0; + protected int flowersPerChunk = 2; + protected int grassPerChunk = 1; + protected int deadBushPerChunk = 0; + protected int mushroomsPerChunk = 0; + protected int reedsPerChunk = 0; + protected int cactiPerChunk = 0; + protected int sandPerChunk = 1; + protected int sandPerChunk2 = 3; + protected int clayPerChunk = 1; + protected int clayExtPerChunk = 0; // 10 + protected int bigMushroomsPerChunk = 0; + + public static GenBiome getBiome(int id) + { + if (id >= 0 && id < BIOMES.length) + { + return BIOMES[id]; + } + else + { + Log.TICK.warn("Biom-ID ist nicht im Bereich: " + id + ", verwende " + Biome.DEF_BIOME.id + " (" + Biome.DEF_BIOME.name + ")"); + return BIOMES[Biome.DEF_BIOME.id]; + } + } + + public static void setAsProvider() { + IBiome.setProvider(new IBiome.BiomeProvider() { + public final IBiome getBiome(Biome base) { + return BIOMES[base.id]; + } + }); + } + + static { + desert.mutate(Biome.DESERT_MOD); + forest.mutate(Biome.FLOWER_FOREST); + taiga.mutate(Biome.TAIGA_MOD); + swampland.mutate(Biome.SWAMP_MOD); + icePlains.mutate(Biome.ICE_SPIKES); + jungle.mutate(Biome.TROPIC_MOD); + jungleEdge.mutate(Biome.TROPIC_EDGE_MOD); + coldTaiga.mutate(Biome.ICE_TAIGA_MOD); + savanna.mutate(Biome.SAVANNA_MOD); + savannaPlateau.mutate(Biome.SAVANNA_PLATEAU_MOD); + mesa.mutate(Biome.MESA_PEAK); + mesaPlateau_F.mutate(Biome.MESA_FOREST_MOD); + mesaPlateau.mutate(Biome.MESA_PLATEAU_MOD); + birchForest.mutate(Biome.BIRCH_FOREST_MOD); + birchForestHills.mutate(Biome.BIRCH_HILLS_MOD); + roofedForest.mutate(Biome.DARK_FOREST_MOD); + megaTaiga.mutate(Biome.SPRUCE_TAIGA); + extremeHills.mutate(Biome.HILLS_MOD); + extremeHillsPlus.mutate(Biome.LARGE_HILLS_MOD); + megaTaiga.mutate(Biome.REDWOOD_TAIGA); + } + + protected GenBiome(Biome base) { + BIOMES[base.id] = this; + this.base = base; + this.addMobs(this.mobs); + } + + protected void addMobs(WeightedList mobs) { + mobs.add(new RngSpawn(EntitySheep.class, 12, 4, 4)); + mobs.add(new RngSpawn(EntityRabbit.class, 10, 3, 10)); + mobs.add(new RngSpawn(EntityPig.class, 10, 4, 4)); + mobs.add(new RngSpawn(EntityChicken.class, 10, 4, 4)); + mobs.add(new RngSpawn(EntityCow.class, 8, 4, 4)); + mobs.add(new RngSpawn(EntityArachnoid.class, 100, 4, 4)); + mobs.add(new RngSpawn(EntityZombie.class, 100, 4, 4)); + mobs.add(new RngSpawn(EntityUndead.class, 100, 4, 4)); + mobs.add(new RngSpawn(EntityHaunter.class, 100, 4, 4)); + mobs.add(new RngSpawn(EntitySlime.class, 100, 4, 4)); +// mobs.add(new Biome.RngSpawn(EntityEnder....class, 10, 1, 4)); + mobs.add(new RngSpawn(EntityMage.class, 5, 1, 1)); + mobs.add(new RngSpawn(EntityBat.class, 10, 8, 8)); + mobs.add(new RngSpawn(EntityMouse.class, 10, 8, 8)); + } + + protected final GenBiome setScaling(Scaling scaling) + { + return this.setScaling(scaling.depth, scaling.scale); + } + + protected final GenBiome setScaling(float depth, float scale) + { + this.depth = depth; + this.scale = scale; + return this; + } + + public WorldGenTree genBigTreeChance(Random rand) + { + return rand.chance(10) ? this.worldGeneratorBigTree : this.worldGeneratorTrees; + } + + public WorldGenTree genBigTreeLegacy(Random rand, BlockPos pos, boolean humid) + { + int noise = (int)((TREE_NOISE.generate((double)pos.getX() * 0.5D, (double)pos.getZ() * 0.5D) / 8D + rand.doublev() * 4D + 4D) / 3D); + return (noise > 0 && rand.chance(noise)) || (humid && rand.chance(3)) ? this.worldGeneratorBigTree : + this.worldGeneratorTrees; + } + + public FeatureGenerator getRandomWorldGenForGrass(Random rand) + { + return new WorldGenTallGrass(Blocks.tallgrass); + } + + public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) + { + return rand.rarity(3) ? BlockFlower.EnumFlowerType.DANDELION : BlockFlower.EnumFlowerType.ROSE; + } + + public State getFiller() { + return this.fillerBlock; + } + + public State getTop() { + return this.topBlock; + } + + protected GenBiome enableColdBeach() + { + this.allowColdBeach = true; + return this; + } + + protected GenBiome disableBeach() + { + this.disallowBeach = true; + return this; + } + + public WeightedList getMobs() + { + return this.mobs; + } + + public float getMobGenChance() + { + return 0.1F; + } + + public void decorate(WorldServer world, Random rand, BlockPos pos) + { + for (int i = 0; i < this.sandPerChunk2; ++i) + { + int j = rand.chOffset(); + int k = rand.chOffset(); + this.sandGen.generate(world, rand, world.getHighestFreePos(pos.add(j, 0, k))); + } + + for (int i1 = 0; i1 < this.clayPerChunk; ++i1) + { + int l1 = rand.chOffset(); + int i6 = rand.chOffset(); + this.clayGen.generate(world, rand, world.getHighestFreePos(pos.add(l1, 0, i6))); + } + + for (int j1 = 0; j1 < this.sandPerChunk; ++j1) + { + int i2 = rand.chOffset(); + int j6 = rand.chOffset(); + this.gravelAsSandGen.generate(world, rand, world.getHighestFreePos(pos.add(i2, 0, j6))); + } + + for (int i1 = 0; i1 < this.clayExtPerChunk; ++i1) + { + int l1 = rand.chOffset(); + int i6 = rand.chOffset(); + this.clayGenExt.generate(world, rand, world.getHighestFreePos(pos.add(l1, 0, i6))); + } + + int k1 = this.treesPerChunk; + + if (rand.chance(10)) + { + ++k1; + } + + for (int j2 = 0; j2 < k1; ++j2) + { + int k6 = rand.chOffset(); + int l = rand.chOffset(); + WorldGenTree treeGen = this.genBigTreeChance(rand); + treeGen.prepare(); + BlockPos blockpos = world.getHeight(pos.add(k6, 0, l)); + + if (treeGen.generate(world, rand, blockpos)) + { + treeGen.finish(world, rand, blockpos); + } + } + + for (int k2 = 0; k2 < this.bigMushroomsPerChunk; ++k2) + { + int l6 = rand.chOffset(); + int k10 = rand.chOffset(); + this.bigMushroomGen.generate(world, rand, world.getHeight(pos.add(l6, 0, k10))); + } + + for (int l2 = 0; l2 < this.flowersPerChunk; ++l2) + { + int i7 = rand.chOffset(); + int l10 = rand.chOffset(); + int j14 = world.getHeight(pos.add(i7, 0, l10)).getY() + 32; + + if (j14 > 0) + { + int k17 = rand.zrange(j14); + BlockPos blockpos1 = pos.add(i7, k17, l10); + BlockFlower.EnumFlowerType blockflower$enumflowertype = this.pickRandomFlower(rand, blockpos1); + + this.yellowFlowerGen.setGeneratedBlock(BlockFlower.getByType(blockflower$enumflowertype)); + this.yellowFlowerGen.generate(world, rand, blockpos1); + } + } + + for (int i3 = 0; i3 < this.grassPerChunk; ++i3) + { + int j7 = rand.chOffset(); + int i11 = rand.chOffset(); + int k14 = world.getHeight(pos.add(j7, 0, i11)).getY() * 2; + + if (k14 > 0) + { + int l17 = rand.zrange(k14); + this.getRandomWorldGenForGrass(rand).generate(world, rand, pos.add(j7, l17, i11)); + } + } + + for (int j3 = 0; j3 < this.deadBushPerChunk; ++j3) + { + int k7 = rand.chOffset(); + int j11 = rand.chOffset(); + int l14 = world.getHeight(pos.add(k7, 0, j11)).getY() * 2; + + if (l14 > 0) + { + int i18 = rand.zrange(l14); + (new WorldGenDeadBush()).generate(world, rand, pos.add(k7, i18, j11)); + } + } + + for (int k3 = 0; k3 < this.waterlilyPerChunk; ++k3) + { + int l7 = rand.chOffset(); + int k11 = rand.chOffset(); + int i15 = world.getHeight(pos.add(l7, 0, k11)).getY() * 2; + + if (i15 > 0) + { + int j18 = rand.zrange(i15); + BlockPos blockpos4; + BlockPos blockpos7; + + for (blockpos4 = pos.add(l7, j18, k11); blockpos4.getY() > 0; blockpos4 = blockpos7) + { + blockpos7 = blockpos4.down(); + + if (!world.isAirBlock(blockpos7)) + { + break; + } + } + + this.waterlilyGen.generate(world, rand, blockpos4); + } + } + + for (int l3 = 0; l3 < this.mushroomsPerChunk; ++l3) + { + if (rand.chance(4)) + { + int i8 = rand.chOffset(); + int l11 = rand.chOffset(); + BlockPos blockpos2 = world.getHeight(pos.add(i8, 0, l11)); + this.mushroomBrownGen.generate(world, rand, blockpos2); + } + + if (rand.chance(8)) + { + int j8 = rand.chOffset(); + int i12 = rand.chOffset(); + int j15 = world.getHeight(pos.add(j8, 0, i12)).getY() * 2; + + if (j15 > 0) + { + int k18 = rand.zrange(j15); + BlockPos blockpos5 = pos.add(j8, k18, i12); + this.mushroomRedGen.generate(world, rand, blockpos5); + } + } + } + + if (this.mushroomsPerChunk != -1 && rand.chance(4)) + { + int i4 = rand.chOffset(); + int k8 = rand.chOffset(); + int j12 = world.getHeight(pos.add(i4, 0, k8)).getY() * 2; + + if (j12 > 0) + { + int k15 = rand.zrange(j12); + this.mushroomBrownGen.generate(world, rand, pos.add(i4, k15, k8)); + } + } + + if (this.mushroomsPerChunk != -1 && rand.chance(8)) + { + int j4 = rand.chOffset(); + int l8 = rand.chOffset(); + int k12 = world.getHeight(pos.add(j4, 0, l8)).getY() * 2; + + if (k12 > 0) + { + int l15 = rand.zrange(k12); + this.mushroomRedGen.generate(world, rand, pos.add(j4, l15, l8)); + } + } + + for (int k4 = 0; k4 < this.reedsPerChunk; ++k4) + { + int i9 = rand.chOffset(); + int l12 = rand.chOffset(); + int i16 = world.getHeight(pos.add(i9, 0, l12)).getY() * 2; + + if (i16 > 0) + { + int l18 = rand.zrange(i16); + this.reedGen.generate(world, rand, pos.add(i9, l18, l12)); + } + } + + for (int l4 = 0; l4 < 10; ++l4) + { + int j9 = rand.chOffset(); + int i13 = rand.chOffset(); + int j16 = world.getHeight(pos.add(j9, 0, i13)).getY() * 2; + + if (j16 > 0) + { + int i19 = rand.zrange(j16); + this.reedGen.generate(world, rand, pos.add(j9, i19, i13)); + } + } + + if (rand.chance(32)) + { + int i5 = rand.chOffset(); + int k9 = rand.chOffset(); + int j13 = world.getHeight(pos.add(i5, 0, k9)).getY() * 2; + + if (j13 > 0) + { + int k16 = rand.zrange(j13); + (new WorldGenPumpkin()).generate(world, rand, pos.add(i5, k16, k9)); + } + } + + for (int j5 = 0; j5 < this.cactiPerChunk; ++j5) + { + int l9 = rand.chOffset(); + int k13 = rand.chOffset(); + int l16 = world.getHeight(pos.add(l9, 0, k13)).getY() * 2; + + if (l16 > 0) + { + int j19 = rand.zrange(l16); + this.cactusGen.generate(world, rand, pos.add(l9, j19, k13)); + } + } + } + + public void genTerrainBlocks(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) + { + this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); + } + + /** + * Given x, z coordinates, we count down all the y positions starting at height - 1 and working our way down. When we hit a + * non-air block, we replace it with this.topBlock (default grass, descendants may set otherwise), and then a + * relatively shallow layer of blocks of type this.fillerBlock (default dirt). A random set of blocks below y == 5 + * (but always including y == 0) is replaced with bedrock in Chunk(...). + * + * If we don't hit non-air until somewhat below sea level, we top with gravel and fill down with stone. + * + * If this.fillerBlock is red sand, we replace some of that with red sandstone. + */ + public final void generateBiomeTerrain(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) + { + int i = worldIn.getSeaLevel(); + State worldState = worldIn.dimension.getFiller(); + Block worldBlock = worldState.getBlock(); + State worldAlt = worldIn.dimension.getAltFiller1(); + State liquid = worldIn.getSurfaceLiquid(); + boolean freeze = liquid.getBlock().getMaterial() == Material.WATER; + State iblockstate = this.topBlock; + State iblockstate1 = this.fillerBlock; + int j = -1; + int k = (int)(noiseVal / 3.0D + 3.0D + rand.doublev() * 0.25D); + int l = x & 15; + int i1 = z & 15; + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + + for (int j1 = chunkPrimerIn.height - 1; j1 >= 0; --j1) + { + State iblockstate2 = chunkPrimerIn.get(i1, j1, l); + + if (iblockstate2.getBlock() == Blocks.air) + { + j = -1; + } + else if (iblockstate2.getBlock() == worldBlock) + { + if (j == -1) + { + if (k <= 0) + { + iblockstate = null; + iblockstate1 = worldState; + } + else if (j1 >= i - 4 && j1 <= i + 1) + { + iblockstate = this.topBlock; + iblockstate1 = this.fillerBlock; + } + + if (j1 < i && (iblockstate == null || iblockstate.getBlock() == Blocks.air)) + { + if (freeze && World.ABSOLUTE_ZERO + worldIn.getTempOffset() + this.base.getTemperature(blockpos$mutableblockpos.set(x, j1, z)) <= 0.0F) + { + iblockstate = Blocks.ice.getState(); + } + else + { + iblockstate = liquid; + } + } + + j = k; + + if (j1 >= i - 1) + { + chunkPrimerIn.set(i1, j1, l, iblockstate); + } + else if (j1 < i - 7 - k) + { + iblockstate = null; + iblockstate1 = worldState; + chunkPrimerIn.set(i1, j1, l, worldAlt); + } + else + { + chunkPrimerIn.set(i1, j1, l, iblockstate1); + } + } + else if (j > 0) + { + --j; + chunkPrimerIn.set(i1, j1, l, iblockstate1); + + if (j == 0 && iblockstate1.getBlock() == Blocks.sand) + { + j = rand.zrange(4) + Math.max(0, j1 - 63); + iblockstate1 = Blocks.sandstone.getState(); //TODO: check! + } + else if (j == 0 && iblockstate1.getBlock() == Blocks.red_sand) + { + j = rand.zrange(4) + Math.max(0, j1 - 63); + iblockstate1 = Blocks.orange_clay.getState(); //TODO: check! + } + } + } + } + } + + public boolean generateBigMushroom(AWorldServer worldIn, BlockPos pos, State state, Random rand) + { + worldIn.setBlockToAir(pos); + FeatureGenerator worldgenerator = null; + + if (state.getBlock() == Blocks.brown_mushroom) + { + worldgenerator = new WorldGenBigMushroom(Blocks.brown_mushroom_block); + } + else if (state.getBlock() == Blocks.red_mushroom) + { + worldgenerator = new WorldGenBigMushroom(Blocks.red_mushroom_block); + } + + if (worldgenerator != null && worldgenerator.generate((WorldServer)worldIn, rand, pos)) + { + return true; + } + else + { + worldIn.setState(pos, state, 3); + return false; + } + } + + private boolean isTypeAt(World worldIn, BlockPos pos, WoodType type) + { + State iblockstate = worldIn.getState(pos); + return iblockstate.getBlock() instanceof BlockSapling && ((BlockSapling)iblockstate.getBlock()).getWoodType() == type; + } + + private boolean isSameSaplingTypeIn(World worldIn, BlockPos pos, int xOff, int yOff, WoodType type) + { + return this.isTypeAt(worldIn, pos.add(xOff, 0, yOff), type) && this.isTypeAt(worldIn, pos.add(xOff + 1, 0, yOff), type) && this.isTypeAt(worldIn, pos.add(xOff, 0, yOff + 1), type) && this.isTypeAt(worldIn, pos.add(xOff + 1, 0, yOff + 1), type); + } + + public void generateTree(AWorldServer worldIn, BlockPos pos, State state, Random rand) + { + WoodType type = state.getBlock() instanceof BlockSapling ? ((BlockSapling)state.getBlock()).getWoodType() : WoodType.OAK; + State log = type == WoodType.CHERRY ? Blocks.cherry_log.getState() : // .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.CHERRY) : + (type == WoodType.MAPLE ? Blocks.maple_log.getState() /* .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.MAPLE) */ : Blocks.oak_log.getState()); + WoodType leaves = type == WoodType.CHERRY || type == WoodType.MAPLE ? type : WoodType.OAK; + FeatureGenerator worldgenerator = (FeatureGenerator)(rand.chance(10) ? new WorldGenBigTree(true, log, leaves) : new WorldGenBaseTree(true, log, leaves)); + int i = 0; + int j = 0; + boolean flag = false; +// leaves = leaves.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()); + + switch (type) + { + case SPRUCE: + label114: + for (i = 0; i >= -1; --i) + { + for (j = 0; j >= -1; --j) + { + if (this.isSameSaplingTypeIn(worldIn, pos, i, j, WoodType.SPRUCE)) + { + worldgenerator = new WorldGenPine(false, rand.chance()); + flag = true; + break label114; + } + } + } + + if (!flag) + { + j = 0; + i = 0; + worldgenerator = new WorldGenTaiga2(true); + } + + break; + + case BIRCH: + worldgenerator = new WorldGenBirch(true, false); + break; + + case TIAN: + worldgenerator = new WorldGenBigTree(true, Blocks.tian_log.getState(), WoodType.TIAN) + .setHeightLimit(6, 20); + break; + + case JUNGLE: + State iblockstate = Blocks.jungle_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE); + WoodType iblockstate1 = WoodType.JUNGLE; // .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE); // .withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); + label269: + + for (i = 0; i >= -1; --i) + { + for (j = 0; j >= -1; --j) + { + if (this.isSameSaplingTypeIn(worldIn, pos, i, j, WoodType.JUNGLE)) + { + worldgenerator = new WorldGenJungle(true, 10, 20, iblockstate, iblockstate1); + flag = true; + break label269; + } + } + } + + if (!flag) + { + j = 0; + i = 0; + worldgenerator = new WorldGenBaseTree(true, rand.range(4, 10), iblockstate, iblockstate1, false); + } + + break; + + case ACACIA: + worldgenerator = new WorldGenSavanna(true); + break; + + case DARK_OAK: + label390: + for (i = 0; i >= -1; --i) + { + for (j = 0; j >= -1; --j) + { + if (this.isSameSaplingTypeIn(worldIn, pos, i, j, WoodType.DARK_OAK)) + { + worldgenerator = new WorldGenDarkOak(true); + flag = true; + break label390; + } + } + } + + if (!flag) + { + return; + } + + case OAK: + case CHERRY: + case MAPLE: + } + + State iblockstate2 = Blocks.air.getState(); + + if (flag) + { + worldIn.setState(pos.add(i, 0, j), iblockstate2, 4); + worldIn.setState(pos.add(i + 1, 0, j), iblockstate2, 4); + worldIn.setState(pos.add(i, 0, j + 1), iblockstate2, 4); + worldIn.setState(pos.add(i + 1, 0, j + 1), iblockstate2, 4); + } + else + { + worldIn.setState(pos, iblockstate2, 4); + } + + if (!worldgenerator.generate((WorldServer)worldIn, rand, pos.add(i, 0, j))) + { + if (flag) + { + worldIn.setState(pos.add(i, 0, j), state, 4); + worldIn.setState(pos.add(i + 1, 0, j), state, 4); + worldIn.setState(pos.add(i, 0, j + 1), state, 4); + worldIn.setState(pos.add(i + 1, 0, j + 1), state, 4); + } + else + { + worldIn.setState(pos, state, 4); + } + } + } + + public void growGrass(AWorldServer worldIn, BlockPos pos, State state, Random rand) + { + BlockPos blockpos = pos.up(); + + for (int i = 0; i < 128; ++i) + { + BlockPos blockpos1 = blockpos; + int j = 0; + + while (true) + { + if (j >= i / 16) + { + if (worldIn.getState(blockpos1).getBlock() == Blocks.air) + { + if (rand.chance(8)) + { + BlockFlower.EnumFlowerType blockflower$enumflowertype = BIOMES[worldIn.getBiomeGenForCoords(blockpos1).id].pickRandomFlower(rand, blockpos1); + BlockFlower blockflower = BlockFlower.getByType(blockflower$enumflowertype); + State iblockstate = blockflower.getState(); + + if (blockflower.canBlockStay(worldIn, blockpos1, iblockstate)) + { + worldIn.setState(blockpos1, iblockstate, 3); + } + } + else + { + State iblockstate1 = Blocks.tallgrass.getState(); + + if (Blocks.tallgrass.canBlockStay(worldIn, blockpos1, iblockstate1)) + { + worldIn.setState(blockpos1, iblockstate1, 3); + } + } + } + + break; + } + + blockpos1 = blockpos1.add(rand.zrange(3) - 1, (rand.zrange(3) - 1) * rand.zrange(3) / 2, rand.zrange(3) - 1); + + if (worldIn.getState(blockpos1.down()).getBlock() != Blocks.grass || worldIn.getState(blockpos1).getBlock().isNormalCube()) + { + break; + } + + ++j; + } + } + } + + protected GenBiome createMutatedBiome(Biome base) + { + return new BiomeMutated(base, this); + } + + private void mutate(Biome base) + { + this.createMutatedBiome(this.mutated = base); + } + + public Class getBiomeClass() + { + return this.getClass(); + } + + public boolean isEqualTo(GenBiome biome) + { + return biome == this ? true : (biome == null ? false : this.getBiomeClass() == biome.getBiomeClass()); + } + + public Temperature getTempCategory() + { + return this.base.temperature < -12.0f ? Temperature.COLD : (this.base.temperature < 20.0f ? Temperature.MEDIUM : Temperature.WARM); + } +} diff --git a/common/src/main/java/common/dimension/RngSpawn.java b/server/src/main/java/server/worldgen/biome/RngSpawn.java similarity index 92% rename from common/src/main/java/common/dimension/RngSpawn.java rename to server/src/main/java/server/worldgen/biome/RngSpawn.java index 82d2d54d..abd00e84 100644 --- a/common/src/main/java/common/dimension/RngSpawn.java +++ b/server/src/main/java/server/worldgen/biome/RngSpawn.java @@ -1,4 +1,4 @@ -package common.dimension; +package server.worldgen.biome; import common.entity.types.EntityLiving; import common.rng.RngItem; diff --git a/common/src/main/java/common/biome/Scaling.java b/server/src/main/java/server/worldgen/biome/Scaling.java similarity index 95% rename from common/src/main/java/common/biome/Scaling.java rename to server/src/main/java/server/worldgen/biome/Scaling.java index 1518b574..eecc2537 100644 --- a/common/src/main/java/common/biome/Scaling.java +++ b/server/src/main/java/server/worldgen/biome/Scaling.java @@ -1,4 +1,4 @@ -package common.biome; +package server.worldgen.biome; public enum Scaling { VARYING_LOW(0.1F, 0.2F), diff --git a/server/src/main/java/server/worldgen/biome/Temperature.java b/server/src/main/java/server/worldgen/biome/Temperature.java new file mode 100644 index 00000000..c61178fa --- /dev/null +++ b/server/src/main/java/server/worldgen/biome/Temperature.java @@ -0,0 +1,5 @@ +package server.worldgen.biome; + +public enum Temperature { + SEA, COLD, MEDIUM, WARM; +} diff --git a/server/src/main/java/server/worldgen/caves/MapGenCaves.java b/server/src/main/java/server/worldgen/caves/MapGenCaves.java index c5e6c470..05374485 100755 --- a/server/src/main/java/server/worldgen/caves/MapGenCaves.java +++ b/server/src/main/java/server/worldgen/caves/MapGenCaves.java @@ -9,22 +9,21 @@ import common.util.ExtMath; import common.world.State; import server.world.WorldServer; import server.worldgen.ChunkPrimer; +import server.worldgen.biome.GenBiome; public class MapGenCaves extends MapGenBase { private final State filler; private final Block replace; private final Block top; - private final State surface; - private final Block surfaceBlock; + private final Block surface; private final Block alt; - public MapGenCaves(State filler, Block replace, Block top, State surface, Block alt) { + public MapGenCaves(State filler, Block replace, Block top, Block surface, Block alt) { this.filler = filler; this.replace = replace; this.top = top; this.surface = surface; - this.surfaceBlock = surface.getBlock(); this.alt = alt; } @@ -188,17 +187,18 @@ public class MapGenCaves extends MapGenBase if (d9 > -0.7D && d10 * d10 + d9 * d9 + d8 * d8 < 1.0D) { - State current = p_180702_5_.get(j3, j2, i2); - State above = j2 + 1 < p_180702_5_.height ? p_180702_5_.get(j3, j2 + 1, i2) : null; - if(above == null) - above = Blocks.air.getState(); + State iblockstate1 = p_180702_5_.get(j3, j2, i2); + State iblockstate2 = // (State)Objects.firstNonNull( + p_180702_5_.get(j3, j2 + 1, i2); //, + if(iblockstate2 == null) + iblockstate2 = Blocks.air.getState(); - if (current.getBlock() == this.surfaceBlock) + if (iblockstate1.getBlock() == this.surface || iblockstate1.getBlock() == Blocks.mycelium) { flag1 = true; } - if (this.canReplace(current, above)) + if (this.func_175793_a(iblockstate1, iblockstate2)) { if (j2 - 1 < 10) { @@ -208,11 +208,11 @@ public class MapGenCaves extends MapGenBase { p_180702_5_.set(j3, j2, i2, Blocks.air.getState()); - if (above.getBlock() == Blocks.sand) + if (iblockstate2.getBlock() == Blocks.sand) { p_180702_5_.set(j3, j2 + 1, i2, Blocks.sandstone.getState()); //TODO: check! } - else if (above.getBlock() == Blocks.red_sand) + else if (iblockstate2.getBlock() == Blocks.red_sand) { p_180702_5_.set(j3, j2 + 1, i2, Blocks.orange_clay.getState()); //TODO: check! } @@ -220,7 +220,7 @@ public class MapGenCaves extends MapGenBase if (flag1 && p_180702_5_.get(j3, j2 - 1, i2).getBlock() == this.top) { blockpos$mutableblockpos.set(j3 + p_180702_3_ * 16, 0, i2 + p_180702_4_ * 16); - p_180702_5_.set(j3, j2 - 1, i2, this.surface); + p_180702_5_.set(j3, j2 - 1, i2, GenBiome.BIOMES[this.worldObj.getBiomeGenForCoords(blockpos$mutableblockpos).id].topBlock.getBlock().getState()); } } } @@ -240,17 +240,10 @@ public class MapGenCaves extends MapGenBase } } - protected boolean canReplace(State state, State above) { - return state.getBlock() == this.replace ? true - : (state.getBlock() == this.top ? true - : (state.getBlock() == this.surfaceBlock ? true - : (state.getBlock() == Blocks.hardened_clay ? true - : (state.getBlock() instanceof BlockColoredClay ? true - : (state.getBlock() == Blocks.sandstone ? true - : /* (p_175793_1_.getBlock() == Blocks.red_sandstone ? true : */ (state.getBlock() == Blocks.mycelium ? true - : (state.getBlock() == Blocks.snow_layer ? true - : (state.getBlock() == Blocks.sand || state.getBlock() == this.alt) && !above.getBlock().getMaterial().isColdLiquid()))))))); // ); - } + protected boolean func_175793_a(State p_175793_1_, State p_175793_2_) + { + return p_175793_1_.getBlock() == this.replace ? true : (p_175793_1_.getBlock() == this.top ? true : (p_175793_1_.getBlock() == this.surface ? true : (p_175793_1_.getBlock() == Blocks.hardened_clay ? true : (p_175793_1_.getBlock() instanceof BlockColoredClay ? true : (p_175793_1_.getBlock() == Blocks.sandstone ? true : /* (p_175793_1_.getBlock() == Blocks.red_sandstone ? true : */ (p_175793_1_.getBlock() == Blocks.mycelium ? true : (p_175793_1_.getBlock() == Blocks.snow_layer ? true : (p_175793_1_.getBlock() == Blocks.sand || p_175793_1_.getBlock() == this.alt) && !p_175793_2_.getBlock().getMaterial().isColdLiquid()))))))); // ); + } /** * Recursively called by generate() diff --git a/server/src/main/java/server/worldgen/caves/MapGenRavine.java b/server/src/main/java/server/worldgen/caves/MapGenRavine.java index 1c7cd95e..4050bdaa 100755 --- a/server/src/main/java/server/worldgen/caves/MapGenRavine.java +++ b/server/src/main/java/server/worldgen/caves/MapGenRavine.java @@ -8,23 +8,22 @@ import common.util.ExtMath; import common.world.State; import server.world.WorldServer; import server.worldgen.ChunkPrimer; +import server.worldgen.biome.GenBiome; public class MapGenRavine extends MapGenBase { private final State filler; private final Block replace; private final Block top; - private final State surface; - private final Block surfaceBlock; + private final Block surface; private float[] field_75046_d = new float[1024]; - public MapGenRavine(State filler, Block replace, Block top, State surface) { + public MapGenRavine(State filler, Block replace, Block top, Block surface) { this.filler = filler; this.replace = replace; this.top = top; this.surface = surface; - this.surfaceBlock = surface.getBlock(); } protected void func_180707_a(long p_180707_1_, int p_180707_3_, int p_180707_4_, ChunkPrimer p_180707_5_, double p_180707_6_, double p_180707_8_, double p_180707_10_, float p_180707_12_, float p_180707_13_, float p_180707_14_, int p_180707_15_, int p_180707_16_, double p_180707_17_) @@ -180,12 +179,12 @@ public class MapGenRavine extends MapGenBase { State iblockstate1 = p_180707_5_.get(j3, j2, i2); - if (iblockstate1.getBlock() == this.surfaceBlock) + if (iblockstate1.getBlock() == this.surface) { flag = true; } - if (iblockstate1.getBlock() == this.replace || iblockstate1.getBlock() == this.top || iblockstate1.getBlock() == this.surfaceBlock) + if (iblockstate1.getBlock() == this.replace || iblockstate1.getBlock() == this.top || iblockstate1.getBlock() == this.surface) { if (j2 - 1 < 10) { @@ -198,7 +197,7 @@ public class MapGenRavine extends MapGenBase if (flag && p_180707_5_.get(j3, j2 - 1, i2).getBlock() == this.top) { blockpos$mutableblockpos.set(j3 + p_180707_3_ * 16, 0, i2 + p_180707_4_ * 16); - p_180707_5_.set(j3, j2 - 1, i2, this.surface); + p_180707_5_.set(j3, j2 - 1, i2, GenBiome.BIOMES[this.worldObj.getBiomeGenForCoords(blockpos$mutableblockpos).id].topBlock); } } } diff --git a/server/src/main/java/server/worldgen/layer/GenLayer.java b/server/src/main/java/server/worldgen/layer/GenLayer.java index 1810299d..2469dc44 100755 --- a/server/src/main/java/server/worldgen/layer/GenLayer.java +++ b/server/src/main/java/server/worldgen/layer/GenLayer.java @@ -1,19 +1,30 @@ package server.worldgen.layer; +import common.biome.Biome; +import server.worldgen.biome.GenBiome; + public abstract class GenLayer { - public static final int NONE = 0; - public static final int RIVER = 1; - public static final int SEA = 2; - public static final int ICE_RIVER = 3; - public static final int ICE_SEA = 4; - private long worldGenSeed; private long chunkSeed; private long baseSeed; protected GenLayer parent; + protected static boolean canBeNearby(int id1, int id2) { + if(id1 == id2) { + return true; + } + else { // if(id1 != Biome.mesaPlateau_F.id && id1 != Biome.mesaPlateau.id) { + final GenBiome biome1 = GenBiome.getBiome(id1); + final GenBiome biome2 = GenBiome.getBiome(id2); + return biome1 != null && biome2 != null ? biome1.isEqualTo(biome2) : false; + } +// else { +// return id2 == Biome.mesaPlateau_F.id || id2 == Biome.mesaPlateau.id; +// } + } + protected static boolean isSea(int id) { - return id == SEA || id == ICE_SEA; + return id == Biome.SEA.id || id == Biome.ICE_SEA.id; } public GenLayer(long base) { diff --git a/server/src/main/java/server/worldgen/layer/GenLayerAddSea.java b/server/src/main/java/server/worldgen/layer/GenLayerAddSea.java index 55f4bcf0..b0345bff 100755 --- a/server/src/main/java/server/worldgen/layer/GenLayerAddSea.java +++ b/server/src/main/java/server/worldgen/layer/GenLayerAddSea.java @@ -1,5 +1,7 @@ package server.worldgen.layer; +import common.biome.Biome; + public class GenLayerAddSea extends GenLayer { private final int rarity; @@ -58,7 +60,7 @@ public class GenLayerAddSea extends GenLayer this.initChunkSeed((long)(areaX + j1), (long)(areaY + i1)); if (k2 == 0 && this.nextInt(this.rarity) == 0) { - aint1[j1 + i1 * areaWidth] = l2 > 1 ? ICE_SEA : SEA; + aint1[j1 + i1 * areaWidth] = l2 > 1 ? Biome.ICE_SEA.id : Biome.SEA.id; } else { diff --git a/server/src/main/java/server/worldgen/layer/GenLayerBiomeEdge.java b/server/src/main/java/server/worldgen/layer/GenLayerBiomeEdge.java new file mode 100755 index 00000000..afc3c293 --- /dev/null +++ b/server/src/main/java/server/worldgen/layer/GenLayerBiomeEdge.java @@ -0,0 +1,168 @@ +package server.worldgen.layer; + +import common.biome.Biome; +import server.worldgen.biome.GenBiome; +import server.worldgen.biome.Temperature; + +public class GenLayerBiomeEdge extends GenLayer +{ + public GenLayerBiomeEdge(long p_i45475_1_, GenLayer p_i45475_3_) + { + super(p_i45475_1_); + this.parent = p_i45475_3_; + } + + /** + * Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall + * amounts, or biomeList[] indices based on the particular GenLayer subclass. + */ + public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight) + { + int[] aint = this.parent.getInts(areaX - 1, areaY - 1, areaWidth + 2, areaHeight + 2); + int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight); + + for (int i = 0; i < areaHeight; ++i) + { + for (int j = 0; j < areaWidth; ++j) + { + this.initChunkSeed((long)(j + areaX), (long)(i + areaY)); + int k = aint[j + 1 + (i + 1) * (areaWidth + 2)]; + + if (!this.replaceBiomeEdgeIfNecessary(aint, aint1, j, i, areaWidth, k, Biome.HILLS.id, Biome.HILLS_EDGE.id) && /* !this.replaceBiomeEdge(aint, aint1, j, i, areaWidth, k, Biome.mesaPlateau_F.id, Biome.mesa.id) && !this.replaceBiomeEdge(aint, aint1, j, i, areaWidth, k, Biome.mesaPlateau.id, Biome.mesa.id) && */ !this.replaceBiomeEdge(aint, aint1, j, i, areaWidth, k, Biome.LARGE_TAIGA.id, Biome.TAIGA.id)) + { + if (k == Biome.DESERT.id) + { + int l1 = aint[j + 1 + (i + 1 - 1) * (areaWidth + 2)]; + int i2 = aint[j + 1 + 1 + (i + 1) * (areaWidth + 2)]; + int j2 = aint[j + 1 - 1 + (i + 1) * (areaWidth + 2)]; + int k2 = aint[j + 1 + (i + 1 + 1) * (areaWidth + 2)]; + + if (l1 != Biome.ICE.id && i2 != Biome.ICE.id && j2 != Biome.ICE.id && k2 != Biome.ICE.id) + { + aint1[j + i * areaWidth] = k; + } + else + { + aint1[j + i * areaWidth] = Biome.LARGE_HILLS.id; + } + } + else if (k == Biome.SWAMP.id) + { + int l = aint[j + 1 + (i + 1 - 1) * (areaWidth + 2)]; + int i1 = aint[j + 1 + 1 + (i + 1) * (areaWidth + 2)]; + int j1 = aint[j + 1 - 1 + (i + 1) * (areaWidth + 2)]; + int k1 = aint[j + 1 + (i + 1 + 1) * (areaWidth + 2)]; + + if (l != Biome.DESERT.id && i1 != Biome.DESERT.id && j1 != Biome.DESERT.id && k1 != Biome.DESERT.id && l != Biome.ICE_TAIGA.id && i1 != Biome.ICE_TAIGA.id && j1 != Biome.ICE_TAIGA.id && k1 != Biome.ICE_TAIGA.id && l != Biome.ICE.id && i1 != Biome.ICE.id && j1 != Biome.ICE.id && k1 != Biome.ICE.id) + { + if (l != Biome.TROPIC.id && k1 != Biome.TROPIC.id && i1 != Biome.TROPIC.id && j1 != Biome.TROPIC.id) + { + aint1[j + i * areaWidth] = k; + } + else + { + aint1[j + i * areaWidth] = Biome.TROPIC_EDGE.id; + } + } + else + { + aint1[j + i * areaWidth] = Biome.PLAIN.id; + } + } + else + { + aint1[j + i * areaWidth] = k; + } + } + } + } + + return aint1; + } + + /** + * Creates a border around a biome if necessary, e.g. A transition from hot to cold climates would otherwise occur. + */ + private boolean replaceBiomeEdgeIfNecessary(int[] p_151636_1_, int[] p_151636_2_, int p_151636_3_, int p_151636_4_, int p_151636_5_, int p_151636_6_, int p_151636_7_, int p_151636_8_) + { + if (!canBeNearby(p_151636_6_, p_151636_7_)) + { + return false; + } + else + { + int i = p_151636_1_[p_151636_3_ + 1 + (p_151636_4_ + 1 - 1) * (p_151636_5_ + 2)]; + int j = p_151636_1_[p_151636_3_ + 1 + 1 + (p_151636_4_ + 1) * (p_151636_5_ + 2)]; + int k = p_151636_1_[p_151636_3_ + 1 - 1 + (p_151636_4_ + 1) * (p_151636_5_ + 2)]; + int l = p_151636_1_[p_151636_3_ + 1 + (p_151636_4_ + 1 + 1) * (p_151636_5_ + 2)]; + + if (this.canBiomesBeNeighbors(i, p_151636_7_) && this.canBiomesBeNeighbors(j, p_151636_7_) && this.canBiomesBeNeighbors(k, p_151636_7_) && this.canBiomesBeNeighbors(l, p_151636_7_)) + { + p_151636_2_[p_151636_3_ + p_151636_4_ * p_151636_5_] = p_151636_6_; + } + else + { + p_151636_2_[p_151636_3_ + p_151636_4_ * p_151636_5_] = p_151636_8_; + } + + return true; + } + } + + /** + * Creates a border around a biome. + */ + private boolean replaceBiomeEdge(int[] p_151635_1_, int[] p_151635_2_, int p_151635_3_, int p_151635_4_, int p_151635_5_, int p_151635_6_, int p_151635_7_, int p_151635_8_) + { + if (p_151635_6_ != p_151635_7_) + { + return false; + } + else + { + int i = p_151635_1_[p_151635_3_ + 1 + (p_151635_4_ + 1 - 1) * (p_151635_5_ + 2)]; + int j = p_151635_1_[p_151635_3_ + 1 + 1 + (p_151635_4_ + 1) * (p_151635_5_ + 2)]; + int k = p_151635_1_[p_151635_3_ + 1 - 1 + (p_151635_4_ + 1) * (p_151635_5_ + 2)]; + int l = p_151635_1_[p_151635_3_ + 1 + (p_151635_4_ + 1 + 1) * (p_151635_5_ + 2)]; + + if (canBeNearby(i, p_151635_7_) && canBeNearby(j, p_151635_7_) && canBeNearby(k, p_151635_7_) && canBeNearby(l, p_151635_7_)) + { + p_151635_2_[p_151635_3_ + p_151635_4_ * p_151635_5_] = p_151635_6_; + } + else + { + p_151635_2_[p_151635_3_ + p_151635_4_ * p_151635_5_] = p_151635_8_; + } + + return true; + } + } + + /** + * Returns if two biomes can logically be neighbors. If one is hot and the other cold, for example, it returns + * false. + */ + private boolean canBiomesBeNeighbors(int p_151634_1_, int p_151634_2_) + { + if (canBeNearby(p_151634_1_, p_151634_2_)) + { + return true; + } + else + { + GenBiome biomegenbase = GenBiome.getBiome(p_151634_1_); + GenBiome biomegenbase1 = GenBiome.getBiome(p_151634_2_); + + if (biomegenbase != null && biomegenbase1 != null) + { + Temperature biomegenbase$tempcategory = biomegenbase.getTempCategory(); + Temperature biomegenbase$tempcategory1 = biomegenbase1.getTempCategory(); + return biomegenbase$tempcategory == biomegenbase$tempcategory1 || biomegenbase$tempcategory == Temperature.MEDIUM || biomegenbase$tempcategory1 == Temperature.MEDIUM; + } + else + { + return false; + } + } + } +} diff --git a/server/src/main/java/server/worldgen/layer/GenLayerHills.java b/server/src/main/java/server/worldgen/layer/GenLayerHills.java new file mode 100755 index 00000000..a855773a --- /dev/null +++ b/server/src/main/java/server/worldgen/layer/GenLayerHills.java @@ -0,0 +1,200 @@ +package server.worldgen.layer; + +import common.biome.Biome; +import common.log.Log; +import server.worldgen.biome.GenBiome; + +public class GenLayerHills extends GenLayer +{ + private GenLayer field_151628_d; + private final int def; + + public GenLayerHills(long p_i45479_1_, GenLayer p_i45479_3_, GenLayer p_i45479_4_, Biome def) + { + super(p_i45479_1_); + this.parent = p_i45479_3_; + this.field_151628_d = p_i45479_4_; + this.def = def.id; + } + + /** + * Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall + * amounts, or biomeList[] indices based on the particular GenLayer subclass. + */ + public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight) + { + int[] aint = this.parent.getInts(areaX - 1, areaY - 1, areaWidth + 2, areaHeight + 2); + int[] aint1 = this.field_151628_d.getInts(areaX - 1, areaY - 1, areaWidth + 2, areaHeight + 2); + int[] aint2 = IntCache.getIntCache(areaWidth * areaHeight); + + for (int i = 0; i < areaHeight; ++i) + { + for (int j = 0; j < areaWidth; ++j) + { + this.initChunkSeed((long)(j + areaX), (long)(i + areaY)); + int k = aint[j + 1 + (i + 1) * (areaWidth + 2)]; + int l = aint1[j + 1 + (i + 1) * (areaWidth + 2)]; + boolean flag = (l - 2) % 29 == 0; + + if (k > 255) + { + Log.TICK.warn("Altes Biom (" + k + ")!"); + } + + if (k != 0 && l >= 2 && (l - 2) % 29 == 1 && k < 128) + { + if (Biome.getBiome(k + 128) != null) + { + aint2[j + i * areaWidth] = k + 128; + } + else + { + aint2[j + i * areaWidth] = k; + } + } + else if (this.nextInt(3) != 0 && !flag) + { + aint2[j + i * areaWidth] = k; + } + else + { + int i1 = k; + + if (k == Biome.DESERT.id) + { + i1 = Biome.DESERT_HILLS.id; + } + else if (k == Biome.FOREST.id) + { + i1 = Biome.FOREST_HILLS.id; + } + else if (k == Biome.BIRCH_FOREST.id) + { + i1 = Biome.BIRCH_HILLS.id; + } + else if (k == Biome.DARK_FOREST.id) + { + i1 = Biome.PLAIN.id; + } + else if (k == Biome.TAIGA.id) + { + i1 = Biome.TAIGA_HILLS.id; + } + else if (k == Biome.LARGE_TAIGA.id) + { + i1 = Biome.LARGE_TAIGA_HILLS.id; + } + else if (k == Biome.ICE_TAIGA.id) + { + i1 = Biome.ICE_TAIGA_HILLS.id; + } + else if (k == Biome.PLAIN.id) + { + if (this.nextInt(3) == 0) + { + i1 = Biome.FOREST_HILLS.id; + } + else + { + i1 = Biome.FOREST.id; + } + } + else if (k == Biome.ICE.id) + { + i1 = Biome.ICE_HILLS.id; + } + else if (k == Biome.TROPIC.id) + { + i1 = Biome.TROPIC_HILLS.id; + } + else if (k == Biome.NONE.id) + { + i1 = this.def; + } + else if (k == Biome.HILLS.id) + { + i1 = Biome.LARGE_HILLS.id; + } + else if (k == Biome.SAVANNA.id) + { + i1 = Biome.SAVANNA_PLATEAU.id; + } +// else if (canBeNearby(k, Biome.mesaPlateau_F.id)) +// { +// i1 = Biome.mesa.id; +// } + else if (k == Biome.SEA.id && this.nextInt(3) == 0) + { + int j1 = this.nextInt(2); + + if (j1 == 0) + { + i1 = Biome.PLAIN.id; + } + else + { + i1 = Biome.FOREST.id; + } + } + + if (flag && i1 != k) + { + GenBiome gb = GenBiome.getBiome(i1); + if (gb != null && gb.mutated != null) + { + i1 = gb.mutated.id; + } + else + { + i1 = k; + } + } + + if (i1 == k) + { + aint2[j + i * areaWidth] = k; + } + else + { + int k2 = aint[j + 1 + (i + 1 - 1) * (areaWidth + 2)]; + int k1 = aint[j + 1 + 1 + (i + 1) * (areaWidth + 2)]; + int l1 = aint[j + 1 - 1 + (i + 1) * (areaWidth + 2)]; + int i2 = aint[j + 1 + (i + 1 + 1) * (areaWidth + 2)]; + int j2 = 0; + + if (canBeNearby(k2, k)) + { + ++j2; + } + + if (canBeNearby(k1, k)) + { + ++j2; + } + + if (canBeNearby(l1, k)) + { + ++j2; + } + + if (canBeNearby(i2, k)) + { + ++j2; + } + + if (j2 >= 3) + { + aint2[j + i * areaWidth] = i1; + } + else + { + aint2[j + i * areaWidth] = k; + } + } + } + } + } + + return aint2; + } +} diff --git a/server/src/main/java/server/worldgen/layer/GenLayerRiver.java b/server/src/main/java/server/worldgen/layer/GenLayerRiver.java index bd71e698..00a03482 100755 --- a/server/src/main/java/server/worldgen/layer/GenLayerRiver.java +++ b/server/src/main/java/server/worldgen/layer/GenLayerRiver.java @@ -1,5 +1,7 @@ package server.worldgen.layer; +import common.biome.Biome; + public class GenLayerRiver extends GenLayer { public GenLayerRiver(long p_i2128_1_, GenLayer p_i2128_3_) @@ -37,7 +39,7 @@ public class GenLayerRiver extends GenLayer } else { - aint1[j1 + i1 * areaWidth] = RIVER; + aint1[j1 + i1 * areaWidth] = Biome.RIVER.id; } } } diff --git a/server/src/main/java/server/worldgen/layer/GenLayerRiverMix.java b/server/src/main/java/server/worldgen/layer/GenLayerRiverMix.java index 14bede6f..39663dfc 100755 --- a/server/src/main/java/server/worldgen/layer/GenLayerRiverMix.java +++ b/server/src/main/java/server/worldgen/layer/GenLayerRiverMix.java @@ -1,26 +1,19 @@ package server.worldgen.layer; -import java.util.Set; - import common.biome.Biome; -import common.collect.Sets; public class GenLayerRiverMix extends GenLayer { private GenLayer biomePatternGeneratorChain; private GenLayer riverPatternGeneratorChain; private final int def; - private final Set freeze = Sets.newHashSet(); - public GenLayerRiverMix(long p_i2129_1_, GenLayer p_i2129_3_, GenLayer p_i2129_4_, Biome def, Biome[] freeze) + public GenLayerRiverMix(long p_i2129_1_, GenLayer p_i2129_3_, GenLayer p_i2129_4_, Biome def) { super(p_i2129_1_); this.biomePatternGeneratorChain = p_i2129_3_; this.riverPatternGeneratorChain = p_i2129_4_; this.def = def.id; - for(Biome biome : freeze) { - this.freeze.add(biome.id); - } } /** @@ -46,23 +39,23 @@ public class GenLayerRiverMix extends GenLayer for (int i = 0; i < areaWidth * areaHeight; ++i) { - if(biome[i] == NONE) + if(biome[i] == Biome.NONE.id) { out[i] = this.def; } - else if(biome[i] == SEA || biome[i] == ICE_SEA) + else if(biome[i] == Biome.SEA.id || biome[i] == Biome.ICE_SEA.id) { out[i] = biome[i]; } - else if (river[i] == RIVER) + else if (river[i] == Biome.RIVER.id) { - if (this.freeze.contains(biome[i])) + if (biome[i] == Biome.ICE.id) { - out[i] = ICE_RIVER; + out[i] = Biome.ICE_RIVER.id; } else // if (biome[i] != Biome.mushroomPlains.id && biome[i] != Biome.mushroomPlainsEdge.id) { - out[i] = RIVER; + out[i] = Biome.RIVER.id; } // else // { diff --git a/server/src/main/java/server/worldgen/layer/GenLayerShore.java b/server/src/main/java/server/worldgen/layer/GenLayerShore.java new file mode 100755 index 00000000..889baa72 --- /dev/null +++ b/server/src/main/java/server/worldgen/layer/GenLayerShore.java @@ -0,0 +1,165 @@ +package server.worldgen.layer; + +import common.biome.Biome; +import server.worldgen.biome.BiomeJungle; +import server.worldgen.biome.GenBiome; + +public class GenLayerShore extends GenLayer +{ + public GenLayerShore(long base, GenLayer parent) + { + super(base); + this.parent = parent; + } + + public int[] getInts(int x, int z, int width, int height) + { + int[] pre = this.parent.getInts(x - 1, z - 1, width + 2, height + 2); + int[] data = IntCache.getIntCache(width * height); + + for (int i = 0; i < height; ++i) + { + for (int j = 0; j < width; ++j) + { + this.initChunkSeed((long)(j + x), (long)(i + z)); + int id = pre[j + 1 + (i + 1) * (width + 2)]; + GenBiome biome = GenBiome.getBiome(id); + +// if (id == Biome.mushroomPlains.id) +// { +// int j2 = pre[j + 1 + (i + 1 - 1) * (width + 2)]; +// int i3 = pre[j + 1 + 1 + (i + 1) * (width + 2)]; +// int l3 = pre[j + 1 - 1 + (i + 1) * (width + 2)]; +// int k4 = pre[j + 1 + (i + 1 + 1) * (width + 2)]; +// +// if (j2 != Biome.swampland.id && i3 != Biome.swampland.id && l3 != Biome.swampland.id && k4 != Biome.swampland.id) +// { +// data[j + i * width] = id; +// } +// else +// { +// data[j + i * width] = Biome.mushroomPlainsEdge.id; +// } +// } +// else + if (biome != null && biome.getBiomeClass() == BiomeJungle.class) + { + int i2 = pre[j + 1 + (i + 1 - 1) * (width + 2)]; + int l2 = pre[j + 1 + 1 + (i + 1) * (width + 2)]; + int k3 = pre[j + 1 - 1 + (i + 1) * (width + 2)]; + int j4 = pre[j + 1 + (i + 1 + 1) * (width + 2)]; + + if (this.canNBJungle(i2) && this.canNBJungle(l2) && this.canNBJungle(k3) && this.canNBJungle(j4)) + { + if (!isSea(i2) && !isSea(l2) && !isSea(k3) && !isSea(j4)) + { + data[j + i * width] = id; + } + else + { + data[j + i * width] = Biome.BEACH.id; + } + } + else + { + data[j + i * width] = Biome.TROPIC_EDGE.id; + } + } + else if (id != Biome.HILLS.id && id != Biome.LARGE_HILLS.id && id != Biome.HILLS_EDGE.id) + { + if (biome != null && biome.allowColdBeach) + { + this.putBeach(pre, data, j, i, width, id, Biome.ICE_BEACH.id); + } + else // if (id != Biome.mesa.id && id != Biome.mesaPlateau_F.id) +// { + if (biome != null && !biome.disallowBeach) + { + int l1 = pre[j + 1 + (i + 1 - 1) * (width + 2)]; + int k2 = pre[j + 1 + 1 + (i + 1) * (width + 2)]; + int j3 = pre[j + 1 - 1 + (i + 1) * (width + 2)]; + int i4 = pre[j + 1 + (i + 1 + 1) * (width + 2)]; + + if (!isSea(l1) && !isSea(k2) && !isSea(j3) && !isSea(i4)) + { + data[j + i * width] = id; + } + else + { + data[j + i * width] = Biome.BEACH.id; + } + } + else + { + data[j + i * width] = id; + } +// } +// else +// { +// int l = pre[j + 1 + (i + 1 - 1) * (width + 2)]; +// int i1 = pre[j + 1 + 1 + (i + 1) * (width + 2)]; +// int j1 = pre[j + 1 - 1 + (i + 1) * (width + 2)]; +// int k1 = pre[j + 1 + (i + 1 + 1) * (width + 2)]; +// +// if (!isSea(l) && !isSea(i1) && !isSea(j1) && !isSea(k1)) +// { +// if (this.canNBMesa(l) && this.canNBMesa(i1) && this.canNBMesa(j1) && this.canNBMesa(k1)) +// { +// data[j + i * width] = id; +// } +// else +// { +// data[j + i * width] = Biome.desert.id; +// } +// } +// else +// { +// data[j + i * width] = id; +// } +// } + } + else + { + this.putBeach(pre, data, j, i, width, id, Biome.STONE_BEACH.id); + } + } + } + + return data; + } + + private void putBeach(int[] pre, int[] data, int x, int z, int width, int biome, int beach) + { + if (isSea(biome)) + { + data[x + z * width] = biome; + } + else + { + int i = pre[x + 1 + (z + 1 - 1) * (width + 2)]; + int j = pre[x + 1 + 1 + (z + 1) * (width + 2)]; + int k = pre[x + 1 - 1 + (z + 1) * (width + 2)]; + int l = pre[x + 1 + (z + 1 + 1) * (width + 2)]; + + if (!isSea(i) && !isSea(j) && !isSea(k) && !isSea(l)) + { + data[x + z * width] = biome; + } + else + { + data[x + z * width] = beach; + } + } + } + + private boolean canNBJungle(int id) + { + GenBiome biome = GenBiome.getBiome(id); + return biome != null && biome.getBiomeClass() == BiomeJungle.class ? true : id == Biome.TROPIC_EDGE.id || id == Biome.TROPIC.id || id == Biome.TROPIC_HILLS.id || id == Biome.FOREST.id || id == Biome.TAIGA.id || isSea(id); + } + +// private boolean canNBMesa(int id) +// { +// return Biome.getBiome(id) instanceof BiomeMesa; +// } +} diff --git a/server/src/main/java/server/worldgen/populator/Populator.java b/server/src/main/java/server/worldgen/populator/Populator.java deleted file mode 100644 index b5147df2..00000000 --- a/server/src/main/java/server/worldgen/populator/Populator.java +++ /dev/null @@ -1,15 +0,0 @@ -package server.worldgen.populator; - -import common.rng.Random; -import common.util.BlockPos; -import server.world.WorldServer; - -public interface Populator { - void decorate(WorldServer world, Random rand, BlockPos pos); - default boolean canGenerateLakes() { - return true; - } - default boolean canGenerateLiquids() { - return true; - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorBasic.java b/server/src/main/java/server/worldgen/populator/PopulatorBasic.java deleted file mode 100755 index 775e84f6..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorBasic.java +++ /dev/null @@ -1,347 +0,0 @@ -package server.worldgen.populator; - -import common.block.foliage.BlockFlower; -import common.init.Blocks; -import common.rng.PerlinGen; -import common.rng.Random; -import common.util.BlockPos; -import server.world.WorldServer; -import server.worldgen.FeatureGenerator; -import server.worldgen.feature.WorldGenClay; -import server.worldgen.feature.WorldGenClayExt; -import server.worldgen.feature.WorldGenSand; -import server.worldgen.foliage.FeatureDoublePlant; -import server.worldgen.foliage.WorldGenBigMushroom; -import server.worldgen.foliage.WorldGenCactus; -import server.worldgen.foliage.WorldGenDeadBush; -import server.worldgen.foliage.WorldGenFlowers; -import server.worldgen.foliage.WorldGenMushroom; -import server.worldgen.foliage.WorldGenPumpkin; -import server.worldgen.foliage.WorldGenReed; -import server.worldgen.foliage.WorldGenTallGrass; -import server.worldgen.foliage.WorldGenWaterlily; -import server.worldgen.tree.WorldGenBaseTree; -import server.worldgen.tree.WorldGenBigTree; -import server.worldgen.tree.WorldGenTree; - -public abstract class PopulatorBasic implements Populator { - public static final PopulatorBasic plains = (new PopulatorPlains()); - public static final PopulatorBasic desert = (new PopulatorDesert()); - public static final PopulatorBasic extremeHills = (new PopulatorHills(false)); - public static final PopulatorBasic extremeHillsPlus = (new PopulatorHills(true)); - public static final PopulatorBasic taiga = (new PopulatorTaiga(0)); - public static final PopulatorBasic megaTaiga = (new PopulatorTaiga(1)); - public static final PopulatorBasic tallTreeTaiga = new PopulatorTaiga(2); - public static final PopulatorBasic swampland = (new PopulatorSwamp()); - public static final PopulatorBasic river = (new PopulatorDefault()); - public static final PopulatorBasic icePlains = (new PopulatorSnow(false)); - public static final PopulatorBasic iceSpikes = new PopulatorSnow(true); - public static final PopulatorBasic beach = (new PopulatorBeach()); - public static final PopulatorBasic jungle = (new PopulatorTropical(false)); - public static final PopulatorBasic jungleEdge = (new PopulatorTropical(true)); - public static final PopulatorBasic stoneBeach = (new PopulatorRocky()); - public static final PopulatorBasic savanna = (new PopulatorSavanna(true)); - public static final PopulatorBasic savannaNoDPlants = new PopulatorSavanna(false); - public static final PopulatorBasic forest = (new PopulatorForest(0)); - public static final PopulatorBasic flowerForest = new PopulatorForest(1); - public static final PopulatorBasic birchForest = (new PopulatorForest(2)); - public static final PopulatorBasic roofedForest = (new PopulatorForest(3)); - public static final PopulatorBasic tallBirchForest = new PopulatorForest(5); - - public static final PopulatorBasic elvenForest = (new PopulatorForest(4)); - public static final PopulatorBasic mesa = (new PopulatorMesa(false)); - public static final PopulatorBasic mesaPlateau_F = (new PopulatorMesa(true)); - public static final PopulatorBasic space = (new PopulatorAsteroids()); - public static final PopulatorBasic mushroomPlains = (new PopulatorMushrooms()); - public static final PopulatorBasic upperHell = (new PopulatorHell()); - public static final PopulatorBasic blackened = (new PopulatorBlackened()); - public static final PopulatorBasic snowLand = (new PopulatorNoMushrooms()); - public static final PopulatorBasic tian = (new PopulatorTian()); - public static final PopulatorBasic moon = (new PopulatorCheese()); - public static final PopulatorBasic chaos = (new PopulatorChaos()); - - protected static final PerlinGen TREE_NOISE = new PerlinGen(new Random(726528729282625L), 8); - protected static final PerlinGen GRASS_NOISE = new PerlinGen(new Random(297363826225L), 1); - protected static final FeatureDoublePlant DOUBLE_PLANT_GEN = new FeatureDoublePlant(); - - protected final WorldGenBaseTree worldGeneratorTrees = new WorldGenBaseTree(false); - protected final WorldGenBigTree worldGeneratorBigTree = new WorldGenBigTree(false); - private final FeatureGenerator clayGen = new WorldGenClay(4); - private final FeatureGenerator sandGen = new WorldGenSand(Blocks.sand, 7); - private final FeatureGenerator gravelAsSandGen = new WorldGenSand(Blocks.gravel, 6); - private final WorldGenFlowers yellowFlowerGen = new WorldGenFlowers(Blocks.dandelion); - private final FeatureGenerator mushroomBrownGen = new WorldGenMushroom(Blocks.brown_mushroom); - private final FeatureGenerator mushroomRedGen = new WorldGenMushroom(Blocks.red_mushroom); - private final FeatureGenerator bigMushroomGen = new WorldGenBigMushroom(); - private final FeatureGenerator reedGen = new WorldGenReed(); - private final FeatureGenerator cactusGen = new WorldGenCactus(); - private final FeatureGenerator waterlilyGen = new WorldGenWaterlily(); - private final FeatureGenerator clayGenExt = new WorldGenClayExt(32); - - protected int waterlilyPerChunk = 0; - protected int treesPerChunk = 0; - protected int flowersPerChunk = 2; - protected int grassPerChunk = 1; - protected int deadBushPerChunk = 0; - protected int mushroomsPerChunk = 0; - protected int reedsPerChunk = 0; - protected int cactiPerChunk = 0; - protected int sandPerChunk = 1; - protected int sandPerChunk2 = 3; - protected int clayPerChunk = 1; - protected int clayExtPerChunk = 0; // 10 - protected int bigMushroomsPerChunk = 0; - - protected WorldGenTree genBigTreeChance(Random rand) - { - return rand.chance(10) ? this.worldGeneratorBigTree : this.worldGeneratorTrees; - } - - protected WorldGenTree genBigTreeLegacy(Random rand, BlockPos pos, boolean humid) - { - int noise = (int)((TREE_NOISE.generate((double)pos.getX() * 0.5D, (double)pos.getZ() * 0.5D) / 8D + rand.doublev() * 4D + 4D) / 3D); - return (noise > 0 && rand.chance(noise)) || (humid && rand.chance(3)) ? this.worldGeneratorBigTree : - this.worldGeneratorTrees; - } - - protected FeatureGenerator getRandomWorldGenForGrass(Random rand) - { - return new WorldGenTallGrass(Blocks.tallgrass); - } - - protected BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) - { - return rand.rarity(3) ? BlockFlower.EnumFlowerType.DANDELION : BlockFlower.EnumFlowerType.ROSE; - } - - public void decorate(WorldServer world, Random rand, BlockPos pos) - { - for (int i = 0; i < this.sandPerChunk2; ++i) - { - int j = rand.chOffset(); - int k = rand.chOffset(); - this.sandGen.generate(world, rand, world.getHighestFreePos(pos.add(j, 0, k))); - } - - for (int i1 = 0; i1 < this.clayPerChunk; ++i1) - { - int l1 = rand.chOffset(); - int i6 = rand.chOffset(); - this.clayGen.generate(world, rand, world.getHighestFreePos(pos.add(l1, 0, i6))); - } - - for (int j1 = 0; j1 < this.sandPerChunk; ++j1) - { - int i2 = rand.chOffset(); - int j6 = rand.chOffset(); - this.gravelAsSandGen.generate(world, rand, world.getHighestFreePos(pos.add(i2, 0, j6))); - } - - for (int i1 = 0; i1 < this.clayExtPerChunk; ++i1) - { - int l1 = rand.chOffset(); - int i6 = rand.chOffset(); - this.clayGenExt.generate(world, rand, world.getHighestFreePos(pos.add(l1, 0, i6))); - } - - int k1 = this.treesPerChunk; - - if (rand.chance(10)) - { - ++k1; - } - - for (int j2 = 0; j2 < k1; ++j2) - { - int k6 = rand.chOffset(); - int l = rand.chOffset(); - WorldGenTree treeGen = this.genBigTreeChance(rand); - treeGen.prepare(); - BlockPos blockpos = world.getHeight(pos.add(k6, 0, l)); - - if (treeGen.generate(world, rand, blockpos)) - { - treeGen.finish(world, rand, blockpos); - } - } - - for (int k2 = 0; k2 < this.bigMushroomsPerChunk; ++k2) - { - int l6 = rand.chOffset(); - int k10 = rand.chOffset(); - this.bigMushroomGen.generate(world, rand, world.getHeight(pos.add(l6, 0, k10))); - } - - for (int l2 = 0; l2 < this.flowersPerChunk; ++l2) - { - int i7 = rand.chOffset(); - int l10 = rand.chOffset(); - int j14 = world.getHeight(pos.add(i7, 0, l10)).getY() + 32; - - if (j14 > 0) - { - int k17 = rand.zrange(j14); - BlockPos blockpos1 = pos.add(i7, k17, l10); - BlockFlower.EnumFlowerType blockflower$enumflowertype = this.pickRandomFlower(rand, blockpos1); - - this.yellowFlowerGen.setGeneratedBlock(BlockFlower.getByType(blockflower$enumflowertype)); - this.yellowFlowerGen.generate(world, rand, blockpos1); - } - } - - for (int i3 = 0; i3 < this.grassPerChunk; ++i3) - { - int j7 = rand.chOffset(); - int i11 = rand.chOffset(); - int k14 = world.getHeight(pos.add(j7, 0, i11)).getY() * 2; - - if (k14 > 0) - { - int l17 = rand.zrange(k14); - this.getRandomWorldGenForGrass(rand).generate(world, rand, pos.add(j7, l17, i11)); - } - } - - for (int j3 = 0; j3 < this.deadBushPerChunk; ++j3) - { - int k7 = rand.chOffset(); - int j11 = rand.chOffset(); - int l14 = world.getHeight(pos.add(k7, 0, j11)).getY() * 2; - - if (l14 > 0) - { - int i18 = rand.zrange(l14); - (new WorldGenDeadBush()).generate(world, rand, pos.add(k7, i18, j11)); - } - } - - for (int k3 = 0; k3 < this.waterlilyPerChunk; ++k3) - { - int l7 = rand.chOffset(); - int k11 = rand.chOffset(); - int i15 = world.getHeight(pos.add(l7, 0, k11)).getY() * 2; - - if (i15 > 0) - { - int j18 = rand.zrange(i15); - BlockPos blockpos4; - BlockPos blockpos7; - - for (blockpos4 = pos.add(l7, j18, k11); blockpos4.getY() > 0; blockpos4 = blockpos7) - { - blockpos7 = blockpos4.down(); - - if (!world.isAirBlock(blockpos7)) - { - break; - } - } - - this.waterlilyGen.generate(world, rand, blockpos4); - } - } - - for (int l3 = 0; l3 < this.mushroomsPerChunk; ++l3) - { - if (rand.chance(4)) - { - int i8 = rand.chOffset(); - int l11 = rand.chOffset(); - BlockPos blockpos2 = world.getHeight(pos.add(i8, 0, l11)); - this.mushroomBrownGen.generate(world, rand, blockpos2); - } - - if (rand.chance(8)) - { - int j8 = rand.chOffset(); - int i12 = rand.chOffset(); - int j15 = world.getHeight(pos.add(j8, 0, i12)).getY() * 2; - - if (j15 > 0) - { - int k18 = rand.zrange(j15); - BlockPos blockpos5 = pos.add(j8, k18, i12); - this.mushroomRedGen.generate(world, rand, blockpos5); - } - } - } - - if (this.mushroomsPerChunk != -1 && rand.chance(4)) - { - int i4 = rand.chOffset(); - int k8 = rand.chOffset(); - int j12 = world.getHeight(pos.add(i4, 0, k8)).getY() * 2; - - if (j12 > 0) - { - int k15 = rand.zrange(j12); - this.mushroomBrownGen.generate(world, rand, pos.add(i4, k15, k8)); - } - } - - if (this.mushroomsPerChunk != -1 && rand.chance(8)) - { - int j4 = rand.chOffset(); - int l8 = rand.chOffset(); - int k12 = world.getHeight(pos.add(j4, 0, l8)).getY() * 2; - - if (k12 > 0) - { - int l15 = rand.zrange(k12); - this.mushroomRedGen.generate(world, rand, pos.add(j4, l15, l8)); - } - } - - for (int k4 = 0; k4 < this.reedsPerChunk; ++k4) - { - int i9 = rand.chOffset(); - int l12 = rand.chOffset(); - int i16 = world.getHeight(pos.add(i9, 0, l12)).getY() * 2; - - if (i16 > 0) - { - int l18 = rand.zrange(i16); - this.reedGen.generate(world, rand, pos.add(i9, l18, l12)); - } - } - - for (int l4 = 0; l4 < 10; ++l4) - { - int j9 = rand.chOffset(); - int i13 = rand.chOffset(); - int j16 = world.getHeight(pos.add(j9, 0, i13)).getY() * 2; - - if (j16 > 0) - { - int i19 = rand.zrange(j16); - this.reedGen.generate(world, rand, pos.add(j9, i19, i13)); - } - } - - if (rand.chance(32)) - { - int i5 = rand.chOffset(); - int k9 = rand.chOffset(); - int j13 = world.getHeight(pos.add(i5, 0, k9)).getY() * 2; - - if (j13 > 0) - { - int k16 = rand.zrange(j13); - (new WorldGenPumpkin()).generate(world, rand, pos.add(i5, k16, k9)); - } - } - - for (int j5 = 0; j5 < this.cactiPerChunk; ++j5) - { - int l9 = rand.chOffset(); - int k13 = rand.chOffset(); - int l16 = world.getHeight(pos.add(l9, 0, k13)).getY() * 2; - - if (l16 > 0) - { - int j19 = rand.zrange(l16); - this.cactusGen.generate(world, rand, pos.add(l9, j19, k13)); - } - } - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorBeach.java b/server/src/main/java/server/worldgen/populator/PopulatorBeach.java deleted file mode 100755 index 1f20ab94..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorBeach.java +++ /dev/null @@ -1,12 +0,0 @@ -package server.worldgen.populator; - -public class PopulatorBeach extends PopulatorBasic -{ - public PopulatorBeach() - { - this.treesPerChunk = -999; - this.deadBushPerChunk = 0; - this.reedsPerChunk = 0; - this.cactiPerChunk = 0; - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorBlackened.java b/server/src/main/java/server/worldgen/populator/PopulatorBlackened.java deleted file mode 100644 index 421caa44..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorBlackened.java +++ /dev/null @@ -1,25 +0,0 @@ -package server.worldgen.populator; - -import common.block.foliage.BlockFlower; -import common.init.Blocks; -import common.init.WoodType; -import common.rng.Random; -import common.util.BlockPos; -import server.worldgen.tree.WorldGenBaseTree; -import server.worldgen.tree.WorldGenTree; - -public class PopulatorBlackened extends PopulatorBasic { - protected final WorldGenTree treeGen = new WorldGenBaseTree(false, Blocks.blackwood_log.getState(), WoodType.BLACKWOOD); - - public PopulatorBlackened() { - this.treesPerChunk = 3; - } - - protected BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) { - return BlockFlower.EnumFlowerType.BLACK_LOTUS; - } - - protected WorldGenTree genBigTreeChance(Random rand) { - return this.treeGen; - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorChaos.java b/server/src/main/java/server/worldgen/populator/PopulatorChaos.java deleted file mode 100755 index 749e0c75..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorChaos.java +++ /dev/null @@ -1,26 +0,0 @@ -package server.worldgen.populator; - -import common.init.Blocks; -import common.rng.Random; -import common.util.BlockPos; -import server.world.WorldServer; -import server.worldgen.FeatureGenerator; -import server.worldgen.foliage.WorldGenMushroom; - -public class PopulatorChaos extends PopulatorBasic -{ - protected FeatureGenerator mushroomBlueGen = new WorldGenMushroom(Blocks.blue_mushroom); - - public void decorate(WorldServer worldIn, Random rand, BlockPos pos) - { - super.decorate(worldIn, rand, pos); - - if (rand.chance(10)) - { - int i8 = rand.chOffset(); - int l11 = rand.chOffset(); - BlockPos blockpos2 = worldIn.getHeight(pos.add(i8, 0, l11)); - this.mushroomBlueGen.generate(worldIn, rand, blockpos2); - } - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorDefault.java b/server/src/main/java/server/worldgen/populator/PopulatorDefault.java deleted file mode 100755 index 7a0a30e7..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorDefault.java +++ /dev/null @@ -1,4 +0,0 @@ -package server.worldgen.populator; - -public class PopulatorDefault extends PopulatorBasic { -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorHell.java b/server/src/main/java/server/worldgen/populator/PopulatorHell.java deleted file mode 100755 index 16f0bb58..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorHell.java +++ /dev/null @@ -1,75 +0,0 @@ -package server.worldgen.populator; - -import common.init.Blocks; -import common.rng.Random; -import common.util.BlockPos; -import server.world.WorldServer; -import server.worldgen.FeatureOres; -import server.worldgen.feature.WorldGenFire; -import server.worldgen.feature.WorldGenGlowStone; -import server.worldgen.feature.WorldGenHellLava; -import server.worldgen.foliage.WorldGenMushroom; - -public class PopulatorHell extends PopulatorBasic -{ - private final WorldGenFire fireGen; - private final WorldGenGlowStone glowStoneGen1; - private final WorldGenGlowStone glowStoneGen2; - private final FeatureOres quartzGen; - private final WorldGenHellLava lavaGen1; - private final WorldGenHellLava lavaGen2; - private final WorldGenMushroom brownMushroomGen; - private final WorldGenMushroom redMushroomGen; - - public PopulatorHell() - { - this.fireGen = new WorldGenFire(); - this.glowStoneGen1 = new WorldGenGlowStone(); - this.glowStoneGen2 = new WorldGenGlowStone(); - this.quartzGen = new FeatureOres(Blocks.quartz_ore.getState(), 16, 0, 14, 10, 118, false); - this.lavaGen1 = new WorldGenHellLava(Blocks.flowing_lava, true); - this.lavaGen2 = new WorldGenHellLava(Blocks.flowing_lava, false); - this.brownMushroomGen = new WorldGenMushroom(Blocks.brown_mushroom); - this.redMushroomGen = new WorldGenMushroom(Blocks.red_mushroom); - } - - public void decorate(WorldServer worldIn, Random rand, BlockPos pos) - { - for (int i = 0; i < 8; ++i) - { - this.lavaGen2.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(120) + 4, rand.zrange(16) + 8)); - } - - for (int j = 0; j < rand.zrange(rand.zrange(10) + 1) + 1; ++j) - { - this.fireGen.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(120) + 4, rand.zrange(16) + 8)); - } - - for (int k = 0; k < rand.zrange(rand.zrange(10) + 1); ++k) - { - this.glowStoneGen1.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(120) + 4, rand.zrange(16) + 8)); - } - - for (int l = 0; l < 10; ++l) - { - this.glowStoneGen2.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(128), rand.zrange(16) + 8)); - } - - if (rand.chance()) - { - this.brownMushroomGen.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(128), rand.zrange(16) + 8)); - } - - if (rand.chance()) - { - this.redMushroomGen.generate(worldIn, rand, pos.add(rand.zrange(16) + 8, rand.zrange(128), rand.zrange(16) + 8)); - } - - this.quartzGen.generate(worldIn, rand, pos); - - for (int j1 = 0; j1 < 16; ++j1) - { - this.lavaGen1.generate(worldIn, rand, pos.add(rand.zrange(16), rand.zrange(108) + 10, rand.zrange(16))); - } - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorHills.java b/server/src/main/java/server/worldgen/populator/PopulatorHills.java deleted file mode 100755 index 826ec956..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorHills.java +++ /dev/null @@ -1,32 +0,0 @@ -package server.worldgen.populator; - -import common.init.Blocks; -import common.rng.Random; -import common.util.BlockPos; -import server.world.WorldServer; -import server.worldgen.FeatureOres; -import server.worldgen.tree.WorldGenTaiga2; -import server.worldgen.tree.WorldGenTree; - -public class PopulatorHills extends PopulatorBasic -{ - private FeatureOres theEmeraldGenerator = new FeatureOres(Blocks.emerald_ore.getState(), 3, 5, 1, 4, 32, false); - private WorldGenTaiga2 field_150634_aD = new WorldGenTaiga2(false); - - protected PopulatorHills(boolean trees) - { - if(trees) - this.treesPerChunk = 3; - } - - protected WorldGenTree genBigTreeChance(Random rand) - { - return (WorldGenTree)(rand.rarity(3) ? this.field_150634_aD : super.genBigTreeChance(rand)); - } - - public void decorate(WorldServer worldIn, Random rand, BlockPos pos) - { - super.decorate(worldIn, rand, pos); - this.theEmeraldGenerator.generate(worldIn, rand, pos); - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorMesa.java b/server/src/main/java/server/worldgen/populator/PopulatorMesa.java deleted file mode 100755 index 14ff8e30..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorMesa.java +++ /dev/null @@ -1,23 +0,0 @@ -package server.worldgen.populator; - -import common.rng.Random; -import server.worldgen.tree.WorldGenTree; - -public class PopulatorMesa extends PopulatorBasic -{ - public PopulatorMesa(boolean soil) - { - this.treesPerChunk = -999; - this.deadBushPerChunk = 20; - this.reedsPerChunk = 3; - this.cactiPerChunk = 5; - this.flowersPerChunk = 0; - if (soil) - this.treesPerChunk = 5; - } - - protected WorldGenTree genBigTreeChance(Random rand) - { - return this.worldGeneratorTrees; - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorMushrooms.java b/server/src/main/java/server/worldgen/populator/PopulatorMushrooms.java deleted file mode 100755 index eb88ea3b..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorMushrooms.java +++ /dev/null @@ -1,11 +0,0 @@ -package server.worldgen.populator; - -public class PopulatorMushrooms extends PopulatorBasic { - public PopulatorMushrooms() { - this.treesPerChunk = -100; - this.flowersPerChunk = -100; - this.grassPerChunk = -100; - this.mushroomsPerChunk = 1; - this.bigMushroomsPerChunk = 1; - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorNoMushrooms.java b/server/src/main/java/server/worldgen/populator/PopulatorNoMushrooms.java deleted file mode 100755 index cbc2b1b7..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorNoMushrooms.java +++ /dev/null @@ -1,9 +0,0 @@ -package server.worldgen.populator; - -public class PopulatorNoMushrooms extends PopulatorBasic -{ - public PopulatorNoMushrooms() - { - this.mushroomsPerChunk = -1; - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorRocky.java b/server/src/main/java/server/worldgen/populator/PopulatorRocky.java deleted file mode 100755 index 36a5e03b..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorRocky.java +++ /dev/null @@ -1,12 +0,0 @@ -package server.worldgen.populator; - -public class PopulatorRocky extends PopulatorBasic -{ - public PopulatorRocky() - { - this.treesPerChunk = -999; - this.deadBushPerChunk = 0; - this.reedsPerChunk = 0; - this.cactiPerChunk = 0; - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorSavanna.java b/server/src/main/java/server/worldgen/populator/PopulatorSavanna.java deleted file mode 100755 index b0022ce4..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorSavanna.java +++ /dev/null @@ -1,52 +0,0 @@ -package server.worldgen.populator; - -import common.init.Blocks; -import common.rng.Random; -import common.util.BlockPos; -import server.world.WorldServer; -import server.worldgen.tree.WorldGenSavanna; -import server.worldgen.tree.WorldGenTree; - -public class PopulatorSavanna extends PopulatorBasic -{ - private static final WorldGenSavanna field_150627_aC = new WorldGenSavanna(false); - - private final boolean dplant; - - protected PopulatorSavanna(boolean dplant) - { - this.dplant = dplant; - if(dplant) { - this.treesPerChunk = 1; - this.flowersPerChunk = 4; - this.grassPerChunk = 20; - } - else { - this.treesPerChunk = 2; - this.flowersPerChunk = 2; - this.grassPerChunk = 5; - } - } - - protected WorldGenTree genBigTreeChance(Random rand) - { - return (WorldGenTree)(rand.rarity(5) ? field_150627_aC : this.worldGeneratorTrees); - } - - public void decorate(WorldServer worldIn, Random rand, BlockPos pos) - { - if(this.dplant) { - DOUBLE_PLANT_GEN.setPlantType(Blocks.large_tallgrass); - - for (int i = 0; i < 7; ++i) - { - int j = rand.chOffset(); - int k = rand.chOffset(); - int l = rand.zrange(worldIn.getHeight(pos.add(j, 0, k)).getY() + 32); - DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j, l, k)); - } - } - - super.decorate(worldIn, rand, pos); - } -} diff --git a/server/src/main/java/server/worldgen/populator/PopulatorSwamp.java b/server/src/main/java/server/worldgen/populator/PopulatorSwamp.java deleted file mode 100755 index eed4b9cf..00000000 --- a/server/src/main/java/server/worldgen/populator/PopulatorSwamp.java +++ /dev/null @@ -1,44 +0,0 @@ -package server.worldgen.populator; - -import common.block.foliage.BlockFlower; -import common.init.Blocks; -import common.rng.Random; -import common.util.BlockPos; -import server.worldgen.FeatureGenerator; -import server.worldgen.foliage.WorldGenTallGrass; -import server.worldgen.tree.WorldGenSwamp; -import server.worldgen.tree.WorldGenTree; - -public class PopulatorSwamp extends PopulatorBasic -{ - protected final WorldGenSwamp worldGeneratorSwamp = new WorldGenSwamp(); - - protected PopulatorSwamp() - { - this.treesPerChunk = 2; - this.flowersPerChunk = 1; - this.deadBushPerChunk = 1; - this.mushroomsPerChunk = 8; - this.reedsPerChunk = 10; - this.clayPerChunk = 1; - this.waterlilyPerChunk = 4; - this.sandPerChunk2 = 0; - this.sandPerChunk = 0; - this.grassPerChunk = 5; - } - - protected WorldGenTree genBigTreeChance(Random rand) - { - return this.worldGeneratorSwamp; - } - - protected BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos) - { - return BlockFlower.EnumFlowerType.BLUE_ORCHID; - } - - protected FeatureGenerator getRandomWorldGenForGrass(Random rand) - { - return new WorldGenTallGrass(Blocks.swamp_grass); - } -} diff --git a/server/src/main/java/server/worldgen/structure/MapGenScatteredFeature.java b/server/src/main/java/server/worldgen/structure/MapGenScatteredFeature.java index 70864642..34b1d671 100755 --- a/server/src/main/java/server/worldgen/structure/MapGenScatteredFeature.java +++ b/server/src/main/java/server/worldgen/structure/MapGenScatteredFeature.java @@ -10,6 +10,7 @@ import server.world.WorldServer; public class MapGenScatteredFeature extends MapGenStructure { + private static final List biomelist = Arrays.asList(Biome.DESERT, Biome.DESERT_HILLS, Biome.TROPIC, Biome.TROPIC_HILLS, Biome.SWAMP); private static final int MAX_DISTANCE = 32; private static final int MIN_DISTANCE = 8; @@ -43,7 +44,20 @@ public class MapGenScatteredFeature extends MapGenStructure if (i == k && j == l) { - return true; + Biome biomegenbase = this.worldObj.getBiomeGenerator().getBiomeGenerator(new BlockPos(i * 16 + 8, 0, j * 16 + 8), null); + + if (biomegenbase == null) + { + return false; + } + + for (Biome biomegenbase1 : biomelist) + { + if (biomegenbase == biomegenbase1) + { + return true; + } + } } return false; @@ -78,16 +92,20 @@ public class MapGenScatteredFeature extends MapGenStructure public Start(WorldServer worldIn, Random p_i2060_2_, int p_i2060_3_, int p_i2060_4_) { super(p_i2060_3_, p_i2060_4_); - float temp = worldIn.getGenTemperature(p_i2060_3_ * 16 + 8, p_i2060_4_ * 16 + 8); + Biome biomegenbase = worldIn.getBiomeGenForCoords(new BlockPos(p_i2060_3_ * 16 + 8, 0, p_i2060_4_ * 16 + 8)); - if(temp >= 40.0f) { - StructureScattered.DesertPyramid componentscatteredfeaturepieces$desertpyramid = new StructureScattered.DesertPyramid(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16); - this.components.add(componentscatteredfeaturepieces$desertpyramid); - } - else if (temp < 30.0f) + if (biomegenbase != Biome.TROPIC && biomegenbase != Biome.TROPIC_HILLS) { - StructureScattered.SwampHut componentscatteredfeaturepieces$swamphut = new StructureScattered.SwampHut(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16); - this.components.add(componentscatteredfeaturepieces$swamphut); + if (biomegenbase == Biome.SWAMP) + { + StructureScattered.SwampHut componentscatteredfeaturepieces$swamphut = new StructureScattered.SwampHut(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16); + this.components.add(componentscatteredfeaturepieces$swamphut); + } + else if (biomegenbase == Biome.DESERT || biomegenbase == Biome.DESERT_HILLS) + { + StructureScattered.DesertPyramid componentscatteredfeaturepieces$desertpyramid = new StructureScattered.DesertPyramid(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16); + this.components.add(componentscatteredfeaturepieces$desertpyramid); + } } else { diff --git a/server/src/main/java/server/worldgen/structure/MapGenVillage.java b/server/src/main/java/server/worldgen/structure/MapGenVillage.java index 3b5b4616..67aadb5f 100755 --- a/server/src/main/java/server/worldgen/structure/MapGenVillage.java +++ b/server/src/main/java/server/worldgen/structure/MapGenVillage.java @@ -11,6 +11,8 @@ import server.world.WorldServer; public class MapGenVillage extends MapGenStructure { + public static final Set villageSpawnBiomes = Sets.newHashSet(Biome.PLAIN, Biome.DESERT, Biome.SAVANNA); + /** World terrain type, 0 for normal, 1 for flat map */ private int terrainType; private int distance; @@ -69,7 +71,12 @@ public class MapGenVillage extends MapGenStructure if (i == k && j == l) { - return true; + boolean flag = this.worldObj.getBiomeGenerator().areBiomesViable(i * 16 + 8, j * 16 + 8, 0, villageSpawnBiomes); + + if (flag) + { + return true; + } } return false; @@ -92,7 +99,7 @@ public class MapGenVillage extends MapGenStructure { super(x, z); List list = StructureVillage.getStructureVillageWeightedPieceList(rand, size); - StructureVillage.Start structurevillagepieces$start = new StructureVillage.Start(worldIn, 0, rand, (x << 4) + 2, (z << 4) + 2, list, size); + StructureVillage.Start structurevillagepieces$start = new StructureVillage.Start(worldIn.getBiomeGenerator(), 0, rand, (x << 4) + 2, (z << 4) + 2, list, size); this.components.add(structurevillagepieces$start); structurevillagepieces$start.buildComponent(structurevillagepieces$start, this.components, rand); List list1 = structurevillagepieces$start.field_74930_j; diff --git a/server/src/main/java/server/worldgen/structure/StructureVillage.java b/server/src/main/java/server/worldgen/structure/StructureVillage.java index 5f57c904..b602697f 100755 --- a/server/src/main/java/server/worldgen/structure/StructureVillage.java +++ b/server/src/main/java/server/worldgen/structure/StructureVillage.java @@ -216,9 +216,12 @@ public class StructureVillage int l = structurecomponent.boundingBox.maxZ - structurecomponent.boundingBox.minZ; int i1 = k > l ? k : l; - p_176066_1_.add(structurecomponent); - start.field_74932_i.add(structurecomponent); - return structurecomponent; + if (start.getBiomeGenerator().areBiomesViable(i, j, i1 / 2 + 4, MapGenVillage.villageSpawnBiomes)) + { + p_176066_1_.add(structurecomponent); + start.field_74932_i.add(structurecomponent); + return structurecomponent; + } } return null; @@ -248,9 +251,12 @@ public class StructureVillage int l = structurecomponent.boundingBox.maxZ - structurecomponent.boundingBox.minZ; int i1 = k > l ? k : l; - p_176069_1_.add(structurecomponent); - start.field_74930_j.add(structurecomponent); - return structurecomponent; + if (start.getBiomeGenerator().areBiomesViable(i, j, i1 / 2 + 4, MapGenVillage.villageSpawnBiomes)) + { + p_176069_1_.add(structurecomponent); + start.field_74930_j.add(structurecomponent); + return structurecomponent; + } } return null; @@ -1405,6 +1411,7 @@ public class StructureVillage public static class Start extends StructureVillage.Well { + public BiomeGenerator biomeGen; public boolean inDesert; public int terrainType; public StructureVillage.PieceWeight structVillagePieceWeight; @@ -1416,14 +1423,21 @@ public class StructureVillage { } - public Start(WorldServer genIn, int p_i2104_2_, Random rand, int p_i2104_4_, int p_i2104_5_, List p_i2104_6_, int p_i2104_7_) + public Start(BiomeGenerator genIn, int p_i2104_2_, Random rand, int p_i2104_4_, int p_i2104_5_, List p_i2104_6_, int p_i2104_7_) { super((StructureVillage.Start)null, 0, rand, p_i2104_4_, p_i2104_5_); + this.biomeGen = genIn; this.structureVillageWeightedPieceList = p_i2104_6_; this.terrainType = p_i2104_7_; - this.inDesert = genIn.getGenTemperature(p_i2104_4_, p_i2104_5_) >= 40.0f; + Biome biomegenbase = genIn.getBiomeGenerator(new BlockPos(p_i2104_4_, 0, p_i2104_5_), Biome.DEF_BIOME); + this.inDesert = biomegenbase == Biome.DESERT || biomegenbase == Biome.DESERT_HILLS; this.func_175846_a(this.inDesert); } + + public BiomeGenerator getBiomeGenerator() + { + return this.biomeGen; + } } public static class Torch extends StructureVillage.Village