223 lines
9.3 KiB
Java
Executable file
223 lines
9.3 KiB
Java
Executable file
package server.biome;
|
|
|
|
import common.biome.Biome;
|
|
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 GenBiome
|
|
{
|
|
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(Biome 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 GenBiome createMutatedBiome(Biome base)
|
|
{
|
|
if (this.base == Biome.FOREST)
|
|
{
|
|
BiomeForest biomegenforest = new BiomeForest(base, 1);
|
|
biomegenforest.setScaling(this.depth, this.scale + 0.2F);
|
|
return biomegenforest;
|
|
}
|
|
else
|
|
{
|
|
return this.base != Biome.BIRCHFOREST && this.base != Biome.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;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|