Glowing grasslands prototype
This commit is contained in:
parent
49bf8441e6
commit
9042173336
39 changed files with 676 additions and 137 deletions
|
@ -119,4 +119,35 @@ public class BlockProperties {
|
|||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum LumecornShape implements StringIdentifiable {
|
||||
LIGHT1("light1", 15),
|
||||
LIGHT2("light2", 14),
|
||||
LIGHT3("light3", 13),
|
||||
MIDDLE("middle", 0),
|
||||
BOTTOM_BIG("bottom_big", 0),
|
||||
BOTTOM_SMALL("bottom_small", 0);
|
||||
|
||||
private final String name;
|
||||
private final int light;
|
||||
|
||||
LumecornShape(String name, int light) {
|
||||
this.name = name;
|
||||
this.light = light;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getLight() {
|
||||
return light;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
80
src/main/java/ru/betterend/blocks/LumecornBlock.java
Normal file
80
src/main/java/ru/betterend/blocks/LumecornBlock.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import ru.betterend.blocks.BlockProperties.LumecornShape;
|
||||
import ru.betterend.blocks.basis.BaseBlockNotFull;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.registry.EndTags;
|
||||
|
||||
public class LumecornBlock extends BaseBlockNotFull implements IRenderTypeable {
|
||||
public static final EnumProperty<LumecornShape> SHAPE = EnumProperty.of("shape", LumecornShape.class);
|
||||
private static final VoxelShape SHAPE_BIG = Block.createCuboidShape(5, 0, 5, 11, 16, 11);
|
||||
private static final VoxelShape SHAPE_MEDIUM = Block.createCuboidShape(6, 0, 6, 10, 16, 10);
|
||||
private static final VoxelShape SHAPE_SMALL = Block.createCuboidShape(7, 0, 7, 9, 16, 9);
|
||||
|
||||
public LumecornBlock() {
|
||||
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).hardness(0.5F).luminance((state) -> {
|
||||
return state.get(SHAPE).getLight();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(SHAPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||
LumecornShape shape = state.get(SHAPE);
|
||||
if (shape == LumecornShape.LIGHT3) {
|
||||
return SHAPE_SMALL;
|
||||
}
|
||||
else if (shape == LumecornShape.LIGHT2) {
|
||||
return SHAPE_MEDIUM;
|
||||
}
|
||||
else {
|
||||
return SHAPE_BIG;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||
LumecornShape shape = state.get(SHAPE);
|
||||
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL) {
|
||||
return world.getBlockState(pos.down()).isIn(EndTags.END_GROUND);
|
||||
}
|
||||
else {
|
||||
return world.getBlockState(pos.down()).isOf(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (!canPlaceAt(state, world, pos)) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
else {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ import ru.betterend.world.biome.BiomeShadowForest;
|
|||
import ru.betterend.world.biome.BiomeSulphurSprings;
|
||||
import ru.betterend.world.biome.BiomeUmbrellaJungle;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
import ru.betterend.world.biome.GlowingGrasslandsBiome;
|
||||
import ru.betterend.world.generator.BELayerRandomSource;
|
||||
import ru.betterend.world.generator.BiomePicker;
|
||||
import ru.betterend.world.generator.BiomeType;
|
||||
|
@ -83,6 +84,7 @@ public class EndBiomes {
|
|||
public static final EndBiome BLOSSOMING_SPIRES = registerBiome(new BiomeBlossomingSpires(), BiomeType.LAND);
|
||||
public static final EndBiome SULPHUR_SPRINGS = registerBiome(new BiomeSulphurSprings(), BiomeType.LAND);
|
||||
public static final EndBiome UMBRELLA_JUNGLE = registerBiome(new BiomeUmbrellaJungle(), BiomeType.LAND);
|
||||
public static final EndBiome GLOWING_GRASSLANDS = registerBiome(new GlowingGrasslandsBiome(), BiomeType.LAND);
|
||||
|
||||
// Better End Void
|
||||
public static final EndBiome ICE_STARFIELD = registerBiome(new BiomeIceStarfield(), BiomeType.VOID);
|
||||
|
|
|
@ -56,6 +56,7 @@ import ru.betterend.blocks.JellyshroomCapBlock;
|
|||
import ru.betterend.blocks.LacugroveSaplingBlock;
|
||||
import ru.betterend.blocks.LanceleafBlock;
|
||||
import ru.betterend.blocks.LanceleafSeedBlock;
|
||||
import ru.betterend.blocks.LumecornBlock;
|
||||
import ru.betterend.blocks.MengerSpongeBlock;
|
||||
import ru.betterend.blocks.MengerSpongeWetBlock;
|
||||
import ru.betterend.blocks.MossyGlowshroomCapBlock;
|
||||
|
@ -221,6 +222,8 @@ public class EndBlocks {
|
|||
|
||||
public static final Block SMALL_JELLYSHROOM = registerBlock("small_jellyshroom", new SmallJellyshroomBlock());
|
||||
|
||||
public static final Block LUMECORN = registerBlock("lumecorn", new LumecornBlock());
|
||||
|
||||
// Crops
|
||||
public static final Block BLOSSOM_BERRY = registerBlock("blossom_berry_seed", new EndCropBlock(EndItems.BLOSSOM_BERRY, PINK_MOSS));
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import ru.betterend.world.features.VineFeature;
|
|||
import ru.betterend.world.features.WallPlantFeature;
|
||||
import ru.betterend.world.features.WallPlantOnLogFeature;
|
||||
import ru.betterend.world.features.bushes.BushFeature;
|
||||
import ru.betterend.world.features.bushes.Lumecorn;
|
||||
import ru.betterend.world.features.bushes.TenaneaBushFeature;
|
||||
import ru.betterend.world.features.terrain.EndLakeFeature;
|
||||
import ru.betterend.world.features.terrain.FloatingSpireFeature;
|
||||
|
@ -68,6 +69,7 @@ public class EndFeatures {
|
|||
public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", new BushFeature(EndBlocks.PYTHADENDRON_LEAVES, EndBlocks.PYTHADENDRON.bark), 4);
|
||||
public static final EndFeature DRAGON_TREE_BUSH = new EndFeature("dragon_tree_bush", new BushFeature(EndBlocks.DRAGON_TREE_LEAVES, EndBlocks.DRAGON_TREE.bark), 15);
|
||||
public static final EndFeature TENANEA_BUSH = new EndFeature("tenanea_bush", new TenaneaBushFeature(), 10);
|
||||
public static final EndFeature LUMECORN = new EndFeature("lumecorn", new Lumecorn(), 5);
|
||||
|
||||
// Plants //
|
||||
public static final EndFeature UMBRELLA_MOSS = new EndFeature("umbrella_moss", new DoublePlantFeature(EndBlocks.UMBRELLA_MOSS, EndBlocks.UMBRELLA_MOSS_TALL, 5), 5);
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package ru.betterend.world.biome;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndFeatures;
|
||||
import ru.betterend.registry.EndSounds;
|
||||
|
||||
public class GlowingGrasslandsBiome extends EndBiome {
|
||||
public GlowingGrasslandsBiome() {
|
||||
super(new BiomeDefinition("glowing_grasslands")
|
||||
.setFogColor(99, 228, 247)
|
||||
.setFogDensity(1.3F)
|
||||
.setMusic(EndSounds.MUSIC_OPENSPACE)
|
||||
.setSurface(EndBlocks.END_MOSS)
|
||||
.addFeature(EndFeatures.END_LAKE_RARE)
|
||||
.addFeature(EndFeatures.LUMECORN)
|
||||
.addFeature(EndFeatures.UMBRELLA_MOSS)
|
||||
.addFeature(EndFeatures.CREEPING_MOSS)
|
||||
.addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS)
|
||||
.addFeature(EndFeatures.CHARNIA_CYAN)
|
||||
.addFeature(EndFeatures.CHARNIA_GREEN)
|
||||
.addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)
|
||||
.addFeature(EndFeatures.CHARNIA_RED_RARE)
|
||||
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package ru.betterend.world.features.bushes;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.blocks.BlockProperties.LumecornShape;
|
||||
import ru.betterend.blocks.LumecornBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class Lumecorn extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
int height = MHelper.randRange(3, 6, random);
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
for (int i = 1; i < height; i++) {
|
||||
mut.move(Direction.UP);
|
||||
if (!world.isAir(mut)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mut.set(pos);
|
||||
if (height == 3) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT2));
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT3));
|
||||
return true;
|
||||
}
|
||||
boolean tall = random.nextBoolean();
|
||||
if (tall) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.MIDDLE));
|
||||
height -= 2;
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
|
||||
height --;
|
||||
}
|
||||
boolean smallBottom = height > 2 && random.nextBoolean();
|
||||
for (int i = 0; i < height; i++) {
|
||||
int size = i - height + 4;
|
||||
size = MathHelper.clamp(size, 1, 3);
|
||||
if (smallBottom && i == 0) {
|
||||
size ++;
|
||||
}
|
||||
if (size == 1) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT1));
|
||||
}
|
||||
else if (size == 2) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT2));
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT3));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue