Neon oasis (WIP)
This commit is contained in:
parent
4ceda82bfb
commit
12447f783f
16 changed files with 202 additions and 63 deletions
|
@ -1,5 +1,9 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -34,13 +38,10 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
|
|||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
||||
public static final DirectionProperty FACING = Properties.FACING;
|
||||
|
||||
private static final VoxelShape MEDIUM_X = Block.createCuboidShape(0, 2, 2, 16, 14, 14);
|
||||
private static final VoxelShape MEDIUM_Y = Block.createCuboidShape(2, 0, 2, 14, 16, 14);
|
||||
private static final VoxelShape MEDIUM_Z = Block.createCuboidShape(2, 2, 0, 14, 14, 16);
|
||||
|
||||
private static final VoxelShape SMALL_X = Block.createCuboidShape(0, 4, 4, 16, 12, 12);
|
||||
private static final VoxelShape SMALL_Y = Block.createCuboidShape(4, 0, 4, 12, 16, 12);
|
||||
private static final VoxelShape SMALL_Z = Block.createCuboidShape(4, 4, 0, 12, 12, 16);
|
||||
private static final EnumMap<Direction, VoxelShape> MEDIUM_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
|
||||
private static final EnumMap<Direction, VoxelShape> SMALL_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
|
||||
private static final EnumMap<Axis, VoxelShape> MEDIUM_SHAPES = Maps.newEnumMap(Axis.class);
|
||||
private static final EnumMap<Axis, VoxelShape> SMALL_SHAPES = Maps.newEnumMap(Axis.class);
|
||||
|
||||
public NeonCactusBlock() {
|
||||
super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(state -> {
|
||||
|
@ -50,6 +51,7 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
|
|||
}
|
||||
return shape == TripleShape.MIDDLE ? 13 : 10;
|
||||
}));
|
||||
setDefaultState(getDefaultState().with(WATERLOGGED, false).with(FACING, Direction.UP).with(SHAPE, TripleShape.TOP));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,18 +101,38 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
|
|||
if (shape == TripleShape.BOTTOM) {
|
||||
return VoxelShapes.fullCube();
|
||||
}
|
||||
Axis dir = state.get(FACING).getAxis();
|
||||
if (shape == TripleShape.MIDDLE) {
|
||||
if (dir == Axis.Y) {
|
||||
return MEDIUM_Y;
|
||||
}
|
||||
return dir == Axis.X ? MEDIUM_X : MEDIUM_Z;
|
||||
Direction dir = state.get(FACING);
|
||||
BlockState next = view.getBlockState(pos.offset(dir));
|
||||
if (next.isOf(this)) {
|
||||
Axis axis = dir.getAxis();
|
||||
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES.get(axis) : SMALL_SHAPES.get(axis);
|
||||
}
|
||||
else {
|
||||
if (dir == Axis.Y) {
|
||||
return SMALL_Y;
|
||||
}
|
||||
return dir == Axis.X ? SMALL_X : SMALL_Z;
|
||||
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES_OPEN.get(dir) : SMALL_SHAPES_OPEN.get(dir);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
MEDIUM_SHAPES.put(Axis.X, Block.createCuboidShape(0, 2, 2, 16, 14, 14));
|
||||
MEDIUM_SHAPES.put(Axis.Y, Block.createCuboidShape(2, 0, 2, 14, 16, 14));
|
||||
MEDIUM_SHAPES.put(Axis.Z, Block.createCuboidShape(2, 2, 0, 14, 14, 16));
|
||||
|
||||
SMALL_SHAPES.put(Axis.X, Block.createCuboidShape(0, 4, 4, 16, 12, 12));
|
||||
SMALL_SHAPES.put(Axis.Y, Block.createCuboidShape(4, 0, 4, 12, 16, 12));
|
||||
SMALL_SHAPES.put(Axis.Z, Block.createCuboidShape(4, 4, 0, 12, 12, 16));
|
||||
|
||||
MEDIUM_SHAPES_OPEN.put(Direction.UP, Block.createCuboidShape(2, 0, 2, 14, 14, 14));
|
||||
MEDIUM_SHAPES_OPEN.put(Direction.DOWN, Block.createCuboidShape(2, 2, 2, 14, 16, 14));
|
||||
MEDIUM_SHAPES_OPEN.put(Direction.NORTH, Block.createCuboidShape(2, 2, 2, 14, 14, 16));
|
||||
MEDIUM_SHAPES_OPEN.put(Direction.SOUTH, Block.createCuboidShape(2, 2, 0, 14, 14, 14));
|
||||
MEDIUM_SHAPES_OPEN.put(Direction.WEST, Block.createCuboidShape(2, 2, 2, 16, 14, 14));
|
||||
MEDIUM_SHAPES_OPEN.put(Direction.EAST, Block.createCuboidShape(0, 2, 2, 14, 14, 14));
|
||||
|
||||
SMALL_SHAPES_OPEN.put(Direction.UP, Block.createCuboidShape(4, 0, 4, 12, 12, 12));
|
||||
SMALL_SHAPES_OPEN.put(Direction.DOWN, Block.createCuboidShape(4, 4, 4, 12, 16, 12));
|
||||
SMALL_SHAPES_OPEN.put(Direction.NORTH, Block.createCuboidShape(4, 4, 4, 12, 12, 16));
|
||||
SMALL_SHAPES_OPEN.put(Direction.SOUTH, Block.createCuboidShape(4, 4, 0, 12, 12, 12));
|
||||
SMALL_SHAPES_OPEN.put(Direction.WEST, Block.createCuboidShape(4, 4, 4, 16, 12, 12));
|
||||
SMALL_SHAPES_OPEN.put(Direction.EAST, Block.createCuboidShape(0, 4, 4, 12, 12, 12));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import ru.betterend.world.biome.land.GlowingGrasslandsBiome;
|
|||
import ru.betterend.world.biome.land.LanternWoodsBiome;
|
||||
import ru.betterend.world.biome.land.MegalakeBiome;
|
||||
import ru.betterend.world.biome.land.MegalakeGroveBiome;
|
||||
import ru.betterend.world.biome.land.NeonOasisBiome;
|
||||
import ru.betterend.world.biome.land.PaintedMountainsBiome;
|
||||
import ru.betterend.world.biome.land.ShadowForestBiome;
|
||||
import ru.betterend.world.biome.land.SulphurSpringsBiome;
|
||||
|
@ -99,6 +100,7 @@ public class EndBiomes {
|
|||
public static final EndBiome DRAGON_GRAVEYARDS = registerBiome(new DragonGraveyardsBiome(), BiomeType.LAND);
|
||||
public static final EndBiome DRY_SHRUBLAND = registerBiome(new DryShrublandBiome(), BiomeType.LAND);
|
||||
public static final EndBiome LANTERN_WOODS = registerBiome(new LanternWoodsBiome(), BiomeType.LAND);
|
||||
public static final EndBiome NEON_OASIS = registerSubBiome(new NeonOasisBiome(), DUST_WASTELANDS);
|
||||
|
||||
// Better End Void
|
||||
public static final EndBiome ICE_STARFIELD = registerBiome(new BiomeIceStarfield(), BiomeType.VOID);
|
||||
|
|
|
@ -28,6 +28,7 @@ import ru.betterend.world.features.GlowPillarFeature;
|
|||
import ru.betterend.world.features.HydraluxFeature;
|
||||
import ru.betterend.world.features.LanceleafFeature;
|
||||
import ru.betterend.world.features.MengerSpongeFeature;
|
||||
import ru.betterend.world.features.NeonCactusFeature;
|
||||
import ru.betterend.world.features.OverworldIslandFeature;
|
||||
import ru.betterend.world.features.SilkMothNestFeature;
|
||||
import ru.betterend.world.features.SingleInvertedScatterFeature;
|
||||
|
@ -90,6 +91,7 @@ public class EndFeatures {
|
|||
public static final EndFeature LUMECORN = new EndFeature("lumecorn", new Lumecorn(), 5);
|
||||
public static final EndFeature LARGE_AMARANITA = new EndFeature("large_amaranita", new LargeAmaranitaFeature(), 5);
|
||||
public static final EndFeature LUCERNIA_BUSH = new EndFeature("lucernia_bush", new BushWithOuterFeature(EndBlocks.LUCERNIA_LEAVES, EndBlocks.LUCERNIA_OUTER_LEAVES, EndBlocks.LUCERNIA.bark), 10);
|
||||
public static final EndFeature NEON_CACTUS = new EndFeature("neon_cactus", new NeonCactusFeature(), 2);
|
||||
|
||||
// Plants //
|
||||
public static final EndFeature UMBRELLA_MOSS = new EndFeature("umbrella_moss", new DoublePlantFeature(EndBlocks.UMBRELLA_MOSS, EndBlocks.UMBRELLA_MOSS_TALL, 5), 5);
|
||||
|
|
|
@ -12,7 +12,6 @@ public class DustWastelandsBiome extends EndBiome {
|
|||
super(new BiomeDefinition("dust_wastelands")
|
||||
.setFogColor(226, 239, 168)
|
||||
.setFogDensity(2)
|
||||
.setCaves(false)
|
||||
.setWaterAndFogColor(192, 180, 131)
|
||||
.setSurface(EndBlocks.ENDSTONE_DUST)
|
||||
.setParticles(ParticleTypes.WHITE_ASH, 0.01F)
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package ru.betterend.world.biome.land;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeatures;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndFeatures;
|
||||
import ru.betterend.registry.EndSounds;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class NeonOasisBiome extends EndBiome {
|
||||
public NeonOasisBiome() {
|
||||
super(new BiomeDefinition("neon_oasis")
|
||||
.setGenChance(0.5F)
|
||||
.setFogColor(226, 239, 168)
|
||||
.setFogDensity(2)
|
||||
.setWaterAndFogColor(192, 180, 131)
|
||||
.setSurface(EndBlocks.ENDSTONE_DUST, EndBlocks.END_MOSS)
|
||||
.setParticles(ParticleTypes.WHITE_ASH, 0.01F)
|
||||
.setLoop(EndSounds.AMBIENT_DUST_WASTELANDS)
|
||||
.setMusic(EndSounds.MUSIC_OPENSPACE)
|
||||
.addFeature(EndFeatures.NEON_CACTUS)
|
||||
.addStructureFeature(ConfiguredStructureFeatures.END_CITY)
|
||||
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class NeonCactusFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).isOf(EndBlocks.ENDSTONE_DUST)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int h = MHelper.randRange(5, 20, random);
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
Direction hor = BlocksHelper.randomHorizontal(random);
|
||||
for (int i = 0; i < h; i++) {
|
||||
if (!world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
break;
|
||||
}
|
||||
int size = (h - i) >> 2;
|
||||
BlocksHelper.setWithUpdate(world, mut,
|
||||
EndBlocks.NEON_CACTUS.getDefaultState()
|
||||
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size))
|
||||
.with(Properties.FACING, Direction.UP)
|
||||
);
|
||||
if (i > 2 && i < (h - 1) && random.nextBoolean()) {
|
||||
int length = h - i - MHelper.randRange(1, 2, random);
|
||||
if (length > 0) {
|
||||
Direction dir2 = hor;
|
||||
hor = hor.rotateYClockwise();
|
||||
int bsize = i > ((h << 1) / 3) ? 0 : size > 1 ? 1 : size;
|
||||
branch(world, mut.offset(dir2), dir2, random, length, bsize);
|
||||
}
|
||||
}
|
||||
mut.move(Direction.UP);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void branch(StructureWorldAccess world, BlockPos pos, Direction dir, Random random, int length, int size) {
|
||||
int rotIndex = length >> 2;
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
Direction hor = BlocksHelper.randomHorizontal(random);
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (!world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
return;
|
||||
}
|
||||
BlocksHelper.setWithUpdate(world, mut,
|
||||
EndBlocks.NEON_CACTUS.getDefaultState()
|
||||
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size))
|
||||
.with(Properties.FACING, dir)
|
||||
);
|
||||
if (i == rotIndex) {
|
||||
dir = Direction.UP;
|
||||
size --;
|
||||
}
|
||||
if (i > 1 && i < (length - 1) && random.nextBoolean()) {
|
||||
Direction dir2 = dir == Direction.UP ? hor : Direction.UP;
|
||||
hor = hor.rotateYClockwise();
|
||||
branch(world, mut.offset(dir2), dir2, random, MHelper.randRange(length / 4, length / 2, random), size > 0 ? size - 1 : size);
|
||||
}
|
||||
mut.move(dir);
|
||||
}
|
||||
}
|
||||
|
||||
private TripleShape getBySize(int size) {
|
||||
return size < 1 ? TripleShape.TOP : size == 1 ? TripleShape.MIDDLE : TripleShape.BOTTOM;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue