Skip to content

Commit

Permalink
Release 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed Sep 27, 2020
1 parent 7f60645 commit 3f9d375
Show file tree
Hide file tree
Showing 21 changed files with 215 additions and 90 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "cn.nukkit:nukkit"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ In addition, this plugin can offload overworld surface noise operations onto the

[![](https://i.loli.net/2019/06/12/5d00613070e3947388.png)](https://www.mcbbs.net/thread-872584-1-1.html "可自定义的更好的原生地形生成器")

If you found any bugs or have any suggestions, please open an issue on [GitHub Issues](https://github.com/wode490390/BetterVanillaGenerator/issues).
If you found any bugs or have any suggestions, please open an issue on [GitHub](https://github.com/wode490390/BetterVanillaGenerator/issues).

If you love this plugin, please star it on [GitHub](https://github.com/wode490390/BetterVanillaGenerator).
If you like this plugin, please star it on [GitHub](https://github.com/wode490390/BetterVanillaGenerator).

*Note: Please back up old worlds before using this plugin.*

Expand Down Expand Up @@ -132,8 +132,8 @@ gpu:

## Metrics Collection

This plugin uses [bStats](https://github.com/wode490390/bStats-Nukkit) - you can opt out using the global bStats config, see the [official website](https://bstats.org/getting-started) for more details.
This plugin uses [bStats](https://github.com/wode490390/bStats-Nukkit). You can opt out using the global bStats config; see the [official website](https://bstats.org/getting-started) for more details.

[![Metrics](https://bstats.org/signatures/bukkit/BetterVanillaGenerator.svg)](https://bstats.org/plugin/bukkit/BetterVanillaGenerator/5198)

###### If I have any grammar and terms error, please correct my wrong :)
###### If I have any grammar and/or term errors, please correct them :)
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>cn.wode490390.nukkit</groupId>
<artifactId>vanillagenerator</artifactId>
<packaging>jar</packaging>
<version>1.2.1</version>
<version>1.2.2</version>
<name>BetterVanillaGenerator</name>
<description>Better vanilla generator plugin for Nukkit</description>
<url>http://wode490390.cn/</url>
Expand Down Expand Up @@ -96,7 +96,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<version>3.2.4</version>
<configuration>
<!--<filters>
<filter>
Expand All @@ -120,7 +120,7 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<version>4.0.2</version>
<executions>
<execution>
<id>get-the-git-infos</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
import cn.nukkit.level.biome.EnumBiome;
import cn.nukkit.level.format.generic.BaseFullChunk;
import cn.nukkit.level.generator.Generator;
import cn.nukkit.level.generator.object.ore.OreType;
import cn.nukkit.level.generator.populator.impl.PopulatorOre;
import cn.nukkit.level.generator.populator.type.Populator;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
import cn.wode490390.nukkit.vanillagenerator.noise.PerlinOctaveGenerator;
import cn.wode490390.nukkit.vanillagenerator.noise.bukkit.OctaveGenerator;
import cn.wode490390.nukkit.vanillagenerator.object.OreType;
import cn.wode490390.nukkit.vanillagenerator.populator.PopulatorOre;
import cn.wode490390.nukkit.vanillagenerator.populator.nether.PopulatorFire;
import cn.wode490390.nukkit.vanillagenerator.populator.nether.PopulatorGlowstone;
import cn.wode490390.nukkit.vanillagenerator.populator.nether.PopulatorLava;
import cn.wode490390.nukkit.vanillagenerator.populator.nether.PopulatorMushroom;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
Expand Down Expand Up @@ -47,11 +48,11 @@ public class NetherGenerator extends VanillaGenerator {
protected long localSeed2;

public NetherGenerator() {

// reflect
}

public NetherGenerator(Map<String, Object> options) {

// reflect
}

@Override
Expand Down Expand Up @@ -282,18 +283,14 @@ public void generateChunk(int chunkX, int chunkZ) {
}
}

this.generationPopulators.forEach((populator) -> {
populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom, chunk);
});
this.generationPopulators.forEach(populator -> populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom, chunk));
}

@Override
public void populateChunk(int chunkX, int chunkZ) {
BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
this.nukkitRandom.setSeed(0xdeadbeef ^ (chunkX << 8) ^ chunkZ ^ this.level.getSeed());
this.populators.forEach((populator) -> {
populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom, chunk);
});
this.populators.forEach(populator -> populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom, chunk));
Biome.getBiome(chunk.getBiomeId(7, 7)).populateChunk(this.level, chunkX, chunkZ, this.nukkitRandom);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import cn.nukkit.level.biome.Biome;
import cn.nukkit.level.biome.EnumBiome;
import cn.nukkit.level.format.generic.BaseFullChunk;
import cn.nukkit.level.generator.object.ore.OreType;
import cn.nukkit.level.generator.populator.impl.PopulatorOre;
import cn.nukkit.level.generator.populator.type.Populator;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
Expand All @@ -26,6 +24,8 @@
import cn.wode490390.nukkit.vanillagenerator.noise.PerlinOctaveGenerator;
import cn.wode490390.nukkit.vanillagenerator.noise.SimplexOctaveGenerator;
import cn.wode490390.nukkit.vanillagenerator.noise.bukkit.OctaveGenerator;
import cn.wode490390.nukkit.vanillagenerator.object.OreType;
import cn.wode490390.nukkit.vanillagenerator.populator.PopulatorOre;
import cn.wode490390.nukkit.vanillagenerator.populator.overworld.PopulatorCaves;
import cn.wode490390.nukkit.vanillagenerator.populator.overworld.PopulatorSnowLayers;
import cn.wode490390.nukkit.vanillagenerator.scheduler.CLNoiseReleaseTask;
Expand All @@ -37,6 +37,8 @@
import com.jogamp.opencl.CLKernel;
import com.jogamp.opencl.CLMemory;
import com.jogamp.opencl.CLProgram;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;

import java.nio.FloatBuffer;
import java.util.List;
Expand All @@ -57,8 +59,8 @@ public static void setUseGraphicsCompute(boolean enable) {
protected MapLayer[] biomeGrid;

protected static final double[][] ELEVATION_WEIGHT = new double[5][5];
protected static final Map<Integer, GroundGenerator> GROUND_MAP = Maps.newHashMap();
protected static final Map<Integer, BiomeHeight> HEIGHT_MAP = Maps.newHashMap();
protected static final Int2ObjectMap<GroundGenerator> GROUND_MAP = new Int2ObjectOpenHashMap<>();
protected static final Int2ObjectMap<BiomeHeight> HEIGHT_MAP = new Int2ObjectOpenHashMap<>();

protected static double coordinateScale = getConfig("overworld.coordinate-scale", 684.412d);
protected static double heightScale = getConfig("overworld.height.scale", 684.412d);
Expand Down Expand Up @@ -147,11 +149,11 @@ protected static void setBiomeHeight(BiomeHeight height, int... biomes) {
protected long localSeed2;

public NormalGenerator() {

// reflect
}

public NormalGenerator(Map<String, Object> options) {

// reflect
}

@Override
Expand Down Expand Up @@ -398,11 +400,7 @@ public void generateChunk(int chunkX, int chunkZ) {
// Use noise
for (int sx = 0; sx < sizeX; sx++) {
for (int sz = 0; sz < sizeZ; sz++) {
if (GROUND_MAP.containsKey(biomes.getBiome(sx, sz))) {
GROUND_MAP.get(biomes.getBiome(sx, sz)).generateTerrainColumn(level, chunkData, this.nukkitRandom, cx + sx, cz + sz, biomes.getBiome(sx, sz), noise.getBuffer().get(sx | sz << 4));
} else {
groundGen.generateTerrainColumn(level, chunkData, this.nukkitRandom, cx + sx, cz + sz, biomes.getBiome(sx, sz), noise.getBuffer().get(sx | sz << 4));
}
GROUND_MAP.getOrDefault(biomes.getBiome(sx, sz), groundGen).generateTerrainColumn(level, chunkData, this.nukkitRandom, cx + sx, cz + sz, biomes.getBiome(sx, sz), noise.getBuffer().get(sx | sz << 4));
chunkData.setBiomeId(sx, sz, biomes.getBiome(sx, sz));
}
}
Expand All @@ -419,11 +417,7 @@ public void generateChunk(int chunkX, int chunkZ) {
double[] surfaceNoise = octaveGenerator.getFractalBrownianMotion(cx, cz, 0.5d, 0.5d);
for (int sx = 0; sx < sizeX; sx++) {
for (int sz = 0; sz < sizeZ; sz++) {
if (GROUND_MAP.containsKey(biomes.getBiome(sx, sz))) {
GROUND_MAP.get(biomes.getBiome(sx, sz)).generateTerrainColumn(level, chunkData, this.nukkitRandom, cx + sx, cz + sz, biomes.getBiome(sx, sz), surfaceNoise[sx | sz << 4]);
} else {
groundGen.generateTerrainColumn(level, chunkData, this.nukkitRandom, cx + sx, cz + sz, biomes.getBiome(sx, sz), surfaceNoise[sx | sz << 4]);
}
GROUND_MAP.getOrDefault(biomes.getBiome(sx, sz), groundGen).generateTerrainColumn(level, chunkData, this.nukkitRandom, cx + sx, cz + sz, biomes.getBiome(sx, sz), surfaceNoise[sx | sz << 4]);
chunkData.setBiomeId(sx, sz, biomes.getBiome(sx, sz));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import cn.nukkit.level.biome.EnumBiome;
import cn.nukkit.math.NukkitRandom;
import cn.wode490390.nukkit.vanillagenerator.noise.bukkit.SimplexOctaveGenerator;
import com.google.common.collect.Maps;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;

public class BiomeClimate {

private static final Map<Integer, Climate> CLIMATE_MAP = Maps.newHashMap();
private static final Int2ObjectMap<Climate> CLIMATE_MAP = new Int2ObjectOpenHashMap<>();
private static final SimplexOctaveGenerator noiseGen;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

import cn.nukkit.level.biome.EnumBiome;
import com.google.common.collect.Maps;
import java.util.Arrays;
import java.util.List;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;

import java.util.Map;
import java.util.Map.Entry;

public class MapLayerBiomeEdge extends MapLayer {

private static final Map<Integer, Integer> MESA_EDGES = Maps.newHashMap();
private static final Map<Integer, Integer> MEGA_TAIGA_EDGES = Maps.newHashMap();
private static final Map<Integer, Integer> DESERT_EDGES = Maps.newHashMap();
private static final Map<Integer, Integer> SWAMP1_EDGES = Maps.newHashMap();
private static final Map<Integer, Integer> SWAMP2_EDGES = Maps.newHashMap();
private static final Map<Map<Integer, Integer>, List<Integer>> EDGES = Maps.newHashMap();
private static final Int2IntMap MESA_EDGES = new Int2IntOpenHashMap();
private static final Int2IntMap MEGA_TAIGA_EDGES = new Int2IntOpenHashMap();
private static final Int2IntMap DESERT_EDGES = new Int2IntOpenHashMap();
private static final Int2IntMap SWAMP1_EDGES = new Int2IntOpenHashMap();
private static final Int2IntMap SWAMP2_EDGES = new Int2IntOpenHashMap();
private static final Map<Int2IntMap, IntList> EDGES = Maps.newHashMap();

static {
MESA_EDGES.put(EnumBiome.MESA_PLATEAU_F.id, EnumBiome.MESA.id);
Expand All @@ -29,9 +32,9 @@ public class MapLayerBiomeEdge extends MapLayer {

EDGES.put(MESA_EDGES, null);
EDGES.put(MEGA_TAIGA_EDGES, null);
EDGES.put(DESERT_EDGES, Arrays.asList(EnumBiome.ICE_PLAINS.id));
EDGES.put(SWAMP1_EDGES, Arrays.asList(EnumBiome.DESERT.id, EnumBiome.COLD_TAIGA.id, EnumBiome.ICE_PLAINS.id));
EDGES.put(SWAMP2_EDGES, Arrays.asList(EnumBiome.JUNGLE.id));
EDGES.put(DESERT_EDGES, IntArrayList.wrap(new int[]{EnumBiome.ICE_PLAINS.id}));
EDGES.put(SWAMP1_EDGES, IntArrayList.wrap(new int[]{EnumBiome.DESERT.id, EnumBiome.COLD_TAIGA.id, EnumBiome.ICE_PLAINS.id}));
EDGES.put(SWAMP2_EDGES, IntArrayList.wrap(new int[]{EnumBiome.JUNGLE.id}));
}

private final MapLayer belowLayer;
Expand All @@ -55,17 +58,18 @@ public int[] generateValues(int x, int z, int sizeX, int sizeZ) {
// This applies biome large edges using Von Neumann neighborhood
int centerVal = values[j + 1 + (i + 1) * gridSizeX];
int val = centerVal;
for (Entry<Map<Integer, Integer>, List<Integer>> entry : EDGES.entrySet()) {
Map<Integer, Integer> map = entry.getKey();
for (Entry<Int2IntMap, IntList> entry : EDGES.entrySet()) {
Int2IntMap map = entry.getKey();
if (map.containsKey(centerVal)) {
int upperVal = values[j + 1 + i * gridSizeX];
int lowerVal = values[j + 1 + (i + 2) * gridSizeX];
int leftVal = values[j + (i + 1) * gridSizeX];
int rightVal = values[j + 2 + (i + 1) * gridSizeX];
if (entry.getValue() == null && (!map.containsKey(upperVal) || !map.containsKey(lowerVal) || !map.containsKey(leftVal) || !map.containsKey(rightVal))) {
IntList entryValue = entry.getValue();
if (entryValue == null && (!map.containsKey(upperVal) || !map.containsKey(lowerVal) || !map.containsKey(leftVal) || !map.containsKey(rightVal))) {
val = map.get(centerVal);
break;
} else if (entry.getValue() != null && (entry.getValue().contains(upperVal) || entry.getValue().contains(lowerVal) || entry.getValue().contains(leftVal) || entry.getValue().contains(rightVal))) {
} else if (entryValue != null && (entryValue.contains(upperVal) || entryValue.contains(lowerVal) || entryValue.contains(leftVal) || entryValue.contains(rightVal))) {
val = map.get(centerVal);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

import cn.nukkit.level.biome.EnumBiome;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.Arrays;
import java.util.List;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;

import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class MapLayerBiomeEdgeThin extends MapLayer {

private static final Set<Integer> OCEANS = Sets.newHashSet();
private static final Map<Integer, Integer> MESA_EDGES = Maps.newHashMap();
private static final Map<Integer, Integer> JUNGLE_EDGES = Maps.newHashMap();
private static final Map<Map<Integer, Integer>, List<Integer>> EDGES = Maps.newHashMap();
private static final IntSet OCEANS = new IntOpenHashSet();
private static final Int2IntMap MESA_EDGES = new Int2IntOpenHashMap();
private static final Int2IntMap JUNGLE_EDGES = new Int2IntOpenHashMap();
private static final Map<Int2IntMap, IntList> EDGES = Maps.newHashMap();

static {
OCEANS.add(EnumBiome.OCEAN.id);
Expand All @@ -33,7 +36,7 @@ public class MapLayerBiomeEdgeThin extends MapLayer {
JUNGLE_EDGES.put(EnumBiome.JUNGLE_EDGE_M.id, EnumBiome.JUNGLE_EDGE.id);

EDGES.put(MESA_EDGES, null);
EDGES.put(JUNGLE_EDGES, Arrays.asList(EnumBiome.JUNGLE.id, EnumBiome.JUNGLE_HILLS.id, EnumBiome.JUNGLE_M.id, EnumBiome.JUNGLE_EDGE_M.id, EnumBiome.FOREST.id, EnumBiome.TAIGA.id));
EDGES.put(JUNGLE_EDGES, IntArrayList.wrap(new int[]{EnumBiome.JUNGLE.id, EnumBiome.JUNGLE_HILLS.id, EnumBiome.JUNGLE_M.id, EnumBiome.JUNGLE_EDGE_M.id, EnumBiome.FOREST.id, EnumBiome.TAIGA.id}));
}

private final MapLayer belowLayer;
Expand All @@ -57,14 +60,14 @@ public int[] generateValues(int x, int z, int sizeX, int sizeZ) {
// This applies biome thin edges using Von Neumann neighborhood
int centerVal = values[j + 1 + (i + 1) * gridSizeX];
int val = centerVal;
for (Entry<Map<Integer, Integer>, List<Integer>> entry : EDGES.entrySet()) {
Map<Integer, Integer> map = entry.getKey();
for (Entry<Int2IntMap, IntList> entry : EDGES.entrySet()) {
Int2IntMap map = entry.getKey();
if (map.containsKey(centerVal)) {
int upperVal = values[j + 1 + i * gridSizeX];
int lowerVal = values[j + 1 + (i + 2) * gridSizeX];
int leftVal = values[j + (i + 1) * gridSizeX];
int rightVal = values[j + 2 + (i + 1) * gridSizeX];
List<Integer> entryValue = entry.getValue();
IntList entryValue = entry.getValue();
if (entryValue == null && (!OCEANS.contains(upperVal) && !map.containsKey(upperVal) || !OCEANS.contains(lowerVal) && !map.containsKey(lowerVal) || !OCEANS.contains(leftVal) && !map.containsKey(leftVal) || !OCEANS.contains(rightVal) && !map.containsKey(rightVal))) {
val = map.get(centerVal);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import cn.nukkit.level.biome.Biome;
import cn.nukkit.level.biome.EnumBiome;
import com.google.common.collect.Maps;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;

public class MapLayerBiomeVariation extends MapLayer {

private static final int[] ISLANDS = new int[]{EnumBiome.PLAINS.id, EnumBiome.FOREST.id};
private static final Map<Integer, int[]> VARIATIONS = Maps.newHashMap();
private static final Int2ObjectMap<int[]> VARIATIONS = new Int2ObjectOpenHashMap<>();

static {
VARIATIONS.put(EnumBiome.DESERT.id, new int[]{EnumBiome.DESERT_HILLS.id});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cn.wode490390.nukkit.vanillagenerator.biomegrid;

import cn.nukkit.level.biome.EnumBiome;
import com.google.common.collect.Maps;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;

public class MapLayerRarePlains extends MapLayer {

private static final Map<Integer, Integer> RARE_PLAINS = Maps.newHashMap();
private static final Int2IntMap RARE_PLAINS = new Int2IntOpenHashMap();

static {
RARE_PLAINS.put(EnumBiome.PLAINS.id, EnumBiome.SUNFLOWER_PLAINS.id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package cn.wode490390.nukkit.vanillagenerator.biomegrid;

import cn.nukkit.level.biome.EnumBiome;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.Map;
import java.util.Set;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;

public class MapLayerRiver extends MapLayer {

private static final Set<Integer> OCEANS = Sets.newHashSet();
private static final Map<Integer, Integer> SPECIAL_RIVERS = Maps.newHashMap();
private static final IntSet OCEANS = new IntOpenHashSet();
private static final Int2IntMap SPECIAL_RIVERS = new Int2IntOpenHashMap();
private static final int CLEAR_VALUE = 0;
private static final int RIVER_VALUE = 1;

Expand Down
Loading

0 comments on commit 3f9d375

Please sign in to comment.