Possible hexmap fixes & tests
This commit is contained in:
parent
59d2874c1a
commit
0bfefa460f
3 changed files with 37 additions and 14 deletions
|
@ -26,8 +26,10 @@ import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
|||
import ru.bclib.util.ColorUtil;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.features.BCLFeature;
|
||||
import ru.bclib.world.structures.BCLStructureFeature;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class BCLBiomeBuilder {
|
||||
private static final BCLBiomeBuilder INSTANCE = new BCLBiomeBuilder();
|
||||
|
@ -410,17 +412,25 @@ public class BCLBiomeBuilder {
|
|||
* Adds vanilla Mushrooms.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder defaultMushrooms(){
|
||||
BiomeDefaultFeatures.addDefaultMushrooms(getGeneration());
|
||||
return this;
|
||||
public BCLBiomeBuilder defaultMushrooms() {
|
||||
return feature(BiomeDefaultFeatures::addDefaultMushrooms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds vanilla Nether Ores.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder netherDefaultOres(){
|
||||
BiomeDefaultFeatures.addNetherDefaultOres(getGeneration());
|
||||
public BCLBiomeBuilder netherDefaultOres() {
|
||||
return feature(BiomeDefaultFeatures::addNetherDefaultOres);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will add features into biome, used for vanilla feature adding functions.
|
||||
* @param featureAdd {@link Consumer} with {@link BiomeGenerationSettings.Builder}.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder feature(Consumer<BiomeGenerationSettings.Builder> featureAdd) {
|
||||
featureAdd.accept(getGeneration());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -433,6 +443,11 @@ public class BCLBiomeBuilder {
|
|||
return feature(feature.getDecoration(), feature.getPlacedFeature());
|
||||
}
|
||||
|
||||
// TODO Make feature registration
|
||||
public BCLBiomeBuilder structure(BCLStructureFeature structure) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize biome creation.
|
||||
* @return created {@link BCLBiome} instance.
|
||||
|
|
|
@ -65,6 +65,9 @@ public class HexBiomeChunk {
|
|||
}
|
||||
|
||||
for (short index = 0; index < SIZE; index++) {
|
||||
if (outBuffer[index] == null) {
|
||||
System.out.println("Buffer is null at " + index + ": " + (index >> SIDE_OFFSET) + " " + (index & SIDE_MASK));
|
||||
}
|
||||
if (outBuffer[index] != null && random.nextInt(4) == 0) {
|
||||
circle(outBuffer, index, outBuffer[index].getSubBiome(random), outBuffer[index]);
|
||||
}
|
||||
|
|
|
@ -48,16 +48,16 @@ public class HexBiomeMap implements BiomeMap {
|
|||
|
||||
@Override
|
||||
public BCLBiome getBiome(double x, double z) {
|
||||
BCLBiome BCLBiome = getRawBiome(x, z);
|
||||
if (BCLBiome!=null && BCLBiome.getEdge() != null) {
|
||||
float offset = scale * BCLBiome.getEdgeSize();
|
||||
BCLBiome biome = getRawBiome(x, z);
|
||||
if (biome.getEdge() != null) {
|
||||
float offset = scale * biome.getEdgeSize();
|
||||
for (byte i = 0; i < 8; i++) {
|
||||
if (getRawBiome(x + offset * EDGE_CIRCLE_X[i], z + offset * EDGE_CIRCLE_Z[i]) != BCLBiome) {
|
||||
return BCLBiome.getEdge();
|
||||
if (getRawBiome(x + offset * EDGE_CIRCLE_X[i], z + offset * EDGE_CIRCLE_Z[i]) != biome) {
|
||||
return biome.getEdge();
|
||||
}
|
||||
}
|
||||
}
|
||||
return BCLBiome;
|
||||
return biome;
|
||||
}
|
||||
|
||||
private BCLBiome getRawBiome(double x, double z) {
|
||||
|
@ -112,13 +112,18 @@ public class HexBiomeMap implements BiomeMap {
|
|||
cz += 1;
|
||||
}
|
||||
|
||||
selector.setLocation(cx, cz);
|
||||
HexBiomeChunk chunk = chunks.get(selector);
|
||||
HexBiomeChunk chunk;
|
||||
synchronized (selector) {
|
||||
selector.setLocation(cx, cz);
|
||||
chunk = chunks.get(selector);
|
||||
}
|
||||
|
||||
if (chunk == null) {
|
||||
RANDOM.setSeed(MHelper.getSeed(seed, cx, cz));
|
||||
chunk = new HexBiomeChunk(RANDOM, picker);
|
||||
chunks.put(new Point(selector), chunk);
|
||||
chunks.put(new Point(cx, cz), chunk);
|
||||
}
|
||||
|
||||
return chunk.getBiome(x, z);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue