Fixed most compiletime errors

This commit is contained in:
Frank 2023-04-29 11:48:56 +02:00
parent e232184b68
commit a974fab707
58 changed files with 449 additions and 679 deletions

View file

@ -101,9 +101,9 @@ public class CrashedShipFeature extends NBTFeature<NBTFeatureConfig> {
rotation,
BlockPos.ZERO
);
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
center = center.offset(0, (int) (getYOffset(structure, world, center, random) + 0.5), 0);
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror);
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
center = center.offset((int) (-offset.getX() * 0.5), 0, (int) (-offset.getZ() * 0.5));
BoundingBox structB = structure.getBoundingBox(placementData, center);
bounds = StructureHelper.intersectBoxes(bounds, structB);

View file

@ -5,21 +5,18 @@ import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature;
import org.betterx.bclib.api.v2.levelgen.structures.templatesystem.DestructionStructureProcessor;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import org.betterx.worlds.together.world.event.WorldBootstrap;
import com.mojang.serialization.Codec;
import net.minecraft.core.*;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.core.Vec3i;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.RandomSource;
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
@ -29,9 +26,6 @@ import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import java.io.IOException;
import java.io.InputStream;
public abstract class NBTFeature<FC extends NBTFeatureConfig> extends Feature<FC> {
public NBTFeature(Codec<FC> codec) {
super(codec);
@ -112,7 +106,7 @@ public abstract class NBTFeature<FC extends NBTFeatureConfig> extends Feature<FC
rotation,
BlockPos.ZERO
);
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
center = center.offset(0, (int) (getYOffset(structure, world, center, random) + 0.5), 0);
BoundingBox bounds = makeBox(center);
StructurePlaceSettings placementData = new StructurePlaceSettings()
@ -120,7 +114,7 @@ public abstract class NBTFeature<FC extends NBTFeatureConfig> extends Feature<FC
.setMirror(mirror)
.setBoundingBox(bounds);
addStructureData(placementData);
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
center = center.offset((int) (-offset.getX() * 0.5), 0, (int) (-offset.getZ() * 0.5));
structure.placeInWorld(world, center, center, placementData, random, 4);
TerrainMerge merge = getTerrainMerge(world, center, random);
@ -199,32 +193,6 @@ public abstract class NBTFeature<FC extends NBTFeatureConfig> extends Feature<FC
return BoundingBox.fromCorners(new Vec3i(sx, 0, sz), new Vec3i(ex, 255, ez));
}
protected static StructureTemplate readStructure(ResourceLocation resource) {
String ns = resource.getNamespace();
String nm = resource.getPath();
try {
InputStream inputstream = MinecraftServer.class.getResourceAsStream("/data/" + ns + "/structures/" + nm + ".nbt");
return readStructureFromStream(inputstream);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
private static StructureTemplate readStructureFromStream(InputStream stream) throws IOException {
final HolderLookup<Block> blockLookup = WorldBootstrap.getLastRegistryAccess()
.lookup(Registries.BLOCK)
.orElseThrow();
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
StructureTemplate template = new StructureTemplate();
template.load(blockLookup, nbttagcompound);
return template;
}
public enum TerrainMerge implements StringRepresentable {
NONE, SURFACE, OBJECT;

View file

@ -127,15 +127,19 @@ public class GeyserFeature extends DefaultFeature {
obj1 = new SDFCappedCone().setHeight(halfHeight + 5).setRadius1(radius1 * 0.5F).setRadius2(radius2);
sdf = new SDFTranslate().setTranslate(0, halfHeight - 13, 0).setSource(obj1);
sdf = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.3F, vec.y() * 0.3F, vec.z() * 0.3F) * 0.5F;
}).setSource(sdf);
sdf = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(
vec.x() * 0.3F,
vec.y() * 0.3F,
vec.z() * 0.3F
) * 0.5F).setSource(sdf);
obj2 = new SDFSphere().setRadius(radius1);
SDF cave = new SDFScale3D().setScale(1.5F, 1, 1.5F).setSource(obj2);
cave = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.1F, vec.y() * 0.1F, vec.z() * 0.1F) * 2F;
}).setSource(cave);
cave = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(
vec.x() * 0.1F,
vec.y() * 0.1F,
vec.z() * 0.1F
) * 2F).setSource(cave);
cave = new SDFTranslate().setTranslate(0, -halfHeight - 10, 0).setSource(cave);
sdf = new SDFSmoothUnion().setRadius(5).setSourceA(cave).setSourceB(sdf);
@ -147,21 +151,24 @@ public class GeyserFeature extends DefaultFeature {
obj1.setBlock(EndBlocks.BRIMSTONE);
obj2.setBlock(EndBlocks.BRIMSTONE);
new SDFDisplacement().setFunction((vec) -> {
return -2F;
}).setSource(sdf).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE);
new SDFDisplacement().setFunction((vec) -> -2F)
.setSource(sdf)
.setReplaceFunction(REPLACE1)
.fillRecursiveIgnore(world, pos, IGNORE);
obj1.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
obj2.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
new SDFDisplacement().setFunction((vec) -> {
return -4F;
}).setSource(cave).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE);
new SDFDisplacement().setFunction((vec) -> -4F)
.setSource(cave)
.setReplaceFunction(REPLACE1)
.fillRecursiveIgnore(world, pos, IGNORE);
obj1.setBlock(Blocks.END_STONE);
obj2.setBlock(Blocks.END_STONE);
new SDFDisplacement().setFunction((vec) -> {
return -6F;
}).setSource(cave).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE);
new SDFDisplacement().setFunction((vec) -> -6F)
.setSource(cave)
.setReplaceFunction(REPLACE1)
.fillRecursiveIgnore(world, pos, IGNORE);
BlocksHelper.setWithoutUpdate(world, pos, WATER);
MutableBlockPos mut = new MutableBlockPos().set(pos);
@ -266,17 +273,15 @@ public class GeyserFeature extends DefaultFeature {
));
double distance = radius1 * 1.7;
BlockPos start = pos.offset(-distance, -halfHeight - 15 - distance, -distance);
BlockPos end = pos.offset(distance, -halfHeight - 5 + distance, distance);
BlockPos start = pos.offset((int) -distance, (int) (-halfHeight - 15 - distance), (int) -distance);
BlockPos end = pos.offset((int) distance, (int) (-halfHeight - 5 + distance), (int) distance);
BlockFixer.fixBlocks(world, start, end);
return true;
}
static {
REPLACE1 = (state) -> {
return state.isAir() || (state.is(CommonBlockTags.GEN_END_STONES));
};
REPLACE1 = (state) -> state.isAir() || (state.is(CommonBlockTags.GEN_END_STONES));
REPLACE2 = (state) -> {
if (state.is(CommonBlockTags.GEN_END_STONES) || state.is(EndBlocks.HYDROTHERMAL_VENT) || state.is(EndBlocks.SULPHUR_CRYSTAL)) {
@ -288,9 +293,7 @@ public class GeyserFeature extends DefaultFeature {
return state.getMaterial().isReplaceable();
};
IGNORE = (state) -> {
return state.is(Blocks.WATER) || state.is(Blocks.CAVE_AIR) || state.is(EndBlocks.SULPHURIC_ROCK.stone) || state
.is(EndBlocks.BRIMSTONE);
};
IGNORE = (state) -> state.is(Blocks.WATER) || state.is(Blocks.CAVE_AIR) || state.is(EndBlocks.SULPHURIC_ROCK.stone) || state
.is(EndBlocks.BRIMSTONE);
}
}

View file

@ -58,15 +58,18 @@ public class DragonTreeFeature extends DefaultFeature {
Vector3f last = SplineHelper.getPos(spline, 3.5F);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
float radius = size * MHelper.randRange(0.5F, 0.7F, random);
makeCap(world, pos.offset(last.x(), last.y(), last.z()), radius, random, noise);
makeCap(world, pos.offset((int) last.x(), (int) last.y(), (int) last.z()), radius, random, noise);
last = spline.get(0);
makeRoots(world, pos.offset(last.x(), last.y(), last.z()), radius, random);
makeRoots(world, pos.offset((int) last.x(), (int) last.y(), (int) last.z()), radius, random);
radius = MHelper.randRange(1.2F, 2.3F, random);
SDF function = SplineHelper.buildSDF(spline, radius, 1.2F, (bpos) -> {
return EndBlocks.DRAGON_TREE.getBark().defaultBlockState();
});
SDF function = SplineHelper.buildSDF(
spline,
radius,
1.2F,
(bpos) -> EndBlocks.DRAGON_TREE.getBark().defaultBlockState()
);
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);
@ -110,7 +113,8 @@ public class DragonTreeFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(CommonBlockTags.GEN_END_STONES)) {
if (world.getBlockState(pos.offset((int) last.x(), (int) last.y(), (int) last.z()))
.is(CommonBlockTags.GEN_END_STONES)) {
SplineHelper.fillSpline(
branch,
world,
@ -136,12 +140,12 @@ public class DragonTreeFeature extends DefaultFeature {
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 1.5F;
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return random.nextFloat() * 3F - 1.5F;
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(
vec.x() * 0.2,
vec.y() * 0.2,
vec.z() * 0.2
) * 1.5F).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> random.nextFloat() * 3F - 1.5F).setSource(sphere);
MutableBlockPos mut = new MutableBlockPos();
sphere.addPostProcess((info) -> {
if (random.nextInt(5) == 0) {
@ -183,9 +187,9 @@ public class DragonTreeFeature extends DefaultFeature {
int count = (int) (radius * 2.5F);
for (int i = 0; i < count; i++) {
BlockPos p = pos.offset(
random.nextGaussian() * 1,
random.nextGaussian() * 1,
random.nextGaussian() * 1
(int) (random.nextGaussian() * 1),
(int) (random.nextGaussian() * 1),
(int) (random.nextGaussian() * 1)
);
boolean place = true;
for (Direction d : Direction.values()) {
@ -218,9 +222,7 @@ public class DragonTreeFeature extends DefaultFeature {
return state.getMaterial().isReplaceable();
};
IGNORE = (state) -> {
return EndBlocks.DRAGON_TREE.isTreeLog(state);
};
IGNORE = EndBlocks.DRAGON_TREE::isTreeLog;
POST = (info) -> {
if (EndBlocks.DRAGON_TREE.isTreeLog(info.getStateUp()) && EndBlocks.DRAGON_TREE.isTreeLog(info.getStateDown())) {

View file

@ -58,7 +58,9 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
);
Vector3f capPos = spline.get(spline.size() - 1);
makeHead(world, pos.offset(capPos.x() + 0.5F, capPos.y() + 1.5F, capPos.z() + 0.5F), Mth.floor(size / 1.6F));
makeHead(world, pos.offset((int) (capPos.x() + 0.5F), (int) (capPos.y() + 1.5F),
(int) (capPos.z() + 0.5F)
), Mth.floor(size / 1.6F));
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);

View file

@ -45,24 +45,25 @@ public class HelixTreeFeature extends DefaultFeature {
float dx;
float dz;
List<Vector3f> spline = new ArrayList<Vector3f>(10);
List<Vector3f> spline = new ArrayList<>(10);
for (int i = 0; i < 10; i++) {
float radius = (0.9F - i * 0.1F) * radiusRange;
dx = (float) Math.sin(i + angle) * radius;
dz = (float) Math.cos(i + angle) * radius;
spline.add(new Vector3f(dx, i * 2, dz));
}
SDF sdf = SplineHelper.buildSDF(spline, 1.7F, 0.5F, (p) -> {
return EndBlocks.HELIX_TREE.getBark().defaultBlockState();
});
SDF sdf = SplineHelper.buildSDF(spline, 1.7F, 0.5F, (p) -> EndBlocks.HELIX_TREE.getBark().defaultBlockState());
SDF rotated = new SDFRotation().setRotation(Axis.YP, (float) Math.PI).setSource(sdf);
sdf = new SDFUnion().setSourceA(rotated).setSourceB(sdf);
Vector3f lastPoint = spline.get(spline.size() - 1);
List<Vector3f> spline2 = SplineHelper.makeSpline(0, 0, 0, 0, 20, 0, 5);
SDF stem = SplineHelper.buildSDF(spline2, 1.0F, 0.5F, (p) -> {
return EndBlocks.HELIX_TREE.getBark().defaultBlockState();
});
SDF stem = SplineHelper.buildSDF(
spline2,
1.0F,
0.5F,
(p) -> EndBlocks.HELIX_TREE.getBark().defaultBlockState()
);
stem = new SDFTranslate().setTranslate(lastPoint.x(), lastPoint.y(), lastPoint.z()).setSource(stem);
sdf = new SDFSmoothUnion().setRadius(3).setSourceA(sdf).setSourceB(stem);
@ -70,16 +71,22 @@ public class HelixTreeFeature extends DefaultFeature {
dx = 30 * scale;
float dy1 = -20 * scale;
float dy2 = 100 * scale;
sdf.addPostProcess(POST).fillArea(world, pos, new AABB(pos.offset(-dx, dy1, -dx), pos.offset(dx, dy2, dx)));
sdf.addPostProcess(POST)
.fillArea(
world,
pos,
new AABB(
pos.offset((int) -dx, (int) dy1, (int) -dx),
pos.offset((int) dx, (int) dy2, (int) dx)
)
);
SplineHelper.scale(spline, scale);
SplineHelper.fillSplineForce(
spline,
world,
EndBlocks.HELIX_TREE.getBark().defaultBlockState(),
pos,
(state) -> {
return state.getMaterial().isReplaceable();
}
(state) -> state.getMaterial().isReplaceable()
);
SplineHelper.rotateSpline(spline, (float) Math.PI);
SplineHelper.fillSplineForce(
@ -87,20 +94,20 @@ public class HelixTreeFeature extends DefaultFeature {
world,
EndBlocks.HELIX_TREE.getBark().defaultBlockState(),
pos,
(state) -> {
return state.getMaterial().isReplaceable();
}
(state) -> state.getMaterial().isReplaceable()
);
SplineHelper.scale(spline2, scale);
BlockPos leafStart = pos.offset(lastPoint.x() + 0.5, lastPoint.y() + 0.5, lastPoint.z() + 0.5);
BlockPos leafStart = pos.offset(
(int) (lastPoint.x() + 0.5),
(int) (lastPoint.y() + 0.5),
(int) (lastPoint.z() + 0.5)
);
SplineHelper.fillSplineForce(
spline2,
world,
EndBlocks.HELIX_TREE.getLog().defaultBlockState(),
leafStart,
(state) -> {
return state.getMaterial().isReplaceable();
}
(state) -> state.getMaterial().isReplaceable()
);
spline.clear();
@ -149,7 +156,7 @@ public class HelixTreeFeature extends DefaultFeature {
}
leaf = leaf.setValue(HelixTreeLeavesBlock.COLOR, 7);
leafStart = leafStart.offset(0, lastPoint.y(), 0);
leafStart = leafStart.offset(0, (int) lastPoint.y(), 0);
if (world.getBlockState(leafStart).isAir()) {
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
leafStart = leafStart.above();

View file

@ -44,9 +44,7 @@ public class JellyshroomFeature extends DefaultFeature {
float radius = height * MHelper.randRange(0.15F, 0.25F, random);
List<Vector3f> spline = SplineHelper.makeSpline(0, -1, 0, 0, height, 0, 3);
SplineHelper.offsetParts(spline, random, 0.5F, 0, 0.5F);
SDF sdf = SplineHelper.buildSDF(spline, radius, 0.8F, (bpos) -> {
return bark;
});
SDF sdf = SplineHelper.buildSDF(spline, radius, 0.8F, (bpos) -> bark);
radius = height * MHelper.randRange(0.7F, 0.9F, random);
if (radius < 1.5F) {
@ -87,7 +85,8 @@ public class JellyshroomFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(CommonBlockTags.GEN_END_STONES)) {
if (world.getBlockState(pos.offset((int) last.x(), (int) last.y(), (int) last.z()))
.is(CommonBlockTags.GEN_END_STONES)) {
SplineHelper.fillSpline(branch, world, wood, pos, REPLACE);
}
}

View file

@ -56,12 +56,15 @@ public class LacugroveFeature extends DefaultFeature {
float radius = MHelper.randRange(6F, 8F, random);
radius *= (size - 15F) / 20F + 1F;
Vector3f center = spline.get(4);
leavesBall(world, pos.offset(center.x(), center.y(), center.z()), radius, random, noise);
leavesBall(world, pos.offset((int) center.x(), (int) center.y(), (int) center.z()), radius, random, noise);
radius = MHelper.randRange(1.2F, 1.8F, random);
SDF function = SplineHelper.buildSDF(spline, radius, 0.7F, (bpos) -> {
return EndBlocks.LACUGROVE.getBark().defaultBlockState();
});
SDF function = SplineHelper.buildSDF(
spline,
radius,
0.7F,
(bpos) -> EndBlocks.LACUGROVE.getBark().defaultBlockState()
);
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);
@ -125,12 +128,12 @@ public class LacugroveFeature extends DefaultFeature {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.LACUGROVE_LEAVES.defaultBlockState()
.setValue(LeavesBlock.DISTANCE, 6));
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3;
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return random.nextFloat() * 3F - 1.5F;
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(
vec.x() * 0.2,
vec.y() * 0.2,
vec.z() * 0.2
) * 3).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> random.nextFloat() * 3F - 1.5F).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere)
.setSourceB(new SDFTranslate().setTranslate(0, -radius - 2, 0).setSource(sphere));
MutableBlockPos mut = new MutableBlockPos();
@ -174,9 +177,9 @@ public class LacugroveFeature extends DefaultFeature {
int count = (int) (radius * 2.5F);
for (int i = 0; i < count; i++) {
BlockPos p = pos.offset(
random.nextGaussian() * 1,
random.nextGaussian() * 1,
random.nextGaussian() * 1
(int) (random.nextGaussian() * 1),
(int) (random.nextGaussian() * 1),
(int) (random.nextGaussian() * 1)
);
boolean place = true;
for (Direction d : Direction.values()) {
@ -212,9 +215,7 @@ public class LacugroveFeature extends DefaultFeature {
return state.getMaterial().isReplaceable();
};
IGNORE = (state) -> {
return EndBlocks.LACUGROVE.isTreeLog(state);
};
IGNORE = EndBlocks.LACUGROVE::isTreeLog;
POST = (info) -> {
if (EndBlocks.LACUGROVE.isTreeLog(info.getStateUp()) && EndBlocks.LACUGROVE.isTreeLog(info.getStateDown())) {

View file

@ -61,7 +61,14 @@ public class LucerniaFeature extends DefaultFeature {
Vector3f last = spline.get(spline.size() - 1);
float leavesRadius = (size * 0.13F + MHelper.randRange(0.8F, 1.5F, random)) * 1.4F;
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
leavesBall(world, pos.offset(last.x(), last.y(), last.z()), leavesRadius, random, noise, config != null);
leavesBall(
world,
pos.offset((int) last.x(), (int) last.y(), (int) last.z()),
leavesRadius,
random,
noise,
config != null
);
}
makeRoots(world, pos.offset(0, MHelper.randRange(3, 5, random), 0), size * 0.35F, random);
@ -191,7 +198,8 @@ public class LucerniaFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(CommonBlockTags.GEN_END_STONES)) {
if (world.getBlockState(pos.offset((int) last.x(), (int) last.y(), (int) last.z()))
.is(CommonBlockTags.GEN_END_STONES)) {
SplineHelper.fillSplineForce(
branch,
world,

View file

@ -64,9 +64,12 @@ public class PythadendronTreeFeature extends DefaultFeature {
pos
);
SDF function = SplineHelper.buildSDF(spline, 1.7F, 1.1F, (bpos) -> {
return EndBlocks.PYTHADENDRON.getBark().defaultBlockState();
});
SDF function = SplineHelper.buildSDF(
spline,
1.7F,
1.1F,
(bpos) -> EndBlocks.PYTHADENDRON.getBark().defaultBlockState()
);
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);
function.fillRecursive(world, pos);
@ -124,10 +127,10 @@ public class PythadendronTreeFeature extends DefaultFeature {
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
if (depth < 3) {
if (s1) {
leavesBall(world, pos.offset(pos1.x(), pos1.y(), pos1.z()), random, noise);
leavesBall(world, pos.offset((int) pos1.x(), (int) pos1.y(), (int) pos1.z()), random, noise);
}
if (s2) {
leavesBall(world, pos.offset(pos2.x(), pos2.y(), pos2.z()), random, noise);
leavesBall(world, pos.offset((int) pos2.x(), (int) pos2.y(), (int) pos2.z()), random, noise);
}
}
@ -151,12 +154,12 @@ public class PythadendronTreeFeature extends DefaultFeature {
.setBlock(EndBlocks.PYTHADENDRON_LEAVES.defaultBlockState()
.setValue(LeavesBlock.DISTANCE, 6));
sphere = new SDFScale3D().setScale(1, 0.6F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3;
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return random.nextFloat() * 3F - 1.5F;
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(
vec.x() * 0.2,
vec.y() * 0.2,
vec.z() * 0.2
) * 3).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> random.nextFloat() * 3F - 1.5F).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere)
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
MutableBlockPos mut = new MutableBlockPos();
@ -211,9 +214,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
return state.getMaterial().isReplaceable();
};
IGNORE = (state) -> {
return EndBlocks.PYTHADENDRON.isTreeLog(state);
};
IGNORE = EndBlocks.PYTHADENDRON::isTreeLog;
POST = (info) -> {
if (EndBlocks.PYTHADENDRON.isTreeLog(info.getStateUp()) && EndBlocks.PYTHADENDRON.isTreeLog(info.getStateDown())) {

View file

@ -58,7 +58,7 @@ public class TenaneaFeature extends DefaultFeature {
Vector3f last = spline.get(spline.size() - 1);
float leavesRadius = (size * 0.3F + MHelper.randRange(0.8F, 1.5F, random)) * 1.4F;
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
leavesBall(world, pos.offset(last.x(), last.y(), last.z()), leavesRadius, random, noise);
leavesBall(world, pos.offset((int) last.x(), (int) last.y(), (int) last.z()), leavesRadius, random, noise);
}
return true;

View file

@ -74,15 +74,13 @@ public class UmbrellaTreeFeature extends DefaultFeature {
if (SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
float rScale = (scale - 1) * 0.4F + 1;
SDF branch = SplineHelper.buildSDF(spline, 1.2F * rScale, 0.8F * rScale, (bpos) -> {
return wood;
});
SDF branch = SplineHelper.buildSDF(spline, 1.2F * rScale, 0.8F * rScale, (bpos) -> wood);
Vector3f vec = spline.get(spline.size() - 1);
float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.4F;
sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch);
SDF mem = makeMembrane(world, radius, random, membrane, center);
SDF mem = makeMembrane(radius, random, membrane, center);
float px = MHelper.floor(vec.x()) + 0.5F;
float py = MHelper.floor(vec.y()) + 0.5F;
@ -95,8 +93,6 @@ public class UmbrellaTreeFeature extends DefaultFeature {
pos.getZ() + (double) (pz * scale),
radius * scale
));
vec = spline.get(0);
}
}
@ -131,7 +127,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
makeRoots(world, pos, (size * 0.5F + 3) * scale, random, wood);
for (Center c : centers) {
if (!world.getBlockState(new BlockPos(c.px, c.py, c.pz)).isAir()) {
if (!world.getBlockState(new BlockPos((int) c.px, (int) c.py, (int) c.pz)).isAir()) {
count = MHelper.floor(MHelper.randRange(5F, 10F, random) * scale);
float startAngle = random.nextFloat() * MHelper.PI2;
for (int i = 0; i < count; i++) {
@ -139,7 +135,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
float dist = MHelper.randRange(1.5F, 2.5F, random) * scale;
double px = c.px + Math.sin(angle) * dist;
double pz = c.pz + Math.cos(angle) * dist;
makeFruits(world, px, c.py - 1, pz, fruit, scale);
makeFruits(world, px, c.py - 1, pz, fruit);
}
}
}
@ -157,14 +153,14 @@ public class UmbrellaTreeFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(CommonBlockTags.GEN_END_STONES)) {
if (world.getBlockState(pos.offset((int) last.x(), (int) last.y(), (int) last.z()))
.is(CommonBlockTags.GEN_END_STONES)) {
SplineHelper.fillSplineForce(branch, world, wood, pos, REPLACE);
}
}
}
private SDF makeMembrane(
WorldGenLevel world,
float radius,
RandomSource random,
BlockState membrane,
@ -189,7 +185,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
return sphere;
}
private void makeFruits(WorldGenLevel world, double px, double py, double pz, BlockState fruit, float scale) {
private void makeFruits(WorldGenLevel world, double px, double py, double pz, BlockState fruit) {
MutableBlockPos mut = new MutableBlockPos().set(px, py, pz);
for (int i = 0; i < 8; i++) {
mut.move(Direction.DOWN);
@ -230,7 +226,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
};
}
private class Center {
private static class Center {
final double px;
final double py;
final double pz;

View file

@ -29,7 +29,8 @@ public class EndLandBiomeDecider extends BiomeDecider {
@Override
public BiomeDecider createInstance(BCLBiomeSource biomeSource) {
return new EndLandBiomeDecider(biomeSource.getBiomeRegistry());
//TODO: 1.19.4: This ok?
return new EndLandBiomeDecider(/*biomeSource.getBiomeRegistry()*/);
}
@Override

View file

@ -24,7 +24,7 @@ public class IslandLayer {
private final SDFRadialNoiseMap noise;
private final SDF island;
private final List<BlockPos> positions = new ArrayList<BlockPos>(9);
private final List<BlockPos> positions = new ArrayList<>(9);
private final Map<BlockPos, SDF> islands = Maps.newHashMap();
private final OpenSimplexNoise density;
private final int seed;
@ -67,17 +67,15 @@ public class IslandLayer {
positions.clear();
for (int pox = -1; pox < 2; pox++) {
int px = pox + ix;
long px2 = px;
for (int poz = -1; poz < 2; poz++) {
int pz = poz + iz;
long pz2 = pz;
if (px2 * px2 + pz2 * pz2 > options.centerDist) {
if ((long) px * (long) px + (long) pz * (long) pz > options.centerDist) {
RANDOM.setSeed(getSeed(px, pz));
double posX = (px + RANDOM.nextFloat()) * options.distance;
double posY = MHelper.randRange(options.minY, options.maxY, RANDOM) * maxHeight;
double posZ = (pz + RANDOM.nextFloat()) * options.distance;
if (density.eval(posX * 0.01, posZ * 0.01) > options.coverage) {
positions.add(new BlockPos(posX, posY, posZ));
positions.add(new BlockPos((int) posX, (int) posY, (int) posZ));
}
}
}