move worldgen to server

This commit is contained in:
Sen 2025-05-14 00:37:46 +02:00
parent e26938ee77
commit 111226fe28
159 changed files with 1917 additions and 1951 deletions

View file

@ -86,6 +86,7 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import server.biome.Biome;
import server.clipboard.ReorderRegistry;
import server.clipboard.RotationRegistry;
import server.command.CommandEnvironment;
@ -144,6 +145,8 @@ public final class Server implements IThreadListener {
public static void main(String[] args) {
Util.checkOs();
Registry.setup("Server thread");
Biome.setAsProvider();
UniverseRegistry.register();
RotationRegistry.register();
ReorderRegistry.register();
boolean debug = System.getProperty("server.debug", null) != null;
@ -907,10 +910,11 @@ public final class Server implements IThreadListener {
public void recreatePlayer(Player conn) {
EntityNPC old = conn.getEntity();
BlockPos pos = old.getPosition();
old.getServerWorld().removePlayerFromTrackers(old);
old.getServerWorld().untrackEntity(old);
old.getServerWorld().removePlayer(old);
old.getServerWorld().removePlayerEntityDangerously(old);
WorldServer oldWorld = (WorldServer)old.getServerWorld();
oldWorld.removePlayerFromTrackers(old);
oldWorld.untrackEntity(old);
oldWorld.removePlayer(old);
oldWorld.removePlayerEntityDangerously(old);
WorldPos bed = old.getSpawnPoint();
WorldPos origin = old.getOrigin();
BlockPos spawn = null;
@ -975,11 +979,12 @@ public final class Server implements IThreadListener {
old.writeToNBT(oldTag);
oldTag.setInteger("Dimension", old.worldObj.dimension.getDimensionId());
oldTag.setString("id", EntityRegistry.getEntityString(old));
old.getServerWorld().removePlayerFromTrackers(old);
old.getServerWorld().untrackEntity(old);
old.getServerWorld().removePlayer(old);
old.getServerWorld().removePlayerEntityDangerously(old);
WorldServer oldWorld = (WorldServer)old.getServerWorld();
oldWorld.removePlayerFromTrackers(old);
oldWorld.untrackEntity(old);
oldWorld.removePlayer(old);
oldWorld.removePlayerEntityDangerously(old);
// old.dead = false;
WorldServer world = tag == null ? this.space : this.getWorld(tag.getInteger("Dimension"));

View file

@ -0,0 +1,879 @@
package server.biome;
import common.biome.BaseBiome;
import common.biome.IBiome;
import common.block.Block;
import common.block.BlockColored;
import common.block.BlockFlower;
import common.block.BlockSand;
import common.block.BlockSapling;
import common.block.BlockTallGrass;
import common.color.DyeColor;
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.animal.EntitySquid;
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.material.Material;
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 Biome implements IBiome {
public static final Biome[] BIOMES = new Biome[256];
public static final Biome none = (new BiomeNone());
public static final Biome plains = (new BiomePlains());
public static final Biome desert = (new BiomeDesert(false)).setScaling(Scaling.PLAINS_LOW);
public static final Biome extremeHills = (new BiomeHills(BaseBiome.EXTREMEHILLS, false)).setScaling(Scaling.HILLS_LARGE);
public static final Biome forest = (new BiomeForest(BaseBiome.FOREST, 0));
public static final Biome taiga = (new BiomeTaiga(BaseBiome.TAIGA, 0)).setScaling(Scaling.PLAINS_MEDIUM);
public static final Biome swampland = (new BiomeSwamp()).setScaling(Scaling.SEA_POND);
public static final Biome river = (new BiomeWater(BaseBiome.RIVER, true)).setScaling(Scaling.SEA_SHALLOW);
public static final Biome exterminated = (new BiomeExterminated());
public static final Biome space = (new BiomeSpace());
public static final Biome frozenSea = (new BiomeWater(BaseBiome.FROZENSEA, false)).enableColdBeach().setScaling(Scaling.SEA_MEDIUM);
public static final Biome frozenRiver = (new BiomeWater(BaseBiome.FROZENRIVER, true)).enableColdBeach().setScaling(Scaling.SEA_SHALLOW);
public static final Biome icePlains = (new BiomeSnow(BaseBiome.ICEPLAINS, false)).enableColdBeach().setScaling(Scaling.PLAINS_LOW);
public static final Biome iceMountains = (new BiomeSnow(BaseBiome.ICEMOUNTAINS, false)).enableColdBeach().setScaling(Scaling.HILLS_LOW);
public static final Biome mushroomPlains = (new BiomeMushroom()).setScaling(Scaling.PLAINS_VARYING);
public static final Biome blackened = (new BiomeBlackened());
public static final Biome beach = (new BiomeBeach(false)).setScaling(Scaling.SEA_SHORE);
public static final Biome desertHills = (new BiomeDesert(true)).setScaling(Scaling.HILLS_LOW);
public static final Biome forestHills = (new BiomeForest(BaseBiome.FORESTHILLS, 0)).setScaling(Scaling.HILLS_LOW);
public static final Biome taigaHills = (new BiomeTaiga(BaseBiome.TAIGAHILLS, 0)).setScaling(Scaling.HILLS_LOW);
public static final Biome extremeHillsEdge = (new BiomeHills(BaseBiome.EXTREMEHILLSEDGE, true)).setScaling(Scaling.HILLS_MEDIUM);
public static final Biome jungle = (new BiomeJungle(BaseBiome.JUNGLE, false));
public static final Biome jungleHills = (new BiomeJungle(BaseBiome.JUNGLEHILLS, false)).setScaling(Scaling.HILLS_LOW);
public static final Biome jungleEdge = (new BiomeJungle(BaseBiome.JUNGLEEDGE, true));
public static final Biome sea = (new BiomeWater(BaseBiome.SEA, false)).setScaling(Scaling.SEA_MEDIUM);
public static final Biome stoneBeach = (new BiomeStoneBeach()).setScaling(Scaling.SEA_VARYING);
public static final Biome coldBeach = (new BiomeBeach(true)).setScaling(Scaling.SEA_SHORE).enableColdBeach();
public static final Biome birchForest = (new BiomeForest(BaseBiome.BIRCHFOREST, 2));
public static final Biome birchForestHills = (new BiomeForest(BaseBiome.BIRCHFORESTHILLS, 2)).setScaling(Scaling.HILLS_LOW);
public static final Biome roofedForest = (new BiomeForest(BaseBiome.ROOFEDFOREST, 3));
public static final Biome coldTaiga = (new BiomeTaiga(BaseBiome.COLDTAIGA, 0)).enableColdBeach().setScaling(Scaling.PLAINS_MEDIUM);
public static final Biome coldTaigaHills = (new BiomeTaiga(BaseBiome.COLDTAIGAHILLS, 0)).enableColdBeach().setScaling(Scaling.HILLS_LOW);
public static final Biome megaTaiga = (new BiomeTaiga(BaseBiome.MEGATAIGA, 1)).setScaling(Scaling.PLAINS_MEDIUM);
public static final Biome megaTaigaHills = (new BiomeTaiga(BaseBiome.MEGATAIGAHILLS, 1)).setScaling(Scaling.HILLS_LOW);
public static final Biome extremeHillsPlus = (new BiomeHills(BaseBiome.EXTREMEHILLSPLUS, true)).setScaling(Scaling.HILLS_LARGE);
public static final Biome savanna = (new BiomeSavanna(false)).setScaling(Scaling.PLAINS_LOW);
public static final Biome savannaPlateau = (new BiomeSavanna(true)).setScaling(Scaling.HILLS_PLATEAU);
public static final Biome mesa = (new BiomeMesa(BaseBiome.MESA, false, false));
public static final Biome mesaPlateau_F = (new BiomeMesa(BaseBiome.MESAPLATEAUF, false, true)).setScaling(Scaling.HILLS_PLATEAU);
public static final Biome mesaPlateau = (new BiomeMesa(BaseBiome.MESAPLATEAU, false, false)).setScaling(Scaling.HILLS_PLATEAU);
public static final Biome snowLand = (new BiomeSnowLand()).enableColdBeach();
public static final Biome tian = (new BiomeTian()).setScaling(Scaling.VARYING_MEDIUM);
public static final Biome elvenForest = (new BiomeForest(BaseBiome.ELVENFOREST, 4));
public static final Biome upperHell = (new BiomeHell(BaseBiome.UPPERHELL, 0));
public static final Biome lowerHell = (new BiomeHell(BaseBiome.LOWERHELL, 1));
public static final Biome hellHills = (new BiomeHell(BaseBiome.HELLHILLS, 1)).setScaling(Scaling.HILLS_LARGE);
public static final Biome soulPlains = (new BiomeHell(BaseBiome.SOULPLAINS, 1)).setScaling(Scaling.SEA_POND);
public static final Biome ashLand = (new BiomeHell(BaseBiome.ASHLAND, 2)).setScaling(Scaling.PLAINS_LOW);
public static final Biome moon = (new BiomeMoon()).setScaling(Scaling.PLAINS_LOW);
public static final Biome chaos = (new BiomeChaos()).setScaling(Scaling.VARYING_CHAOTIC);
protected static final PerlinGen TREE_NOISE;
protected static final PerlinGen GRASS_NOISE;
protected static final FeatureDoublePlant DOUBLE_PLANT_GEN;
public final BaseBiome base;
protected final WeightedList<RngSpawn> mobs = new WeightedList<RngSpawn>();
protected final WorldGenBaseTree worldGeneratorTrees = new WorldGenBaseTree(false);
protected final WorldGenBigTree worldGeneratorBigTree = new WorldGenBigTree(false);
protected final WorldGenSwamp worldGeneratorSwamp = new WorldGenSwamp();
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.flower, BlockFlower.EnumFlowerType.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 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 Biome getBiome(int id)
{
if (id >= 0 && id < BIOMES.length)
{
return BIOMES[id];
}
else
{
Log.JNI.warn("Biom-ID ist nicht im Bereich: " + id + ", verwende " + BaseBiome.DEF_BIOME.id + " (" + BaseBiome.DEF_BIOME.name + ")");
return BIOMES[BaseBiome.DEF_BIOME.id];
}
}
public static void setAsProvider() {
IBiome.setProvider(new IBiome.BiomeProvider() {
public final IBiome getBiome(BaseBiome base) {
return BIOMES[base.id];
}
});
}
protected Biome(BaseBiome base) {
BIOMES[base.id] = this;
this.base = base;
this.addMobs(this.mobs);
}
protected void addMobs(WeightedList<RngSpawn> 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(EntitySquid.class, 10, 4, 4));
mobs.add(new RngSpawn(EntityBat.class, 10, 8, 8));
mobs.add(new RngSpawn(EntityMouse.class, 10, 8, 8));
}
protected final Biome setScaling(Scaling scaling)
{
return this.setScaling(scaling.depth, scaling.scale);
}
protected final Biome 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)
{
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)) || (this.base.isHighHumidity() && rand.chance(3)) ? this.worldGeneratorBigTree :
this.worldGeneratorTrees;
}
public FeatureGenerator getRandomWorldGenForGrass(Random rand)
{
return new WorldGenTallGrass(BlockTallGrass.EnumType.GRASS);
}
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 Biome enableColdBeach()
{
this.allowColdBeach = true;
return this;
}
protected Biome disableBeach()
{
this.disallowBeach = true;
return this;
}
public WeightedList<RngSpawn> 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.getTopSolidOrLiquidBlock(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.getTopSolidOrLiquidBlock(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.getTopSolidOrLiquidBlock(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.getTopSolidOrLiquidBlock(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);
BlockFlower blockflower = blockflower$enumflowertype.getBlockType().getBlock();
if (blockflower.getMaterial() != Material.air)
{
this.yellowFlowerGen.setGeneratedBlock(blockflower, 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().getMaterial() == Material.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().getMaterial() == Material.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 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.ORANGE) : Blocks.sandstone.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());
State leaves = type == WoodType.CHERRY ? Blocks.cherry_leaves.getState() :
(type == WoodType.MAPLE ? Blocks.maple_leaves.getState() : Blocks.oak_leaves.getState());
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(), Blocks.tian_leaves.getState())
.setHeightLimit(6, 20);
break;
case JUNGLE:
State iblockstate = Blocks.jungle_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE);
State iblockstate1 = Blocks.jungle_leaves.getState(); // .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().getMaterial() == Material.air)
{
if (rand.chance(8))
{
BlockFlower.EnumFlowerType blockflower$enumflowertype = BIOMES[worldIn.getBiomeGenForCoords(blockpos1).id].pickRandomFlower(rand, blockpos1);
BlockFlower blockflower = blockflower$enumflowertype.getBlockType().getBlock();
State iblockstate = blockflower.getState().withProperty(blockflower.getTypeProperty(), blockflower$enumflowertype);
if (blockflower.canBlockStay(worldIn, blockpos1, iblockstate))
{
worldIn.setState(blockpos1, iblockstate, 3);
}
}
else
{
State iblockstate1 = Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS);
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 Biome createMutatedBiome(BaseBiome base)
{
return new BiomeMutated(base, this);
}
public Class <? extends Biome > getBiomeClass()
{
return this.getClass();
}
public boolean isEqualTo(Biome 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);
}
static
{
desert.createMutatedBiome(BaseBiome.DESERTM);
forest.createMutatedBiome(BaseBiome.FLOWERFOREST);
taiga.createMutatedBiome(BaseBiome.TAIGAM);
swampland.createMutatedBiome(BaseBiome.SWAMPLANDM);
icePlains.createMutatedBiome(BaseBiome.ICEPLAINSSPIKES);
jungle.createMutatedBiome(BaseBiome.JUNGLEM);
jungleEdge.createMutatedBiome(BaseBiome.JUNGLEEDGEM);
coldTaiga.createMutatedBiome(BaseBiome.COLDTAIGAM);
savanna.createMutatedBiome(BaseBiome.SAVANNAM);
savannaPlateau.createMutatedBiome(BaseBiome.SAVANNAPLATEAUM);
mesa.createMutatedBiome(BaseBiome.MESABRYCE);
mesaPlateau_F.createMutatedBiome(BaseBiome.MESAPLATEAUFM);
mesaPlateau.createMutatedBiome(BaseBiome.MESAPLATEAUM);
birchForest.createMutatedBiome(BaseBiome.BIRCHFORESTM);
birchForestHills.createMutatedBiome(BaseBiome.BIRCHFORESTHILLSM);
roofedForest.createMutatedBiome(BaseBiome.ROOFEDFORESTM);
megaTaiga.createMutatedBiome(BaseBiome.MEGASPRUCETAIGA);
extremeHills.createMutatedBiome(BaseBiome.EXTREMEHILLSM);
extremeHillsPlus.createMutatedBiome(BaseBiome.EXTREMEHILLSPLUSM);
megaTaiga.createMutatedBiome(BaseBiome.REDWOODTAIGAHILLSM);
TREE_NOISE = new PerlinGen(new Random(667L), 8);
GRASS_NOISE = new PerlinGen(new Random(2345L), 1);
DOUBLE_PLANT_GEN = new FeatureDoublePlant();
}
}

View file

@ -0,0 +1,22 @@
package server.biome;
import common.biome.BaseBiome;
import common.init.Blocks;
import common.rng.WeightedList;
public class BiomeBeach extends Biome
{
public BiomeBeach(boolean cold)
{
super(cold ? BaseBiome.COLDBEACH : BaseBiome.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<RngSpawn> mobs) {
}
}

View file

@ -0,0 +1,35 @@
package server.biome;
import common.biome.BaseBiome;
import common.block.BlockFlower;
import common.entity.npc.EntityMetalhead;
import common.init.Blocks;
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 Biome {
protected final WorldGenTree treeGen = new WorldGenBaseTree(false, Blocks.blackwood_log.getState(), Blocks.blackwood_leaves.getState());
public BiomeBlackened() {
super(BaseBiome.BLACKENED);
this.topBlock = Blocks.blackened_soil.getState();
this.fillerBlock = Blocks.blackened_dirt.getState();
this.treesPerChunk = 3;
this.generateLakes = false;
}
protected void addMobs(WeightedList<RngSpawn> 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;
}
}

View file

@ -0,0 +1,45 @@
package server.biome;
import common.biome.BaseBiome;
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 Biome
{
protected FeatureGenerator mushroomBlueGen = new WorldGenMushroom(Blocks.blue_mushroom);
public BiomeChaos()
{
super(BaseBiome.CHAOS);
this.topBlock = Blocks.obsidian.getState();
this.fillerBlock = Blocks.obsidian.getState();
}
protected void addMobs(WeightedList<RngSpawn> mobs) {
for(Class<? extends Entity> clazz : EntityRegistry.getAllClasses()) {
if(EntityLiving.class.isAssignableFrom(clazz))
mobs.add(new RngSpawn((Class<? extends EntityLiving>)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);
}
}
}

View file

@ -0,0 +1,40 @@
package server.biome;
import common.biome.BaseBiome;
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 BiomeDesert extends Biome
{
public BiomeDesert(boolean hills)
{
super(hills ? BaseBiome.DESERTHILLS : BaseBiome.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;
}
protected void addMobs(WeightedList<RngSpawn> mobs) {
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos)
{
super.decorate(worldIn, rand, pos);
if (rand.chance(1000))
{
int i = rand.chOffset();
int j = rand.chOffset();
BlockPos blockpos = worldIn.getHeight(pos.add(i, 0, j)).up();
(new WorldGenDesertWells()).generate(worldIn, rand, blockpos);
}
}
}

View file

@ -0,0 +1,22 @@
package server.biome;
import common.biome.BaseBiome;
import common.init.Blocks;
import common.rng.Random;
import common.rng.WeightedList;
import common.util.BlockPos;
import server.world.WorldServer;
public class BiomeExterminated extends Biome {
public BiomeExterminated() {
super(BaseBiome.EXTERMINATED);
this.topBlock = Blocks.air.getState();
this.fillerBlock = Blocks.air.getState();
}
protected void addMobs(WeightedList<RngSpawn> mobs) {
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos) {
}
}

View file

@ -0,0 +1,223 @@
package server.biome;
import common.biome.BaseBiome;
import common.block.BlockDoublePlant;
import common.block.BlockFlower;
import common.entity.animal.EntityWolf;
import common.entity.npc.EntityElf;
import common.entity.npc.EntityWoodElf;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import common.util.ExtMath;
import server.world.WorldServer;
import server.worldgen.foliage.WorldGenBigMushroom;
import server.worldgen.tree.WorldGenBaseTree;
import server.worldgen.tree.WorldGenBigTree;
import server.worldgen.tree.WorldGenBirch;
import server.worldgen.tree.WorldGenDarkOak;
import server.worldgen.tree.WorldGenTree;
public class BiomeForest extends Biome
{
private static final BlockDoublePlant.EnumPlantType[] FLOWER_TYPES = new BlockDoublePlant.EnumPlantType[] {
BlockDoublePlant.EnumPlantType.SYRINGA, BlockDoublePlant.EnumPlantType.ROSE, BlockDoublePlant.EnumPlantType.PAEONIA
};
protected static final WorldGenBirch tallBirch = new WorldGenBirch(false, true);
protected static final WorldGenBirch normalBirch = new WorldGenBirch(false, false);
protected static final WorldGenDarkOak darkOak = new WorldGenDarkOak(false);
private final int subType;
// protected LeavesType leavesType = null;
// protected WorldGenBaseTree cherry;
// protected WorldGenBaseTree maple;
// protected WorldGenBigTree cherryBig;
// protected WorldGenBigTree mapleBig;
protected WorldGenBaseTree cherry = new WorldGenBaseTree(false, Blocks.cherry_log.getState(), // .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.CHERRY),
Blocks.cherry_leaves.getState()); // .withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()));
protected WorldGenBaseTree maple = new WorldGenBaseTree(false, Blocks.maple_log.getState(), // .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.MAPLE),
Blocks.maple_leaves.getState()); // .withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()));
protected WorldGenBigTree cherryBig = new WorldGenBigTree(false, Blocks.cherry_log.getState(), // .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.CHERRY),
Blocks.cherry_leaves.getState()); // .withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()));
protected WorldGenBigTree mapleBig = new WorldGenBigTree(false, Blocks.maple_log.getState(), // .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.MAPLE),
Blocks.maple_leaves.getState()); // .withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()));
public BiomeForest(BaseBiome base, int type)
{
super(base);
this.subType = type;
this.treesPerChunk = 10;
this.grassPerChunk = 2;
if (this.subType == 1)
{
this.treesPerChunk = 6;
this.flowersPerChunk = 100;
this.grassPerChunk = 1;
}
if (this.subType == 4)
{
this.treesPerChunk = 20;
this.flowersPerChunk = 20;
this.grassPerChunk = 1;
this.reedsPerChunk = 50;
this.waterlilyPerChunk = 4;
}
if (this.subType == 0)
{
this.mobs.add(new RngSpawn(EntityWolf.class, 5, 4, 4));
}
if (this.subType == 3)
{
this.treesPerChunk = -999;
}
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));
}
}
public WorldGenTree genBigTreeChance(Random rand)
{
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) :
this.subType == 4 && rand.chance(42) ? this.worldGeneratorBigTree : this.worldGeneratorTrees) :
(this.subType == 4 || rand.chance(this.subType == 2 ? 30 : 2) ? (rand.chance(this.subType == 4 ? 32 : 5) ? this.mapleBig : this.maple) : normalBirch)));
}
public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos)
{
if (this.subType == 1)
{
double d0 = ExtMath.clampd((1.0D + GRASS_NOISE.generate((double)pos.getX() / 48.0D, (double)pos.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
BlockFlower.EnumFlowerType blockflower$enumflowertype = BlockFlower.EnumFlowerType.values()[(int)(d0 * (double)BlockFlower.EnumFlowerType.values().length)];
return blockflower$enumflowertype == BlockFlower.EnumFlowerType.BLUE_ORCHID ? BlockFlower.EnumFlowerType.ROSE : blockflower$enumflowertype;
}
else if (this.subType == 4)
{
double d0 = ExtMath.clampd((1.0D + GRASS_NOISE.generate((double)pos.getX() / 48.0D, (double)pos.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
return BlockFlower.EnumFlowerType.values()[(int)(d0 * (double)BlockFlower.EnumFlowerType.values().length)];
}
else
{
return super.pickRandomFlower(rand, pos);
}
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos)
{
// if(worldIn.getLeavesGen() != this.leavesType) {
// this.leavesType = worldIn.getLeavesGen();
// this.cherry = new WorldGenBaseTree(false, Blocks.log2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.CHERRY),
// Blocks.cherry_leaves.getDefaultState().withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()));
// this.maple = new WorldGenBaseTree(false, Blocks.log2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.MAPLE),
// Blocks.maple_leaves.getDefaultState().withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()));
// this.cherryBig = new WorldGenBigTree(false, Blocks.log2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.CHERRY),
// Blocks.cherry_leaves.getDefaultState().withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()));
// this.mapleBig = new WorldGenBigTree(false, Blocks.log2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.MAPLE),
// Blocks.maple_leaves.getDefaultState().withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen()));
// }
if (this.subType == 3)
{
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
int k = i * 4 + rand.range(9, 11);
int l = j * 4 + rand.range(9, 11);
BlockPos blockpos = worldIn.getHeight(pos.add(k, 0, l));
if (rand.chance(20))
{
WorldGenBigMushroom worldgenbigmushroom = new WorldGenBigMushroom();
worldgenbigmushroom.generate(worldIn, rand, blockpos);
}
else
{
WorldGenTree worldgenabstracttree = this.genBigTreeChance(rand);
worldgenabstracttree.prepare();
if (worldgenabstracttree.generate(worldIn, rand, blockpos))
{
worldgenabstracttree.finish(worldIn, rand, blockpos);
}
}
}
}
}
int j1 = rand.range(-3, 1);
if (this.subType == 1)
{
j1 += 2;
}
for (int k1 = 0; k1 < j1; ++k1)
{
// int l1 = rand.nextInt(3);
// if (l1 == 0)
// {
DOUBLE_PLANT_GEN.setPlantType(rand.pick(FLOWER_TYPES));
// }
// else if (l1 == 1)
// {
// DOUBLE_PLANT_GENERATOR.setPlantType();
// }
// else if (l1 == 2)
// {
// DOUBLE_PLANT_GENERATOR.setPlantType();
// }
for (int i2 = 0; i2 < 5; ++i2)
{
int j2 = rand.chOffset();
int k2 = rand.chOffset();
int i1 = rand.zrange(worldIn.getHeight(pos.add(j2, 0, k2)).getY() + 32);
if (DOUBLE_PLANT_GEN.generate(worldIn, rand, new BlockPos(pos.getX() + j2, i1, pos.getZ() + k2)))
{
break;
}
}
}
super.decorate(worldIn, rand, pos);
}
protected Biome createMutatedBiome(BaseBiome base)
{
if (this.base == BaseBiome.FOREST)
{
BiomeForest biomegenforest = new BiomeForest(base, 1);
biomegenforest.setScaling(this.depth, this.scale + 0.2F);
return biomegenforest;
}
else
{
return this.base != BaseBiome.BIRCHFOREST && this.base != BaseBiome.BIRCHFORESTHILLS ? 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;
}
};
}
}
}

View file

@ -0,0 +1,129 @@
package server.biome;
import common.biome.BaseBiome;
import common.entity.npc.EntityBloodElf;
import common.entity.npc.EntityCultivator;
import common.entity.npc.EntityFireDemon;
import common.entity.npc.EntityMagma;
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 Biome
{
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(BaseBiome 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<RngSpawn> mobs) {
mobs.add(new RngSpawn(EntityFireDemon.class, 50, 4, 4));
mobs.add(new RngSpawn(EntityTiefling.class, 100, 4, 4));
mobs.add(new RngSpawn(EntityMagma.class, 1, 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();
// }
}

View file

@ -0,0 +1,101 @@
package server.biome;
import common.biome.BaseBiome;
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 Biome
{
// 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(BaseBiome 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(Biome p_150633_1_)
{
this.field_150638_aH = this.field_150637_aG;
this.setScaling(p_150633_1_.depth, p_150633_1_.scale);
return this;
}
protected Biome createMutatedBiome(BaseBiome base)
{
return (new BiomeHills(base, false)).mutateHills(this);
}
}

View file

@ -0,0 +1,84 @@
package server.biome;
import common.biome.BaseBiome;
import common.block.BlockTallGrass;
import common.entity.animal.EntityChicken;
import common.entity.animal.EntityOcelot;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
import server.worldgen.foliage.WorldGenMelon;
import server.worldgen.foliage.WorldGenShrub;
import server.worldgen.foliage.WorldGenTallGrass;
import server.worldgen.foliage.WorldGenVines;
import server.worldgen.tree.WorldGenBaseTree;
import server.worldgen.tree.WorldGenJungle;
import server.worldgen.tree.WorldGenTree;
public class BiomeJungle extends Biome
{
private static final State LOG = Blocks.jungle_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE);
private static final State LEAVES = Blocks.jungle_leaves.getState(); // .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE); // .withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
private static final State BUSH = Blocks.oak_leaves.getState(); // .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK); // .withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
private final boolean edge;
public BiomeJungle(BaseBiome base, boolean edge)
{
super(base);
this.edge = edge;
if (edge)
{
this.treesPerChunk = 2;
}
else
{
this.treesPerChunk = 50;
}
this.grassPerChunk = 25;
this.flowersPerChunk = 4;
if (!edge)
{
this.mobs.add(new RngSpawn(EntityOcelot.class, 2, 1, 1));
}
this.mobs.add(new RngSpawn(EntityChicken.class, 10, 4, 4));
}
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))));
}
/**
* Gets a WorldGen appropriate for this biome.
*/
public FeatureGenerator getRandomWorldGenForGrass(Random rand)
{
return rand.chance(4) ? new WorldGenTallGrass(BlockTallGrass.EnumType.FERN) : new WorldGenTallGrass(BlockTallGrass.EnumType.GRASS);
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos)
{
super.decorate(worldIn, rand, pos);
int i = rand.chOffset();
int j = rand.chOffset();
int k = rand.zrange(worldIn.getHeight(pos.add(i, 0, j)).getY() * 2);
(new WorldGenMelon()).generate(worldIn, rand, pos.add(i, k, j));
WorldGenVines worldgenvines = new WorldGenVines();
for (j = 0; j < 50; ++j)
{
k = rand.chOffset();
int l = 128;
int i1 = rand.chOffset();
worldgenvines.generate(worldIn, rand, pos.add(k, 128, i1));
}
}
}

View file

@ -0,0 +1,332 @@
package server.biome;
import java.util.Arrays;
import common.biome.BaseBiome;
import common.block.Block;
import common.block.BlockColored;
import common.block.BlockDirt;
import common.block.BlockSand;
import common.color.DyeColor;
import common.init.Blocks;
import common.material.Material;
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 Biome
{
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(BaseBiome 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.sand.getState().withProperty(BlockSand.VARIANT, BlockSand.EnumType.RED_SAND);
this.fillerBlock = Blocks.stained_hardened_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<RngSpawn> 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.stained_hardened_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().getMaterial() == Material.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().getMaterial() == Material.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.stained_hardened_clay.getState();
iblockstate3 = this.fillerBlock;
}
if (i1 < l1 && (iblockstate == null || iblockstate.getBlock().getMaterial() == Material.air))
{
iblockstate = liquid;
}
l = k + Math.max(0, i1 - l1);
if (i1 < l1 - 1)
{
chunkPrimerIn.set(k1, i1, j1, iblockstate3);
if (iblockstate3.getBlock() == Blocks.stained_hardened_clay)
{
chunkPrimerIn.set(k1, i1, j1, iblockstate3.getBlock().getState().withProperty(BlockColored.COLOR, DyeColor.ORANGE));
}
}
else if (this.soil && i1 > 86 + k * 2)
{
if (flag)
{
chunkPrimerIn.set(k1, i1, j1, Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT));
}
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.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.ORANGE);
}
chunkPrimerIn.set(k1, i1, j1, iblockstate4);
}
}
else if (l > 0)
{
--l;
if (flag1)
{
chunkPrimerIn.set(k1, i1, j1, Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.ORANGE));
}
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.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.ORANGE);
}
}
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.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.YELLOW);
}
}
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.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.BROWN);
}
}
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.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.RED);
}
}
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.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.WHITE);
if (j4 + k1 > 1 && random.chance())
{
this.layers[j4 + k1 - 1] = Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.SILVER);
}
if (j4 + k1 < 63 && random.chance())
{
this.layers[j4 + k1 + 1] = Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.SILVER);
}
}
}
}
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 Biome createMutatedBiome(BaseBiome base)
{
boolean bryce = this.base == BaseBiome.MESA;
BiomeMesa mesa = new BiomeMesa(base, bryce, this.soil);
if (!bryce)
{
mesa.setScaling(Scaling.HILLS_LOW);
}
return mesa;
}
}

View file

@ -0,0 +1,26 @@
package server.biome;
import common.biome.BaseBiome;
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 BiomeMoon extends Biome {
private FeatureOres cheeseGenerator = new FeatureOres(Blocks.moon_cheese.getState(), 8, 8, 12, 24, 52, false);
public BiomeMoon() {
super(BaseBiome.MOON);
this.topBlock = Blocks.moon_rock.getState();
this.fillerBlock = Blocks.moon_rock.getState();
}
protected void addMobs(WeightedList<RngSpawn> mobs) {
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos) {
this.cheeseGenerator.generate(worldIn, rand, pos);
}
}

View file

@ -0,0 +1,24 @@
package server.biome;
import common.biome.BaseBiome;
import common.entity.animal.EntityMooshroom;
import common.init.Blocks;
import common.rng.WeightedList;
public class BiomeMushroom extends Biome
{
public BiomeMushroom()
{
super(BaseBiome.MUSHROOMPLAINS);
this.treesPerChunk = -100;
this.flowersPerChunk = -100;
this.grassPerChunk = -100;
this.mushroomsPerChunk = 1;
this.bigMushroomsPerChunk = 1;
this.topBlock = Blocks.mycelium.getState();
}
protected void addMobs(WeightedList<RngSpawn> mobs) {
mobs.add(new RngSpawn(EntityMooshroom.class, 8, 4, 8));
}
}

View file

@ -0,0 +1,83 @@
package server.biome;
import common.biome.BaseBiome;
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 Biome
{
protected Biome baseBiome;
public BiomeMutated(BaseBiome base, Biome 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<RngSpawn> 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 <? extends Biome > getBiomeClass()
{
return this.baseBiome.getBiomeClass();
}
/**
* returns true if the biome specified is equal to this biome
*/
public boolean isEqualTo(Biome biome)
{
return this.baseBiome.isEqualTo(biome);
}
public Temperature getTempCategory()
{
return this.baseBiome.getTempCategory();
}
}

View file

@ -0,0 +1,30 @@
package server.biome;
import common.biome.BaseBiome;
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 Biome {
public BiomeNone() {
super(BaseBiome.NONE);
this.topBlock = Blocks.air.getState();
this.fillerBlock = Blocks.air.getState();
}
protected void addMobs(WeightedList<RngSpawn> 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;
}
}

View file

@ -0,0 +1,120 @@
package server.biome;
import common.biome.BaseBiome;
import common.block.BlockDoublePlant;
import common.block.BlockFlower;
import common.entity.animal.EntityHorse;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
public class BiomePlains extends Biome
{
private static final BlockFlower.EnumFlowerType[] TULIP_TYPES = new BlockFlower.EnumFlowerType[] {
BlockFlower.EnumFlowerType.ORANGE_TULIP, BlockFlower.EnumFlowerType.RED_TULIP,
BlockFlower.EnumFlowerType.PINK_TULIP, BlockFlower.EnumFlowerType.WHITE_TULIP
};
private static final BlockFlower.EnumFlowerType[] FLOWER_TYPES = new BlockFlower.EnumFlowerType[] {
BlockFlower.EnumFlowerType.POPPY, BlockFlower.EnumFlowerType.HOUSTONIA, BlockFlower.EnumFlowerType.OXEYE_DAISY
};
// protected boolean field_150628_aC;
protected BiomePlains()
{
super(BaseBiome.PLAINS);
this.setScaling(Scaling.PLAINS_LOW);
this.mobs.add(new RngSpawn(EntityHorse.class, 5, 2, 6));
this.treesPerChunk = -999;
this.flowersPerChunk = 4;
this.grassPerChunk = 10;
}
public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos)
{
double d0 = GRASS_NOISE.generate((double)pos.getX() / 200.0D, (double)pos.getZ() / 200.0D);
if (d0 < -0.8D)
{
return rand.pick(TULIP_TYPES);
// int j = rand.nextInt(4);
//
// switch (j)
// {
// case 0:
// return BlockFlower.EnumFlowerType.ORANGE_TULIP;
//
// case 1:
// return BlockFlower.EnumFlowerType.RED_TULIP;
//
// case 2:
// return BlockFlower.EnumFlowerType.PINK_TULIP;
//
// case 3:
// default:
// return BlockFlower.EnumFlowerType.WHITE_TULIP;
// }
}
else if (rand.rarity(3))
{
return rand.pick(FLOWER_TYPES);
// int i = rand.nextInt(3);
// return i == 0 ? BlockFlower.EnumFlowerType.POPPY : (i == 1 ? BlockFlower.EnumFlowerType.HOUSTONIA : BlockFlower.EnumFlowerType.OXEYE_DAISY);
}
else
{
return BlockFlower.EnumFlowerType.DANDELION;
}
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos)
{
double d0 = GRASS_NOISE.generate((double)(pos.getX() + 8) / 200.0D, (double)(pos.getZ() + 8) / 200.0D);
if (d0 < -0.8D)
{
this.flowersPerChunk = 15;
this.grassPerChunk = 5;
}
else
{
this.flowersPerChunk = 4;
this.grassPerChunk = 10;
DOUBLE_PLANT_GEN.setPlantType(BlockDoublePlant.EnumPlantType.GRASS);
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));
}
}
// int n = rand.range(0, 2);
if (rand.chance())
{
DOUBLE_PLANT_GEN.setPlantType(BlockDoublePlant.EnumPlantType.SUNFLOWER);
// for (int i1 = 0; i1 < 10; ++i1)
// {
int j1 = rand.chOffset();
int k1 = rand.chOffset();
int l1 = rand.zrange(worldIn.getHeight(pos.add(j1, 0, k1)).getY() + 32);
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j1, l1, k1));
// }
}
super.decorate(worldIn, rand, pos);
}
// protected Biome createMutatedBiome(int p_180277_1_)
// {
// BiomePlains biomegenplains = new BiomePlains(p_180277_1_);
// biomegenplains.setBiomeName("sunflowerPlains");
// biomegenplains.field_150628_aC = true;
// biomegenplains.setColor(9286496);
// return biomegenplains;
// }
}

View file

@ -0,0 +1,89 @@
package server.biome;
import common.biome.BaseBiome;
import common.block.BlockDirt;
import common.block.BlockDoublePlant;
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 Biome
{
private static final WorldGenSavanna field_150627_aC = new WorldGenSavanna(false);
protected BiomeSavanna(boolean plateau)
{
super(plateau ? BaseBiome.SAVANNAPLATEAU : BaseBiome.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 Biome createMutatedBiome(BaseBiome base)
{
Biome 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(BlockDoublePlant.EnumPlantType.GRASS);
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(BaseBiome base, Biome 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.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT);
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos)
{
this.decorateNormal(worldIn, rand, pos);
}
}
}

View file

@ -0,0 +1,65 @@
package server.biome;
import common.biome.BaseBiome;
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;
import server.worldgen.feature.WorldGenIceSpike;
import server.worldgen.tree.WorldGenTaiga2;
import server.worldgen.tree.WorldGenTree;
public class BiomeSnow extends Biome
{
private final WorldGenIceSpike spikeGen = new WorldGenIceSpike();
private final WorldGenIcePath pathGen = new WorldGenIcePath(4);
private final boolean spiky;
public BiomeSnow(BaseBiome base, boolean spiky)
{
super(base);
this.spiky = spiky;
if(spiky)
this.topBlock = Blocks.snow.getState();
}
protected void addMobs(WeightedList<RngSpawn> mobs) {
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos)
{
if (this.spiky)
{
for (int i = 0; i < 3; ++i)
{
int j = rand.chOffset();
int k = rand.chOffset();
this.spikeGen.generate(worldIn, rand, worldIn.getHeight(pos.add(j, 0, k)));
}
for (int l = 0; l < 2; ++l)
{
int i1 = rand.chOffset();
int j1 = rand.chOffset();
this.pathGen.generate(worldIn, rand, worldIn.getHeight(pos.add(i1, 0, j1)));
}
}
super.decorate(worldIn, rand, pos);
}
public WorldGenTree genBigTreeChance(Random rand)
{
return new WorldGenTaiga2(false);
}
protected Biome createMutatedBiome(BaseBiome base)
{
Biome 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;
}
}

View file

@ -0,0 +1,23 @@
package server.biome;
import common.biome.BaseBiome;
import common.entity.animal.EntitySheep;
import common.entity.npc.EntitySpirit;
import common.init.Blocks;
import common.rng.WeightedList;
public class BiomeSnowLand extends Biome
{
public BiomeSnowLand()
{
super(BaseBiome.SNOWLAND);
this.topBlock = Blocks.snow.getState();
this.fillerBlock = Blocks.snow.getState();
this.mushroomsPerChunk = -1;
}
protected void addMobs(WeightedList<RngSpawn> mobs) {
mobs.add(new RngSpawn(EntitySheep.class, 50, 4, 4));
mobs.add(new RngSpawn(EntitySpirit.class, 10, 1, 1));
}
}

View file

@ -0,0 +1,39 @@
package server.biome;
import common.biome.BaseBiome;
import common.block.BlockDirt;
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 BiomeSpace extends Biome
{
protected FeatureGenerator asteroidGen1 = new WorldGenAsteroid(Blocks.stone.getState(),
Blocks.rock.getState());
protected FeatureGenerator asteroidGen2 = new WorldGenAsteroid(Blocks.dirt.getState(),
Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT));
public BiomeSpace()
{
super(BaseBiome.SPACE);
this.topBlock = Blocks.air.getState();
this.fillerBlock = Blocks.air.getState();
}
protected void addMobs(WeightedList<RngSpawn> mobs) {
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos)
{
if(rand.chance(5)) {
int x = rand.chOffset();
int z = rand.chOffset();
rand.chance(this.asteroidGen1, this.asteroidGen2, 100).generate(worldIn, rand,
pos.add(x, rand.range(16, 495), z));
}
}
}

View file

@ -0,0 +1,23 @@
package server.biome;
import common.biome.BaseBiome;
import common.init.Blocks;
import common.rng.WeightedList;
public class BiomeStoneBeach extends Biome
{
public BiomeStoneBeach()
{
super(BaseBiome.STONEBEACH);
// 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<RngSpawn> mobs) {
}
}

View file

@ -0,0 +1,75 @@
package server.biome;
import common.biome.BaseBiome;
import common.block.BlockDirectional;
import common.block.BlockFlower;
import common.entity.npc.EntitySlime;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import server.world.WorldServer;
import server.worldgen.ChunkPrimer;
import server.worldgen.tree.WorldGenTree;
public class BiomeSwamp extends Biome
{
protected BiomeSwamp()
{
super(BaseBiome.SWAMPLAND);
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 void genTerrainBlocks(WorldServer worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal)
{
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().getMaterial() != Material.air)
{
if (k == 62 && chunkPrimerIn.get(j, k, i).getBlock() != Blocks.water)
{
chunkPrimerIn.set(j, k, i, Blocks.water.getState());
if (d0 < 0.12D)
{
chunkPrimerIn.set(j, k + 1, i, Blocks.waterlily.getState().withProperty(BlockDirectional.FACING, Facing.randHorizontal(rand)));
}
}
break;
}
}
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
}

View file

@ -0,0 +1,115 @@
package server.biome;
import common.biome.BaseBiome;
import common.block.BlockDirt;
import common.block.BlockDoublePlant;
import common.block.BlockTallGrass;
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;
import server.worldgen.tree.WorldGenPine;
import server.worldgen.tree.WorldGenTaiga1;
import server.worldgen.tree.WorldGenTaiga2;
import server.worldgen.tree.WorldGenTree;
public class BiomeTaiga extends Biome
{
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 int field_150644_aH;
public BiomeTaiga(BaseBiome base, int p_i45385_2_)
{
super(base);
this.field_150644_aH = p_i45385_2_;
this.mobs.add(new RngSpawn(EntityWolf.class, 8, 4, 4));
this.treesPerChunk = 10;
if (p_i45385_2_ != 1 && p_i45385_2_ != 2)
{
this.grassPerChunk = 1;
this.mushroomsPerChunk = 1;
}
else
{
this.grassPerChunk = 7;
this.deadBushPerChunk = 1;
this.mushroomsPerChunk = 3;
}
}
public WorldGenTree genBigTreeChance(Random rand)
{
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));
}
/**
* Gets a WorldGen appropriate for this biome.
*/
public FeatureGenerator getRandomWorldGenForGrass(Random rand)
{
return rand.rarity(5) ? new WorldGenTallGrass(BlockTallGrass.EnumType.FERN) : new WorldGenTallGrass(BlockTallGrass.EnumType.GRASS);
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos)
{
if (this.field_150644_aH == 1 || this.field_150644_aH == 2)
{
int i = rand.zrange(3);
for (int j = 0; j < i; ++j)
{
int k = rand.chOffset();
int l = rand.chOffset();
BlockPos blockpos = worldIn.getHeight(pos.add(k, 0, l));
field_150643_aG.generate(worldIn, rand, blockpos);
}
}
DOUBLE_PLANT_GEN.setPlantType(BlockDoublePlant.EnumPlantType.FERN);
for (int i1 = 0; i1 < 7; ++i1)
{
int j1 = rand.chOffset();
int k1 = rand.chOffset();
int l1 = rand.zrange(worldIn.getHeight(pos.add(j1, 0, k1)).getY() + 32);
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j1, l1, k1));
}
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.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT);
}
else if (noiseVal > -0.95D)
{
this.topBlock = Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL);
}
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
protected Biome createMutatedBiome(BaseBiome base)
{
return this.base == BaseBiome.MEGATAIGA ? (new BiomeTaiga(base, 2)).setScaling(this.depth, this.scale) : super.createMutatedBiome(base);
}
}

View file

@ -0,0 +1,83 @@
package server.biome;
import common.biome.BaseBiome;
import common.block.BlockFlower;
import common.entity.animal.EntityBat;
import common.entity.animal.EntityMouse;
import common.entity.animal.EntityRabbit;
import common.entity.npc.EntityCultivator;
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.WorldGenSpikes;
import server.worldgen.foliage.WorldGenMushroom;
import server.worldgen.tree.WorldGenBaseTree;
import server.worldgen.tree.WorldGenBigTree;
import server.worldgen.tree.WorldGenTree;
public class BiomeTian extends Biome
{
protected FeatureGenerator spikeGen = new WorldGenSpikes(Blocks.tian_soil, 128, 2, 3, Blocks.obsidian.getState(), true);
protected FeatureGenerator mushroomBlueGen = new WorldGenMushroom(Blocks.blue_mushroom);
protected WorldGenTree treeGen1 = new WorldGenBigTree(false, Blocks.tian_log.getState(), Blocks.tian_leaves.getState())
.setHeightLimit(6, 8);
protected WorldGenTree treeGen2 = new WorldGenBigTree(false, Blocks.tian_log.getState(), Blocks.tian_leaves.getState())
.setHeightLimit(14, 20);
protected WorldGenTree treeGen3 = new WorldGenBaseTree(false, Blocks.tian_log.getState(), Blocks.tian_leaves.getState());
protected WorldGenTree treeGen4 = new WorldGenBigTree(false, Blocks.tian_log.getState(), Blocks.tian_leaves.getState())
.setHeightLimit(12, 15);
public BiomeTian()
{
super(BaseBiome.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<RngSpawn> mobs) {
// mobs.add(new Biome.RngSpawn(EntityHaunter.class, 50, 4, 4));
mobs.add(new RngSpawn(EntityCultivator.class, 50, 1, 1));
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));
}
public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos)
{
return BlockFlower.EnumFlowerType.BLACK_LOTUS;
}
public WorldGenTree genBigTreeChance(Random rand)
{
return rand.pick(rand.chance(this.treeGen2, this.treeGen1, 4), rand.chance(this.treeGen3, this.treeGen4, 15));
}
public void decorate(WorldServer worldIn, Random rand, BlockPos pos)
{
super.decorate(worldIn, rand, pos);
for (int l3 = 0; l3 < 2; ++l3)
{
if (rand.chance(4))
{
int i8 = rand.chOffset();
int l11 = rand.chOffset();
BlockPos blockpos2 = worldIn.getHeight(pos.add(i8, 0, l11));
this.mushroomBlueGen.generate(worldIn, rand, blockpos2);
}
}
if (rand.chance(4))
{
int i = rand.chOffset();
int j = rand.chOffset();
this.spikeGen.generate(worldIn, rand, worldIn.getTopSolidOrLiquidBlock(pos.add(i, 0, j)));
}
}
}

View file

@ -0,0 +1,23 @@
package server.biome;
import common.biome.BaseBiome;
import common.entity.animal.EntitySquid;
import common.rng.WeightedList;
public class BiomeWater extends Biome {
private final boolean river;
public BiomeWater(BaseBiome base, boolean river) {
super(base);
this.river = river;
this.disableBeach();
}
protected void addMobs(WeightedList<RngSpawn> mobs) {
mobs.add(new RngSpawn(EntitySquid.class, 10, 4, 4));
}
public Temperature getTempCategory() {
return this.river ? super.getTempCategory() : Temperature.SEA;
}
}

View file

@ -0,0 +1,17 @@
package server.biome;
import common.entity.types.EntityLiving;
import common.rng.RngItem;
public class RngSpawn extends RngItem {
public final Class<? extends EntityLiving> type;
public final int min;
public final int max;
public RngSpawn(Class<? extends EntityLiving> type, int weight, int min, int max) {
super(weight);
this.type = type;
this.min = min;
this.max = max;
}
}

View file

@ -0,0 +1,28 @@
package server.biome;
public enum Scaling {
VARYING_LOW(0.1F, 0.2F),
VARYING_MEDIUM(0.1F, 1.0F),
VARYING_CHAOTIC(1.0F, 2.0F),
SEA_VARYING(0.1F, 0.8F),
SEA_SHORE(0.0F, 0.025F),
SEA_POND(-0.2F, 0.1F),
SEA_SHALLOW(-0.5F, 0.0F),
SEA_MEDIUM(-1.0F, 0.1F),
SEA_DEEP(-1.8F, 0.1F),
PLAINS_LOW(0.125F, 0.05F),
PLAINS_MEDIUM(0.2F, 0.2F),
PLAINS_VARYING(0.2F, 0.3F),
HILLS_LOW(0.45F, 0.3F),
HILLS_MEDIUM(0.8F, 0.3F),
HILLS_LARGE(1.0F, 0.5F),
HILLS_PLATEAU(1.5F, 0.025F);
public final float depth;
public final float scale;
private Scaling(float depth, float scale) {
this.depth = depth;
this.scale = scale;
}
}

View file

@ -0,0 +1,5 @@
package server.biome;
public enum Temperature {
SEA, COLD, MEDIUM, WARM;
}

View file

@ -841,17 +841,17 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
public void onCriticalHit(Entity entityHit)
{
this.entity.getServerWorld().sendToAllTrackingAndSelf(this.entity, new SPacketAnimation(entityHit, 4));
this.getEntityWorld().sendToAllTrackingAndSelf(this.entity, new SPacketAnimation(entityHit, 4));
}
public void onEnchantmentCritical(Entity entityHit)
{
this.entity.getServerWorld().sendToAllTrackingAndSelf(this.entity, new SPacketAnimation(entityHit, 5));
this.getEntityWorld().sendToAllTrackingAndSelf(this.entity, new SPacketAnimation(entityHit, 5));
}
public void updateEffectMeta()
{
this.entity.getServerWorld().updateTrackedPlayer(this.entity);
this.getEntityWorld().updateTrackedPlayer(this.entity);
}
public void playSound(SoundEvent name, float volume)
@ -990,7 +990,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
for (Chunk chunk1 : list)
{
this.entity.getServerWorld().updateChunksForPlayer(this.entity, chunk1);
this.getEntityWorld().updateChunksForPlayer(this.entity, chunk1);
}
}
}
@ -1367,7 +1367,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
int ny = this.clipboard[0].length;
int nz = this.clipboard[0][0].length;
BlockPos to = this.entity.getPosition();
ClipboardPlacer placer = new ClipboardPlacer((WorldServer)this.entity.getServerWorld());
ClipboardPlacer placer = new ClipboardPlacer(this.getEntityWorld());
BlockTransform transform = null;
if(this.rotation != 0 || this.flipX || this.flipZ) {
transform = new BlockTransform();
@ -2125,7 +2125,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
this.entity.vehicle.updateRiderPosition();
}
this.entity.getServerWorld().updateMountedMovingPlayer(this.entity);
this.getEntityWorld().updateMountedMovingPlayer(this.entity);
if (this.entity.vehicle != null)
{
@ -2278,7 +2278,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
// }
this.entity.onGround = packetIn.isOnGround();
this.entity.getServerWorld().updateMountedMovingPlayer(this.entity);
this.getEntityWorld().updateMountedMovingPlayer(this.entity);
this.handleFalling(this.entity.posY - d7, packetIn.isOnGround());
}
else if (this.tickTime - this.lastMoved > 20)

View file

@ -15,7 +15,7 @@ import java.util.Map.Entry;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
import common.biome.Biome;
import common.biome.BaseBiome;
import common.block.Block;
import common.block.BlockCactus;
import common.block.BlockCarpet;
@ -916,7 +916,7 @@ public abstract class Converter {
}
tag.setTag("Sections", sections);
byte[] biomes = new byte[256];
Arrays.fill(biomes, (byte)(Biome.DEF_BIOME.id & 255));
Arrays.fill(biomes, (byte)(BaseBiome.DEF_BIOME.id & 255));
tag.setByteArray("Biomes", biomes);
}
NBTTagList ents = tag.getTagList("Entities", 10);

View file

@ -2,8 +2,6 @@ package server.world;
import java.util.Set;
import common.biome.Biome;
import common.biome.RngSpawn;
import common.block.Block;
import common.collect.Sets;
import common.entity.npc.EntityNPC;
@ -18,6 +16,8 @@ import common.util.ChunkPos;
import common.util.ExtMath;
import common.world.Chunk;
import common.world.World;
import server.biome.Biome;
import server.biome.RngSpawn;
public abstract class Spawner {
private static final int MOB_COUNT_DIV = (int)Math.pow(17.0D, 2.0D);

View file

@ -13,8 +13,7 @@ import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
import common.biome.Biome;
import common.biome.RngSpawn;
import common.biome.BaseBiome;
import common.block.Block;
import common.block.BlockDoor;
import common.block.BlockEventData;
@ -81,25 +80,41 @@ import common.world.LightType;
import common.world.State;
import common.world.Weather;
import common.world.World;
import common.worldgen.BiomeGenSingle;
import common.worldgen.BiomeGenerator;
import common.worldgen.BlockReplacer;
import common.worldgen.ChunkGenerator;
import common.worldgen.ChunkPrimer;
import common.worldgen.FeatureDungeons;
import common.worldgen.FeatureLakes;
import common.worldgen.FeatureLiquids;
import common.worldgen.FeatureOres;
import common.worldgen.GeneratorDebug;
import common.worldgen.GeneratorDestroyed;
import common.worldgen.LootConstants;
import common.worldgen.caves.MapGenBigCaves;
import common.worldgen.caves.MapGenCaves;
import common.worldgen.caves.MapGenRavine;
import common.worldgen.FeatureLake;
import common.worldgen.FeatureLiquid;
import common.worldgen.FeatureOre;
import server.Server;
import server.biome.Biome;
import server.biome.RngSpawn;
import server.clipboard.ClipboardBlock;
import server.network.Player;
import server.village.VillageCollection;
import server.worldgen.BiomeGenLayered;
import server.worldgen.BiomeGenPerlin;
import server.worldgen.BiomeGenSingle;
import server.worldgen.BlockReplacer;
import server.worldgen.ChunkGenerator;
import server.worldgen.ChunkPrimer;
import server.worldgen.FeatureDungeons;
import server.worldgen.FeatureLakes;
import server.worldgen.FeatureLiquids;
import server.worldgen.FeatureOres;
import server.worldgen.GeneratorCavern;
import server.worldgen.GeneratorDebug;
import server.worldgen.GeneratorDestroyed;
import server.worldgen.GeneratorFlat;
import server.worldgen.GeneratorIsland;
import server.worldgen.GeneratorPerlin;
import server.worldgen.GeneratorSimple;
import server.worldgen.MobConstants;
import server.worldgen.ReplacerAltBiome;
import server.worldgen.ReplacerAltSurface;
import server.worldgen.ReplacerBiome;
import server.worldgen.ReplacerTopLayer;
import server.worldgen.caves.MapGenBigCaves;
import server.worldgen.caves.MapGenCaves;
import server.worldgen.caves.MapGenRavine;
import server.worldgen.structure.MapGenBridge;
import server.worldgen.structure.MapGenMineshaft;
import server.worldgen.structure.MapGenScatteredFeature;
@ -131,7 +146,7 @@ public final class WorldServer extends AWorldServer {
private final IntHashMap<EntityTrackerEntry> trackMap = new IntHashMap();
private final Map<String, WorldSavedData> dataMap = Maps.<String, WorldSavedData>newHashMap();
private final List<WorldSavedData> dataList = Lists.<WorldSavedData>newArrayList();
private final Biome[] biomes = new Biome[256];
private final BaseBiome[] biomes = new BaseBiome[256];
private MapGenCaves caveGen;
private MapGenBigCaves bigCaveGen;
@ -175,6 +190,105 @@ public final class WorldServer extends AWorldServer {
public static float clampGravity() {
return ExtMath.clampf(Config.gravity, -10.0f, 10.0f);
}
private BiomeGenerator createBiomeGenerator(Random rand) {
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 BaseBiome[0] : this.dimension.getAddBiomes(), this.dimension.getAddRarity(),
this.dimension.getHotBiomes() == null ? new BaseBiome[] {this.dimension.getDefaultBiome()} : this.dimension.getHotBiomes(),
this.dimension.getMediumBiomes() == null ? new BaseBiome[] {this.dimension.getDefaultBiome()} : this.dimension.getMediumBiomes(),
this.dimension.getColdBiomes() == null ? new BaseBiome[] {this.dimension.getDefaultBiome()} : this.dimension.getColdBiomes(),
this.dimension.getFrostBiomes() == null ? new BaseBiome[] {this.dimension.getDefaultBiome()} : this.dimension.getFrostBiomes()) : new BiomeGenSingle(this.dimension.getDefaultBiome());
}
private ChunkGenerator createChunkGenerator(Random rand) {
switch(this.dimension.getGeneratorType()) {
case FLAT:
return this.dimension.getLayers() == null ? new GeneratorFlat(this.dimension.getSeaLevel(), this.dimension.getFiller()) : new GeneratorFlat(this.dimension.getLayers());
case PERLIN:
default:
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.dimension.getBiomeSize() > 0 ? null : new BiomeGenPerlin(rand.longv()));
case ISLAND:
return new GeneratorIsland(rand, this.dimension.getFiller());
case CAVERN:
return new GeneratorCavern(rand, this.dimension.getFiller(), this.dimension.getLiquid());
case DESTROYED:
return new GeneratorDestroyed(this.dimension.getSeaLevel());
}
}
private BlockReplacer createBlockReplacer(Random rand) {
switch(this.dimension.getReplacerType()) {
case BIOMES:
default:
return new ReplacerBiome(rand);
case SIMPLE:
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:
return new ReplacerTopLayer(this.dimension.getSurface(), this.dimension.getFiller().getBlock());
case NONE:
return null;
}
}
private FeatureDungeons createDungeonGenerator() {
return this.dimension.getDungeons() > 0 ? new FeatureDungeons(this.dimension.getDungeons()) : null;
}
private MapGenCaves createCaveGenerator() {
return this.dimension.hasCaves() ?
(new MapGenCaves(this.dimension.getCaveFiller(), this.dimension.getFiller().getBlock(), this.dimension.getTop().getBlock(),
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().getBlock())) : null;
}
private MapGenBigCaves createBigCaveGenerator() {
return this.dimension.hasStrideCaves() ?
(new MapGenBigCaves(this.dimension.getFiller().getBlock(),
this.dimension.getTop().getBlock(), this.dimension.getSurface().getBlock())) : null;
}
private FeatureOres[] createOres() {
if(this.dimension.getOres().isEmpty())
return null;
FeatureOres[] gens = new FeatureOres[this.dimension.getOres().size()];
for(int z = 0; z < gens.length; z++) {
FeatureOre gen = this.dimension.getOres().get(z);
gens[z] = new FeatureOres(gen.state, gen.count, gen.more, gen.size, gen.min, gen.max, gen.dist);
}
return gens;
}
private FeatureLakes[] createLakes() {
if(this.dimension.getLakes().isEmpty())
return null;
FeatureLakes[] gens = new FeatureLakes[this.dimension.getLakes().size()];
for(int z = 0; z < gens.length; z++) {
FeatureLake gen = this.dimension.getLakes().get(z);
gens[z] = new FeatureLakes(gen.state, gen.filler, gen.top, gen.chance, gen.minHeight, gen.maxHeight, gen.ratiod);
}
return gens;
}
private FeatureLiquids[] createLiquids() {
if(this.dimension.getLiquids().isEmpty())
return null;
FeatureLiquids[] gens = new FeatureLiquids[this.dimension.getLiquids().size()];
for(int z = 0; z < gens.length; z++) {
FeatureLiquid gen = this.dimension.getLiquids().get(z);
gens[z] = new FeatureLiquids(gen.state, gen.chance, gen.minHeight, gen.maxHeight, gen.lower);
}
return gens;
}
public WorldServer(Server server, long dtime, Dimension dim, boolean debug) {
super(dim, debug);
@ -220,7 +334,7 @@ public final class WorldServer extends AWorldServer {
// GeneratorSettings settings = !debug && !this.exterminated ? dim.getSettings() : null;
if(debug) {
this.liquid = Blocks.air.getState();
this.biomeGen = new BiomeGenSingle(Biome.none);
this.biomeGen = new BiomeGenSingle(BaseBiome.NONE);
this.generator = new GeneratorDebug();
this.replacer = null;
this.populate = false;
@ -301,13 +415,13 @@ public final class WorldServer extends AWorldServer {
// }
else {
this.liquid = this.dimension.getLiquid();
this.biomeGen = this.dimension.createBiomeGenerator(this.grng);
this.generator = this.dimension.createChunkGenerator(this.grng);
this.replacer = this.dimension.createBlockReplacer(this.grng);
this.biomeGen = this.createBiomeGenerator(this.grng);
this.generator = this.createChunkGenerator(this.grng);
this.replacer = this.createBlockReplacer(this.grng);
this.populate = this.dimension.hasPopulator();
this.caveGen = this.dimension.createCaveGenerator();
this.bigCaveGen = this.dimension.createBigCaveGenerator();
this.ravineGen = this.dimension.createRavineGenerator();
this.caveGen = this.createCaveGenerator();
this.bigCaveGen = this.createBigCaveGenerator();
this.ravineGen = this.createRavineGenerator();
this.base = this.dimension.getWorldFloor();
this.ceil = this.dimension.getWorldCeiling();
this.mobs = this.dimension.hasMobs();
@ -318,10 +432,10 @@ public final class WorldServer extends AWorldServer {
this.scatteredGen = this.dimension.hasScattered() ? new MapGenScatteredFeature() : null;
this.bridgeGen = this.dimension.hasFortresses() ? new MapGenBridge() : null;
this.seaLevel = this.dimension.getSeaLevel();
this.ores = this.dimension.getOres();
this.lakes = this.dimension.getLakes();
this.liquids = this.dimension.getLiquids();
this.dungeons = this.dimension.createDungeonGenerator();
this.ores = this.createOres();
this.lakes = this.createLakes();
this.liquids = this.createLiquids();
this.dungeons = this.createDungeonGenerator();
}
this.height = this.generator.getMaximumHeight();
// this.teleporter = new Teleporter(this);
@ -482,13 +596,13 @@ public final class WorldServer extends AWorldServer {
}
private WeightedList<RngSpawn> getSpawnTypes(BlockPos pos) {
Biome biome = this.getBiomeGenForCoords(pos);
BaseBiome 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 LootConstants.FORTRESS_MOBS;
return MobConstants.FORTRESS_MOBS;
else if(this.scatteredGen != null && this.scatteredGen.hasMageHut(pos))
return LootConstants.MAGEHUT_MOBS;
return biome.getMobs();
return MobConstants.MAGEHUT_MOBS;
return Biome.BIOMES[biome.id].getMobs();
}
public RngSpawn getSpawnListEntryForTypeAt(BlockPos pos) {
@ -509,11 +623,11 @@ public final class WorldServer extends AWorldServer {
return this.biomeGen;
}
public Biome getBiomeGenForCoords(final BlockPos pos) {
public BaseBiome getBiomeGenForCoords(final BlockPos pos) {
if(this.isBlockLoaded(pos))
return this.getChunk(pos).getBiome(pos, this.biomeGen);
else
return this.biomeGen.getBiomeGenerator(pos, Biome.DEF_BIOME);
return this.biomeGen.getBiomeGenerator(pos, BaseBiome.DEF_BIOME);
}
public void setItemData(String dataID, WorldSavedData worldSavedDataIn) {
@ -1423,7 +1537,7 @@ public final class WorldServer extends AWorldServer {
int bx = x * 16;
int bz = z * 16;
BlockPos pos = new BlockPos(bx, 0, bz);
Biome biome = this.getBiomeGenForCoords(pos.add(16, 0, 16));
Biome biome = Biome.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;
@ -1521,7 +1635,7 @@ public final class WorldServer extends AWorldServer {
if(this.scatteredGen != null) {
this.scatteredGen.generate(this, x, z, primer);
}
return new Chunk(this, primer, this.base, this.ceil, this.grng, this.biomes, x, z);
return new Chunk(this, primer.getData(), primer.height, this.base, this.ceil, this.grng, this.biomes, x, z);
}
public boolean isExterminated() {
@ -1627,7 +1741,7 @@ public final class WorldServer extends AWorldServer {
this.scatteredGen = null;
this.bridgeGen = null;
this.generator = new GeneratorDestroyed(this.dimension.getSeaLevel());
this.biomeGen = new BiomeGenSingle(Biome.exterminated);
this.biomeGen = new BiomeGenSingle(BaseBiome.EXTERMINATED);
this.replacer = null;
this.populate = false;
this.liquid = Blocks.air.getState();
@ -2131,7 +2245,7 @@ public final class WorldServer extends AWorldServer {
// return new LazyBlock(state, this, position);
// }
public final boolean setBiome(BlockPos position, Biome biome) {
public final boolean setBiome(BlockPos position, BaseBiome biome) {
Chunk chunk = this.getChunk(position);
if((chunk != null) && (chunk.isLoaded())) {
chunk.getBiomes()[((position.getZ() & 0xF) << 4 | position.getX() & 0xF)] = (byte)biome.id;
@ -2140,7 +2254,7 @@ public final class WorldServer extends AWorldServer {
return false;
}
public final void setBiomes(BlockPos start, BlockPos end, Biome biome) {
public final void setBiomes(BlockPos start, BlockPos end, BaseBiome biome) {
Set<ChunkPos> chunks = Sets.newHashSet();
for(int x = start.getX(); x <= end.getX(); x++) {
for(int z = start.getZ(); z <= end.getZ(); z++) {
@ -2185,7 +2299,7 @@ public final class WorldServer extends AWorldServer {
}
public boolean isBlockinHighHumidity(BlockPos pos) {
Biome biomegenbase = this.getBiomeGenForCoords(pos);
BaseBiome biomegenbase = this.getBiomeGenForCoords(pos);
return biomegenbase.isHighHumidity();
}

View file

@ -0,0 +1,277 @@
package server.worldgen;
import java.util.List;
import java.util.Set;
import common.biome.BaseBiome;
import common.collect.Lists;
import common.util.BlockPos;
import common.util.LongHashMap;
import common.worldgen.BiomeGenerator;
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 BaseBiome[] biomes = new BaseBiome[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 BaseBiome getBiomeGenAt(int x, int z)
{
return this.biomes[x & 15 | (z & 15) << 4];
}
}
private final GenLayer genBiomes;
private final GenLayer biomeIndexLayer;
private final LongHashMap<CacheBlock> cacheMap = new LongHashMap();
private final List<CacheBlock> cache = Lists.<CacheBlock>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, BaseBiome def, boolean fixed, int biomeSize, int riverSize, int snowRarity, int seaRarity,
BaseBiome[] add, int addRarity, BaseBiome[] hot, BaseBiome[] medium, BaseBiome[] cold, BaseBiome[] 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 BaseBiome getBiomeGenerator(BlockPos pos, BaseBiome def) {
int x = pos.getX();
int z = pos.getZ();
BaseBiome 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) {
BaseBiome biome = BaseBiome.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) {
BaseBiome biome = BaseBiome.getBiomeDef(aint[i]);
factors[i] = (double)biome.getFactor();
}
}
}
public void getGenBiomes(BaseBiome[] 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] = BaseBiome.getBiomeDef(aint[i]);
}
}
public void getChunkBiomes(BaseBiome[] oldBiomeList, int x, int z, int width, int depth) {
this.getBiomes(oldBiomeList, x, z, width, depth, true);
}
public void getBiomes(BaseBiome[] 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) {
BaseBiome[] 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] = BaseBiome.getBiomeDef(aint[i]);
}
}
}
public boolean areBiomesViable(int x, int z, int size, Set<BaseBiome> 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) {
BaseBiome biome = BaseBiome.getBiome(aint[k1]);
if(!allowed.contains(biome)) {
return false;
}
}
return true;
}
// public BlockPos findBiomePosition(int x, int z, int range, Set<Biome> 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;
// }
}

View file

@ -0,0 +1,50 @@
package server.worldgen;
import common.rng.PerlinGenOld;
import common.rng.Random;
public class BiomeGenPerlin {
private final PerlinGenOld tempNoiseGen;
private final PerlinGenOld rainNoiseGen;
private final PerlinGenOld multNoiseGen;
private final double[] tempMult = new double[256];
private final double[] temperature = new double[256];
private final double[] humidity = new double[256];
public BiomeGenPerlin(long seed) {
this.tempNoiseGen = new PerlinGenOld(new Random(seed * 9871L), 4);
this.rainNoiseGen = new PerlinGenOld(new Random(seed * 39811L), 4);
this.multNoiseGen = new PerlinGenOld(new Random(seed * 0x84a59L), 2);
}
public void generate(double[] factors, int xPos, int zPos) {
xPos *= 16;
zPos *= 16;
this.tempNoiseGen.generate(this.temperature, xPos, zPos, 16, 16, 0.02500000037252903D, 0.02500000037252903D, 0.25D);
this.rainNoiseGen.generate(this.humidity, xPos, zPos, 16, 16, 0.05000000074505806D, 0.05000000074505806D, 0.33333333333333331D);
this.multNoiseGen.generate(this.tempMult, xPos, zPos, 16, 16, 0.25D, 0.25D, 0.58823529411764708D);
int pos = 0;
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
double tempMul = this.tempMult[pos] * 1.1000000000000001D + 0.5D;
double factor = 0.01D;
double ifactor = 1.0D - factor;
double temp = (this.temperature[pos] * 0.14999999999999999D + 0.69999999999999996D) * ifactor + tempMul * factor;
factor = 0.002D;
ifactor = 1.0D - factor;
double rain = (this.humidity[pos] * 0.14999999999999999D + 0.5D) * ifactor + tempMul * factor;
temp = 1.0D - (1.0D - temp) * (1.0D - temp);
if(temp < 0.0D)
temp = 0.0D;
if(rain < 0.0D)
rain = 0.0D;
if(temp > 1.0D)
temp = 1.0D;
if(rain > 1.0D)
rain = 1.0D;
factors[z * 16 + x] = temp * rain;
pos++;
}
}
}
}

View file

@ -0,0 +1,48 @@
package server.worldgen;
import java.util.Arrays;
import java.util.Set;
import common.biome.BaseBiome;
import common.util.BlockPos;
import common.worldgen.BiomeGenerator;
public class BiomeGenSingle implements BiomeGenerator {
private final BaseBiome biome;
public BiomeGenSingle(BaseBiome biome) {
this.biome = biome;
}
public BaseBiome getBiomeGenerator(BlockPos pos, BaseBiome def) {
return this.biome;
}
public void getGenBiomes(BaseBiome[] biomes, int x, int z, int width, int height) {
Arrays.fill(biomes, 0, width * height, this.biome);
}
public void getChunkBiomes(BaseBiome[] oldBiomeList, int x, int z, int width, int depth) {
Arrays.fill(oldBiomeList, 0, width * depth, this.biome);
}
public void getBiomes(BaseBiome[] 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<Biome> 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<BaseBiome> 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());
}
}

View file

@ -0,0 +1,9 @@
package server.worldgen;
import common.biome.BaseBiome;
import common.rng.Random;
import server.world.WorldServer;
public interface BlockReplacer {
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, BaseBiome[] biomes);
}

View file

@ -0,0 +1,8 @@
package server.worldgen;
import server.world.WorldServer;
public interface ChunkGenerator {
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer);
public int getMaximumHeight();
}

View file

@ -0,0 +1,28 @@
package server.worldgen;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.world.State;
public class ChunkPrimer {
public final int height;
private final short[] data;
public ChunkPrimer(int height) {
this.data = new short[Math.max(height, 256) * 256];
this.height = height;
}
public short[] getData() {
return this.data;
}
public State get(int x, int y, int z) {
State state = BlockRegistry.STATEMAP.getByValue(this.data[x << 4 | z | y << 8]);
return state != null ? state : Blocks.air.getState();
}
public void set(int x, int y, int z, State state) {
this.data[x << 4 | z | y << 8] = (short)BlockRegistry.STATEMAP.get(state);
}
}

View file

@ -0,0 +1,178 @@
package server.worldgen;
import common.init.Blocks;
import common.init.Items;
import common.item.RngLoot;
import common.log.Log;
import common.material.Material;
import common.rng.Random;
import common.rng.WeightedList;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityMobSpawner;
import common.util.BlockPos;
import common.util.Facing;
import server.world.WorldServer;
public class FeatureDungeons
{
private static final String[] SPAWNERTYPES = new String[] {"Undead", "Zombie", "Zombie", "Arachnoid"};
private final int chance;
public FeatureDungeons(int chance) {
this.chance = chance;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
boolean flag = false;
for(int z = 0; z < this.chance; z++) {
flag |= this.generateDungeon(worldIn, rand, position.add(rand.chOffset(), rand.zrange(256), rand.chOffset()));
}
return flag;
}
private boolean generateDungeon(WorldServer worldIn, Random rand, BlockPos position)
{
int i = 3;
int j = rand.zrange(2) + 2;
int k = -j - 1;
int l = j + 1;
int i1 = -1;
int j1 = 4;
int k1 = rand.zrange(2) + 2;
int l1 = -k1 - 1;
int i2 = k1 + 1;
int j2 = 0;
for (int k2 = k; k2 <= l; ++k2)
{
for (int l2 = -1; l2 <= 4; ++l2)
{
for (int i3 = l1; i3 <= i2; ++i3)
{
BlockPos blockpos = position.add(k2, l2, i3);
Material material = worldIn.getState(blockpos).getBlock().getMaterial();
boolean flag = material.isSolid();
if (l2 == -1 && !flag)
{
return false;
}
if (l2 == 4 && !flag)
{
return false;
}
if ((k2 == k || k2 == l || i3 == l1 || i3 == i2) && l2 == 0 && worldIn.isAirBlock(blockpos) && worldIn.isAirBlock(blockpos.up()))
{
++j2;
}
}
}
}
if (j2 >= 1 && j2 <= 5)
{
for (int k3 = k; k3 <= l; ++k3)
{
for (int i4 = 3; i4 >= -1; --i4)
{
for (int k4 = l1; k4 <= i2; ++k4)
{
BlockPos blockpos1 = position.add(k3, i4, k4);
if (k3 != k && i4 != -1 && k4 != l1 && k3 != l && i4 != 4 && k4 != i2)
{
if (worldIn.getState(blockpos1).getBlock() != Blocks.chest)
{
worldIn.setBlockToAir(blockpos1);
}
}
else if (blockpos1.getY() >= 0 && !worldIn.getState(blockpos1.down()).getBlock().getMaterial().isSolid())
{
worldIn.setBlockToAir(blockpos1);
}
else if (worldIn.getState(blockpos1).getBlock().getMaterial().isSolid() && worldIn.getState(blockpos1).getBlock() != Blocks.chest)
{
if (i4 == -1 && rand.zrange(4) != 0)
{
worldIn.setState(blockpos1, Blocks.mossy_cobblestone.getState(), 2);
}
else
{
worldIn.setState(blockpos1, Blocks.cobblestone.getState(), 2);
}
}
}
}
}
for (int l3 = 0; l3 < 2; ++l3)
{
for (int j4 = 0; j4 < 3; ++j4)
{
int l4 = position.getX() + rand.zrange(j * 2 + 1) - j;
int i5 = position.getY();
int j5 = position.getZ() + rand.zrange(k1 * 2 + 1) - k1;
BlockPos blockpos2 = new BlockPos(l4, i5, j5);
if (worldIn.isAirBlock(blockpos2))
{
int j3 = 0;
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
{
if (worldIn.getState(blockpos2.offset(enumfacing)).getBlock().getMaterial().isSolid())
{
++j3;
}
}
if (j3 == 1)
{
worldIn.setState(blockpos2, Blocks.chest.correctFacing(worldIn, blockpos2, Blocks.chest.getState()), 2);
WeightedList<RngLoot> list = RngLoot.addToList(LootConstants.DUNGEON_CHEST, Items.enchanted_book.getRandom(rand));
TileEntity tileentity1 = worldIn.getTileEntity(blockpos2);
if (tileentity1 instanceof TileEntityChest)
{
RngLoot.generateChestContents(rand, list, (TileEntityChest)tileentity1, 8);
}
break;
}
}
}
}
worldIn.setState(position, Blocks.mob_spawner.getState(), 2);
TileEntity tileentity = worldIn.getTileEntity(position);
if (tileentity instanceof TileEntityMobSpawner)
{
((TileEntityMobSpawner)tileentity).setEntityName(this.pickMobSpawner(rand));
}
else
{
Log.JNI.warn("Konnte kein Mob-Spawner-Objekt bei (" + position.getX() + ", " + position.getY() + ", " + position.getZ() + ") erstellen");
}
return true;
}
else
{
return false;
}
}
/**
* Randomly decides which spawner to use in a dungeon
*/
private String pickMobSpawner(Random p_76543_1_)
{
return SPAWNERTYPES[p_76543_1_.zrange(SPAWNERTYPES.length)];
}
}

View file

@ -0,0 +1,35 @@
package server.worldgen;
import common.rng.Random;
import common.util.BlockPos;
import common.world.State;
import server.world.WorldServer;
public abstract class FeatureGenerator
{
private final boolean doBlockNotify;
public FeatureGenerator()
{
this(false);
}
public FeatureGenerator(boolean notify)
{
this.doBlockNotify = notify;
}
public abstract boolean generate(WorldServer worldIn, Random rand, BlockPos position);
protected void setBlockAndNotifyAdequately(WorldServer worldIn, BlockPos pos, State state)
{
if (this.doBlockNotify)
{
worldIn.setState(pos, state, 3);
}
else
{
worldIn.setState(pos, state, 2);
}
}
}

View file

@ -0,0 +1,221 @@
package server.worldgen;
import common.block.Block;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import common.world.LightType;
import common.world.State;
import server.biome.Biome;
import server.world.WorldServer;
public class FeatureLakes
{
public final State state;
private final Block block;
public final State filler;
// public final Block replace;
public final State top;
public final int chance;
public final int minHeight;
public final int maxHeight;
public final boolean ratiod;
public FeatureLakes(State state, State filler, /* Block replace, */ State top, int chance, int minHeight, int maxHeight,
boolean ratiod)
{
this.state = state;
this.block = state.getBlock();
this.filler = filler;
// this.replace = replace;
this.top = top;
this.chance = chance;
this.ratiod = ratiod;
if(minHeight > maxHeight) {
this.minHeight = maxHeight;
this.maxHeight = minHeight;
}
else {
this.minHeight = minHeight;
this.maxHeight = maxHeight;
}
}
// public WorldGenLakes(Block block)
// {
// this(block, block == Blocks.lava ? Blocks.stone.getDefaultState() : null, Blocks.dirt, Blocks.grass.getDefaultState());
// }
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
if(this.ratiod) {
if(this.chance >= 1 && rand.chance(this.chance)) {
int y = rand.range(this.minHeight, this.maxHeight); // rand.zrange(rand.zrange(248) + 8);
if(y < worldIn.getSeaLevel() || rand.chance(this.chance * 5 / 4))
return this.generateLake(worldIn, rand, position.add(rand.chOffset(), y, rand.chOffset()));
}
}
else {
if(this.chance >= 1 && rand.chance(this.chance))
return this.generateLake(worldIn, rand, position.add(rand.chOffset(), rand.range(this.minHeight, this.maxHeight),
rand.chOffset()));
}
return false;
}
private boolean generateLake(WorldServer worldIn, Random rand, BlockPos position)
{
for (position = position.add(-8, 0, -8); position.getY() > 5 && worldIn.isAirBlock(position); position = position.down())
{
;
}
if (position.getY() <= 4)
{
return false;
}
else
{
position = position.down(4);
boolean[] aboolean = new boolean[2048];
int i = rand.zrange(4) + 4;
for (int j = 0; j < i; ++j)
{
double d0 = rand.doublev() * 6.0D + 3.0D;
double d1 = rand.doublev() * 4.0D + 2.0D;
double d2 = rand.doublev() * 6.0D + 3.0D;
double d3 = rand.doublev() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
double d4 = rand.doublev() * (8.0D - d1 - 4.0D) + 2.0D + d1 / 2.0D;
double d5 = rand.doublev() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;
for (int l = 1; l < 15; ++l)
{
for (int i1 = 1; i1 < 15; ++i1)
{
for (int j1 = 1; j1 < 7; ++j1)
{
double d6 = ((double)l - d3) / (d0 / 2.0D);
double d7 = ((double)j1 - d4) / (d1 / 2.0D);
double d8 = ((double)i1 - d5) / (d2 / 2.0D);
double d9 = d6 * d6 + d7 * d7 + d8 * d8;
if (d9 < 1.0D)
{
aboolean[(l * 16 + i1) * 8 + j1] = true;
}
}
}
}
}
for (int k1 = 0; k1 < 16; ++k1)
{
for (int l2 = 0; l2 < 16; ++l2)
{
for (int k = 0; k < 8; ++k)
{
boolean flag = !aboolean[(k1 * 16 + l2) * 8 + k] && (k1 < 15 && aboolean[((k1 + 1) * 16 + l2) * 8 + k] || k1 > 0 && aboolean[((k1 - 1) * 16 + l2) * 8 + k] || l2 < 15 && aboolean[(k1 * 16 + l2 + 1) * 8 + k] || l2 > 0 && aboolean[(k1 * 16 + (l2 - 1)) * 8 + k] || k < 7 && aboolean[(k1 * 16 + l2) * 8 + k + 1] || k > 0 && aboolean[(k1 * 16 + l2) * 8 + (k - 1)]);
if (flag)
{
Material material = worldIn.getState(position.add(k1, k, l2)).getBlock().getMaterial();
if (k >= 4 && material.isLiquid())
{
return false;
}
if (k < 4 && !material.isSolid() && worldIn.getState(position.add(k1, k, l2)).getBlock() != this.block)
{
return false;
}
}
}
}
}
for (int l1 = 0; l1 < 16; ++l1)
{
for (int i3 = 0; i3 < 16; ++i3)
{
for (int i4 = 0; i4 < 8; ++i4)
{
if (aboolean[(l1 * 16 + i3) * 8 + i4])
{
worldIn.setState(position.add(l1, i4, i3), i4 >= 4 ? Blocks.air.getState() : this.state, 2);
}
}
}
}
if(this.top != null) {
Block replace = worldIn.dimension.getTop().getBlock();
for (int i2 = 0; i2 < 16; ++i2)
{
for (int j3 = 0; j3 < 16; ++j3)
{
for (int j4 = 4; j4 < 8; ++j4)
{
if (aboolean[(i2 * 16 + j3) * 8 + j4])
{
BlockPos blockpos = position.add(i2, j4 - 1, j3);
if (worldIn.getState(blockpos).getBlock() == replace && worldIn.getLightFor(LightType.SKY, position.add(i2, j4, j3)) > 0)
{
Biome biomegenbase = Biome.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);
}
}
}
}
}
}
}
if (this.filler != null) // && this.block.getMaterial() == Material.lava)
{
for (int j2 = 0; j2 < 16; ++j2)
{
for (int k3 = 0; k3 < 16; ++k3)
{
for (int k4 = 0; k4 < 8; ++k4)
{
boolean flag1 = !aboolean[(j2 * 16 + k3) * 8 + k4] && (j2 < 15 && aboolean[((j2 + 1) * 16 + k3) * 8 + k4] || j2 > 0 && aboolean[((j2 - 1) * 16 + k3) * 8 + k4] || k3 < 15 && aboolean[(j2 * 16 + k3 + 1) * 8 + k4] || k3 > 0 && aboolean[(j2 * 16 + (k3 - 1)) * 8 + k4] || k4 < 7 && aboolean[(j2 * 16 + k3) * 8 + k4 + 1] || k4 > 0 && aboolean[(j2 * 16 + k3) * 8 + (k4 - 1)]);
if (flag1 && (k4 < 4 || rand.zrange(2) != 0) && worldIn.getState(position.add(j2, k4, k3)).getBlock().getMaterial().isSolid())
{
worldIn.setState(position.add(j2, k4, k3), this.filler, 2);
}
}
}
}
}
if (this.block.getMaterial() == Material.water)
{
for (int k2 = 0; k2 < 16; ++k2)
{
for (int l3 = 0; l3 < 16; ++l3)
{
int l4 = 3; // not 4 !!
if (worldIn.canBlockFreeze(position.add(k2, l4, l3), false))
{
worldIn.setState(position.add(k2, l4, l3), Blocks.ice.getState(), 2);
}
}
}
}
return true;
}
}
}

View file

@ -0,0 +1,128 @@
package server.worldgen;
import common.block.Block;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import common.world.State;
import server.world.WorldServer;
public class FeatureLiquids
{
public final State state;
private final Block block;
// public final Block replace;
public final int chance;
public final int minHeight;
public final int maxHeight;
public final boolean lower;
// public WorldGenLiquids(Block block)
// {
// this(block, Blocks.stone);
// }
public FeatureLiquids(State state, /* Block replace, */ int chance, int minHeight, int maxHeight, boolean lower)
{
this.state = state;
this.block = state.getBlock();
// replace = replace;
this.chance = chance;
this.lower = lower;
if(minHeight > maxHeight) {
this.minHeight = lower && maxHeight < 1 ? 1 : maxHeight;
this.maxHeight = minHeight;
}
else {
this.minHeight = lower && minHeight < 1 ? 1 : minHeight;
this.maxHeight = maxHeight;
}
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
Block replace = worldIn.dimension.getFiller().getBlock();
boolean flag = false;
for(int z = 0; z < this.chance; z++) {
if(this.lower)
// 8, 247)
flag |= this.generateLiquid(worldIn, rand, position.add(rand.chOffset(), rand.zrange(rand.range(this.minHeight,
rand.range(this.minHeight, this.maxHeight))), rand.chOffset()), replace);
else
// int i17 = this.randomGenerator.range(8, 255);
flag |= this.generateLiquid(worldIn, rand, position.add(rand.chOffset(), rand.range(this.minHeight,
rand.range(this.minHeight, this.maxHeight)), rand.chOffset()), replace);
}
return flag;
}
private boolean generateLiquid(WorldServer worldIn, Random rand, BlockPos position, Block replace)
{
if (worldIn.getState(position.up()).getBlock() != replace)
{
return false;
}
else if (worldIn.getState(position.down()).getBlock() != replace)
{
return false;
}
else if (worldIn.getState(position).getBlock().getMaterial() != Material.air && worldIn.getState(position).getBlock() != replace)
{
return false;
}
else
{
int i = 0;
if (worldIn.getState(position.west()).getBlock() == replace)
{
++i;
}
if (worldIn.getState(position.east()).getBlock() == replace)
{
++i;
}
if (worldIn.getState(position.north()).getBlock() == replace)
{
++i;
}
if (worldIn.getState(position.south()).getBlock() == replace)
{
++i;
}
int j = 0;
if (worldIn.isAirBlock(position.west()))
{
++j;
}
if (worldIn.isAirBlock(position.east()))
{
++j;
}
if (worldIn.isAirBlock(position.north()))
{
++j;
}
if (worldIn.isAirBlock(position.south()))
{
++j;
}
if (i == 3 && j == 1)
{
worldIn.setState(position, this.state, 2);
worldIn.forceBlockUpdateTick(this.block, position, rand);
}
return true;
}
}
}

View file

@ -0,0 +1,167 @@
package server.worldgen;
import common.block.Block;
import common.rng.Random;
import common.util.BlockPos;
import common.util.ExtMath;
import common.world.State;
import server.world.WorldServer;
public class FeatureOres
{
public final State oreBlock;
// private final Block replace;
public final boolean distributed;
private final int spawnTries;
private final int moreTries;
public final int numberOfBlocks;
private final int minHeight;
private final int maxHeight;
public final int spawns;
public final int min;
public final int max;
public final int more;
// public FeatureOres(IBlockState state, boolean dist, int spawns, int count, int min, int max) {
// this(state, dist, spawns, 0, count, min, max);
// }
// public FeatureOres(IBlockState state, boolean dist, int spawns, int more, int count, int min, int max) {
// this(state, dist, spawns, more, count, min, max, null);
// }
public FeatureOres(State state, int count, int more, int size, int min, int max, boolean dist) // , Block replace)
{
this.spawns = count;
this.min = min;
this.max = max;
this.more = more;
count = count == 2 ? 3 : count;
this.oreBlock = state;
this.distributed = dist;
if(this.distributed) {
min = min < 0 ? 0 : (min > 511 ? 511 : min);
max = max < 0 ? 0 : (max > 512 ? 512 : max);
if(min + max > 511) {
max = 512 - min;
}
if(min - max < 0) {
max = min;
}
}
else {
min = min < 0 ? 0 : (min > 512 ? 512 : min);
max = max < 0 ? 0 : (max > 512 ? 512 : max);
if (max < min)
{
int i = min;
min = max;
max = i;
}
else if (max == min)
{
if (min < 511)
{
++max;
}
else
{
--min;
}
}
}
this.minHeight = min;
this.maxHeight = max;
int minTries = count <= 0 ? 1 : 0;
this.spawnTries = count < 0 ? 0 : count;
this.moreTries = more < minTries ? minTries : more;
this.numberOfBlocks = size < 1 ? 1 : size;
// this.replace = replace;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
Block replace = /* this.replace != null ? this.replace : */ worldIn.dimension.getFiller().getBlock();
int tries = this.spawnTries == 0 ?
(rand.zrange(this.moreTries) == 0 ? 1 : 0) :
(this.spawnTries + (this.moreTries == 0 ? 0 : rand.zrange(this.moreTries + 1)));
// tries = tries == 0 ? (this.numberOfBlocks == 1 ? (rand.nextInt(10) == 0 ? 1 : 0) : rand.nextInt(2)) : tries;
for(int j = 0; j < tries; j++) {
BlockPos blockpos;
if(this.distributed) {
blockpos = position.add(rand.zrange(16), rand.zrange(this.maxHeight) + rand.zrange(this.maxHeight) + this.minHeight - this.maxHeight, rand.zrange(16));
}
else {
blockpos = position.add(rand.zrange(16), rand.zrange(this.maxHeight - this.minHeight) + this.minHeight, rand.zrange(16));
}
if(this.numberOfBlocks == 1) {
if(worldIn.getState(blockpos).getBlock() == replace) {
worldIn.setState(blockpos, this.oreBlock, 2);
}
}
else { // if(position.getX() >= -67000000 && position.getZ() >= -67000000 && position.getX() <= 67000000 && position.getZ() <= 67000000) {
this.generateVein(worldIn, rand, blockpos, replace); // Fix dist
}
}
return true;
}
private void generateVein(WorldServer worldIn, Random rand, BlockPos position, Block replace)
{
float f = rand.floatv() * (float)Math.PI;
double d0 = (double)(/* (float)(position.getX() + 8) */ 8.0f + ExtMath.sin(f) * (float)this.numberOfBlocks / 8.0F);
double d1 = (double)(/* (float)(position.getX() + 8) */ 8.0f - ExtMath.sin(f) * (float)this.numberOfBlocks / 8.0F);
double d2 = (double)(/* (float)(position.getZ() + 8) */ 8.0f + ExtMath.cos(f) * (float)this.numberOfBlocks / 8.0F);
double d3 = (double)(/* (float)(position.getZ() + 8) */ 8.0f - ExtMath.cos(f) * (float)this.numberOfBlocks / 8.0F);
double d4 = (double)(/* position.getY() + */ rand.zrange(3) - 2);
double d5 = (double)(/* position.getY() + */ rand.zrange(3) - 2);
for (int i = 0; i < this.numberOfBlocks; ++i)
{
float f1 = (float)i / (float)this.numberOfBlocks;
double d6 = d0 + (d1 - d0) * (double)f1;
double d7 = d4 + (d5 - d4) * (double)f1;
double d8 = d2 + (d3 - d2) * (double)f1;
double d9 = rand.doublev() * (double)this.numberOfBlocks / 16.0D;
double d10 = (double)(ExtMath.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
double d11 = (double)(ExtMath.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
int j = ExtMath.floord(d6 - d10 / 2.0D);
int k = ExtMath.floord(d7 - d11 / 2.0D);
int l = ExtMath.floord(d8 - d10 / 2.0D);
int i1 = ExtMath.floord(d6 + d10 / 2.0D);
int j1 = ExtMath.floord(d7 + d11 / 2.0D);
int k1 = ExtMath.floord(d8 + d10 / 2.0D);
for (int l1 = j; l1 <= i1; ++l1)
{
double d12 = ((double)l1 + 0.5D - d6) / (d10 / 2.0D);
if (d12 * d12 < 1.0D)
{
for (int i2 = k; i2 <= j1; ++i2)
{
double d13 = ((double)i2 + 0.5D - d7) / (d11 / 2.0D);
if (d12 * d12 + d13 * d13 < 1.0D)
{
for (int j2 = l; j2 <= k1; ++j2)
{
double d14 = ((double)j2 + 0.5D - d8) / (d10 / 2.0D);
if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D)
{
BlockPos blockpos = position.add(l1, i2, j2); // new BlockPos(l1, i2, j2);
if (worldIn.getState(blockpos).getBlock() == replace)
{
worldIn.setState(blockpos, this.oreBlock, 2);
}
}
}
}
}
}
}
}
}
}

View file

@ -0,0 +1,200 @@
package server.worldgen;
import common.rng.OctaveGen;
import common.rng.Random;
import common.util.ExtMath;
import common.world.State;
import server.world.WorldServer;
public class GeneratorCavern implements ChunkGenerator
{
private final OctaveGen noiseGen2;
private final OctaveGen noiseGen3;
private final OctaveGen noiseGen1;
// private final OctaveGen noiseGen4;
// private final OctaveGen noiseGen5;
private final double[] noiseField = new double[425];
private final double[] noiseData1 = new double[425];
private final double[] noiseData2 = new double[425];
private final double[] noiseData3 = new double[425];
// private final double[] noiseData4 = new double[25];
// private final double[] noiseData5 = new double[25];
private final State filler;
private final State liquid;
// public GeneratorCavern(Dimension dim, Random rand) {
// this(rand);
// }
public GeneratorCavern(Random rand, State filler, State liquid)
{
this.noiseGen2 = new OctaveGen(rand, 16);
this.noiseGen3 = new OctaveGen(rand, 16);
this.noiseGen1 = new OctaveGen(rand, 8);
// this.noiseGen4 = new OctaveGen(rand, 10);
// this.noiseGen5 = new OctaveGen(rand, 16);
this.filler = filler;
this.liquid = liquid;
}
public int getMaximumHeight() {
return 128;
}
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
{
int range = 4;
int lh = world.getSeaLevel() / 2 + 1;
int xr = range + 1;
int yr = 17;
int zr = range + 1;
this.genNoisemap(x * range, 0, z * range);
for (int j1 = 0; j1 < range; ++j1)
{
for (int k1 = 0; k1 < range; ++k1)
{
for (int l1 = 0; l1 < 16; ++l1)
{
double d0 = 0.125D;
double d1 = this.noiseField[((j1 + 0) * zr + k1 + 0) * yr + l1 + 0];
double d2 = this.noiseField[((j1 + 0) * zr + k1 + 1) * yr + l1 + 0];
double d3 = this.noiseField[((j1 + 1) * zr + k1 + 0) * yr + l1 + 0];
double d4 = this.noiseField[((j1 + 1) * zr + k1 + 1) * yr + l1 + 0];
double d5 = (this.noiseField[((j1 + 0) * zr + k1 + 0) * yr + l1 + 1] - d1) * d0;
double d6 = (this.noiseField[((j1 + 0) * zr + k1 + 1) * yr + l1 + 1] - d2) * d0;
double d7 = (this.noiseField[((j1 + 1) * zr + k1 + 0) * yr + l1 + 1] - d3) * d0;
double d8 = (this.noiseField[((j1 + 1) * zr + k1 + 1) * yr + l1 + 1] - d4) * d0;
for (int i2 = 0; i2 < 8; ++i2)
{
double d9 = 0.25D;
double d10 = d1;
double d11 = d2;
double d12 = (d3 - d1) * d9;
double d13 = (d4 - d2) * d9;
for (int j2 = 0; j2 < 4; ++j2)
{
double d14 = 0.25D;
double d15 = d10;
double d16 = (d11 - d10) * d14;
for (int k2 = 0; k2 < 4; ++k2)
{
State iblockstate = null;
if (l1 * 8 + i2 < lh)
{
iblockstate = this.liquid;
}
if (d15 > 0.0D)
{
iblockstate = this.filler;
}
int l2 = j2 + j1 * 4;
int i3 = i2 + l1 * 8;
int j3 = k2 + k1 * 4;
primer.set(l2, i3, j3, iblockstate);
d15 += d16;
}
d10 += d12;
d11 += d13;
}
d1 += d5;
d2 += d6;
d3 += d7;
d4 += d8;
}
}
}
}
}
private void genNoisemap(int x, int y, int z)
{
int xs = 5;
int ys = 17;
int zs = 5;
double d0 = 684.412D;
double d1 = 2053.236D;
// this.noiseGen4.generate(this.noiseData4, x, y, z, xs, 1, zs, 1.0D, 0.0D, 1.0D);
// this.noiseGen5.generate(this.noiseData5, x, y, z, xs, 1, zs, 100.0D, 0.0D, 100.0D);
this.noiseGen1.generate(this.noiseData1, x, y, z, xs, ys, zs, d0 / 80.0D, d1 / 60.0D, d0 / 80.0D);
this.noiseGen2.generate(this.noiseData2, x, y, z, xs, ys, zs, d0, d1, d0);
this.noiseGen3.generate(this.noiseData3, x, y, z, xs, ys, zs, d0, d1, d0);
int i = 0;
double[] adouble = new double[ys];
for (int j = 0; j < ys; ++j)
{
adouble[j] = Math.cos((double)j * Math.PI * 6.0D / (double)ys) * 2.0D;
double d2 = (double)j;
if (j > ys / 2)
{
d2 = (double)(ys - 1 - j);
}
if (d2 < 4.0D)
{
d2 = 4.0D - d2;
adouble[j] -= d2 * d2 * d2 * 10.0D;
}
}
for (int l = 0; l < xs; ++l)
{
for (int i1 = 0; i1 < zs; ++i1)
{
double d3 = 0.0D;
for (int k = 0; k < ys; ++k)
{
double d4 = 0.0D;
double d5 = adouble[k];
double d6 = this.noiseData2[i] / 512.0D;
double d7 = this.noiseData3[i] / 512.0D;
double d8 = (this.noiseData1[i] / 10.0D + 1.0D) / 2.0D;
if (d8 < 0.0D)
{
d4 = d6;
}
else if (d8 > 1.0D)
{
d4 = d7;
}
else
{
d4 = d6 + (d7 - d6) * d8;
}
d4 = d4 - d5;
if (k > ys - 4)
{
double d9 = (double)((float)(k - (ys - 4)) / 3.0F);
d4 = d4 * (1.0D - d9) + -10.0D * d9;
}
if ((double)k < d3)
{
double d10 = (d3 - (double)k) / 4.0D;
d10 = ExtMath.clampd(d10, 0.0D, 1.0D);
d4 = d4 * (1.0D - d10) + -10.0D * d10;
}
this.noiseField[i] = d4;
++i;
}
}
}
}
}

View file

@ -0,0 +1,27 @@
package server.worldgen;
import common.world.State;
import common.worldgen.DebugStates;
import server.world.WorldServer;
public class GeneratorDebug implements ChunkGenerator
{
public int getMaximumHeight() {
return 72;
}
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
{
for(int bx = 0; bx < 16; ++bx) {
for(int bz = 0; bz < 16; ++bz) {
int sx = x * 16 + bx;
int sz = z * 16 + bz;
// primer.set(bx, 60, bz, Blocks.glass.getDefaultState());
State state = DebugStates.getState(sx, sz);
if(state != null) {
primer.set(bx, 1, bz, state);
}
}
}
}
}

View file

@ -0,0 +1,38 @@
package server.worldgen;
import common.init.Blocks;
import common.rng.Random;
import common.world.State;
import server.world.WorldServer;
public class GeneratorDestroyed implements ChunkGenerator
{
private final State block = Blocks.coal_block.getState();
private final State alt = Blocks.soul_sand.getState();
private final State gap = Blocks.air.getState();
private final State liquid = Blocks.lava.getState();
private final State top = Blocks.obsidian.getState();
private final int height;
private final Random rand = new Random(); // NON-DETERMINISTIC!!
public GeneratorDestroyed(int height) {
this.height = height;
}
public int getMaximumHeight() {
return this.height;
}
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
{
for(int by = 0; by < this.height; ++by) {
for(int bx = 0; bx < 16; ++bx) {
for(int bz = 0; bz < 16; ++bz) {
primer.set(bx, by, bz, by >= this.height - this.rand.zrange(3) ? this.gap :
(by == this.height - 1 ? this.top : this.rand.chance(this.block, (by == this.height - 3 ?
this.liquid : this.alt), 15)));
}
}
}
}
}

View file

@ -0,0 +1,50 @@
package server.worldgen;
import java.util.Arrays;
import common.world.State;
import server.world.WorldServer;
public class GeneratorFlat implements ChunkGenerator {
private final State[] layers;
public GeneratorFlat(State ... layers) {
this.layers = layers;
}
public GeneratorFlat(int height, State layer) {
this.layers = new State[height];
Arrays.fill(this.layers, layer);
}
// public GeneratorFlat(GeneratorSettings settings)
// {
// int layers = 0;
// for(FlatSettings layer : settings.flatLayers) {
// layers += layer.height;
// }
// layers = layers > 512 ? 512 : layers;
// this.flatLayers = new IBlockState[layers];
// int pos = 0;
// for(FlatSettings layer : settings.flatLayers) {
// for(int z = 0; z < layer.height; z++) {
// this.flatLayers[pos++] = layer.state;
// }
// }
// }
public int getMaximumHeight() {
return this.layers.length;
}
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer) {
for(int by = 0; by < this.layers.length; by++) {
State state = this.layers[by];
for(int bx = 0; bx < 16; bx++) {
for(int bz = 0; bz < 16; bz++) {
primer.set(bx, by, bz, state);
}
}
}
}
}

View file

@ -0,0 +1,190 @@
package server.worldgen;
import common.rng.OctaveGen;
import common.rng.Random;
import common.util.ExtMath;
import common.world.State;
import server.world.WorldServer;
public class GeneratorIsland implements ChunkGenerator
{
private final OctaveGen noiseGen1;
private final OctaveGen noiseGen2;
private final OctaveGen noiseGen3;
private final OctaveGen noiseGen4;
private final OctaveGen noiseGen5;
private final double[] densities = new double[297];
private final double[] noiseData1 = new double[297];
private final double[] noiseData2 = new double[297];
private final double[] noiseData3 = new double[297];
private final double[] noiseData4 = new double[9];
private final double[] noiseData5 = new double[9];
private final State filler;
// public GeneratorIsland(Dimension dim, Random rand) {
// this(rand, dim.getFiller());
// }
public GeneratorIsland(Random rand, State filler)
{
this.noiseGen1 = new OctaveGen(rand, 16);
this.noiseGen2 = new OctaveGen(rand, 16);
this.noiseGen3 = new OctaveGen(rand, 8);
this.noiseGen4 = new OctaveGen(rand, 10);
this.noiseGen5 = new OctaveGen(rand, 16);
this.filler = filler;
}
public int getMaximumHeight() {
return 128;
}
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
{
int range = 2;
int xr = range + 1;
int yr = 33;
int zr = range + 1;
this.genNoisemap(x * range, 0, z * range);
for (int i1 = 0; i1 < range; ++i1)
{
for (int j1 = 0; j1 < range; ++j1)
{
for (int k1 = 0; k1 < 32; ++k1)
{
double d0 = 0.25D;
double d1 = this.densities[((i1 + 0) * zr + j1 + 0) * yr + k1 + 0];
double d2 = this.densities[((i1 + 0) * zr + j1 + 1) * yr + k1 + 0];
double d3 = this.densities[((i1 + 1) * zr + j1 + 0) * yr + k1 + 0];
double d4 = this.densities[((i1 + 1) * zr + j1 + 1) * yr + k1 + 0];
double d5 = (this.densities[((i1 + 0) * zr + j1 + 0) * yr + k1 + 1] - d1) * d0;
double d6 = (this.densities[((i1 + 0) * zr + j1 + 1) * yr + k1 + 1] - d2) * d0;
double d7 = (this.densities[((i1 + 1) * zr + j1 + 0) * yr + k1 + 1] - d3) * d0;
double d8 = (this.densities[((i1 + 1) * zr + j1 + 1) * yr + k1 + 1] - d4) * d0;
for (int l1 = 0; l1 < 4; ++l1)
{
double d9 = 0.125D;
double d10 = d1;
double d11 = d2;
double d12 = (d3 - d1) * d9;
double d13 = (d4 - d2) * d9;
for (int i2 = 0; i2 < 8; ++i2)
{
double d14 = 0.125D;
double d15 = d10;
double d16 = (d11 - d10) * d14;
for (int j2 = 0; j2 < 8; ++j2)
{
State iblockstate = null;
if (d15 > 0.0D)
{
iblockstate = this.filler;
}
int k2 = i2 + i1 * 8;
int l2 = l1 + k1 * 4;
int i3 = j2 + j1 * 8;
primer.set(k2, l2, i3, iblockstate);
d15 += d16;
}
d10 += d12;
d11 += d13;
}
d1 += d5;
d2 += d6;
d3 += d7;
d4 += d8;
}
}
}
}
}
private void genNoisemap(int x, int y, int z)
{
int xs = 3;
int ys = 33;
int zs = 3;
double d0 = 684.412D;
double d1 = 684.412D;
this.noiseGen4.generate(this.noiseData4, x, z, xs, zs, 1.121D, 1.121D, 0.5D);
this.noiseGen5.generate(this.noiseData5, x, z, xs, zs, 200.0D, 200.0D, 0.5D);
d0 = d0 * 2.0D;
this.noiseGen3.generate(this.noiseData1, x, y, z, xs, ys, zs, d0 / 80.0D, d1 / 160.0D, d0 / 80.0D);
this.noiseGen1.generate(this.noiseData2, x, y, z, xs, ys, zs, d0, d1, d0);
this.noiseGen2.generate(this.noiseData3, x, y, z, xs, ys, zs, d0, d1, d0);
int i = 0;
for (int j = 0; j < xs; ++j)
{
for (int k = 0; k < zs; ++k)
{
float f = (float)(j + x) / 1.0F;
float f1 = (float)(k + z) / 1.0F;
float f2 = 100.0F - ExtMath.sqrtf(f * f + f1 * f1) * 8.0F;
if (f2 > 80.0F)
{
f2 = 80.0F;
}
if (f2 < -100.0F)
{
f2 = -100.0F;
}
for (int l = 0; l < ys; ++l)
{
double d2 = 0.0D;
double d3 = this.noiseData2[i] / 512.0D;
double d4 = this.noiseData3[i] / 512.0D;
double d5 = (this.noiseData1[i] / 10.0D + 1.0D) / 2.0D;
if (d5 < 0.0D)
{
d2 = d3;
}
else if (d5 > 1.0D)
{
d2 = d4;
}
else
{
d2 = d3 + (d4 - d3) * d5;
}
d2 = d2 - 8.0D;
d2 = d2 + (double)f2;
int i1 = 2;
if (l > ys / 2 - i1)
{
double d6 = (double)((float)(l - (ys / 2 - i1)) / 64.0F);
d6 = ExtMath.clampd(d6, 0.0D, 1.0D);
d2 = d2 * (1.0D - d6) + -3000.0D * d6;
}
i1 = 8;
if (l < i1)
{
double d7 = (double)((float)(i1 - l) / ((float)i1 - 1.0F));
d2 = d2 * (1.0D - d7) + -30.0D * d7;
}
this.densities[i] = d2;
++i;
}
}
}
}
}

View file

@ -0,0 +1,297 @@
package server.worldgen;
import common.biome.BaseBiome;
import common.dimension.Dimension;
import common.rng.NoiseGen;
import common.rng.OctaveGen;
import common.rng.Random;
import common.util.ExtMath;
import common.world.State;
import server.biome.Biome;
import server.world.WorldServer;
public class GeneratorPerlin implements ChunkGenerator
{
private static final float[] PARABOLIC = new float[25];
static {
for (int x = -2; x <= 2; ++x)
{
for (int z = -2; z <= 2; ++z)
{
float v = 10.0F / ExtMath.sqrtf((float)(x * x + z * z) + 0.2F);
PARABOLIC[x + 2 + (z + 2) * 5] = v;
}
}
}
private final NoiseGen lowerNoiseGen;
private final NoiseGen upperNoiseGen;
private final NoiseGen mainNoiseGen;
private final NoiseGen depthNoiseGen;
private final State block;
private final State liquid;
private final float coordinateScale;
private final float heightScale;
private final float upperLimitScale;
private final float lowerLimitScale;
private final float depthNoiseScaleX;
private final float depthNoiseScaleZ;
private final float amplification;
private final float mainNoiseScaleX;
private final float mainNoiseScaleY;
private final float mainNoiseScaleZ;
private final float baseSize;
private final float stretchY;
private final float biomeDepthWeight;
private final float biomeDepthOffset;
private final float biomeScaleWeight;
private final float biomeScaleOffset;
private final double[] noiseTable = new double[825];
private final double[] mainNoise = new double[825];
private final double[] lowerNoise = new double[825];
private final double[] upperNoise = new double[825];
private final double[] depthNoise = new double[25];
private final BaseBiome[] biomes = new BaseBiome[100];
// public GeneratorNew(Random rand, GeneratorSettings settings)
// {
// this(rand, settings.farlands, settings.seaLevel, Blocks.stone.getDefaultState(),
// settings.useLavaSeas ? Blocks.lava.getDefaultState() : Blocks.water.getDefaultState(),
// settings.coordinateScale, settings.heightScale, settings.upperLimitScale, settings.lowerLimitScale,
// settings.depthNoiseScaleX, settings.depthNoiseScaleZ, settings.amplification, settings.mainNoiseScaleX,
// 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) {
this(rand, /* dim.hasFarLands(), dim.getSeaLevel(), */ block, liquid,
settings.coordinateScale, settings.heightScale, settings.upperLimitScale, settings.lowerLimitScale,
settings.depthNoiseScaleX, settings.depthNoiseScaleZ, settings.amplification, settings.mainNoiseScaleX,
settings.mainNoiseScaleY, settings.mainNoiseScaleZ, settings.baseSize, settings.stretchY, settings.biomeDepthWeight,
settings.biomeDepthOffset, settings.biomeScaleWeight, settings.biomeScaleOffset);
// 684.412F, 684.412F, 512.0F, 512.0F, 200.0F, 200.0F, 0.0F, 80.0F, 160.0F, 80.0F, 8.5F, 12.0F, 1.0F, 0.0F, 1.0F, 0.0F);
}
private GeneratorPerlin(Random rand, /* boolean farlands, int seaLevel, */ State block, State liquid,
float coordinateScale, float heightScale, float upperLimitScale, float lowerLimitScale, float depthNoiseScaleX,
float depthNoiseScaleZ, float amplification, float mainNoiseScaleX, float mainNoiseScaleY, float mainNoiseScaleZ,
float baseSize, float stretchY, float biomeDepthWeight, float biomeDepthOffset, float biomeScaleWeight, float biomeScaleOffset)
{
this.lowerNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
this.upperNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
this.mainNoiseGen = /* farlands ? new OctaveGenOld(rand, 8) : */ new OctaveGen(rand, 8);
this.depthNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
this.liquid = liquid;
this.block = block;
this.coordinateScale = coordinateScale;
this.heightScale = heightScale;
this.upperLimitScale = upperLimitScale;
this.lowerLimitScale = lowerLimitScale;
this.depthNoiseScaleX = depthNoiseScaleX;
this.depthNoiseScaleZ = depthNoiseScaleZ;
this.amplification = amplification;
this.mainNoiseScaleX = mainNoiseScaleX;
this.mainNoiseScaleY = mainNoiseScaleY;
this.mainNoiseScaleZ = mainNoiseScaleZ;
this.baseSize = baseSize;
this.stretchY = stretchY;
this.biomeDepthWeight = biomeDepthWeight;
this.biomeDepthOffset = biomeDepthOffset;
this.biomeScaleWeight = biomeScaleWeight;
this.biomeScaleOffset = biomeScaleOffset;
}
public int getMaximumHeight() {
return 256;
}
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
{
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)
{
int x1 = xb * 5;
int x2 = (xb + 1) * 5;
for (int zb = 0; zb < 4; ++zb)
{
int xz1 = (x1 + zb) * 33;
int xz2 = (x1 + zb + 1) * 33;
int xz3 = (x2 + zb) * 33;
int xz4 = (x2 + zb + 1) * 33;
for (int yb = 0; yb < 32; ++yb)
{
double mul1 = 0.125D;
double m1 = this.noiseTable[xz1 + yb];
double m2 = this.noiseTable[xz2 + yb];
double m3 = this.noiseTable[xz3 + yb];
double m4 = this.noiseTable[xz4 + yb];
double n1 = (this.noiseTable[xz1 + yb + 1] - m1) * mul1;
double n2 = (this.noiseTable[xz2 + yb + 1] - m2) * mul1;
double n3 = (this.noiseTable[xz3 + yb + 1] - m3) * mul1;
double n4 = (this.noiseTable[xz4 + yb + 1] - m4) * mul1;
for (int ys = 0; ys < 8; ++ys)
{
double mul2 = 0.25D;
double o1 = m1;
double o2 = m2;
double o3 = (m3 - m1) * mul2;
double o4 = (m4 - m2) * mul2;
for (int xs = 0; xs < 4; ++xs)
{
double mul3 = 0.25D;
double step = (o2 - o1) * mul3;
double val = o1 - step;
for (int zs = 0; zs < 4; ++zs)
{
if ((val += step) > 0.0D)
{
primer.set(xb * 4 + xs, yb * 8 + ys, zb * 4 + zs, this.block);
}
else if (yb * 8 + ys < sea)
{
primer.set(xb * 4 + xs, yb * 8 + ys, zb * 4 + zs, this.liquid);
}
}
o1 += o3;
o2 += o4;
}
m1 += n1;
m2 += n2;
m3 += n3;
m4 += n4;
}
}
}
}
}
private void genNoisemap(int x, int y, int z)
{
this.depthNoiseGen.generate(this.depthNoise, x, z, 5, 5, (double)this.depthNoiseScaleX, (double)this.depthNoiseScaleZ, 0.5);
float scale = this.coordinateScale;
float height = this.heightScale;
this.mainNoiseGen.generate(this.mainNoise, x, y, z, 5, 33, 5, (double)(scale / this.mainNoiseScaleX), (double)(height / this.mainNoiseScaleY), (double)(scale / this.mainNoiseScaleZ));
this.lowerNoiseGen.generate(this.lowerNoise, x, y, z, 5, 33, 5, (double)scale, (double)height, (double)scale);
this.upperNoiseGen.generate(this.upperNoise, x, y, z, 5, 33, 5, (double)scale, (double)height, (double)scale);
z = 0;
x = 0;
int pos = 0;
int dpos = 0;
for (int u = 0; u < 5; ++u)
{
for (int v = 0; v < 5; ++v)
{
float max = 0.0F;
float min = 0.0F;
float sum = 0.0F;
int range = 2;
Biome biome = Biome.BIOMES[this.biomes[u + 2 + (v + 2) * 10].id];
for (int a = -range; a <= range; ++a)
{
for (int b = -range; b <= range; ++b)
{
Biome biome2 = Biome.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)
{
bmin = 1.0F + bmin * this.amplification;
bmax = 1.0F + bmax * this.amplification * 2.0F;
}
float fact = PARABOLIC[a + 2 + (b + 2) * 5] / (bmin + 2.0F);
if (biome2.depth > biome.depth)
{
fact /= 2.0F;
}
max += bmax * fact;
min += bmin * fact;
sum += fact;
}
}
max = max / sum;
min = min / sum;
max = max * 0.9F + 0.1F;
min = (min * 4.0F - 1.0F) / 8.0F;
double depth = this.depthNoise[dpos] / 8000.0D;
if (depth < 0.0D)
{
depth = -depth * 0.3D;
}
depth = depth * 3.0D - 2.0D;
if (depth < 0.0D)
{
depth = depth / 2.0D;
if (depth < -1.0D)
{
depth = -1.0D;
}
depth = depth / 1.4D;
depth = depth / 2.0D;
}
else
{
if (depth > 1.0D)
{
depth = 1.0D;
}
depth = depth / 8.0D;
}
++dpos;
double low = (double)min;
double high = (double)max;
low = low + depth * 0.2D;
low = low * (double)this.baseSize / 8.0D;
double shift = (double)this.baseSize + low * 4.0D;
for (int w = 0; w < 33; ++w)
{
double damp = ((double)w - shift) * (double)this.stretchY * 128.0D / 256.0D / high;
if (damp < 0.0D)
{
damp *= 4.0D;
}
double lower = this.lowerNoise[pos] / (double)this.lowerLimitScale;
double upper = this.upperNoise[pos] / (double)this.upperLimitScale;
double base = (this.mainNoise[pos] / 10.0D + 1.0D) / 2.0D;
double noise = (base < 0.0D ? lower : (base > 1.0D ? upper : lower + (upper - lower) * base)) - damp;
if (w > 29)
{
double attn = (double)((float)(w - 29) / 3.0F);
noise = noise * (1.0D - attn) + -10.0D * attn;
}
this.noiseTable[pos] = noise;
++pos;
}
}
}
}
}

View file

@ -0,0 +1,235 @@
package server.worldgen;
import common.rng.NoiseGen;
import common.rng.OctaveGen;
import common.rng.Random;
import common.world.State;
import server.world.WorldServer;
public class GeneratorSimple implements ChunkGenerator
{
private final BiomeGenPerlin biomeGen;
private final NoiseGen lowerNoiseGen;
private final NoiseGen upperNoiseGen;
private final NoiseGen mainNoiseGen;
private final NoiseGen biomeNoiseGen;
private final NoiseGen depthNoiseGen;
private final State filler;
private final State liquid;
private final double noiseTable[] = new double[425];
private final double mainNoise[] = new double[425];
private final double lowerNoise[] = new double[425];
private final double upperNoise[] = new double[425];
private final double biomeNoise[] = new double[25];
private final double depthNoise[] = new double[25];
private final double[] factors = new double[256];
// public GeneratorSimple(long seed, Random rand, GeneratorSettings settings)
// {
// this(rand, settings.farlands, Blocks.stone.getDefaultState(),
// settings.useLavaSeas ? Blocks.lava.getDefaultState() : Blocks.water.getDefaultState(),
// settings.biomeMode == 2 ? new BiomeGenPerlin(seed) : null);
// }
// public GeneratorSimple(Dimension dim, Random rand)
// {
// this(rand, /* dim.hasFarLands(), */ dim.getFiller(), dim.getLiquid(),
// dim.hasBiomes() ? null : new BiomeGenPerlin(rand.longv()));
// }
public GeneratorSimple(Random rand, /* boolean farlands, */ State filler, State liquid, BiomeGenPerlin biomeGen)
{
this.lowerNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
this.upperNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
this.mainNoiseGen = /* farlands ? new OctaveGenOld(rand, 8) : */ new OctaveGen(rand, 8);
this.biomeNoiseGen = /* farlands ? new OctaveGenOld(rand, 10) : */ new OctaveGen(rand, 10);
this.depthNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
this.filler = filler;
this.liquid = liquid;
this.biomeGen = biomeGen;
}
public int getMaximumHeight() {
return 128;
}
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
{
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;
byte yr = 17;
int zr = range + 1;
this.genNoisemap(x * range, 0, z * range);
for(int xb = 0; xb < range; xb++)
{
for(int zb = 0; zb < range; zb++)
{
for(int yb = 0; yb < 16; yb++)
{
double mul1 = 0.125D;
double d1 = this.noiseTable[((xb + 0) * zr + (zb + 0)) * yr + (yb + 0)];
double d2 = this.noiseTable[((xb + 0) * zr + (zb + 1)) * yr + (yb + 0)];
double d3 = this.noiseTable[((xb + 1) * zr + (zb + 0)) * yr + (yb + 0)];
double d4 = this.noiseTable[((xb + 1) * zr + (zb + 1)) * yr + (yb + 0)];
double d5 = (this.noiseTable[((xb + 0) * zr + (zb + 0)) * yr + (yb + 1)] - d1) * mul1;
double d6 = (this.noiseTable[((xb + 0) * zr + (zb + 1)) * yr + (yb + 1)] - d2) * mul1;
double d7 = (this.noiseTable[((xb + 1) * zr + (zb + 0)) * yr + (yb + 1)] - d3) * mul1;
double d8 = (this.noiseTable[((xb + 1) * zr + (zb + 1)) * yr + (yb + 1)] - d4) * mul1;
for(int ys = 0; ys < 8; ys++)
{
double mul2 = 0.25D;
double n1 = d1;
double n2 = d2;
double n3 = (d3 - d1) * mul2;
double n4 = (d4 - d2) * mul2;
for(int xs = 0; xs < 4; xs++)
{
// int off = xs + xb * 4 << 11 | 0 + zb * 4 << 7 | yb * 8 + ys;
// char zo = '\200';
double mul3 = 0.25D;
double val = n1;
double step = (n2 - n1) * mul3;
for(int zs = 0; zs < 4; zs++)
{
if(val > 0.0D)
{
primer.set(xs + xb * 4, ys + yb * 8, zs + zb * 4, this.filler);
// primer.setBlockStateLegacy(off, this.filler);
}
else if(yb * 8 + ys < sea)
{
primer.set(xs + xb * 4, ys + yb * 8, zs + zb * 4, this.liquid);
// primer.setBlockStateLegacy(off, this.liquid);
}
// off += zo;
val += step;
}
n1 += n3;
n2 += n4;
}
d1 += d5;
d2 += d6;
d3 += d7;
d4 += d8;
}
}
}
}
}
private void genNoisemap(int x, int y, int z)
{
int xs = 5;
int ys = 17;
int zs = 5;
double scale = 684.41200000000003D;
double height = 684.41200000000003D;
// double temps[] = this.biomeGen.temperature;
// double rains[] = this.biomeGen.humidity;
this.biomeNoiseGen.generate(this.biomeNoise, x, z, xs, zs, 1.121D, 1.121D, 0.5D);
this.depthNoiseGen.generate(this.depthNoise, x, z, xs, zs, 200D, 200D, 0.5D);
this.mainNoiseGen.generate(this.mainNoise, x, y, z, xs, ys, zs, scale / 80D, height / 160D, scale / 80D);
this.lowerNoiseGen.generate(this.lowerNoise, x, y, z, xs, ys, zs, scale, height, scale);
this.upperNoiseGen.generate(this.upperNoise, x, y, z, xs, ys, zs, scale, height, scale);
int pos = 0;
int dpos = 0;
int ps = 16 / xs;
for(int u = 0; u < xs; u++)
{
int px = u * ps + ps / 2;
for(int v = 0; v < zs; v++)
{
int pz = v * ps + ps / 2;
// double temp = temps[px * 16 + pz];
// double rain = rains[px * 16 + pz] * temp;
double fact = 1.0D - this.factors[pz * 16 + px];
fact *= fact;
fact *= fact;
fact = 1.0D - fact;
double high = (this.biomeNoise[dpos] + 256D) / 512D;
high *= fact;
if(high > 1.0D)
{
high = 1.0D;
}
double depth = this.depthNoise[dpos] / 8000D;
if(depth < 0.0D)
{
depth = -depth * 0.29999999999999999D;
}
depth = depth * 3D - 2D;
if(depth < 0.0D)
{
depth /= 2D;
if(depth < -1D)
{
depth = -1D;
}
depth /= 1.3999999999999999D;
depth /= 2D;
high = 0.0D;
} else
{
if(depth > 1.0D)
{
depth = 1.0D;
}
depth /= 8D;
}
if(high < 0.0D)
{
high = 0.0D;
}
high += 0.5D;
depth = (depth * (double)ys) / 16D;
double shift = (double)ys / 2D + depth * 4D;
dpos++;
for(int w = 0; w < ys; w++)
{
double noise = 0.0D;
double damp = (((double)w - shift) * 12D) / high;
if(damp < 0.0D)
{
damp *= 4D;
}
double lower = this.lowerNoise[pos] / 512D;
double upper = this.upperNoise[pos] / 512D;
double base = (this.mainNoise[pos] / 10D + 1.0D) / 2D;
if(base < 0.0D)
{
noise = lower;
} else
if(base > 1.0D)
{
noise = upper;
} else
{
noise = lower + (upper - lower) * base;
}
noise -= damp;
if(w > ys - 4)
{
double d13 = (float)(w - (ys - 4)) / 3F;
noise = noise * (1.0D - d13) + -10D * d13;
}
this.noiseTable[pos] = noise;
pos++;
}
}
}
}
}

