Start migration
This commit is contained in:
parent
6630ce0cab
commit
47ed597358
491 changed files with 12045 additions and 11953 deletions
|
@ -2,8 +2,8 @@ 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.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -12,32 +12,32 @@ import ru.betterend.util.BlocksHelper;
|
|||
import ru.betterend.util.MHelper;
|
||||
|
||||
public abstract class ScatterFeature extends DefaultFeature {
|
||||
private static final Mutable POS = new Mutable();
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
private final int radius;
|
||||
|
||||
|
||||
public ScatterFeature(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius);
|
||||
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius);
|
||||
|
||||
public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos);
|
||||
|
||||
|
||||
protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) {
|
||||
return getPosOnSurfaceWG(world, pos);
|
||||
}
|
||||
|
||||
|
||||
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos) {
|
||||
if (pos.getY() < 5) {
|
||||
return false;
|
||||
}
|
||||
else if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) {
|
||||
} else if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean getGroundPlant(StructureWorldAccess world, Mutable pos) {
|
||||
|
||||
protected boolean getGroundPlant(StructureWorldAccess world, MutableBlockPos pos) {
|
||||
int down = BlocksHelper.downRay(world, pos, 16);
|
||||
if (down > Math.abs(getYOffset() * 2)) {
|
||||
return false;
|
||||
|
@ -45,23 +45,24 @@ public abstract class ScatterFeature extends DefaultFeature {
|
|||
pos.setY(pos.getY() - down);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected int getYOffset() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
protected int getChance() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@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) {
|
||||
center = getCenterGround(world, center);
|
||||
|
||||
|
||||
if (!canSpawn(world, center)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
float r = MHelper.randRange(radius * 0.5F, radius, random);
|
||||
int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random));
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -69,13 +70,14 @@ public abstract class ScatterFeature extends DefaultFeature {
|
|||
float theta = random.nextFloat() * MHelper.PI2;
|
||||
float x = pr * (float) Math.cos(theta);
|
||||
float z = pr * (float) Math.sin(theta);
|
||||
|
||||
|
||||
POS.set(center.getX() + x, center.getY() + getYOffset(), center.getZ() + z);
|
||||
if (getGroundPlant(world, POS) && canGenerate(world, random, center, POS, r) && (getChance() < 2 || random.nextInt(getChance()) == 0)) {
|
||||
if (getGroundPlant(world, POS) && canGenerate(world, random, center, POS, r)
|
||||
&& (getChance() < 2 || random.nextInt(getChance()) == 0)) {
|
||||
generate(world, random, POS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue