Glowing grasslands update

This commit is contained in:
paulevsGitch 2021-01-20 18:08:36 +03:00
parent 31163e7658
commit 77c56433cc
57 changed files with 382 additions and 107 deletions

View file

@ -2,10 +2,10 @@ package ru.betterend.world.features.bushes;
import java.util.Random;
import net.minecraft.block.BlockState;
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;
@ -22,7 +22,7 @@ public class Lumecorn extends DefaultFeature {
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
int height = MHelper.randRange(3, 6, random);
int height = MHelper.randRange(4, 7, random);
Mutable mut = new Mutable().set(pos);
for (int i = 1; i < height; i++) {
mut.move(Direction.UP);
@ -31,39 +31,31 @@ public class Lumecorn extends DefaultFeature {
}
}
mut.set(pos);
if (height == 3) {
BlockState topMiddle = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP_MIDDLE);
BlockState middle = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_MIDDLE);
BlockState bottom = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_BOTTOM);
BlockState top = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP);
if (height == 4) {
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));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom);
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), topMiddle);
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), top);
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;
if (random.nextBoolean()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
}
else {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
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 --;
}
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));
}
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom);
for (int i = 4; i < height; i++) {
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), middle);
}
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), topMiddle);
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), top);
return false;
}
}