Update to BCLib 0.3.0

This commit is contained in:
paulevsGitch 2021-07-20 00:39:58 +03:00
parent 1a52251af0
commit b2431153dc
294 changed files with 7484 additions and 1440 deletions

View file

@ -16,7 +16,6 @@ import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConf
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import ru.bclib.util.MHelper;
import ru.bclib.util.StructureHelper;
import ru.betterend.BetterEnd;
import ru.betterend.world.structures.piece.NBTPiece;
@ -32,10 +31,25 @@ public class EternalPortalStructure extends FeatureBaseStructure {
if (x + z < 1024L) {
return false;
}
if (chunkGenerator.getBaseHeight(pos.getBlockX(8), pos.getBlockX(8), Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor) < 5) {
if (chunkGenerator.getBaseHeight(
pos.getBlockX(8),
pos.getBlockX(8),
Heightmap.Types.WORLD_SURFACE_WG,
levelHeightAccessor
) < 5) {
return false;
}
return super.isFeatureChunk(chunkGenerator, biomeSource, worldSeed, chunkRandom, pos, biome, chunkPos, featureConfig, levelHeightAccessor);
return super.isFeatureChunk(
chunkGenerator,
biomeSource,
worldSeed,
chunkRandom,
pos,
biome,
chunkPos,
featureConfig,
levelHeightAccessor
);
}
@Override
@ -53,7 +67,14 @@ public class EternalPortalStructure extends FeatureBaseStructure {
int x = chunkPos.getBlockX(8);
int z = chunkPos.getBlockZ(8);
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
this.pieces.add(new NBTPiece(STRUCTURE_ID, STRUCTURE, new BlockPos(x, y - 4, z), random.nextInt(5), true, random));
this.pieces.add(new NBTPiece(
STRUCTURE_ID,
STRUCTURE,
new BlockPos(x, y - 4, z),
random.nextInt(5),
true,
random
));
}
}
}

View file

@ -48,7 +48,12 @@ public abstract class FeatureBaseStructure extends StructureFeature<NoneFeatureC
int m = chunkGenerator.getFirstOccupiedHeight(k, l, Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor);
int n = chunkGenerator.getFirstOccupiedHeight(k, l + j, Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor);
int o = chunkGenerator.getFirstOccupiedHeight(k + i, l, Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor);
int p = chunkGenerator.getFirstOccupiedHeight(k + i, l + j, Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor);
int p = chunkGenerator.getFirstOccupiedHeight(
k + i,
l + j,
Heightmap.Types.WORLD_SURFACE_WG,
levelHeightAccessor
);
return Math.min(Math.min(m, n), Math.min(o, p));
}
}

View file

@ -37,7 +37,10 @@ public class GiantIceStarStructure extends SDFStructureFeature {
int count = MHelper.randRange(minCount, maxCount, random);
List<Vector3f> points = getFibonacciPoints(count);
SDF sdf = null;
SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size).setBlock(EndBlocks.DENSE_SNOW);
SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F)
.setRadius2(0)
.setHeight(size)
.setBlock(EndBlocks.DENSE_SNOW);
spike = new SDFTranslate().setTranslate(0, size - 0.5F, 0).setSource(spike);
for (Vector3f point : points) {
SDF rotated = spike;
@ -69,7 +72,11 @@ public class GiantIceStarStructure extends SDFStructureFeature {
float px = bpos.getX() - center.getX();
float py = bpos.getY() - center.getY();
float pz = bpos.getZ() - center.getZ();
float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F + random.nextFloat() * randScale;
float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(
px,
py,
pz
) * 0.4F + random.nextFloat() * randScale;
if (distance < ancientRadius) {
return ancient;
}

View file

@ -34,7 +34,8 @@ public class GiantMossyGlowshroomStructure extends SDFStructureFeature {
SDFCappedCone cone1 = new SDFCappedCone().setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F);
SDFCappedCone cone2 = new SDFCappedCone().setHeight(3F).setRadius1(2.5F).setRadius2(13F);
SDF posedCone2 = new SDFTranslate().setTranslate(0, 5, 0).setSource(cone2);
SDF posedCone3 = new SDFTranslate().setTranslate(0, 12F, 0).setSource(new SDFScale().setScale(2).setSource(cone2));
SDF posedCone3 = new SDFTranslate().setTranslate(0, 12F, 0)
.setSource(new SDFScale().setScale(2).setSource(cone2));
SDF upCone = new SDFSubtraction().setSourceA(posedCone2).setSourceB(posedCone3);
SDF wave = new SDFFlatWave().setRaysCount(12).setIntensity(1.3F).setSource(upCone);
SDF cones = new SDFSmoothUnion().setRadius(3).setSourceA(cone1).setSourceB(wave);
@ -53,18 +54,23 @@ public class GiantMossyGlowshroomStructure extends SDFStructureFeature {
OpenSimplexNoise noise = new OpenSimplexNoise(1234);
cones = new SDFCoordModify().setFunction((pos) -> {
float dist = MHelper.length(pos.x(), pos.z());
float y = pos.y() + (float) noise.eval(pos.x() * 0.1 + center.getX(), pos.z() * 0.1 + center.getZ()) * dist * 0.3F - dist * 0.15F;
float y = pos.y() + (float) noise.eval(
pos.x() * 0.1 + center.getX(),
pos.z() * 0.1 + center.getZ()
) * dist * 0.3F - dist * 0.15F;
pos.set(pos.x(), y, pos.z());
}).setSource(cones);
SDFTranslate HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones));
SDFTranslate HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0)
.setSource(cones));
SDF roots = new SDFSphere().setRadius(4F);
SDFPrimitive primRoots = (SDFPrimitive) roots;
roots = new SDFScale3D().setScale(1, 0.7F, 1).setSource(roots);
SDFFlatWave rotRoots = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).setSource(roots);
SDFBinary function = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(rotRoots));
SDFBinary function = new SDFSmoothUnion().setRadius(4)
.setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(rotRoots));
cone1.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP);
cone2.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP);
@ -85,38 +91,58 @@ public class GiantMossyGlowshroomStructure extends SDFStructureFeature {
rotRoots.setAngle(random.nextFloat() * MHelper.PI2);
function.setSourceA(sdf);
return new SDFRound().setRadius(1.5F).setSource(new SDFScale().setScale(scale).setSource(function)).addPostProcess((info) -> {
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) {
if (random.nextBoolean() && info.getStateUp().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState().setValue(MossyGlowshroomCapBlock.TRANSITION, true));
return info.getState();
}
else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp()) || !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM.bark.defaultBlockState());
return info.getState();
}
}
else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown().getBlock())) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState().setValue(MossyGlowshroomCapBlock.TRANSITION, true));
return info.getState();
}
return new SDFRound().setRadius(1.5F)
.setSource(new SDFScale().setScale(scale).setSource(function))
.addPostProcess((info) -> {
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) {
if (random.nextBoolean() && info.getStateUp()
.getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()
.setValue(
MossyGlowshroomCapBlock.TRANSITION,
true
));
return info.getState();
}
else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp()) || !EndBlocks.MOSSY_GLOWSHROOM
.isTreeLog(info.getStateDown())) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM.bark.defaultBlockState());
return info.getState();
}
}
else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown().getBlock())) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()
.setValue(
MossyGlowshroomCapBlock.TRANSITION,
true
));
return info.getState();
}
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState());
return info.getState();
}
else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (info.getState(dir) == AIR) {
info.setBlockPos(info.getPos().relative(dir), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
}
}
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState());
return info.getState();
}
else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (info.getState(dir) == AIR) {
info.setBlockPos(
info.getPos().relative(dir),
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState()
.setValue(FurBlock.FACING, dir)
);
}
}
if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
info.setBlockPos(info.getPos().below(), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().setValue(FurBlock.FACING, Direction.DOWN));
}
}
return info.getState();
});
if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
info.setBlockPos(
info.getPos().below(),
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState()
.setValue(FurBlock.FACING, Direction.DOWN)
);
}
}
return info.getState();
});
}
}

View file

@ -33,7 +33,13 @@ public class MountainStructure extends FeatureBaseStructure {
if (y > 5) {
float radius = MHelper.randRange(50, 100, random);
float height = radius * MHelper.randRange(0.8F, 1.2F, random);
CrystalMountainPiece piece = new CrystalMountainPiece(new BlockPos(x, y, z), radius, height, random, biome);
CrystalMountainPiece piece = new CrystalMountainPiece(
new BlockPos(x, y, z),
radius,
height,
random,
biome
);
this.pieces.add(piece);
}

View file

@ -51,6 +51,10 @@ public class PaintedMountainStructure extends FeatureBaseStructure {
}
static {
VARIANTS = new BlockState[]{Blocks.END_STONE.defaultBlockState(), EndBlocks.FLAVOLITE.stone.defaultBlockState(), EndBlocks.VIOLECITE.stone.defaultBlockState(),};
VARIANTS = new BlockState[] {
Blocks.END_STONE.defaultBlockState(),
EndBlocks.FLAVOLITE.stone.defaultBlockState(),
EndBlocks.VIOLECITE.stone.defaultBlockState(),
};
}
}

View file

@ -68,7 +68,8 @@ public class CrystalMountainPiece extends MountainPiece {
continue;
}
pos.setY(minY);
while (!chunk.getBlockState(pos).is(TagAPI.GEN_TERRAIN) && pos.getY() > 56 && !chunk.getBlockState(pos.below()).is(Blocks.CAVE_AIR)) {
while (!chunk.getBlockState(pos).is(TagAPI.GEN_TERRAIN) && pos.getY() > 56 && !chunk.getBlockState(
pos.below()).is(Blocks.CAVE_AIR)) {
pos.setY(pos.getY() - 1);
}
minY = pos.getY();
@ -81,10 +82,18 @@ public class CrystalMountainPiece extends MountainPiece {
maxY += center.getY();
int maxYI = (int) (maxY);
int cover = maxYI - 1;
boolean needCover = (noise1.eval(px * 0.1, pz * 0.1) + MHelper.randRange(-0.4, 0.4, random) - (center.getY() + 14) * 0.1) > 0;
boolean needCover = (noise1.eval(px * 0.1, pz * 0.1) + MHelper.randRange(
-0.4,
0.4,
random
) - (center.getY() + 14) * 0.1) > 0;
for (int y = minY - 1; y < maxYI; y++) {
pos.setY(y);
chunk.setBlockState(pos, needCover && y == cover ? top : Blocks.END_STONE.defaultBlockState(), false);
chunk.setBlockState(
pos,
needCover && y == cover ? top : Blocks.END_STONE.defaultBlockState(),
false
);
}
}
}

View file

@ -125,13 +125,20 @@ public class LakePiece extends BasePiece {
else if (dist <= r3 && mut.getY() < center.getY()) {
BlockState state = chunk.getBlockState(mut);
BlockPos worldPos = mut.offset(sx, 0, sz);
if (!state.isCollisionShapeFullBlock(world, worldPos) && !state.isRedstoneConductor(world, worldPos)) {
if (!state.isCollisionShapeFullBlock(world, worldPos) && !state.isRedstoneConductor(
world,
worldPos
)) {
state = chunk.getBlockState(mut.above());
if (state.isAir()) {
state = random.nextBoolean() ? ENDSTONE : world.getBiome(worldPos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
state = random.nextBoolean() ? ENDSTONE : world.getBiome(worldPos)
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
}
else {
state = state.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.defaultBlockState();
state = state.getFluidState()
.isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.defaultBlockState();
}
chunk.setBlockState(mut, state, false);
}
@ -160,10 +167,14 @@ public class LakePiece extends BasePiece {
BlockState bState = chunk.getBlockState(mut);
if (bState.isAir()) {
bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.offset(sx, 0, sz)).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.offset(sx, 0, sz))
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
}
else {
bState = bState.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.defaultBlockState();
bState = bState.getFluidState()
.isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.defaultBlockState();
}
mut.setY(y);
@ -178,10 +189,14 @@ public class LakePiece extends BasePiece {
mut.setY(y + 1);
BlockState bState = chunk.getBlockState(mut);
if (bState.isAir()) {
bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.offset(sx, 0, sz)).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.offset(sx, 0, sz))
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
}
else {
bState = bState.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.defaultBlockState();
bState = bState.getFluidState()
.isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.defaultBlockState();
}
mut.setY(y);
makeEndstonePillar(chunk, mut, bState);

View file

@ -93,7 +93,10 @@ public abstract class MountainPiece extends BasePiece {
return h;
}
h = MHelper.floor(noise2.eval(pos.getX() * 0.01, pos.getZ() * 0.01) * noise2.eval(pos.getX() * 0.002, pos.getZ() * 0.002) * 8 + 8);
h = MHelper.floor(noise2.eval(pos.getX() * 0.01, pos.getZ() * 0.01) * noise2.eval(
pos.getX() * 0.002,
pos.getZ() * 0.002
) * 8 + 8);
if (h < 0) {
heightmap.put(p, 0);

View file

@ -70,8 +70,14 @@ public class NBTPiece extends BasePiece {
@Override
public boolean postProcess(WorldGenLevel world, StructureFeatureManager arg, ChunkGenerator chunkGenerator, Random random, BoundingBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
BoundingBox bounds = BoundingBox.fromCorners(new Vec3i(blockBox.minX(), this.boundingBox.minY(), blockBox.minZ()), new Vec3i(blockBox.maxX(), this.boundingBox.maxX(), blockBox.maxZ()));
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
BoundingBox bounds = BoundingBox.fromCorners(new Vec3i(
blockBox.minX(),
this.boundingBox.minY(),
blockBox.minZ()
), new Vec3i(blockBox.maxX(), this.boundingBox.maxX(), blockBox.maxZ()));
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation)
.setMirror(mirror)
.setBoundingBox(bounds);
structure.placeInWorld(world, pos, pos, placementData, random, 2);
if (erosion > 0) {
int x1 = MHelper.min(bounds.maxX(), boundingBox.maxX());

View file

@ -87,7 +87,10 @@ public class PaintedMountainPiece extends MountainPiece {
maxY *= (float) noise1.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F;
maxY *= (float) noise1.eval(px * 0.1, pz * 0.1) * 0.1F + 0.9F;
maxY += center.getY();
float offset = (float) (noise1.eval(px * 0.07, pz * 0.07) * 5 + noise1.eval(px * 0.2, pz * 0.2) * 2 + 7);
float offset = (float) (noise1.eval(px * 0.07, pz * 0.07) * 5 + noise1.eval(
px * 0.2,
pz * 0.2
) * 2 + 7);
for (int y = minY - 1; y < maxY; y++) {
pos.setY(y);
int index = MHelper.floor((y + offset) * 0.65F) % slises.length;