Neon cactus growing (WIP) & additional textures

This commit is contained in:
paulevsGitch 2021-04-26 21:51:53 +03:00
parent d897bb09d8
commit 387a430fde
28 changed files with 554 additions and 55 deletions

View file

@ -6,10 +6,13 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.CactusBottom;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
@ -31,9 +34,23 @@ public class NeonCactusFeature extends DefaultFeature {
break;
}
int size = (h - i) >> 2;
BlocksHelper.setWithUpdate(world, mut,
EndBlocks.NEON_CACTUS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, getBySize(size))
.setValue(BlockStateProperties.FACING, Direction.UP));
BlockState state = EndBlocks.NEON_CACTUS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, getBySize(size)).setValue(BlockStateProperties.FACING, Direction.UP);
if (i == 0) {
BlockState down = world.getBlockState(mut.below());
if (down.is(Blocks.END_STONE) || down.is(EndBlocks.ENDSTONE_DUST)) {
state = state.setValue(BlockProperties.CACTUS_BOTTOM, CactusBottom.SAND);
}
else if (down.is(EndBlocks.END_MOSS)) {
state = state.setValue(BlockProperties.CACTUS_BOTTOM, CactusBottom.MOSS);
}
else {
state = state.setValue(BlockProperties.CACTUS_BOTTOM, CactusBottom.EMPTY);
}
}
else {
state = state.setValue(BlockProperties.CACTUS_BOTTOM, CactusBottom.EMPTY);
}
BlocksHelper.setWithUpdate(world, mut, state);
if (i > 2 && i < (h - 1) && random.nextBoolean()) {
int length = h - i - MHelper.randRange(1, 2, random);
if (length > 0) {

View file

@ -25,8 +25,7 @@ public abstract class WallScatterFeature extends DefaultFeature {
public abstract void generate(WorldGenLevel world, Random random, BlockPos pos, Direction dir);
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
NoneFeatureConfiguration featureConfig) {
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center, NoneFeatureConfiguration featureConfig) {
int maxY = world.getHeight(Heightmap.Types.WORLD_SURFACE, center.getX(), center.getZ());
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
if (maxY < 10 || maxY < minY) {

View file

@ -4,36 +4,32 @@ import java.util.Random;
import ru.betterend.world.biome.EndBiome;
public class BiomeChunk
{
public class BiomeChunk {
protected static final int WIDTH = 16;
private static final int SM_WIDTH = WIDTH >> 1;
private static final int MASK_OFFSET = SM_WIDTH - 1;
protected static final int MASK_WIDTH = WIDTH - 1;
private final EndBiome[][] biomes;
public BiomeChunk(BiomeMap map, Random random, BiomePicker picker)
{
public BiomeChunk(BiomeMap map, Random random, BiomePicker picker) {
EndBiome[][] PreBio = new EndBiome[SM_WIDTH][SM_WIDTH];
biomes = new EndBiome[WIDTH][WIDTH];
for (int x = 0; x < SM_WIDTH; x++)
for (int z = 0; z < SM_WIDTH; z++)
PreBio[x][z] = picker.getBiome(random);
for (int x = 0; x < WIDTH; x++)
for (int z = 0; z < WIDTH; z++)
biomes[x][z] = PreBio[offsetXZ(x, random)][offsetXZ(z, random)].getSubBiome(random);
}
public EndBiome getBiome(int x, int z)
{
public EndBiome getBiome(int x, int z) {
return biomes[x & MASK_WIDTH][z & MASK_WIDTH];
}
private int offsetXZ(int x, Random random)
{
private int offsetXZ(int x, Random random) {
return ((x + random.nextInt(2)) >> 1) & MASK_OFFSET;
}
}