View file

@ -0,0 +1,71 @@
package server.worldgen;
import common.color.DyeColor;
import common.init.Blocks;
import common.init.ItemRegistry;
import common.init.Items;
import common.item.RngLoot;
import common.rng.WeightedList;
public abstract class LootConstants {
public static final WeightedList<RngLoot> VILLAGE_BLACKSMITH = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 3),
new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 1, 3, 5), new RngLoot(Items.bread, 0, 1, 3, 15),
new RngLoot(Items.apple, 0, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 0, 1, 1, 5), new RngLoot(Items.iron_sword, 0, 1, 1, 5),
new RngLoot(Items.iron_chestplate, 0, 1, 1, 5), new RngLoot(Items.iron_helmet, 0, 1, 1, 5), new RngLoot(Items.iron_leggings, 0, 1, 1, 5),
new RngLoot(Items.iron_boots, 0, 1, 1, 5), new RngLoot(ItemRegistry.getItemFromBlock(Blocks.obsidian), 0, 3, 7, 5),
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_sapling), 0, 3, 7, 5), new RngLoot(Items.saddle, 0, 1, 1, 3),
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1),
new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1));
public static final WeightedList<RngLoot> STRONGHOLD_CHEST = new WeightedList(new RngLoot(Items.orb, 0, 1, 1, 10),
new RngLoot(Items.diamond, 0, 1, 3, 3), new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 1, 3, 5),
new RngLoot(Items.redstone, 0, 4, 9, 5), new RngLoot(Items.bread, 0, 1, 3, 15), new RngLoot(Items.apple, 0, 1, 3, 15),
new RngLoot(Items.iron_pickaxe, 0, 1, 1, 5), new RngLoot(Items.iron_sword, 0, 1, 1, 5), new RngLoot(Items.iron_chestplate, 0, 1, 1, 5),
new RngLoot(Items.iron_helmet, 0, 1, 1, 5), new RngLoot(Items.iron_leggings, 0, 1, 1, 5), new RngLoot(Items.iron_boots, 0, 1, 1, 5),
new RngLoot(Items.golden_apple, 0, 1, 1, 1), new RngLoot(Items.saddle, 0, 1, 1, 1), new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1),
new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1), new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1));
public static final WeightedList<RngLoot> STRONGHOLD_LIBRARY = new WeightedList(new RngLoot(Items.book, 0, 1, 3, 20),
new RngLoot(Items.paper, 0, 2, 7, 20), new RngLoot(Items.string, 0, 1, 1, 1), new RngLoot(Items.navigator, 0, 1, 1, 1));
public static final WeightedList<RngLoot> STRONGHOLD_CROSS = new WeightedList(new RngLoot(Items.iron_ingot, 0, 1, 5, 10),
new RngLoot(Items.gold_ingot, 0, 1, 3, 5), new RngLoot(Items.redstone, 0, 4, 9, 5), new RngLoot(Items.coal, 0, 3, 8, 10),
new RngLoot(Items.bread, 0, 1, 3, 15), new RngLoot(Items.apple, 0, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 0, 1, 1, 1));
public static final WeightedList<RngLoot> DESERT_PYRAMID = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 3),
new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 2, 7, 15), new RngLoot(Items.emerald, 0, 1, 3, 2),
new RngLoot(Items.bone, 0, 4, 6, 20), new RngLoot(Items.rotten_flesh, 0, 3, 7, 16), new RngLoot(Items.saddle, 0, 1, 1, 3),
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1),
new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1));
public static final WeightedList<RngLoot> JUNGLE_MAIN = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 3),
new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 2, 7, 15), new RngLoot(Items.emerald, 0, 1, 3, 2),
new RngLoot(Items.bone, 0, 4, 6, 20), new RngLoot(Items.rotten_flesh, 0, 3, 7, 16), new RngLoot(Items.saddle, 0, 1, 1, 3),
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1),
new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1));
public static final WeightedList<RngLoot> JUNGLE_TRAP = new WeightedList(new RngLoot(Items.arrow, 0, 2, 7, 30));
public static final WeightedList<RngLoot> MINESHAFT_CHEST = new WeightedList(new RngLoot(Items.iron_ingot, 0, 1, 5, 10),
new RngLoot(Items.gold_ingot, 0, 1, 3, 5), new RngLoot(Items.redstone, 0, 4, 9, 5),
new RngLoot(Items.dye, DyeColor.BLUE.getDyeDamage(), 4, 9, 5), new RngLoot(Items.diamond, 0, 1, 2, 3),
new RngLoot(Items.coal, 0, 3, 8, 10), new RngLoot(Items.bread, 0, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 0, 1, 1, 1),
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.rail), 0, 4, 8, 1), new RngLoot(Items.melon_stem, 0, 2, 4, 10),
new RngLoot(Items.pumpkin_stem, 0, 2, 4, 10), new RngLoot(Items.saddle, 0, 1, 1, 3), new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1));
public static final WeightedList<RngLoot> HELL_FORTRESS = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 5),
new RngLoot(Items.iron_ingot, 0, 1, 5, 5), new RngLoot(Items.gold_ingot, 0, 1, 3, 15), new RngLoot(Items.gold_sword, 0, 1, 1, 5),
new RngLoot(Items.gold_chestplate, 0, 1, 1, 5), new RngLoot(Items.flint_and_steel, 0, 1, 1, 5),
new RngLoot(Items.soul_wart, 0, 3, 7, 5), new RngLoot(Items.saddle, 0, 1, 1, 10), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 8),
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 5), new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 3),
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.obsidian), 0, 2, 4, 2));
public static final WeightedList<RngLoot> DUNGEON_CHEST = new WeightedList(new RngLoot(Items.saddle, 0, 1, 1, 11),
new RngLoot(Items.iron_ingot, 0, 1, 4, 11), new RngLoot(Items.bread, 0, 1, 1, 11), new RngLoot(Items.wheats, 0, 1, 4, 11),
new RngLoot(Items.gunpowder, 0, 1, 4, 11), new RngLoot(Items.string, 0, 1, 4, 11), new RngLoot(Items.bucket, 0, 1, 1, 11),
new RngLoot(Items.golden_apple, 0, 1, 1, 1), new RngLoot(Items.redstone, 0, 1, 4, 11), new RngLoot(Items.aluminium_ingot, 0, 1, 1, 5),
new RngLoot(Items.copper_ingot, 0, 1, 1, 5), new RngLoot(Items.name_tag, 0, 1, 1, 11), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 3),
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 6), new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 2),
new RngLoot(Items.record_13, 0, 1, 1, 1), new RngLoot(Items.record_cat, 0, 1, 1, 1), new RngLoot(Items.record_blocks, 0, 1, 1, 1),
new RngLoot(Items.record_chirp, 0, 1, 1, 1), new RngLoot(Items.record_far, 0, 1, 1, 1), new RngLoot(Items.record_mall, 0, 1, 1, 1),
new RngLoot(Items.record_mellohi, 0, 1, 1, 1), new RngLoot(Items.record_stal, 0, 1, 1, 1), new RngLoot(Items.record_strad, 0, 1, 1, 1),
new RngLoot(Items.record_ward, 0, 1, 1, 1), new RngLoot(Items.record_11, 0, 1, 1, 1), new RngLoot(Items.record_wait, 0, 1, 1, 1),
new RngLoot(Items.record_delay, 0, 1, 1, 1), new RngLoot(Items.record_extend, 0, 1, 1, 1));
public static final WeightedList<RngLoot> ABANDONED_ITEMS = new WeightedList(new RngLoot(Items.stick, 0, 1, 3, 10),
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_planks), 0, 1, 3, 10),
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_log), 0, 1, 3, 10), new RngLoot(Items.stone_axe, 0, 1, 1, 3),
new RngLoot(Items.wood_axe, 0, 1, 1, 5), new RngLoot(Items.stone_pickaxe, 0, 1, 1, 3), new RngLoot(Items.wood_pickaxe, 0, 1, 1, 5),
new RngLoot(Items.apple, 0, 2, 3, 5), new RngLoot(Items.bread, 0, 2, 3, 3),
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.acacia_log), 0, 1, 3, 10));
}

View file

@ -0,0 +1,16 @@
package server.worldgen;
import common.entity.npc.EntityDarkMage;
import common.entity.npc.EntityMage;
import common.entity.npc.EntityMagma;
import common.entity.npc.EntityTiefling;
import common.entity.npc.EntityUndead;
import common.rng.WeightedList;
import server.biome.RngSpawn;
public abstract class MobConstants {
public static final WeightedList<RngSpawn> MAGEHUT_MOBS = new WeightedList<RngSpawn>(new RngSpawn(EntityMage.class, 1, 1, 1));
public static final WeightedList<RngSpawn> FORTRESS_MOBS = new WeightedList<RngSpawn>(new RngSpawn(EntityDarkMage.class, 10, 2, 3),
new RngSpawn(EntityTiefling.class, 5, 4, 4), new RngSpawn(EntityUndead.class, 10, 4, 4),
new RngSpawn(EntityMagma.class, 3, 4, 4));
}

View file

@ -0,0 +1,131 @@
package server.worldgen;
import common.biome.BaseBiome;
import common.block.Block;
import common.init.Blocks;
import common.rng.NoiseGen;
import common.rng.OctaveGen;
import common.rng.Random;
import common.world.State;
import server.biome.Biome;
import server.world.WorldServer;
public class ReplacerAltBiome implements BlockReplacer
{
private final NoiseGen altNoiseGen;
private final NoiseGen exclNoiseGen;
private final State filler;
private final State liquid;
private final State alt1;
private final State alt2;
private final Block block;
private final double alt2Noise[] = new double[256];
private final double alt1Noise[] = new double[256];
private final double exclNoise[] = new double[256];
// public ReplacerAltBiome(Random rand, GeneratorSettings settings)
// {
// this(rand, settings.farlands, Blocks.stone.getDefaultState(),
// settings.useLavaSeas ? Blocks.lava.getDefaultState() : Blocks.water.getDefaultState(),
// Blocks.sand.getDefaultState(), Blocks.gravel.getDefaultState());
// }
// public ReplacerAltBiome(Dimension dim, Random rand)
// {
// this(rand, /* dim.hasFarLands(), */ dim.getFiller(), dim.getLiquid(), dim.getAltFiller2(), dim.getAltFiller1());
// }
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);
this.filler = filler;
this.liquid = liquid;
this.alt1 = alt1;
this.alt2 = alt2;
this.block = filler.getBlock();
}
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, BaseBiome[] biomes)
{
int seaLevel = world.getSeaLevel();
double scale = 0.03125D;
this.altNoiseGen.generate( this.alt2Noise , x * 16, 0 /*.0D */ , z * 16, 16, 1, 16, scale, 1.0D, scale);
this.altNoiseGen.generate(this.alt1Noise, z * 16, 109 /*.0134D */, x * 16, 16, 1, 16, scale, 1.0D, scale);
this.exclNoiseGen.generate( this.exclNoise , x * 16, 0 /*.0D */ , z * 16, 16, 1, 16, scale * 2D, scale * 2D, scale * 2D);
for(int pz = 0; pz < 16; pz++)
{
for(int px = 0; px < 16; px++)
{
Biome biome = Biome.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 = biome.topBlock;
State fillerBlock = biome.fillerBlock;
for(int py = primer.height - 1; py >= 0; py--)
{
Block currentBlock = primer.get(px, py, pz).getBlock();
if(currentBlock == Blocks.air)
{
rockHeight = -1;
continue;
}
if(currentBlock != this.block)
{
continue;
}
if(rockHeight == -1)
{
if(excl <= 0)
{
topBlock = Blocks.air.getState();
fillerBlock = this.filler;
} else
if(py >= seaLevel - 4 && py <= seaLevel + 1)
{
topBlock = biome.topBlock;
fillerBlock = biome.fillerBlock;
if(alt1)
{
topBlock = Blocks.air.getState();
}
if(alt1)
{
fillerBlock = this.alt2;
}
if(alt2)
{
topBlock = this.alt1;
}
if(alt2)
{
fillerBlock = this.alt1;
}
}
if(py < seaLevel && topBlock.getBlock() == Blocks.air)
{
topBlock = this.liquid;
}
rockHeight = excl;
if(py >= seaLevel - 1)
{
primer.set(px, py, pz, topBlock);
} else
{
primer.set(px, py, pz, fillerBlock);
}
continue;
}
if(rockHeight > 0)
{
rockHeight--;
primer.set(px, py, pz, fillerBlock);
}
}
}
}
}
}

View file

@ -0,0 +1,131 @@
package server.worldgen;
import common.biome.BaseBiome;
import common.block.Block;
import common.material.Material;
import common.rng.OctaveGen;
import common.rng.Random;
import common.world.State;
import server.world.WorldServer;
public class ReplacerAltSurface implements BlockReplacer
{
private final OctaveGen altNoiseGen;
private final OctaveGen exclNoiseGen;
private final double[] alt2Noise = new double[256];
private final double[] alt1Noise = new double[256];
private final double[] exclNoise = new double[256];
private final State filler;
private final State alt1;
private final State alt2;
private final State liquid;
private final Block fillerBlock;
// public ReplacerAltSurface(Dimension dim, Random rand) {
// this(rand, dim.getFiller(), dim.getAltFiller1(), dim.getAltFiller2(), dim.getLiquid());
// }
public ReplacerAltSurface(Random rand, State filler, State alt1, State alt2, State liquid)
{
this.altNoiseGen = new OctaveGen(rand, 4);
this.exclNoiseGen = new OctaveGen(rand, 4);
this.filler = filler;
this.alt1 = alt1;
this.alt2 = alt2;
this.liquid = liquid;
this.fillerBlock = filler.getBlock();
}
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, BaseBiome[] biomes)
{
int i = world.getSeaLevel() + 1;
double d0 = 0.03125D;
this.altNoiseGen.generate(this.alt2Noise, x * 16, z * 16, 0, 16, 16, 1, d0, d0, 1.0D);
this.altNoiseGen.generate(this.alt1Noise, x * 16, 109, z * 16, 16, 1, 16, d0, 1.0D, d0);
this.exclNoiseGen.generate(this.exclNoise, x * 16, z * 16, 0, 16, 16, 1, d0 * 2.0D, d0 * 2.0D, d0 * 2.0D);
for (int j = 0; j < 16; ++j)
{
for (int k = 0; k < 16; ++k)
{
boolean flag = this.alt2Noise[j + k * 16] + rand.doublev() * 0.2D > 0.0D;
boolean flag1 = this.alt1Noise[j + k * 16] + rand.doublev() * 0.2D > 0.0D;
int l = (int)(this.exclNoise[j + k * 16] / 3.0D + 3.0D + rand.doublev() * 0.25D);
int i1 = -1;
State iblockstate = this.filler;
State iblockstate1 = this.filler;
for (int j1 = primer.height - 1; j1 >= 0; --j1)
{
// if (j1 < (primer.height - 1) - rand.zrange(5) || this.ceiling == null)
// {
State iblockstate2 = primer.get(k, j1, j);
if (iblockstate2.getBlock() != null && iblockstate2.getBlock().getMaterial() != Material.air)
{
if (iblockstate2.getBlock() == this.fillerBlock)
{
if (i1 == -1)
{
if (l <= 0)
{
iblockstate = null;
iblockstate1 = this.filler;
}
else if (j1 >= i - 4 && j1 <= i + 1)
{
iblockstate = this.filler;
iblockstate1 = this.filler;
if (flag1)
{
iblockstate = this.alt1;
iblockstate1 = this.filler;
}
if (flag)
{
iblockstate = this.alt2;
iblockstate1 = this.alt2;
}
}
if (j1 < i && (iblockstate == null || iblockstate.getBlock().getMaterial() == Material.air))
{
iblockstate = this.liquid;
}
i1 = l;
if (j1 >= i - 1)
{
primer.set(k, j1, j, iblockstate);
}
else
{
primer.set(k, j1, j, iblockstate1);
}
}
else if (i1 > 0)
{
--i1;
primer.set(k, j1, j, iblockstate1);
}
}
}
else
{
i1 = -1;
}
// }
// else
// {
// primer.set(k, j1, j, this.ceiling);
// }
}
}
}
}
}

View file

@ -0,0 +1,33 @@
package server.worldgen;
import common.biome.BaseBiome;
import common.rng.PerlinGen;
import common.rng.Random;
import server.biome.Biome;
import server.world.WorldServer;
public class ReplacerBiome implements BlockReplacer
{
private final PerlinGen stoneNoiseGen;
private final double[] stoneNoise = new double[256];
public ReplacerBiome(Random rand)
{
this.stoneNoiseGen = new PerlinGen(rand, 4);
}
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, BaseBiome[] biomes)
{
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 i = 0; i < 16; ++i)
{
for (int j = 0; j < 16; ++j)
{
Biome biome = Biome.BIOMES[biomes[j + i * 16].id];
biome.genTerrainBlocks(world, rand, primer, x * 16 + i, z * 16 + j, this.stoneNoise[j + i * 16]);
}
}
}
}

View file

@ -0,0 +1,75 @@
package server.worldgen;
import common.biome.BaseBiome;
import common.block.Block;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.world.State;
import server.world.WorldServer;
public class ReplacerTopLayer implements BlockReplacer
{
private final State filler;
private final Block replace;
// public ReplacerTopLayer(Dimension dim) {
// this(dim.getSurface(), dim.getFiller().getBlock());
// }
public ReplacerTopLayer(State filler, Block replace) {
this.filler = filler;
this.replace = replace;
}
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, BaseBiome[] biomes)
{
for (int i = 0; i < 16; ++i)
{
for (int j = 0; j < 16; ++j)
{
int k = 1;
int l = -1;
State iblockstate = this.filler;
State iblockstate1 = this.filler;
for (int i1 = primer.height - 1; i1 >= 0; --i1)
{
State iblockstate2 = primer.get(i, i1, j);
if (iblockstate2.getBlock().getMaterial() == Material.air)
{
l = -1;
}
else if (iblockstate2.getBlock() == this.replace)
{
if (l == -1)
{
if (k <= 0)
{
iblockstate = Blocks.air.getState();
iblockstate1 = this.filler;
}
l = k;
if (i1 >= 0)
{
primer.set(i, i1, j, iblockstate);
}
else
{
primer.set(i, i1, j, iblockstate1);
}
}
else if (l > 0)
{
--l;
primer.set(i, i1, j, iblockstate1);
}
}
}
}
}
}
}

View file

@ -0,0 +1,44 @@
package server.worldgen.caves;
import common.rng.Random;
import server.world.WorldServer;
import server.worldgen.ChunkPrimer;
public class MapGenBase
{
/** The number of Chunks to gen-check in any given direction. */
protected int range = 8;
/** The RNG used by the MapGen classes. */
protected Random rand = new Random();
/** This world object. */
protected WorldServer worldObj;
public void generate(WorldServer worldIn, int x, int z, ChunkPrimer chunkPrimerIn)
{
int i = this.range;
this.worldObj = worldIn;
this.rand.setSeed(worldIn.getSeed());
long j = this.rand.longv();
long k = this.rand.longv();
for (int l = x - i; l <= x + i; ++l)
{
for (int i1 = z - i; i1 <= z + i; ++i1)
{
long j1 = (long)l * j;
long k1 = (long)i1 * k;
this.rand.setSeed(j1 ^ k1 ^ worldIn.getSeed());
this.recursiveGenerate(worldIn, l, i1, x, z, chunkPrimerIn);
}
}
}
/**
* Recursively called by generate()
*/
protected void recursiveGenerate(WorldServer worldIn, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
{
}
}

View file

@ -0,0 +1,233 @@
package server.worldgen.caves;
import common.block.Block;
import common.init.Blocks;
import common.rng.Random;
import common.util.ExtMath;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.ChunkPrimer;
public class MapGenBigCaves extends MapGenBase
{
private final Block replace;
private final Block top;
private final Block surface;
public MapGenBigCaves(Block replace, Block top, Block surface) {
this.replace = replace;
this.top = top;
this.surface = surface;
}
protected void func_180705_a(long p_180705_1_, int p_180705_3_, int p_180705_4_, ChunkPrimer p_180705_5_, double p_180705_6_, double p_180705_8_, double p_180705_10_)
{
this.func_180704_a(p_180705_1_, p_180705_3_, p_180705_4_, p_180705_5_, p_180705_6_, p_180705_8_, p_180705_10_, 1.0F + this.rand.floatv() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D);
}
protected void func_180704_a(long p_180704_1_, int p_180704_3_, int p_180704_4_, ChunkPrimer p_180704_5_, double p_180704_6_, double p_180704_8_, double p_180704_10_, float p_180704_12_, float p_180704_13_, float p_180704_14_, int p_180704_15_, int p_180704_16_, double p_180704_17_)
{
double d0 = (double)(p_180704_3_ * 16 + 8);
double d1 = (double)(p_180704_4_ * 16 + 8);
float f = 0.0F;
float f1 = 0.0F;
Random random = new Random(p_180704_1_);
if (p_180704_16_ <= 0)
{
int i = this.range * 16 - 16;
p_180704_16_ = i - random.zrange(i / 4);
}
boolean flag1 = false;
if (p_180704_15_ == -1)
{
p_180704_15_ = p_180704_16_ / 2;
flag1 = true;
}
int j = random.zrange(p_180704_16_ / 2) + p_180704_16_ / 4;
for (boolean flag = random.zrange(6) == 0; p_180704_15_ < p_180704_16_; ++p_180704_15_)
{
double d2 = 1.5D + (double)(ExtMath.sin((float)p_180704_15_ * (float)Math.PI / (float)p_180704_16_) * p_180704_12_ * 1.0F);
double d3 = d2 * p_180704_17_;
float f2 = ExtMath.cos(p_180704_14_);
float f3 = ExtMath.sin(p_180704_14_);
p_180704_6_ += (double)(ExtMath.cos(p_180704_13_) * f2);
p_180704_8_ += (double)f3;
p_180704_10_ += (double)(ExtMath.sin(p_180704_13_) * f2);
if (flag)
{
p_180704_14_ = p_180704_14_ * 0.92F;
}
else
{
p_180704_14_ = p_180704_14_ * 0.7F;
}
p_180704_14_ = p_180704_14_ + f1 * 0.1F;
p_180704_13_ += f * 0.1F;
f1 = f1 * 0.9F;
f = f * 0.75F;
f1 = f1 + (random.floatv() - random.floatv()) * random.floatv() * 2.0F;
f = f + (random.floatv() - random.floatv()) * random.floatv() * 4.0F;
if (!flag1 && p_180704_15_ == j && p_180704_12_ > 1.0F)
{
this.func_180704_a(random.longv(), p_180704_3_, p_180704_4_, p_180704_5_, p_180704_6_, p_180704_8_, p_180704_10_, random.floatv() * 0.5F + 0.5F, p_180704_13_ - ((float)Math.PI / 2F), p_180704_14_ / 3.0F, p_180704_15_, p_180704_16_, 1.0D);
this.func_180704_a(random.longv(), p_180704_3_, p_180704_4_, p_180704_5_, p_180704_6_, p_180704_8_, p_180704_10_, random.floatv() * 0.5F + 0.5F, p_180704_13_ + ((float)Math.PI / 2F), p_180704_14_ / 3.0F, p_180704_15_, p_180704_16_, 1.0D);
return;
}
if (flag1 || random.zrange(4) != 0)
{
double d4 = p_180704_6_ - d0;
double d5 = p_180704_10_ - d1;
double d6 = (double)(p_180704_16_ - p_180704_15_);
double d7 = (double)(p_180704_12_ + 2.0F + 16.0F);
if (d4 * d4 + d5 * d5 - d6 * d6 > d7 * d7)
{
return;
}
if (p_180704_6_ >= d0 - 16.0D - d2 * 2.0D && p_180704_10_ >= d1 - 16.0D - d2 * 2.0D && p_180704_6_ <= d0 + 16.0D + d2 * 2.0D && p_180704_10_ <= d1 + 16.0D + d2 * 2.0D)
{
int j2 = ExtMath.floord(p_180704_6_ - d2) - p_180704_3_ * 16 - 1;
int k = ExtMath.floord(p_180704_6_ + d2) - p_180704_3_ * 16 + 1;
int k2 = ExtMath.floord(p_180704_8_ - d3) - 1;
int l = ExtMath.floord(p_180704_8_ + d3) + 1;
int l2 = ExtMath.floord(p_180704_10_ - d2) - p_180704_4_ * 16 - 1;
int i1 = ExtMath.floord(p_180704_10_ + d2) - p_180704_4_ * 16 + 1;
if (j2 < 0)
{
j2 = 0;
}
if (k > 16)
{
k = 16;
}
if (k2 < 1)
{
k2 = 1;
}
if (l > 120)
{
l = 120;
}
if (l2 < 0)
{
l2 = 0;
}
if (i1 > 16)
{
i1 = 16;
}
boolean flag2 = false;
for (int j1 = j2; !flag2 && j1 < k; ++j1)
{
for (int k1 = l2; !flag2 && k1 < i1; ++k1)
{
for (int l1 = l + 1; !flag2 && l1 >= k2 - 1; --l1)
{
if (l1 >= 0 && l1 < 128)
{
State iblockstate = p_180704_5_.get(j1, l1, k1);
if (iblockstate.getBlock().getMaterial().isLiquid())
{
flag2 = true;
}
if (l1 != k2 - 1 && j1 != j2 && j1 != k - 1 && k1 != l2 && k1 != i1 - 1)
{
l1 = k2;
}
}
}
}
}
if (!flag2)
{
for (int i3 = j2; i3 < k; ++i3)
{
double d10 = ((double)(i3 + p_180704_3_ * 16) + 0.5D - p_180704_6_) / d2;
for (int j3 = l2; j3 < i1; ++j3)
{
double d8 = ((double)(j3 + p_180704_4_ * 16) + 0.5D - p_180704_10_) / d2;
for (int i2 = l; i2 > k2; --i2)
{
double d9 = ((double)(i2 - 1) + 0.5D - p_180704_8_) / d3;
if (d9 > -0.7D && d10 * d10 + d9 * d9 + d8 * d8 < 1.0D)
{
State iblockstate1 = p_180704_5_.get(i3, i2, j3);
if (iblockstate1.getBlock() == this.replace || iblockstate1.getBlock() == this.top || iblockstate1.getBlock() == this.surface)
{
p_180704_5_.set(i3, i2, j3, Blocks.air.getState());
}
}
}
}
}
if (flag1)
{
break;
}
}
}
}
}
}
/**
* Recursively called by generate()
*/
protected void recursiveGenerate(WorldServer worldIn, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
{
int i = this.rand.zrange(this.rand.zrange(this.rand.zrange(10) + 1) + 1);
if (this.rand.zrange(5) != 0)
{
i = 0;
}
for (int j = 0; j < i; ++j)
{
double d0 = (double)(chunkX * 16 + this.rand.zrange(16));
double d1 = (double)this.rand.zrange(128);
double d2 = (double)(chunkZ * 16 + this.rand.zrange(16));
int k = 1;
if (this.rand.zrange(4) == 0)
{
this.func_180705_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2);
k += this.rand.zrange(4);
}
for (int l = 0; l < k; ++l)
{
float f = this.rand.floatv() * (float)Math.PI * 2.0F;
float f1 = (this.rand.floatv() - 0.5F) * 2.0F / 8.0F;
float f2 = this.rand.floatv() * 2.0F + this.rand.floatv();
this.func_180704_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2, f2 * 2.0F, f, f1, 0, 0, 0.5D);
}
}
}
}

View file

@ -0,0 +1,286 @@
package server.worldgen.caves;
import common.block.Block;
import common.block.BlockColored;
import common.block.BlockSand;
import common.color.DyeColor;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import common.util.ExtMath;
import common.world.State;
import server.biome.Biome;
import server.world.WorldServer;
import server.worldgen.ChunkPrimer;
public class MapGenCaves extends MapGenBase
{
private final State filler;
private final Block replace;
private final Block top;
private final Block surface;
private final 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.alt = alt;
}
protected void func_180703_a(long p_180703_1_, int p_180703_3_, int p_180703_4_, ChunkPrimer p_180703_5_, double p_180703_6_, double p_180703_8_, double p_180703_10_)
{
this.func_180702_a(p_180703_1_, p_180703_3_, p_180703_4_, p_180703_5_, p_180703_6_, p_180703_8_, p_180703_10_, 1.0F + this.rand.floatv() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D);
}
protected void func_180702_a(long p_180702_1_, int p_180702_3_, int p_180702_4_, ChunkPrimer p_180702_5_, double p_180702_6_, double p_180702_8_, double p_180702_10_, float p_180702_12_, float p_180702_13_, float p_180702_14_, int p_180702_15_, int p_180702_16_, double p_180702_17_)
{
double d0 = (double)(p_180702_3_ * 16 + 8);
double d1 = (double)(p_180702_4_ * 16 + 8);
float f = 0.0F;
float f1 = 0.0F;
Random random = new Random(p_180702_1_);
if (p_180702_16_ <= 0)
{
int i = this.range * 16 - 16;
p_180702_16_ = i - random.zrange(i / 4);
}
boolean flag2 = false;
if (p_180702_15_ == -1)
{
p_180702_15_ = p_180702_16_ / 2;
flag2 = true;
}
int j = random.zrange(p_180702_16_ / 2) + p_180702_16_ / 4;
for (boolean flag = random.zrange(6) == 0; p_180702_15_ < p_180702_16_; ++p_180702_15_)
{
double d2 = 1.5D + (double)(ExtMath.sin((float)p_180702_15_ * (float)Math.PI / (float)p_180702_16_) * p_180702_12_ * 1.0F);
double d3 = d2 * p_180702_17_;
float f2 = ExtMath.cos(p_180702_14_);
float f3 = ExtMath.sin(p_180702_14_);
p_180702_6_ += (double)(ExtMath.cos(p_180702_13_) * f2);
p_180702_8_ += (double)f3;
p_180702_10_ += (double)(ExtMath.sin(p_180702_13_) * f2);
if (flag)
{
p_180702_14_ = p_180702_14_ * 0.92F;
}
else
{
p_180702_14_ = p_180702_14_ * 0.7F;
}
p_180702_14_ = p_180702_14_ + f1 * 0.1F;
p_180702_13_ += f * 0.1F;
f1 = f1 * 0.9F;
f = f * 0.75F;
f1 = f1 + (random.floatv() - random.floatv()) * random.floatv() * 2.0F;
f = f + (random.floatv() - random.floatv()) * random.floatv() * 4.0F;
if (!flag2 && p_180702_15_ == j && p_180702_12_ > 1.0F && p_180702_16_ > 0)
{
this.func_180702_a(random.longv(), p_180702_3_, p_180702_4_, p_180702_5_, p_180702_6_, p_180702_8_, p_180702_10_, random.floatv() * 0.5F + 0.5F, p_180702_13_ - ((float)Math.PI / 2F), p_180702_14_ / 3.0F, p_180702_15_, p_180702_16_, 1.0D);
this.func_180702_a(random.longv(), p_180702_3_, p_180702_4_, p_180702_5_, p_180702_6_, p_180702_8_, p_180702_10_, random.floatv() * 0.5F + 0.5F, p_180702_13_ + ((float)Math.PI / 2F), p_180702_14_ / 3.0F, p_180702_15_, p_180702_16_, 1.0D);
return;
}
if (flag2 || random.zrange(4) != 0)
{
double d4 = p_180702_6_ - d0;
double d5 = p_180702_10_ - d1;
double d6 = (double)(p_180702_16_ - p_180702_15_);
double d7 = (double)(p_180702_12_ + 2.0F + 16.0F);
if (d4 * d4 + d5 * d5 - d6 * d6 > d7 * d7)
{
return;
}
if (p_180702_6_ >= d0 - 16.0D - d2 * 2.0D && p_180702_10_ >= d1 - 16.0D - d2 * 2.0D && p_180702_6_ <= d0 + 16.0D + d2 * 2.0D && p_180702_10_ <= d1 + 16.0D + d2 * 2.0D)
{
int k2 = ExtMath.floord(p_180702_6_ - d2) - p_180702_3_ * 16 - 1;
int k = ExtMath.floord(p_180702_6_ + d2) - p_180702_3_ * 16 + 1;
int l2 = ExtMath.floord(p_180702_8_ - d3) - 1;
int l = ExtMath.floord(p_180702_8_ + d3) + 1;
int i3 = ExtMath.floord(p_180702_10_ - d2) - p_180702_4_ * 16 - 1;
int i1 = ExtMath.floord(p_180702_10_ + d2) - p_180702_4_ * 16 + 1;
if (k2 < 0)
{
k2 = 0;
}
if (k > 16)
{
k = 16;
}
if (l2 < 1)
{
l2 = 1;
}
if (l > 248)
{
l = 248;
}
if (i3 < 0)
{
i3 = 0;
}
if (i1 > 16)
{
i1 = 16;
}
boolean flag3 = false;
for (int j1 = k2; !flag3 && j1 < k; ++j1)
{
for (int k1 = i3; !flag3 && k1 < i1; ++k1)
{
for (int l1 = l + 1; !flag3 && l1 >= l2 - 1; --l1)
{
if (l1 >= 0 && l1 < p_180702_5_.height)
{
State iblockstate = p_180702_5_.get(j1, l1, k1);
if (iblockstate.getBlock().getMaterial().isLiquid())
{
flag3 = true;
}
if (l1 != l2 - 1 && j1 != k2 && j1 != k - 1 && k1 != i3 && k1 != i1 - 1)
{
l1 = l2;
}
}
}
}
}
if (!flag3)
{
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int j3 = k2; j3 < k; ++j3)
{
double d10 = ((double)(j3 + p_180702_3_ * 16) + 0.5D - p_180702_6_) / d2;
for (int i2 = i3; i2 < i1; ++i2)
{
double d8 = ((double)(i2 + p_180702_4_ * 16) + 0.5D - p_180702_10_) / d2;
boolean flag1 = false;
if (d10 * d10 + d8 * d8 < 1.0D)
{
for (int j2 = l; j2 > l2; --j2)
{
double d9 = ((double)(j2 - 1) + 0.5D - p_180702_8_) / d3;
if (d9 > -0.7D && d10 * d10 + d9 * d9 + d8 * d8 < 1.0D)
{
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 (iblockstate1.getBlock() == this.surface || iblockstate1.getBlock() == Blocks.mycelium)
{
flag1 = true;
}
if (this.func_175793_a(iblockstate1, iblockstate2))
{
if (j2 - 1 < 10)
{
p_180702_5_.set(j3, j2, i2, this.filler);
}
else
{
p_180702_5_.set(j3, j2, i2, Blocks.air.getState());
if (iblockstate2.getBlock() == Blocks.sand)
{
p_180702_5_.set(j3, j2 + 1, i2, iblockstate2.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.ORANGE) : Blocks.sandstone.getState()); //TODO: check!
}
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, Biome.BIOMES[this.worldObj.getBiomeGenForCoords(blockpos$mutableblockpos).id].topBlock.getBlock().getState());
}
}
}
}
}
}
}
}
if (flag2)
{
break;
}
}
}
}
}
}
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() == Blocks.stained_hardened_clay ? 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()
*/
protected void recursiveGenerate(WorldServer worldIn, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
{
int i = this.rand.zrange(this.rand.zrange(this.rand.zrange(15) + 1) + 1);
if (this.rand.zrange(7) != 0)
{
i = 0;
}
for (int j = 0; j < i; ++j)
{
double d0 = (double)(chunkX * 16 + this.rand.zrange(16));
double d1 = (double)this.rand.zrange(this.rand.zrange(120) + 8);
double d2 = (double)(chunkZ * 16 + this.rand.zrange(16));
int k = 1;
if (this.rand.zrange(4) == 0)
{
this.func_180703_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2);
k += this.rand.zrange(4);
}
for (int l = 0; l < k; ++l)
{
float f = this.rand.floatv() * (float)Math.PI * 2.0F;
float f1 = (this.rand.floatv() - 0.5F) * 2.0F / 8.0F;
float f2 = this.rand.floatv() * 2.0F + this.rand.floatv();
if (this.rand.zrange(10) == 0)
{
f2 *= this.rand.floatv() * this.rand.floatv() * 3.0F + 1.0F;
}
this.func_180702_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2, f2, f, f1, 0, 0, 1.0D);
}
}
}
}

View file

@ -0,0 +1,241 @@
package server.worldgen.caves;
import common.block.Block;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import common.util.ExtMath;
import common.world.State;
import server.biome.Biome;
import server.world.WorldServer;
import server.worldgen.ChunkPrimer;
public class MapGenRavine extends MapGenBase
{
private final State filler;
private final Block replace;
private final Block top;
private final Block surface;
private float[] field_75046_d = new float[1024];
public MapGenRavine(State filler, Block replace, Block top, Block surface) {
this.filler = filler;
this.replace = replace;
this.top = top;
this.surface = surface;
}
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_)
{
Random random = new Random(p_180707_1_);
double d0 = (double)(p_180707_3_ * 16 + 8);
double d1 = (double)(p_180707_4_ * 16 + 8);
float f = 0.0F;
float f1 = 0.0F;
if (p_180707_16_ <= 0)
{
int i = this.range * 16 - 16;
p_180707_16_ = i - random.zrange(i / 4);
}
boolean flag1 = false;
if (p_180707_15_ == -1)
{
p_180707_15_ = p_180707_16_ / 2;
flag1 = true;
}
float f2 = 1.0F;
for (int j = 0; j < 256; ++j)
{
if (j == 0 || random.zrange(3) == 0)
{
f2 = 1.0F + random.floatv() * random.floatv() * 1.0F;
}
this.field_75046_d[j] = f2 * f2;
}
for (; p_180707_15_ < p_180707_16_; ++p_180707_15_)
{
double d9 = 1.5D + (double)(ExtMath.sin((float)p_180707_15_ * (float)Math.PI / (float)p_180707_16_) * p_180707_12_ * 1.0F);
double d2 = d9 * p_180707_17_;
d9 = d9 * ((double)random.floatv() * 0.25D + 0.75D);
d2 = d2 * ((double)random.floatv() * 0.25D + 0.75D);
float f3 = ExtMath.cos(p_180707_14_);
float f4 = ExtMath.sin(p_180707_14_);
p_180707_6_ += (double)(ExtMath.cos(p_180707_13_) * f3);
p_180707_8_ += (double)f4;
p_180707_10_ += (double)(ExtMath.sin(p_180707_13_) * f3);
p_180707_14_ = p_180707_14_ * 0.7F;
p_180707_14_ = p_180707_14_ + f1 * 0.05F;
p_180707_13_ += f * 0.05F;
f1 = f1 * 0.8F;
f = f * 0.5F;
f1 = f1 + (random.floatv() - random.floatv()) * random.floatv() * 2.0F;
f = f + (random.floatv() - random.floatv()) * random.floatv() * 4.0F;
if (flag1 || random.zrange(4) != 0)
{
double d3 = p_180707_6_ - d0;
double d4 = p_180707_10_ - d1;
double d5 = (double)(p_180707_16_ - p_180707_15_);
double d6 = (double)(p_180707_12_ + 2.0F + 16.0F);
if (d3 * d3 + d4 * d4 - d5 * d5 > d6 * d6)
{
return;
}
if (p_180707_6_ >= d0 - 16.0D - d9 * 2.0D && p_180707_10_ >= d1 - 16.0D - d9 * 2.0D && p_180707_6_ <= d0 + 16.0D + d9 * 2.0D && p_180707_10_ <= d1 + 16.0D + d9 * 2.0D)
{
int k2 = ExtMath.floord(p_180707_6_ - d9) - p_180707_3_ * 16 - 1;
int k = ExtMath.floord(p_180707_6_ + d9) - p_180707_3_ * 16 + 1;
int l2 = ExtMath.floord(p_180707_8_ - d2) - 1;
int l = ExtMath.floord(p_180707_8_ + d2) + 1;
int i3 = ExtMath.floord(p_180707_10_ - d9) - p_180707_4_ * 16 - 1;
int i1 = ExtMath.floord(p_180707_10_ + d9) - p_180707_4_ * 16 + 1;
if (k2 < 0)
{
k2 = 0;
}
if (k > 16)
{
k = 16;
}
if (l2 < 1)
{
l2 = 1;
}
if (l > 248)
{
l = 248;
}
if (i3 < 0)
{
i3 = 0;
}
if (i1 > 16)
{
i1 = 16;
}
boolean flag2 = false;
for (int j1 = k2; !flag2 && j1 < k; ++j1)
{
for (int k1 = i3; !flag2 && k1 < i1; ++k1)
{
for (int l1 = l + 1; !flag2 && l1 >= l2 - 1; --l1)
{
if (l1 >= 0 && l1 < p_180707_5_.height)
{
State iblockstate = p_180707_5_.get(j1, l1, k1);
if (iblockstate.getBlock().getMaterial().isLiquid())
{
flag2 = true;
}
if (l1 != l2 - 1 && j1 != k2 && j1 != k - 1 && k1 != i3 && k1 != i1 - 1)
{
l1 = l2;
}
}
}
}
}
if (!flag2)
{
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int j3 = k2; j3 < k; ++j3)
{
double d10 = ((double)(j3 + p_180707_3_ * 16) + 0.5D - p_180707_6_) / d9;
for (int i2 = i3; i2 < i1; ++i2)
{
double d7 = ((double)(i2 + p_180707_4_ * 16) + 0.5D - p_180707_10_) / d9;
boolean flag = false;
if (d10 * d10 + d7 * d7 < 1.0D)
{
for (int j2 = l; j2 > l2; --j2)
{
double d8 = ((double)(j2 - 1) + 0.5D - p_180707_8_) / d2;
if ((d10 * d10 + d7 * d7) * (double)this.field_75046_d[j2 - 1] + d8 * d8 / 6.0D < 1.0D)
{
State iblockstate1 = p_180707_5_.get(j3, j2, i2);
if (iblockstate1.getBlock() == this.surface)
{
flag = true;
}
if (iblockstate1.getBlock() == this.replace || iblockstate1.getBlock() == this.top || iblockstate1.getBlock() == this.surface)
{
if (j2 - 1 < 10)
{
p_180707_5_.set(j3, j2, i2, this.filler);
}
else
{
p_180707_5_.set(j3, j2, i2, Blocks.air.getState());
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, Biome.BIOMES[this.worldObj.getBiomeGenForCoords(blockpos$mutableblockpos).id].topBlock);
}
}
}
}
}
}
}
}
if (flag1)
{
break;
}
}
}
}
}
}
/**
* Recursively called by generate()
*/
protected void recursiveGenerate(WorldServer worldIn, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
{
if (this.rand.zrange(50) == 0)
{
double d0 = (double)(chunkX * 16 + this.rand.zrange(16));
double d1 = (double)(this.rand.zrange(this.rand.zrange(40) + 8) + 20);
double d2 = (double)(chunkZ * 16 + this.rand.zrange(16));
int i = 1;
for (int j = 0; j < i; ++j)
{
float f = this.rand.floatv() * (float)Math.PI * 2.0F;
float f1 = (this.rand.floatv() - 0.5F) * 2.0F / 8.0F;
float f2 = (this.rand.floatv() * 2.0F + this.rand.floatv()) * 2.0F;
this.func_180707_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2, f2, f, f1, 0, 0, 3.0D);
}
}
}
}

View file

@ -0,0 +1,62 @@
package server.worldgen.feature;
import common.block.Block;
import common.init.Blocks;
import common.item.RngLoot;
import common.material.Material;
import common.rng.Random;
import common.rng.WeightedList;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
import server.worldgen.LootConstants;
public class WorldGenAbandonedChest extends FeatureGenerator
{
private final WeightedList<RngLoot> items;
private final int amount;
// BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).up();
public WorldGenAbandonedChest(WeightedList<RngLoot> items, int amount)
{
this.items = items;
this.amount = amount;
}
public WorldGenAbandonedChest() {
this(LootConstants.ABANDONED_ITEMS, 10);
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
Block block;
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 1)
{
position = position.down();
}
if (position.getY() < 1)
{
return false;
}
else
{
position = position.up();
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = position.add(rand.zrange(4) - rand.zrange(4), rand.zrange(3) - rand.zrange(3), rand.zrange(4) - rand.zrange(4));
if (worldIn.isAirBlock(blockpos) && worldIn.isBlockSolid(blockpos.down()))
{
worldIn.setState(blockpos, Blocks.chest.getState(), 2);
TileEntity tileentity = worldIn.getTileEntity(blockpos);
if(tileentity instanceof TileEntityChest)
RngLoot.generateChestContents(rand, this.items, (TileEntityChest)tileentity, this.amount);
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,70 @@
package server.worldgen.feature;
import common.rng.Random;
import common.util.BlockPos;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenAsteroid extends FeatureGenerator {
private final State[] blocks;
public WorldGenAsteroid(State ... blocks) {
this.blocks = blocks;
}
public boolean generate(WorldServer world, Random rand, BlockPos pos) {
for(pos = pos.add(-8, 0, -8); pos.getY() > 9 && !world.isAirBlock(pos); pos = pos.down()) {
;
}
if(pos.getY() <= 8)
return false;
pos = pos.down(8);
boolean[] set = new boolean[4096];
int iter = rand.range(1, 15);
for(int n = 0; n < iter; ++n) {
double d0 = rand.doublev() * 6.0D + 3.0D;
double d1 = rand.doublev() * 6.0D + 3.0D;
double d2 = rand.doublev() * 6.0D + 3.0D;
double d3 = rand.doublev() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
double d4 = rand.doublev() * (16.0D - d1 - 2.0D) + 1.0D + d1 / 2.0D;
double d5 = rand.doublev() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;
for(int x = 1; x < 15; ++x) {
for(int z = 1; z < 15; ++z) {
for(int y = 1; y < 15; ++y) {
double dx = ((double)x - d3) / (d0 / 2.0D);
double dy = ((double)y - d4) / (d1 / 2.0D);
double dz = ((double)z - d5) / (d2 / 2.0D);
double dist = dx * dx + dy * dy + dz * dz;
if(dist < 1.0D) {
set[(x * 16 + z) * 16 + y] = true;
}
}
}
}
}
for(int x = 0; x < 16; ++x) {
for(int z = 0; z < 16; ++z) {
for(int y = 0; y < 16; ++y) {
boolean flag = !set[(x * 16 + z) * 16 + y]
&& (x < 15 && set[((x + 1) * 16 + z) * 16 + y] || x > 0 && set[((x - 1) * 16 + z) * 16 + y]
|| z < 15 && set[(x * 16 + z + 1) * 16 + y] || z > 0 && set[(x * 16 + (z - 1)) * 16 + y]
|| y < 7 && set[(x * 16 + z) * 16 + y + 1] || y > 0 && set[(x * 16 + z) * 16 + (y - 1)]);
if(flag && !world.isAirBlock(pos.add(x, y, z))) {
return false;
}
}
}
}
for(int x = 0; x < 16; ++x) {
for(int z = 0; z < 16; ++z) {
for(int y = 0; y < 16; ++y) {
if(set[(x * 16 + z) * 16 + y]) {
world.setState(pos.add(x, y, z), rand.pick(this.blocks), 2);
}
}
}
}
return true;
}
}

View file

@ -0,0 +1,73 @@
package server.worldgen.feature;
import common.block.Block;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenBlockBlob extends FeatureGenerator
{
private final Block field_150545_a;
private final int field_150544_b;
public WorldGenBlockBlob(Block p_i45450_1_, int p_i45450_2_)
{
// super(false);
this.field_150545_a = p_i45450_1_;
this.field_150544_b = p_i45450_2_;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
while (true)
{
label0:
{
if (position.getY() > 3)
{
if (worldIn.isAirBlock(position.down()))
{
break label0;
}
Block block = worldIn.getState(position.down()).getBlock();
if (block != Blocks.grass && block != Blocks.dirt && block != Blocks.stone)
{
break label0;
}
}
if (position.getY() <= 3)
{
return false;
}
int i1 = this.field_150544_b;
for (int i = 0; i1 >= 0 && i < 3; ++i)
{
int j = i1 + rand.zrange(2);
int k = i1 + rand.zrange(2);
int l = i1 + rand.zrange(2);
float f = (float)(j + k + l) * 0.333F + 0.5F;
for (BlockPos blockpos : BlockPos.getAllInBox(position.add(-j, -k, -l), position.add(j, k, l)))
{
if (blockpos.distanceSq(position) <= (double)(f * f))
{
worldIn.setState(blockpos, this.field_150545_a.getState(), 4);
}
}
position = position.add(-(i1 + 1) + rand.zrange(2 + i1 * 2), 0 - rand.zrange(2), -(i1 + 1) + rand.zrange(2 + i1 * 2));
}
return true;
}
position = position.down();
}
}
}

View file

@ -0,0 +1,59 @@
package server.worldgen.feature;
import common.block.Block;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenClay extends FeatureGenerator
{
protected Block clayBlock = Blocks.clay;
/** The number of blocks to generate. */
protected int numberOfBlocks;
public WorldGenClay(int blocks)
{
this.numberOfBlocks = blocks;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
if (!worldIn.getState(position).getBlock().getMaterial().isColdLiquid())
{
return false;
}
else
{
int i = rand.zrange(this.numberOfBlocks - 2) + 2;
int j = 1;
for (int k = position.getX() - i; k <= position.getX() + i; ++k)
{
for (int l = position.getZ() - i; l <= position.getZ() + i; ++l)
{
int i1 = k - position.getX();
int j1 = l - position.getZ();
if (i1 * i1 + j1 * j1 <= i * i)
{
for (int k1 = position.getY() - j; k1 <= position.getY() + j; ++k1)
{
BlockPos blockpos = new BlockPos(k, k1, l);
Block block = worldIn.getState(blockpos).getBlock();
if (block == Blocks.dirt || block == Blocks.clay)
{
worldIn.setState(blockpos, this.clayBlock.getState(), 2);
}
}
}
}
}
return true;
}
}
}

View file

@ -0,0 +1,54 @@
package server.worldgen.feature;
import common.block.Block;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import common.util.ExtMath;
import server.world.WorldServer;
public class WorldGenClayExt extends WorldGenClay {
public WorldGenClayExt(int blocks) {
super(blocks);
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
if(!worldIn.getState(position).getBlock().getMaterial().isColdLiquid()) {
return false;
}
float f = rand.floatv() * 3.141593F;
double d = (float)position.getX() + (ExtMath.sin(f) * (float)numberOfBlocks) / 8F;
double d1 = (float)position.getX() - (ExtMath.sin(f) * (float)numberOfBlocks) / 8F;
double d2 = (float)position.getZ() + (ExtMath.cos(f) * (float)numberOfBlocks) / 8F;
double d3 = (float)position.getZ() - (ExtMath.cos(f) * (float)numberOfBlocks) / 8F;
double d4 = position.getY() + rand.zrange(3) + 2;
double d5 = position.getY() + rand.zrange(3) + 2;
for(int l = 0; l <= numberOfBlocks; l++) {
double d6 = d + ((d1 - d) * (double)l) / (double)numberOfBlocks;
double d7 = d4 + ((d5 - d4) * (double)l) / (double)numberOfBlocks;
double d8 = d2 + ((d3 - d2) * (double)l) / (double)numberOfBlocks;
double d9 = (rand.doublev() * (double)numberOfBlocks) / 16D;
double d10 = (double)(ExtMath.sin(((float)l * 3.141593F) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
double d11 = (double)(ExtMath.sin(((float)l * 3.141593F) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
for(int i1 = (int)(d6 - d10 / 2D); i1 <= (int)(d6 + d10 / 2D); i1++) {
for(int j1 = (int)(d7 - d11 / 2D); j1 <= (int)(d7 + d11 / 2D); j1++) {
for(int k1 = (int)(d8 - d10 / 2D); k1 <= (int)(d8 + d10 / 2D); k1++) {
double d12 = (((double)i1 + 0.5D) - d6) / (d10 / 2D);
double d13 = (((double)j1 + 0.5D) - d7) / (d11 / 2D);
double d14 = (((double)k1 + 0.5D) - d8) / (d10 / 2D);
if(d12 * d12 + d13 * d13 + d14 * d14 >= 1.0D) {
continue;
}
BlockPos blockpos = new BlockPos(i1, j1, k1);
Block block = worldIn.getState(blockpos).getBlock();
if(block == Blocks.sand) {
worldIn.setState(blockpos, this.clayBlock.getState(), 2);
}
}
}
}
}
return true;
}
}

View file

@ -0,0 +1,106 @@
package server.worldgen.feature;
import common.block.BlockSand;
import common.block.BlockSlab;
import common.init.Blocks;
import common.pattern.BlockStateHelper;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Predicates;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenDesertWells extends FeatureGenerator
{
private static final BlockStateHelper field_175913_a = BlockStateHelper.forBlock(Blocks.sand).where(BlockSand.VARIANT, Predicates.equalTo(BlockSand.EnumType.SAND));
private final State field_175911_b = Blocks.sandstone_slab.getState().withProperty(BlockSlab.FACING, Facing.DOWN);
private final State field_175912_c = Blocks.sandstone.getState();
private final State field_175910_d = Blocks.flowing_water.getState();
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
while (worldIn.isAirBlock(position) && position.getY() > 2)
{
position = position.down();
}
if (!field_175913_a.test(worldIn.getState(position)))
{
return false;
}
else
{
for (int i = -2; i <= 2; ++i)
{
for (int j = -2; j <= 2; ++j)
{
if (worldIn.isAirBlock(position.add(i, -1, j)) && worldIn.isAirBlock(position.add(i, -2, j)))
{
return false;
}
}
}
for (int l = -1; l <= 0; ++l)
{
for (int l1 = -2; l1 <= 2; ++l1)
{
for (int k = -2; k <= 2; ++k)
{
worldIn.setState(position.add(l1, l, k), this.field_175912_c, 2);
}
}
}
worldIn.setState(position, this.field_175910_d, 2);
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
{
worldIn.setState(position.offset(enumfacing), this.field_175910_d, 2);
}
for (int i1 = -2; i1 <= 2; ++i1)
{
for (int i2 = -2; i2 <= 2; ++i2)
{
if (i1 == -2 || i1 == 2 || i2 == -2 || i2 == 2)
{
worldIn.setState(position.add(i1, 1, i2), this.field_175912_c, 2);
}
}
}
worldIn.setState(position.add(2, 1, 0), this.field_175911_b, 2);
worldIn.setState(position.add(-2, 1, 0), this.field_175911_b, 2);
worldIn.setState(position.add(0, 1, 2), this.field_175911_b, 2);
worldIn.setState(position.add(0, 1, -2), this.field_175911_b, 2);
for (int j1 = -1; j1 <= 1; ++j1)
{
for (int j2 = -1; j2 <= 1; ++j2)
{
if (j1 == 0 && j2 == 0)
{
worldIn.setState(position.add(j1, 4, j2), this.field_175912_c, 2);
}
else
{
worldIn.setState(position.add(j1, 4, j2), this.field_175911_b, 2);
}
}
}
for (int k1 = 1; k1 <= 3; ++k1)
{
worldIn.setState(position.add(-1, k1, -1), this.field_175912_c, 2);
worldIn.setState(position.add(-1, k1, 1), this.field_175912_c, 2);
worldIn.setState(position.add(1, k1, -1), this.field_175912_c, 2);
worldIn.setState(position.add(1, k1, 1), this.field_175912_c, 2);
}
return true;
}
}
}

View file

@ -0,0 +1,25 @@
package server.worldgen.feature;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenFire extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 64; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
if (worldIn.isAirBlock(blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.hellrock)
{
worldIn.setState(blockpos, Blocks.fire.getState(), 2);
}
}
return true;
}
}

View file

@ -0,0 +1,58 @@
package server.worldgen.feature;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenGlowStone extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
if (!worldIn.isAirBlock(position))
{
return false;
}
else if (worldIn.getState(position.up()).getBlock() != Blocks.hellrock)
{
return false;
}
else
{
worldIn.setState(position, Blocks.glowstone.getState(), 2);
for (int i = 0; i < 1500; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), -rand.zrange(12), rand.zrange(8) - rand.zrange(8));
if (worldIn.getState(blockpos).getBlock().getMaterial() == Material.air)
{
int j = 0;
for (Facing enumfacing : Facing.values())
{
if (worldIn.getState(blockpos.offset(enumfacing)).getBlock() == Blocks.glowstone)
{
++j;
}
if (j > 1)
{
break;
}
}
if (j == 1)
{
worldIn.setState(blockpos, Blocks.glowstone.getState(), 2);
}
}
}
return true;
}
}
}

View file

@ -0,0 +1,97 @@
package server.worldgen.feature;
import common.block.Block;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenHellLava extends FeatureGenerator
{
private final Block field_150553_a;
private final boolean field_94524_b;
public WorldGenHellLava(Block p_i45453_1_, boolean p_i45453_2_)
{
this.field_150553_a = p_i45453_1_;
this.field_94524_b = p_i45453_2_;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
if (worldIn.getState(position.up()).getBlock() != Blocks.hellrock)
{
return false;
}
else if (worldIn.getState(position).getBlock().getMaterial() != Material.air && worldIn.getState(position).getBlock() != Blocks.hellrock)
{
return false;
}
else
{
int i = 0;
if (worldIn.getState(position.west()).getBlock() == Blocks.hellrock)
{
++i;
}
if (worldIn.getState(position.east()).getBlock() == Blocks.hellrock)
{
++i;
}
if (worldIn.getState(position.north()).getBlock() == Blocks.hellrock)
{
++i;
}
if (worldIn.getState(position.south()).getBlock() == Blocks.hellrock)
{
++i;
}
if (worldIn.getState(position.down()).getBlock() == Blocks.hellrock)
{
++i;
}
int j = 0;
if (worldIn.isAirBlock(position.west()))
{
++j;
}
if (worldIn.isAirBlock(position.east()))
{
++j;
}
if (worldIn.isAirBlock(position.north()))
{
++j;
}
if (worldIn.isAirBlock(position.south()))
{
++j;
}
if (worldIn.isAirBlock(position.down()))
{
++j;
}
if (!this.field_94524_b && i == 4 && j == 1 || i == 5)
{
worldIn.setState(position, this.field_150553_a.getState(), 2);
worldIn.forceBlockUpdateTick(this.field_150553_a, position, rand);
}
return true;
}
}
}

View file

@ -0,0 +1,62 @@
package server.worldgen.feature;
import common.block.Block;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenIcePath extends FeatureGenerator
{
private Block block = Blocks.packed_ice;
private int basePathWidth;
public WorldGenIcePath(int p_i45454_1_)
{
this.basePathWidth = p_i45454_1_;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
while (worldIn.isAirBlock(position) && position.getY() > 2)
{
position = position.down();
}
if (worldIn.getState(position).getBlock() != Blocks.snow)
{
return false;
}
else
{
int i = rand.zrange(this.basePathWidth - 2) + 2;
int j = 1;
for (int k = position.getX() - i; k <= position.getX() + i; ++k)
{
for (int l = position.getZ() - i; l <= position.getZ() + i; ++l)
{
int i1 = k - position.getX();
int j1 = l - position.getZ();
if (i1 * i1 + j1 * j1 <= i * i)
{
for (int k1 = position.getY() - j; k1 <= position.getY() + j; ++k1)
{
BlockPos blockpos = new BlockPos(k, k1, l);
Block block = worldIn.getState(blockpos).getBlock();
if (block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice)
{
worldIn.setState(blockpos, this.block.getState(), 2);
}
}
}
}
}
return true;
}
}
}

View file

@ -0,0 +1,120 @@
package server.worldgen.feature;
import common.block.Block;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import common.util.ExtMath;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenIceSpike extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
while (worldIn.isAirBlock(position) && position.getY() > 2)
{
position = position.down();
}
if (worldIn.getState(position).getBlock() != Blocks.snow)
{
return false;
}
else
{
position = position.up(rand.zrange(4));
int i = rand.zrange(4) + 7;
int j = i / 4 + rand.zrange(2);
if (j > 1 && rand.zrange(60) == 0)
{
position = position.up(10 + rand.zrange(30));
}
for (int k = 0; k < i; ++k)
{
float f = (1.0F - (float)k / (float)i) * (float)j;
int l = ExtMath.ceilf(f);
for (int i1 = -l; i1 <= l; ++i1)
{
float f1 = (float)ExtMath.absi(i1) - 0.25F;
for (int j1 = -l; j1 <= l; ++j1)
{
float f2 = (float)ExtMath.absi(j1) - 0.25F;
if ((i1 == 0 && j1 == 0 || f1 * f1 + f2 * f2 <= f * f) && (i1 != -l && i1 != l && j1 != -l && j1 != l || rand.floatv() <= 0.75F))
{
Block block = worldIn.getState(position.add(i1, k, j1)).getBlock();
if (block.getMaterial() == Material.air || block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice)
{
this.setBlockAndNotifyAdequately(worldIn, position.add(i1, k, j1), Blocks.packed_ice.getState());
}
if (k != 0 && l > 1)
{
block = worldIn.getState(position.add(i1, -k, j1)).getBlock();
if (block.getMaterial() == Material.air || block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice)
{
this.setBlockAndNotifyAdequately(worldIn, position.add(i1, -k, j1), Blocks.packed_ice.getState());
}
}
}
}
}
}
int k1 = j - 1;
if (k1 < 0)
{
k1 = 0;
}
else if (k1 > 1)
{
k1 = 1;
}
for (int l1 = -k1; l1 <= k1; ++l1)
{
for (int i2 = -k1; i2 <= k1; ++i2)
{
BlockPos blockpos = position.add(l1, -1, i2);
int j2 = 50;
if (Math.abs(l1) == 1 && Math.abs(i2) == 1)
{
j2 = rand.zrange(5);
}
while (blockpos.getY() > 50)
{
Block block1 = worldIn.getState(blockpos).getBlock();
if (block1.getMaterial() != Material.air && block1 != Blocks.dirt && block1 != Blocks.snow && block1 != Blocks.ice && block1 != Blocks.packed_ice)
{
break;
}
this.setBlockAndNotifyAdequately(worldIn, blockpos, Blocks.packed_ice.getState());
blockpos = blockpos.down();
--j2;
if (j2 <= 0)
{
blockpos = blockpos.down(rand.zrange(5) + 1);
j2 = rand.zrange(5);
}
}
}
}
return true;
}
}
}

View file

@ -0,0 +1,60 @@
package server.worldgen.feature;
import common.block.Block;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenSand extends FeatureGenerator
{
private Block block;
/** The maximum radius used when generating a patch of blocks. */
private int radius;
public WorldGenSand(Block p_i45462_1_, int p_i45462_2_)
{
this.block = p_i45462_1_;
this.radius = p_i45462_2_;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
if (!worldIn.getState(position).getBlock().getMaterial().isColdLiquid())
{
return false;
}
else
{
int i = rand.zrange(this.radius - 2) + 2;
int j = 2;
for (int k = position.getX() - i; k <= position.getX() + i; ++k)
{
for (int l = position.getZ() - i; l <= position.getZ() + i; ++l)
{
int i1 = k - position.getX();
int j1 = l - position.getZ();
if (i1 * i1 + j1 * j1 <= i * i)
{
for (int k1 = position.getY() - j; k1 <= position.getY() + j; ++k1)
{
BlockPos blockpos = new BlockPos(k, k1, l);
Block block = worldIn.getState(blockpos).getBlock();
if (block == Blocks.dirt || block == Blocks.grass)
{
worldIn.setState(blockpos, this.block.getState(), 2);
}
}
}
}
}
return true;
}
}
}

View file

@ -0,0 +1,84 @@
package server.worldgen.feature;
import common.block.Block;
import common.entity.Entity;
import common.entity.item.EntityCrystal;
import common.rng.Random;
import common.util.BlockPos;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenSpikes extends FeatureGenerator
{
private final Block base;
private final int maxHeight;
private final int minRadius;
private final int maxRadius;
private final State block;
private final boolean crystals;
public WorldGenSpikes(Block base, int maxHeight, int minRadius, int maxRadius, State placed, boolean crystals)
{
this.base = base;
this.maxHeight = maxHeight;
this.minRadius = minRadius;
this.maxRadius = maxRadius;
this.block = placed;
this.crystals = crystals;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
if (worldIn.isAirBlock(position) && worldIn.getState(position.down()).getBlock() == this.base)
{
int i = rand.zrange(this.maxHeight - 6) + 6;
int j = rand.range(this.minRadius, this.maxRadius);
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int k = position.getX() - j; k <= position.getX() + j; ++k)
{
for (int l = position.getZ() - j; l <= position.getZ() + j; ++l)
{
int i1 = k - position.getX();
int j1 = l - position.getZ();
if (i1 * i1 + j1 * j1 <= j * j + 1 && worldIn.getState(blockpos$mutableblockpos.set(k, position.getY() - 1, l)).getBlock() != this.base)
{
return false;
}
}
}
for (int l1 = position.getY(); l1 < position.getY() + i && l1 < 512; ++l1)
{
for (int i2 = position.getX() - j; i2 <= position.getX() + j; ++i2)
{
for (int j2 = position.getZ() - j; j2 <= position.getZ() + j; ++j2)
{
int k2 = i2 - position.getX();
int k1 = j2 - position.getZ();
if (k2 * k2 + k1 * k1 <= j * j + 1)
{
worldIn.setState(new BlockPos(i2, l1, j2), this.block, 2);
}
}
}
}
if(this.crystals) {
Entity entity = new EntityCrystal(worldIn);
entity.setLocationAndAngles((double)((float)position.getX() + 0.5F), (double)(position.getY() + i), (double)((float)position.getZ() + 0.5F), rand.floatv() * 360.0F, 0.0F);
worldIn.spawnEntityInWorld(entity);
// if(worldIn.dimension.getDimensionId() == 1)
// worldIn.setBlockState(position.up(i), Blocks.obsidian.getDefaultState(), 2);
}
return true;
}
else
{
return false;
}
}
}

View file

@ -0,0 +1,35 @@
package server.worldgen.foliage;
import common.block.BlockDoublePlant;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
public class FeatureDoublePlant
{
private BlockDoublePlant.EnumPlantType type;
public void setPlantType(BlockDoublePlant.EnumPlantType type)
{
this.type = type;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
boolean flag = false;
for (int i = 0; i < 64; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 254) && Blocks.double_plant.canPlaceBlockAt(worldIn, blockpos))
{
Blocks.double_plant.placeAt(worldIn, blockpos, this.type, 2);
flag = true;
}
}
return flag;
}
}

View file

@ -0,0 +1,223 @@
package server.worldgen.foliage;
import common.block.Block;
import common.block.BlockHugeMushroom;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenBigMushroom extends FeatureGenerator
{
/** The mushroom type. 0 for brown, 1 for red. */
private Block mushroomType;
public WorldGenBigMushroom(Block p_i46449_1_)
{
super(true);
this.mushroomType = p_i46449_1_;
}
public WorldGenBigMushroom()
{
super(false);
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
// if (this.mushroomType == null)
// {
this.mushroomType = rand.chance() ? Blocks.brown_mushroom_block : Blocks.red_mushroom_block;
// }
int i = rand.zrange(3) + 4;
boolean flag = true;
if (position.getY() >= 1 && position.getY() + i + 1 < 512)
{
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
{
int k = 3;
if (j <= position.getY() + 3)
{
k = 0;
}
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
{
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
{
if (j >= 0 && j < 512)
{
Block block = worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock();
if (block.getMaterial() != Material.air && block.getMaterial() != Material.leaves)
{
flag = false;
}
}
else
{
flag = false;
}
}
}
}
if (!flag)
{
return false;
}
else
{
Block block1 = worldIn.getState(position.down()).getBlock();
if (block1 != Blocks.dirt && block1 != Blocks.grass && block1 != Blocks.mycelium)
{
return false;
}
else
{
int k2 = position.getY() + i;
if (this.mushroomType == Blocks.red_mushroom_block)
{
k2 = position.getY() + i - 3;
}
for (int l2 = k2; l2 <= position.getY() + i; ++l2)
{
int j3 = 1;
if (l2 < position.getY() + i)
{
++j3;
}
if (this.mushroomType == Blocks.brown_mushroom_block)
{
j3 = 3;
}
int k3 = position.getX() - j3;
int l3 = position.getX() + j3;
int j1 = position.getZ() - j3;
int k1 = position.getZ() + j3;
for (int l1 = k3; l1 <= l3; ++l1)
{
for (int i2 = j1; i2 <= k1; ++i2)
{
int j2 = 5;
if (l1 == k3)
{
--j2;
}
else if (l1 == l3)
{
++j2;
}
if (i2 == j1)
{
j2 -= 3;
}
else if (i2 == k1)
{
j2 += 3;
}
BlockHugeMushroom.EnumType blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.byMetadata(j2);
if (this.mushroomType == Blocks.brown_mushroom_block || l2 < position.getY() + i)
{
if ((l1 == k3 || l1 == l3) && (i2 == j1 || i2 == k1))
{
continue;
}
if (l1 == position.getX() - (j3 - 1) && i2 == j1)
{
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
}
if (l1 == k3 && i2 == position.getZ() - (j3 - 1))
{
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
}
if (l1 == position.getX() + (j3 - 1) && i2 == j1)
{
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
}
if (l1 == l3 && i2 == position.getZ() - (j3 - 1))
{
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
}
if (l1 == position.getX() - (j3 - 1) && i2 == k1)
{
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
}
if (l1 == k3 && i2 == position.getZ() + (j3 - 1))
{
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
}
if (l1 == position.getX() + (j3 - 1) && i2 == k1)
{
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
}
if (l1 == l3 && i2 == position.getZ() + (j3 - 1))
{
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
}
}
if (blockhugemushroom$enumtype == BlockHugeMushroom.EnumType.CENTER && l2 < position.getY() + i)
{
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.ALL_INSIDE;
}
if (position.getY() >= position.getY() + i - 1 || blockhugemushroom$enumtype != BlockHugeMushroom.EnumType.ALL_INSIDE)
{
BlockPos blockpos = new BlockPos(l1, l2, i2);
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.mushroomType.getState().withProperty(BlockHugeMushroom.VARIANT, blockhugemushroom$enumtype));
}
}
}
}
}
for (int i3 = 0; i3 < i; ++i3)
{
Block block2 = worldIn.getState(position.up(i3)).getBlock();
if (!block2.isFullBlock())
{
this.setBlockAndNotifyAdequately(worldIn, position.up(i3), this.mushroomType.getState().withProperty(BlockHugeMushroom.VARIANT, BlockHugeMushroom.EnumType.STEM));
}
}
return true;
}
}
}
else
{
return false;
}
}
}

View file

@ -0,0 +1,33 @@
package server.worldgen.foliage;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenCactus extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 10; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
if (worldIn.isAirBlock(blockpos))
{
int j = 1 + rand.zrange(rand.zrange(3) + 1);
for (int k = 0; k < j; ++k)
{
if (Blocks.cactus.canBlockStay(worldIn, blockpos))
{
worldIn.setState(blockpos.up(k), Blocks.cactus.getState(), 2);
}
}
}
}
return true;
}
}

View file

@ -0,0 +1,34 @@
package server.worldgen.foliage;
import common.block.Block;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenDeadBush extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
Block block;
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
{
position = position.down();
}
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
if (worldIn.isAirBlock(blockpos) && Blocks.deadbush.canBlockStay(worldIn, blockpos, Blocks.deadbush.getState()))
{
worldIn.setState(blockpos, Blocks.deadbush.getState(), 2);
}
}
return true;
}
}

View file

@ -0,0 +1,40 @@
package server.worldgen.foliage;
import common.block.BlockFlower;
import common.rng.Random;
import common.util.BlockPos;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenFlowers extends FeatureGenerator
{
private BlockFlower flower;
private State field_175915_b;
public WorldGenFlowers(BlockFlower p_i45632_1_, BlockFlower.EnumFlowerType p_i45632_2_)
{
this.setGeneratedBlock(p_i45632_1_, p_i45632_2_);
}
public void setGeneratedBlock(BlockFlower p_175914_1_, BlockFlower.EnumFlowerType p_175914_2_)
{
this.flower = p_175914_1_;
this.field_175915_b = p_175914_1_.getState().withProperty(p_175914_1_.getTypeProperty(), p_175914_2_);
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 64; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.flower.canBlockStay(worldIn, blockpos, this.field_175915_b))
{
worldIn.setState(blockpos, this.field_175915_b, 2);
}
}
return true;
}
}

View file

@ -0,0 +1,25 @@
package server.worldgen.foliage;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenMelon extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 64; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
if (Blocks.melon_block.canPlaceBlockAt(worldIn, blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass)
{
worldIn.setState(blockpos, Blocks.melon_block.getState(), 2);
}
}
return true;
}
}

View file

@ -0,0 +1,32 @@
package server.worldgen.foliage;
import common.block.BlockBush;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenMushroom extends FeatureGenerator
{
private BlockBush field_175908_a;
public WorldGenMushroom(BlockBush p_i45633_1_)
{
this.field_175908_a = p_i45633_1_;
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 64; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.field_175908_a.canBlockStay(worldIn, blockpos, this.field_175908_a.getState()))
{
worldIn.setState(blockpos, this.field_175908_a.getState(), 2);
}
}
return true;
}
}

