Start migration
This commit is contained in:
parent
6630ce0cab
commit
47ed597358
491 changed files with 12045 additions and 11953 deletions
|
@ -2,9 +2,9 @@ package ru.betterend.world.features;
|
|||
|
||||
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.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;
|
||||
|
@ -15,25 +15,26 @@ import ru.betterend.util.MHelper;
|
|||
public abstract class WallScatterFeature extends DefaultFeature {
|
||||
private static final Direction[] DIR = BlocksHelper.makeHorizontal();
|
||||
private final int radius;
|
||||
|
||||
|
||||
public WallScatterFeature(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir);
|
||||
|
||||
|
||||
public abstract void generate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir);
|
||||
|
||||
|
||||
@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);
|
||||
if (maxY < 10 || maxY < minY) {
|
||||
return false;
|
||||
}
|
||||
int py = MHelper.randRange(minY, maxY, random);
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
mut.setX(center.getX() + x);
|
||||
for (int y = -radius; y <= radius; y++) {
|
||||
|
@ -42,7 +43,7 @@ public abstract class WallScatterFeature extends DefaultFeature {
|
|||
mut.setZ(center.getZ() + z);
|
||||
if (random.nextInt(4) == 0 && world.isAir(mut)) {
|
||||
shuffle(random);
|
||||
for (Direction dir: DIR) {
|
||||
for (Direction dir : DIR) {
|
||||
if (canGenerate(world, random, mut, dir)) {
|
||||
generate(world, random, mut, dir);
|
||||
break;
|
||||
|
@ -52,10 +53,10 @@ public abstract class WallScatterFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void shuffle(Random random) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int j = random.nextInt(4);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue