Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -2,12 +2,12 @@ package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.block.BlockState;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.tags.BlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.Heightmap;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator;
@ -17,15 +17,15 @@ import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
public class SilkMothNestFeature extends DefaultFeature {
private static final Mutable POS = new Mutable();
private static final MutableBlockPos POS = new MutableBlockPos();
private boolean canGenerate(StructureWorldAccess world, BlockPos pos) {
BlockState state = world.getBlockState(pos.up());
if (state.isIn(BlockTags.LEAVES) || state.isIn(BlockTags.LOGS)) {
state = world.getBlockState(pos);
if ((state.isAir() || state.isOf(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isAir(pos.down())) {
for (Direction dir: BlocksHelper.HORIZONTAL) {
if (world.getBlockState(pos.down().offset(dir)).getMaterial().blocksMovement()) {
if ((state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isAir(pos.below())) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (world.getBlockState(pos.below().offset(dir)).getMaterial().blocksMovement()) {
return false;
}
return true;
@ -34,9 +34,10 @@ public class SilkMothNestFeature extends DefaultFeature {
}
return false;
}
@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) {
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
POS.set(center);
@ -44,9 +45,11 @@ public class SilkMothNestFeature extends DefaultFeature {
POS.setY(y);
if (canGenerate(world, POS)) {
Direction dir = BlocksHelper.randomHorizontal(random);
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.getDefaultState().with(Properties.HORIZONTAL_FACING, dir).with(BlockProperties.ACTIVE, false));
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState()
.with(Properties.HORIZONTAL_FACING, dir).with(BlockProperties.ACTIVE, false));
POS.setY(y - 1);
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.getDefaultState().with(Properties.HORIZONTAL_FACING, dir));
BlocksHelper.setWithoutUpdate(world, POS,
EndBlocks.SILK_MOTH_NEST.defaultBlockState().with(Properties.HORIZONTAL_FACING, dir));
return true;
}
}