View file

@ -0,0 +1,27 @@
package server.worldgen.foliage;
import common.block.BlockPumpkin;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenPumpkin extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 64; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
if (worldIn.isAirBlock(blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass && Blocks.pumpkin.canPlaceBlockAt(worldIn, blockpos))
{
worldIn.setState(blockpos, Blocks.pumpkin.getState().withProperty(BlockPumpkin.FACING, Facing.Plane.HORIZONTAL.random(rand)), 2);
}
}
return true;
}
}

View file

@ -0,0 +1,39 @@
package server.worldgen.foliage;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenReed extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 20; ++i)
{
BlockPos blockpos = position.add(rand.zrange(4) - rand.zrange(4), 0, rand.zrange(4) - rand.zrange(4));
if (worldIn.isAirBlock(blockpos))
{
BlockPos blockpos1 = blockpos.down();
if (worldIn.getState(blockpos1.west()).getBlock().getMaterial() == Material.water || worldIn.getState(blockpos1.east()).getBlock().getMaterial() == Material.water || worldIn.getState(blockpos1.north()).getBlock().getMaterial() == Material.water || worldIn.getState(blockpos1.south()).getBlock().getMaterial() == Material.water)
{
int j = 2 + rand.zrange(rand.zrange(3) + 1);
for (int k = 0; k < j; ++k)
{
if (Blocks.reeds.canBlockStay(worldIn, blockpos))
{
worldIn.setState(blockpos.up(k), Blocks.reeds.getState(), 2);
}
}
}
}
}
return true;
}
}

View file

@ -0,0 +1,70 @@
package server.worldgen.foliage;
import common.block.Block;
import common.block.BlockLeaves;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.tree.WorldGenBaseTree;
public class WorldGenShrub extends WorldGenBaseTree
{
private final State leavesMetadata;
private final State woodMetadata;
public WorldGenShrub(State log, State leaves)
{
super(false);
this.woodMetadata = log;
this.leavesMetadata = leaves.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
Block block;
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
{
position = position.down();
}
Block block1 = worldIn.getState(position).getBlock();
if (block1 == Blocks.dirt || block1 == Blocks.grass)
{
position = position.up();
this.setBlockAndNotifyAdequately(worldIn, position, this.woodMetadata);
for (int i = position.getY(); i <= position.getY() + 2; ++i)
{
int j = i - position.getY();
int k = 2 - j;
for (int l = position.getX() - k; l <= position.getX() + k; ++l)
{
int i1 = l - position.getX();
for (int j1 = position.getZ() - k; j1 <= position.getZ() + k; ++j1)
{
int k1 = j1 - position.getZ();
if (Math.abs(i1) != k || Math.abs(k1) != k || rand.zrange(2) != 0)
{
BlockPos blockpos = new BlockPos(l, i, j1);
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
}
}
}
}
}
}
return true;
}
}

View file

@ -0,0 +1,43 @@
package server.worldgen.foliage;
import common.block.Block;
import common.block.BlockTallGrass;
import common.init.Blocks;
import common.material.Material;
import common.rng.Random;
import common.util.BlockPos;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenTallGrass extends FeatureGenerator
{
private final State tallGrassState;
public WorldGenTallGrass(BlockTallGrass.EnumType p_i45629_1_)
{
this.tallGrassState = Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, p_i45629_1_);
}
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
Block block;
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
{
position = position.down();
}
for (int i = 0; i < 128; ++i)
{
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
if (worldIn.isAirBlock(blockpos) && Blocks.tallgrass.canBlockStay(worldIn, blockpos, this.tallGrassState))
{
worldIn.setState(blockpos, this.tallGrassState, 2);
}
}
return true;
}
}

View file

@ -0,0 +1,38 @@
package server.worldgen.foliage;
import common.block.BlockVine;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenVines extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
for (; position.getY() < 128; position = position.up())
{
if (worldIn.isAirBlock(position))
{
for (Facing enumfacing : Facing.Plane.HORIZONTAL.facings())
{
if (Blocks.vine.canPlaceBlockOnSide(worldIn, position, enumfacing))
{
State iblockstate = Blocks.vine.getState().withProperty(BlockVine.NORTH, Boolean.valueOf(enumfacing == Facing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(enumfacing == Facing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(enumfacing == Facing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(enumfacing == Facing.WEST));
worldIn.setState(position, iblockstate, 2);
break;
}
}
}
else
{
position = position.add(rand.zrange(4) - rand.zrange(4), 0, rand.zrange(4) - rand.zrange(4));
}
}
return true;
}
}

View file

@ -0,0 +1,29 @@
package server.worldgen.foliage;
import common.block.BlockDirectional;
import common.init.Blocks;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import server.world.WorldServer;
import server.worldgen.FeatureGenerator;
public class WorldGenWaterlily extends FeatureGenerator
{
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 10; ++i)
{
int j = position.getX() + rand.zrange(8) - rand.zrange(8);
int k = position.getY() + rand.zrange(4) - rand.zrange(4);
int l = position.getZ() + rand.zrange(8) - rand.zrange(8);
if (worldIn.isAirBlock(new BlockPos(j, k, l)) && Blocks.waterlily.canPlaceBlockAt(worldIn, new BlockPos(j, k, l)))
{
worldIn.setState(new BlockPos(j, k, l), Blocks.waterlily.getState().withProperty(BlockDirectional.FACING, Facing.randHorizontal(rand)), 2);
}
}
return true;
}
}

View file

@ -0,0 +1,96 @@
package server.worldgen.layer;
import common.biome.BaseBiome;
import server.biome.Biome;
public abstract class GenLayer {
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 Biome biome1 = Biome.getBiome(id1);
final Biome biome2 = Biome.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 == BaseBiome.SEA.id || id == BaseBiome.FROZENSEA.id;
}
public GenLayer(long base) {
this.baseSeed = base;
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
this.baseSeed += base;
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
this.baseSeed += base;
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
this.baseSeed += base;
}
public abstract int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight);
public void initWorldGenSeed(long seed) {
this.worldGenSeed = seed;
if(this.parent != null) {
this.parent.initWorldGenSeed(seed);
}
this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L;
this.worldGenSeed += this.baseSeed;
this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L;
this.worldGenSeed += this.baseSeed;
this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L;
this.worldGenSeed += this.baseSeed;
}
public void initChunkSeed(long x, long z) {
this.chunkSeed = this.worldGenSeed;
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
this.chunkSeed += x;
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
this.chunkSeed += z;
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
this.chunkSeed += x;
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
this.chunkSeed += z;
}
protected int nextInt(int range) {
int i = (int)((this.chunkSeed >> 24) % (long)range);
if(i < 0) {
i += range;
}
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
this.chunkSeed += this.worldGenSeed;
return i;
}
protected int getRandom(int... ids) {
return ids[this.nextInt(ids.length)];
}
protected int getFrequent(int a, int b, int c, int d) {
return
b == c && c == d ? b :
(a == b && a == c ? a :
(a == b && a == d ? a :
(a == c && a == d ? a :
(a == b && c != d ? a :
(a == c && b != d ? a :
(a == d && b != c ? a :
(b == c && a != d ? b :
(b == d && a != c ? b :
(c == d && a != b ? c :
this.getRandom(a, b, c, d)
)))))))));
}
}

View file

@ -0,0 +1,103 @@
package server.worldgen.layer;
public class GenLayerAddAreas extends GenLayer
{
public GenLayerAddAreas(long p_i2119_1_, GenLayer p_i2119_3_)
{
super(p_i2119_1_);
this.parent = p_i2119_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 i = areaX - 1;
int j = areaY - 1;
int k = areaWidth + 2;
int l = areaHeight + 2;
int[] aint = this.parent.getInts(i, j, k, l);
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
for (int i1 = 0; i1 < areaHeight; ++i1)
{
for (int j1 = 0; j1 < areaWidth; ++j1)
{
int k1 = aint[j1 + 0 + (i1 + 0) * k];
int l1 = aint[j1 + 2 + (i1 + 0) * k];
int i2 = aint[j1 + 0 + (i1 + 2) * k];
int j2 = aint[j1 + 2 + (i1 + 2) * k];
int k2 = aint[j1 + 1 + (i1 + 1) * k];
this.initChunkSeed((long)(j1 + areaX), (long)(i1 + areaY));
if (k2 != 0 || k1 == 0 && l1 == 0 && i2 == 0 && j2 == 0)
{
if (k2 > 0 && (k1 == 0 || l1 == 0 || i2 == 0 || j2 == 0))
{
if (this.nextInt(5) == 0)
{
if (k2 == 4)
{
aint1[j1 + i1 * areaWidth] = 4;
}
else
{
aint1[j1 + i1 * areaWidth] = 0;
}
}
else
{
aint1[j1 + i1 * areaWidth] = k2;
}
}
else
{
aint1[j1 + i1 * areaWidth] = k2;
}
}
else
{
int l2 = 1;
int i3 = 1;
if (k1 != 0 && this.nextInt(l2++) == 0)
{
i3 = k1;
}
if (l1 != 0 && this.nextInt(l2++) == 0)
{
i3 = l1;
}
if (i2 != 0 && this.nextInt(l2++) == 0)
{
i3 = i2;
}
if (j2 != 0 && this.nextInt(l2++) == 0)
{
i3 = j2;
}
if (this.nextInt(3) == 0)
{
aint1[j1 + i1 * areaWidth] = i3;
}
else if (i3 == 4)
{
aint1[j1 + i1 * areaWidth] = 4;
}
else
{
aint1[j1 + i1 * areaWidth] = 0;
}
}
}
}
return aint1;
}
}

View file

@ -0,0 +1,54 @@
package server.worldgen.layer;
import common.biome.BaseBiome;
public class GenLayerAddExtra extends GenLayer
{
private final int[] biomes;
private final int rarity;
public GenLayerAddExtra(long base, GenLayer parent, BaseBiome[] biomes, int rarity)
{
super(base);
this.parent = parent;
this.biomes = new int[biomes.length];
for(int z = 0; z < biomes.length; z++) {
this.biomes[z] = biomes[z].id;
}
this.rarity = rarity < 1 ? 1 : rarity;
}
public int[] getInts(int x, int z, int width, int height)
{
int i = x - 1;
int j = z - 1;
int k = width + 2;
int l = height + 2;
int[] pre = this.parent.getInts(i, j, k, l);
int[] data = IntCache.getIntCache(width * height);
for (int i1 = 0; i1 < height; ++i1)
{
for (int j1 = 0; j1 < width; ++j1)
{
int k1 = pre[j1 + 0 + (i1 + 0) * k];
int l1 = pre[j1 + 2 + (i1 + 0) * k];
int i2 = pre[j1 + 0 + (i1 + 2) * k];
int j2 = pre[j1 + 2 + (i1 + 2) * k];
int k2 = pre[j1 + 1 + (i1 + 1) * k];
this.initChunkSeed((long)(j1 + x), (long)(i1 + z));
if (this.biomes.length > 0 && k2 == 0 && k1 < 2 && l1 < 2 && i2 < 2 && j2 < 2 && this.nextInt(this.rarity) == 0)
{
data[j1 + i1 * width] = this.biomes[this.nextInt(this.biomes.length)];
}
else
{
data[j1 + i1 * width] = k2;
}
}
}
return data;
}
}

View file

@ -0,0 +1,74 @@
package server.worldgen.layer;
import common.biome.BaseBiome;
public class GenLayerAddSea extends GenLayer
{
private final int rarity;
public GenLayerAddSea(long p_i45472_1_, GenLayer p_i45472_3_, int rarity)
{
super(p_i45472_1_);
this.parent = p_i45472_3_;
this.rarity = rarity < 1 ? 1 : rarity;
}
/**
* 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 i = areaX - 1;
int j = areaY - 1;
int k = areaWidth + 2;
int l = areaHeight + 2;
int[] aint = this.parent.getInts(i, j, k, l);
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
for (int i1 = 0; i1 < areaHeight; ++i1)
{
for (int j1 = 0; j1 < areaWidth; ++j1)
{
int k1 = aint[j1 + 1 + (i1 + 1 - 1) * (areaWidth + 2)];
int l1 = aint[j1 + 1 + 1 + (i1 + 1) * (areaWidth + 2)];
int i2 = aint[j1 + 1 - 1 + (i1 + 1) * (areaWidth + 2)];
int j2 = aint[j1 + 1 + (i1 + 1 + 1) * (areaWidth + 2)];
int k2 = aint[j1 + 1 + (i1 + 1) * k];
int l2 = 0;
if (k1 == 4)
{
++l2;
}
if (l1 == 4)
{
++l2;
}
if (i2 == 4)
{
++l2;
}
if (j2 == 4)
{
++l2;
}
this.initChunkSeed((long)(areaX + j1), (long)(areaY + i1));
if (k2 == 0 && this.nextInt(this.rarity) == 0)
{
aint1[j1 + i1 * areaWidth] = l2 > 1 ? BaseBiome.FROZENSEA.id : BaseBiome.SEA.id;
}
else
{
aint1[j1 + i1 * areaWidth] = k2;
}
}
}
return aint1;
}
}

View file

@ -0,0 +1,62 @@
package server.worldgen.layer;
public class GenLayerAddSnow extends GenLayer
{
private final int rarity;
public GenLayerAddSnow(long p_i2121_1_, GenLayer p_i2121_3_, int snowRarity)
{
super(p_i2121_1_);
this.parent = p_i2121_3_;
this.rarity = snowRarity < 1 ? 1 : snowRarity;
}
/**
* 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 i = areaX - 1;
int j = areaY - 1;
int k = areaWidth + 2;
int l = areaHeight + 2;
int[] aint = this.parent.getInts(i, j, k, l);
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
for (int i1 = 0; i1 < areaHeight; ++i1)
{
for (int j1 = 0; j1 < areaWidth; ++j1)
{
int k1 = aint[j1 + 1 + (i1 + 1) * k];
this.initChunkSeed((long)(j1 + areaX), (long)(i1 + areaY));
if (k1 == 0)
{
aint1[j1 + i1 * areaWidth] = 0;
}
else
{
int l1 = this.nextInt(this.rarity);
if (l1 == 0)
{
l1 = 4;
}
else if (l1 <= 1)
{
l1 = 3;
}
else
{
l1 = 1;
}
aint1[j1 + i1 * areaWidth] = l1;
}
}
}
return aint1;
}
}

View file

@ -0,0 +1,30 @@
package server.worldgen.layer;
public class GenLayerBase extends GenLayer
{
public GenLayerBase(long base)
{
super(base);
}
public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight)
{
int[] aint = IntCache.getIntCache(areaWidth * areaHeight);
for (int i = 0; i < areaHeight; ++i)
{
for (int j = 0; j < areaWidth; ++j)
{
this.initChunkSeed((long)(areaX + j), (long)(areaY + i));
aint[j + i * areaWidth] = this.nextInt(2);
}
}
if (areaX > -areaWidth && areaX <= 0 && areaY > -areaHeight && areaY <= 0)
{
aint[-areaX + -areaY * areaWidth] = 1;
}
return aint;
}
}

View file

@ -0,0 +1,71 @@
package server.worldgen.layer;
import common.biome.BaseBiome;
public class GenLayerBiome extends GenLayer
{
private final BaseBiome[] hot;
private final BaseBiome[] medium;
private final BaseBiome[] cold;
private final BaseBiome[] frost;
private final int def;
private final int fixed;
public GenLayerBiome(long base, GenLayer parent, BaseBiome[] hot, BaseBiome[] medium, BaseBiome[] cold, BaseBiome[] frost, BaseBiome def, boolean fixed)
{
super(base);
this.parent = parent;
this.def = def.id;
this.fixed = fixed ? def.id : -1;
this.hot = hot;
this.medium = medium;
this.cold = cold;
this.frost = frost;
}
public int[] getInts(int x, int z, int width, int height)
{
int[] pre = this.parent.getInts(x, z, width, height);
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 + i * width];
if (this.fixed >= 0)
{
data[j + i * width] = this.fixed;
}
else if (id == 0 || isSea(id))
{
data[j + i * width] = id;
}
else if (id == 1)
{
data[j + i * width] = this.hot[this.nextInt(this.hot.length)].id;
}
else if (id == 2)
{
data[j + i * width] = this.medium[this.nextInt(this.medium.length)].id;
}
else if (id == 3)
{
data[j + i * width] = this.cold[this.nextInt(this.cold.length)].id;
}
else if (id == 4)
{
data[j + i * width] = this.frost[this.nextInt(this.frost.length)].id;
}
else
{
data[j + i * width] = this.def;
}
}
}
return data;
}
}

View file

@ -0,0 +1,168 @@
package server.worldgen.layer;
import common.biome.BaseBiome;
import server.biome.Biome;
import server.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, BaseBiome.EXTREMEHILLS.id, BaseBiome.EXTREMEHILLSEDGE.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, BaseBiome.MEGATAIGA.id, BaseBiome.TAIGA.id))
{
if (k == BaseBiome.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 != BaseBiome.ICEPLAINS.id && i2 != BaseBiome.ICEPLAINS.id && j2 != BaseBiome.ICEPLAINS.id && k2 != BaseBiome.ICEPLAINS.id)
{
aint1[j + i * areaWidth] = k;
}
else
{
aint1[j + i * areaWidth] = BaseBiome.EXTREMEHILLSPLUS.id;
}
}
else if (k == BaseBiome.SWAMPLAND.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 != BaseBiome.DESERT.id && i1 != BaseBiome.DESERT.id && j1 != BaseBiome.DESERT.id && k1 != BaseBiome.DESERT.id && l != BaseBiome.COLDTAIGA.id && i1 != BaseBiome.COLDTAIGA.id && j1 != BaseBiome.COLDTAIGA.id && k1 != BaseBiome.COLDTAIGA.id && l != BaseBiome.ICEPLAINS.id && i1 != BaseBiome.ICEPLAINS.id && j1 != BaseBiome.ICEPLAINS.id && k1 != BaseBiome.ICEPLAINS.id)
{
if (l != BaseBiome.JUNGLE.id && k1 != BaseBiome.JUNGLE.id && i1 != BaseBiome.JUNGLE.id && j1 != BaseBiome.JUNGLE.id)
{
aint1[j + i * areaWidth] = k;
}
else
{
aint1[j + i * areaWidth] = BaseBiome.JUNGLEEDGE.id;
}
}
else
{
aint1[j + i * areaWidth] = BaseBiome.PLAINS.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
{
Biome biomegenbase = Biome.getBiome(p_151634_1_);
Biome biomegenbase1 = Biome.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;
}
}
}
}

View file

@ -0,0 +1,111 @@
package server.worldgen.layer;
public class GenLayerEdge extends GenLayer
{
private final GenLayerEdge.Mode mode;
public GenLayerEdge(long p_i45474_1_, GenLayer p_i45474_3_, GenLayerEdge.Mode p_i45474_4_)
{
super(p_i45474_1_);
this.parent = p_i45474_3_;
this.mode = p_i45474_4_;
}
/**
* 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)
{
switch (this.mode)
{
case COOL_WARM:
default:
return this.getIntsCoolWarm(areaX, areaY, areaWidth, areaHeight);
case HEAT_ICE:
return this.getIntsHeatIce(areaX, areaY, areaWidth, areaHeight);
}
}
private int[] getIntsCoolWarm(int p_151626_1_, int p_151626_2_, int p_151626_3_, int p_151626_4_)
{
int i = p_151626_1_ - 1;
int j = p_151626_2_ - 1;
int k = 1 + p_151626_3_ + 1;
int l = 1 + p_151626_4_ + 1;
int[] aint = this.parent.getInts(i, j, k, l);
int[] aint1 = IntCache.getIntCache(p_151626_3_ * p_151626_4_);
for (int i1 = 0; i1 < p_151626_4_; ++i1)
{
for (int j1 = 0; j1 < p_151626_3_; ++j1)
{
this.initChunkSeed((long)(j1 + p_151626_1_), (long)(i1 + p_151626_2_));
int k1 = aint[j1 + 1 + (i1 + 1) * k];
if (k1 == 1)
{
int l1 = aint[j1 + 1 + (i1 + 1 - 1) * k];
int i2 = aint[j1 + 1 + 1 + (i1 + 1) * k];
int j2 = aint[j1 + 1 - 1 + (i1 + 1) * k];
int k2 = aint[j1 + 1 + (i1 + 1 + 1) * k];
boolean flag = l1 == 3 || i2 == 3 || j2 == 3 || k2 == 3;
boolean flag1 = l1 == 4 || i2 == 4 || j2 == 4 || k2 == 4;
if (flag || flag1)
{
k1 = 2;
}
}
aint1[j1 + i1 * p_151626_3_] = k1;
}
}
return aint1;
}
private int[] getIntsHeatIce(int p_151624_1_, int p_151624_2_, int p_151624_3_, int p_151624_4_)
{
int i = p_151624_1_ - 1;
int j = p_151624_2_ - 1;
int k = 1 + p_151624_3_ + 1;
int l = 1 + p_151624_4_ + 1;
int[] aint = this.parent.getInts(i, j, k, l);
int[] aint1 = IntCache.getIntCache(p_151624_3_ * p_151624_4_);
for (int i1 = 0; i1 < p_151624_4_; ++i1)
{
for (int j1 = 0; j1 < p_151624_3_; ++j1)
{
int k1 = aint[j1 + 1 + (i1 + 1) * k];
if (k1 == 4)
{
int l1 = aint[j1 + 1 + (i1 + 1 - 1) * k];
int i2 = aint[j1 + 1 + 1 + (i1 + 1) * k];
int j2 = aint[j1 + 1 - 1 + (i1 + 1) * k];
int k2 = aint[j1 + 1 + (i1 + 1 + 1) * k];
boolean flag = l1 == 2 || i2 == 2 || j2 == 2 || k2 == 2;
boolean flag1 = l1 == 1 || i2 == 1 || j2 == 1 || k2 == 1;
if (flag1 || flag)
{
k1 = 3;
}
}
aint1[j1 + i1 * p_151624_3_] = k1;
}
}
return aint1;
}
public static enum Mode
{
COOL_WARM,
HEAT_ICE;
}
}

View file

@ -0,0 +1,17 @@
package server.worldgen.layer;
public class GenLayerFuzzyZoom extends GenLayerZoom
{
public GenLayerFuzzyZoom(long p_i2123_1_, GenLayer p_i2123_3_)
{
super(p_i2123_1_, p_i2123_3_);
}
/**
* returns the most frequently occurring number of the set, or a random number from those provided
*/
protected int getFrequent(int p_151617_1_, int p_151617_2_, int p_151617_3_, int p_151617_4_)
{
return this.getRandom(p_151617_1_, p_151617_2_, p_151617_3_, p_151617_4_);
}
}

View file

@ -0,0 +1,198 @@
package server.worldgen.layer;
import common.biome.BaseBiome;
import common.log.Log;
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_, BaseBiome 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.JNI.warn("Altes Biom (" + k + ")!");
}
if (k != 0 && l >= 2 && (l - 2) % 29 == 1 && k < 128)
{
if (BaseBiome.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 == BaseBiome.DESERT.id)
{
i1 = BaseBiome.DESERTHILLS.id;
}
else if (k == BaseBiome.FOREST.id)
{
i1 = BaseBiome.FORESTHILLS.id;
}
else if (k == BaseBiome.BIRCHFOREST.id)
{
i1 = BaseBiome.BIRCHFORESTHILLS.id;
}
else if (k == BaseBiome.ROOFEDFOREST.id)
{
i1 = BaseBiome.PLAINS.id;
}
else if (k == BaseBiome.TAIGA.id)
{
i1 = BaseBiome.TAIGAHILLS.id;
}
else if (k == BaseBiome.MEGATAIGA.id)
{
i1 = BaseBiome.MEGATAIGAHILLS.id;
}
else if (k == BaseBiome.COLDTAIGA.id)
{
i1 = BaseBiome.COLDTAIGAHILLS.id;
}
else if (k == BaseBiome.PLAINS.id)
{
if (this.nextInt(3) == 0)
{
i1 = BaseBiome.FORESTHILLS.id;
}
else
{
i1 = BaseBiome.FOREST.id;
}
}
else if (k == BaseBiome.ICEPLAINS.id)
{
i1 = BaseBiome.ICEMOUNTAINS.id;
}
else if (k == BaseBiome.JUNGLE.id)
{
i1 = BaseBiome.JUNGLEHILLS.id;
}
else if (k == BaseBiome.NONE.id)
{
i1 = this.def;
}
else if (k == BaseBiome.EXTREMEHILLS.id)
{
i1 = BaseBiome.EXTREMEHILLSPLUS.id;
}
else if (k == BaseBiome.SAVANNA.id)
{
i1 = BaseBiome.SAVANNAPLATEAU.id;
}
// else if (canBeNearby(k, Biome.mesaPlateau_F.id))
// {
// i1 = Biome.mesa.id;
// }
else if (k == BaseBiome.SEA.id && this.nextInt(3) == 0)
{
int j1 = this.nextInt(2);
if (j1 == 0)
{
i1 = BaseBiome.PLAINS.id;
}
else
{
i1 = BaseBiome.FOREST.id;
}
}
if (flag && i1 != k)
{
if (BaseBiome.getBiome(i1 + 128) != null)
{
i1 += 128;
}
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;
}
}

View file

@ -0,0 +1,45 @@
package server.worldgen.layer;
public class GenLayerRemoveEmpty extends GenLayer
{
public GenLayerRemoveEmpty(long p_i45480_1_, GenLayer p_i45480_3_)
{
super(p_i45480_1_);
this.parent = p_i45480_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 i = areaX - 1;
int j = areaY - 1;
int k = areaWidth + 2;
int l = areaHeight + 2;
int[] aint = this.parent.getInts(i, j, k, l);
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
for (int i1 = 0; i1 < areaHeight; ++i1)
{
for (int j1 = 0; j1 < areaWidth; ++j1)
{
int k1 = aint[j1 + 1 + (i1 + 1 - 1) * (areaWidth + 2)];
int l1 = aint[j1 + 1 + 1 + (i1 + 1) * (areaWidth + 2)];
int i2 = aint[j1 + 1 - 1 + (i1 + 1) * (areaWidth + 2)];
int j2 = aint[j1 + 1 + (i1 + 1 + 1) * (areaWidth + 2)];
int k2 = aint[j1 + 1 + (i1 + 1) * k];
aint1[j1 + i1 * areaWidth] = k2;
this.initChunkSeed((long)(j1 + areaX), (long)(i1 + areaY));
if (k2 == 0 && k1 == 0 && l1 == 0 && i2 == 0 && j2 == 0 && this.nextInt(2) == 0)
{
aint1[j1 + i1 * areaWidth] = 1;
}
}
}
return aint1;
}
}

View file

@ -0,0 +1,54 @@
package server.worldgen.layer;
import common.biome.BaseBiome;
public class GenLayerRiver extends GenLayer
{
public GenLayerRiver(long p_i2128_1_, GenLayer p_i2128_3_)
{
super(p_i2128_1_);
super.parent = p_i2128_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 i = areaX - 1;
int j = areaY - 1;
int k = areaWidth + 2;
int l = areaHeight + 2;
int[] aint = this.parent.getInts(i, j, k, l);
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
for (int i1 = 0; i1 < areaHeight; ++i1)
{
for (int j1 = 0; j1 < areaWidth; ++j1)
{
int k1 = this.func_151630_c(aint[j1 + 0 + (i1 + 1) * k]);
int l1 = this.func_151630_c(aint[j1 + 2 + (i1 + 1) * k]);
int i2 = this.func_151630_c(aint[j1 + 1 + (i1 + 0) * k]);
int j2 = this.func_151630_c(aint[j1 + 1 + (i1 + 2) * k]);
int k2 = this.func_151630_c(aint[j1 + 1 + (i1 + 1) * k]);
if (k2 == k1 && k2 == i2 && k2 == l1 && k2 == j2)
{
aint1[j1 + i1 * areaWidth] = -1;
}
else
{
aint1[j1 + i1 * areaWidth] = BaseBiome.RIVER.id;
}
}
}
return aint1;
}
private int func_151630_c(int p_151630_1_)
{
return p_151630_1_ >= 2 ? 2 + (p_151630_1_ & 1) : p_151630_1_;
}
}

Some files were not shown because too many files have changed in this diff Show more