Merge branch 'master' of https://github.com/paulevsGitch/BetterEnd
This commit is contained in:
commit
6410088aaa
8 changed files with 173 additions and 39 deletions
|
@ -10,10 +10,12 @@ import ru.betterend.world.features.BlueVineFeature;
|
||||||
import ru.betterend.world.features.DoublePlantFeature;
|
import ru.betterend.world.features.DoublePlantFeature;
|
||||||
import ru.betterend.world.features.EndFeature;
|
import ru.betterend.world.features.EndFeature;
|
||||||
import ru.betterend.world.features.EndLakeFeature;
|
import ru.betterend.world.features.EndLakeFeature;
|
||||||
|
import ru.betterend.world.features.EndLilyFeature;
|
||||||
import ru.betterend.world.features.MossyGlowshroomFeature;
|
import ru.betterend.world.features.MossyGlowshroomFeature;
|
||||||
import ru.betterend.world.features.PythadendronBushFeature;
|
import ru.betterend.world.features.PythadendronBushFeature;
|
||||||
import ru.betterend.world.features.PythadendronTreeFeature;
|
import ru.betterend.world.features.PythadendronTreeFeature;
|
||||||
import ru.betterend.world.features.SinglePlantFeature;
|
import ru.betterend.world.features.SinglePlantFeature;
|
||||||
|
import ru.betterend.world.features.UnderwaterPlantFeature;
|
||||||
import ru.betterend.world.features.VineFeature;
|
import ru.betterend.world.features.VineFeature;
|
||||||
|
|
||||||
public class FeatureRegistry {
|
public class FeatureRegistry {
|
||||||
|
@ -35,6 +37,9 @@ public class FeatureRegistry {
|
||||||
|
|
||||||
public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(BlockRegistry.DENSE_VINE, 24), 3);
|
public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(BlockRegistry.DENSE_VINE, 24), 3);
|
||||||
|
|
||||||
|
public static final EndFeature BUBBLE_CORAL = new EndFeature("bubble_coral", new UnderwaterPlantFeature(BlockRegistry.BUBBLE_CORAL, 4), 20);
|
||||||
|
public static final EndFeature END_LILY = new EndFeature("end_lily", new EndLilyFeature(5), 20);
|
||||||
|
|
||||||
// Features //
|
// Features //
|
||||||
public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4);
|
public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4);
|
||||||
public static final EndFeature RARE_END_LAKE = EndFeature.makeLakeFeature("rare_end_lake", new EndLakeFeature(), 40);
|
public static final EndFeature RARE_END_LAKE = EndFeature.makeLakeFeature("rare_end_lake", new EndLakeFeature(), 40);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.FallingBlock;
|
import net.minecraft.block.FallingBlock;
|
||||||
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.Property;
|
import net.minecraft.state.property.Property;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tag.BlockTags;
|
||||||
|
@ -138,8 +139,8 @@ public class BlocksHelper {
|
||||||
POS.setY(y);
|
POS.setY(y);
|
||||||
state = world.getBlockState(POS);
|
state = world.getBlockState(POS);
|
||||||
|
|
||||||
// Liquids
|
// Liquids & water plants
|
||||||
if (!state.getFluidState().isEmpty()) {
|
if (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.UNDERWATER_PLANT) || state.getMaterial().equals(Material.REPLACEABLE_UNDERWATER_PLANT)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Falling blocks
|
// Falling blocks
|
||||||
|
|
|
@ -28,6 +28,8 @@ public class BiomeFoggyMushroomland extends EndBiome {
|
||||||
.addFeature(FeatureRegistry.UMBRELLA_MOSS)
|
.addFeature(FeatureRegistry.UMBRELLA_MOSS)
|
||||||
.addFeature(FeatureRegistry.CREEPING_MOSS)
|
.addFeature(FeatureRegistry.CREEPING_MOSS)
|
||||||
.addFeature(FeatureRegistry.DENSE_VINE)
|
.addFeature(FeatureRegistry.DENSE_VINE)
|
||||||
|
.addFeature(FeatureRegistry.END_LILY)
|
||||||
|
.addFeature(FeatureRegistry.BUBBLE_CORAL)
|
||||||
.addMobSpawn(EntityRegistry.DRAGONFLY, 80, 2, 5)
|
.addMobSpawn(EntityRegistry.DRAGONFLY, 80, 2, 5)
|
||||||
.addMobSpawn(EntityRegistry.END_SLIME, 10, 1, 2)
|
.addMobSpawn(EntityRegistry.END_SLIME, 10, 1, 2)
|
||||||
.addMobSpawn(EntityType.ENDERMAN, 10, 1, 2));
|
.addMobSpawn(EntityType.ENDERMAN, 10, 1, 2));
|
||||||
|
|
|
@ -9,18 +9,13 @@ import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.util.math.BlockPos.Mutable;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.WorldAccess;
|
|
||||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||||
import ru.betterend.blocks.BlockEndLily;
|
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
|
||||||
import ru.betterend.noise.OpenSimplexNoise;
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
import ru.betterend.registry.BiomeRegistry;
|
|
||||||
import ru.betterend.registry.BlockRegistry;
|
import ru.betterend.registry.BlockRegistry;
|
||||||
import ru.betterend.registry.BlockTagRegistry;
|
import ru.betterend.registry.BlockTagRegistry;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
import ru.betterend.world.biome.EndBiome;
|
|
||||||
|
|
||||||
public class EndLakeFeature extends DefaultFeature {
|
public class EndLakeFeature extends DefaultFeature {
|
||||||
private static final BlockState END_STONE = Blocks.END_STONE.getDefaultState();
|
private static final BlockState END_STONE = Blocks.END_STONE.getDefaultState();
|
||||||
|
@ -160,30 +155,24 @@ public class EndLakeFeature extends DefaultFeature {
|
||||||
if (y2 + x2 + z2 <= r) {
|
if (y2 + x2 + z2 <= r) {
|
||||||
state = world.getBlockState(POS);
|
state = world.getBlockState(POS);
|
||||||
if (canReplace(state)) {
|
if (canReplace(state)) {
|
||||||
BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR);
|
state = world.getBlockState(POS.up());
|
||||||
if (y == waterLevel - 1) {
|
state = canReplace(state) ? (y < waterLevel ? WATER : AIR) : state;
|
||||||
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
|
BlocksHelper.setWithoutUpdate(world, POS, state);
|
||||||
|
if (y == waterLevel - 1 && !state.getFluidState().isEmpty()) {
|
||||||
|
world.getFluidTickScheduler().schedule(POS, state.getFluidState().getFluid(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos = POS.down();
|
pos = POS.down();
|
||||||
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||||
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
|
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
|
||||||
if (random.nextInt(3) == 0 && pos.getY() < waterLevel - 1) {
|
|
||||||
EndBiome biome = BiomeRegistry.getFromBiome(world.getBiome(POS));
|
|
||||||
if (biome == BiomeRegistry.FOGGY_MUSHROOMLAND) {
|
|
||||||
generateFoggyMushroomland(world, x, z, waterLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pos = POS.up();
|
pos = POS.up();
|
||||||
if (canReplace(world.getBlockState(pos))) {
|
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) {
|
||||||
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) {
|
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
|
if (y == waterLevel - 1) {
|
||||||
if (y == waterLevel - 1) {
|
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
|
||||||
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
|
|
||||||
}
|
|
||||||
pos = pos.up();
|
|
||||||
}
|
}
|
||||||
|
pos = pos.up();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Make border
|
// Make border
|
||||||
|
@ -210,7 +199,7 @@ public class EndLakeFeature extends DefaultFeature {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateFoggyMushroomland(WorldAccess world, int x, int z, int waterLevel) {
|
/*private void generateFoggyMushroomland(WorldAccess world, int x, int z, int waterLevel) {
|
||||||
if (NOISE.eval(x * 0.1, z * 0.1, 0) > 0) {
|
if (NOISE.eval(x * 0.1, z * 0.1, 0) > 0) {
|
||||||
BlocksHelper.setWithoutUpdate(world, POS, BlockRegistry.BUBBLE_CORAL.getDefaultState());
|
BlocksHelper.setWithoutUpdate(world, POS, BlockRegistry.BUBBLE_CORAL.getDefaultState());
|
||||||
}
|
}
|
||||||
|
@ -223,7 +212,7 @@ public class EndLakeFeature extends DefaultFeature {
|
||||||
}
|
}
|
||||||
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.TOP));
|
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.TOP));
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private boolean canReplace(BlockState state) {
|
private boolean canReplace(BlockState state) {
|
||||||
return state.getMaterial().isReplaceable()
|
return state.getMaterial().isReplaceable()
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package ru.betterend.world.features;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
|
import ru.betterend.blocks.BlockEndLilySeed;
|
||||||
|
import ru.betterend.registry.BlockRegistry;
|
||||||
|
|
||||||
|
public class EndLilyFeature extends UnderwaterPlantScatter {
|
||||||
|
public EndLilyFeature(int radius) {
|
||||||
|
super(radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||||
|
BlockEndLilySeed seed = (BlockEndLilySeed) BlockRegistry.END_LILY_SEED;
|
||||||
|
seed.grow(world, random, blockPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getChance() {
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,20 +23,44 @@ public abstract class ScatterFeature extends DefaultFeature {
|
||||||
|
|
||||||
public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos);
|
public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos);
|
||||||
|
|
||||||
|
protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) {
|
||||||
|
return getPosOnSurfaceWG(world, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos) {
|
||||||
|
if (pos.getY() < 5) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean getGroundPlant(StructureWorldAccess world, Mutable pos) {
|
||||||
|
int down = BlocksHelper.downRay(world, pos, 16);
|
||||||
|
if (down > 10) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pos.setY(pos.getY() - down);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getYOffset() {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getChance() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||||
center = getPosOnSurfaceWG(world, center);
|
center = getCenterGround(world, center);
|
||||||
|
|
||||||
if (center.getY() < 5) {
|
if (!canSpawn(world, center)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!world.getBlockState(center.down()).isIn(BlockTagRegistry.END_GROUND)) {
|
|
||||||
//center = getPosOnSurfaceRaycast(world, new BlockPos(center.getX(), 72, center.getZ()), 72);
|
|
||||||
//if (center.getY() < 5 || !world.getBlockState(center.down()).isIn(BlockTagRegistry.END_GROUND)) {
|
|
||||||
return false;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
float r = MHelper.randRange(radius * 0.5F, radius, random);
|
float r = MHelper.randRange(radius * 0.5F, radius, random);
|
||||||
int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random));
|
int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random));
|
||||||
|
@ -46,12 +70,8 @@ public abstract class ScatterFeature extends DefaultFeature {
|
||||||
float x = pr * (float) Math.cos(theta);
|
float x = pr * (float) Math.cos(theta);
|
||||||
float z = pr * (float) Math.sin(theta);
|
float z = pr * (float) Math.sin(theta);
|
||||||
|
|
||||||
POS.set(center.getX() + x, center.getY() + 5, center.getZ() + z);
|
POS.set(center.getX() + x, center.getY() + getYOffset(), center.getZ() + z);
|
||||||
int down = BlocksHelper.downRay(world, POS, 16);
|
if (getGroundPlant(world, POS) && canGenerate(world, random, center, POS, r) && (getChance() < 2 || random.nextInt(getChance()) == 0)) {
|
||||||
if (down > 10) continue;
|
|
||||||
POS.setY(POS.getY() - down);
|
|
||||||
|
|
||||||
if (canGenerate(world, random, center, POS, r)) {
|
|
||||||
generate(world, random, POS);
|
generate(world, random, POS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package ru.betterend.world.features;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
|
import ru.betterend.blocks.basis.BlockDoublePlant;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
|
public class UnderwaterPlantFeature extends UnderwaterPlantScatter {
|
||||||
|
private final Block plant;
|
||||||
|
|
||||||
|
public UnderwaterPlantFeature(Block plant, int radius) {
|
||||||
|
super(radius);
|
||||||
|
this.plant = plant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||||
|
return plant.canPlaceAt(plant.getDefaultState(), world, blockPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||||
|
if (plant instanceof BlockDoublePlant) {
|
||||||
|
int rot = random.nextInt(4);
|
||||||
|
BlockState state = plant.getDefaultState().with(BlockDoublePlant.ROTATION, rot);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, blockPos, state);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(BlockDoublePlant.TOP, true));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package ru.betterend.world.features;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockPos.Mutable;
|
||||||
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
|
|
||||||
|
public abstract class UnderwaterPlantScatter extends ScatterFeature {
|
||||||
|
private static final Mutable POS = new Mutable();
|
||||||
|
|
||||||
|
public UnderwaterPlantScatter(int radius) {
|
||||||
|
super(radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) {
|
||||||
|
POS.setX(pos.getX());
|
||||||
|
POS.setZ(pos.getZ());
|
||||||
|
POS.setY(0);
|
||||||
|
return getGround(world, POS).toImmutable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||||
|
return !world.getFluidState(blockPos).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos) {
|
||||||
|
return !world.getFluidState(pos).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean getGroundPlant(StructureWorldAccess world, Mutable pos) {
|
||||||
|
return getGround(world, pos).getY() < 128;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getYOffset() {
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getChance() {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockPos getGround(StructureWorldAccess world, Mutable pos) {
|
||||||
|
while (pos.getY() < 128 && world.getFluidState(pos).isEmpty()) {
|
||||||
|
pos.setY(pos.getY() + 1);
|
||||||
|
}
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue