Skip to content

Commit 61a16ae

Browse files
authored
Merge pull request #8 from HydrolienF/1.21.1
1.21.1
2 parents 545f8ed + 0c8ad75 commit 61a16ae

40 files changed

+1204
-367
lines changed

.github/workflows/build.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: SonarCloud
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
jobs:
9+
build:
10+
name: Build and analyze
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
- name: Set up JDK 21
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: 21
20+
distribution: 'temurin'
21+
- name: Cache SonarCloud packages
22+
uses: actions/cache@v3
23+
with:
24+
path: ~/.sonar/cache
25+
key: ${{ runner.os }}-sonar
26+
restore-keys: ${{ runner.os }}-sonar
27+
- name: Cache Gradle packages
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.gradle/caches
31+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
32+
restore-keys: ${{ runner.os }}-gradle
33+
- name: Build and analyze
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
36+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
37+
run: ./gradlew build sonar --info

README.md

+16-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[ ![discord-shield][] ][discord-invite]
99

1010
# Underilla
11-
Underilla is a Bukkit / Spigot based plugin for Minecraft Servers to 'merge' existing custom Minecraft word surfaces and vanilla undergrounds. It works by allowing the vanilla generation engine create chunks as normal, then intercepting the generator and forcing the surface of the original world, which works as a reference. In oder worlds, Underilla generates a brand-new world with vanilla undergrounds, but cloning the surface of an already existing world.
11+
Underilla is a Paper based plugin for Minecraft Servers to 'merge' existing custom Minecraft word surfaces and vanilla undergrounds. It works by allowing the vanilla generation engine create chunks as normal, then intercepting the generator and forcing the surface of the original world, which works as a reference. In oder worlds, Underilla generates a brand-new world with vanilla undergrounds, but cloning the surface of an already existing world.
1212

1313
It's original purpose is adding vanilla caves to custom [WorldPainter](https://www.worldpainter.net/) worlds, but it would perfectly work for any pre-generated world.
1414

@@ -20,20 +20,20 @@ It's original purpose is adding vanilla caves to custom [WorldPainter](https://w
2020
- **None:** No actual vanilla underground noise is generated. `generate_noodle_caves` setting can still be on, to generate noodle caves.
2121
- **Absolute:** A Y coordinate value divides the original world surface and vanilla underground.
2222
- **Surface:** Mix the original world surface and vanilla underground at a variable y that depends of original & vanilla world surface. It have the best racio generated world quality & performance.
23-
- **Relative:** This is the cool one. The reference world's surface will be dynamically carved into vanilla underground; which means there's no actual height-based division.
23+
- **Relative:** **This strategie still need improvement, for now you should use Surface**. The reference world's surface will be dynamically carved into vanilla underground; which means there's no actual height-based division.
2424
- Custom caves also supported. If using Relative merge strategy, every non-solid block and surroundings will be preserved, thus, if the reference world has itself an underground system, it'll be transferred over to the merged world.
2525
- Heightmap fixed. Underilla re-calculates heightmaps when merging chunks, getting rid of floating and buried structures. Vanilla villagers and other structures are placed at the right height.
2626
- Biome overwrite. Biomes from the reference world will be transferred and overwrite biomes from de vanilla seed being used. Cave biomes underground will be preserved.
2727

2828
## Getting started
2929
### Perquisites
3030

31-
- Java 17.
31+
- Java 21.
3232
- A pre-generated world to use as a reference (Such as a WorldPainter world).
33-
- A Spigot / Paper (or forks) Minecraft Server of version [1.19.4 - 1.20.4]. It might work with upper version, but only 1.19.4, 1.20.1, 1.20.2, 1.20.4 have been tested.
33+
- A [Paper](https://papermc.io/software/paper) (or forks) Minecraft Server of version [1.21 - 1.21.1]. It might work with upper version, but only 1.21.1 have been tested. Use old release for [1.19 - 1.20.6] compatibility.
3434

3535
### Single player or non-Bukkit
36-
Underilla is currently only implemented as a Spigot plugin, so it runs only on Spigot (or fork) servers. If you have a Vanilla, Forge or non Bukkit-based server; or looking for a single player experience; you may [use a local Spigot server](https://www.spigotmc.org/wiki/spigot-installation/) to pre-generate a fully-merged world and then copy the resulting world folder to your actual `saves` folder.
36+
Underilla is currently only implemented as a Paper plugin, so it runs only on Paper (or fork) servers. If you have a Vanilla, Forge or non Bukkit-based server; or looking for a single player experience; you may [use a local Paper server](https://papermc.io/software/paper) to pre-generate a fully-merged world and then copy the resulting world folder to your actual `saves` folder.
3737

3838
### Installation
3939

@@ -58,7 +58,8 @@ Underilla is currently only implemented as a Spigot plugin, so it runs only on S
5858
**Important:** Make sure your server's main world is still set to `world`. Aside from this plugin, the server itself doesn't need to "know" about the reference world.
5959

6060
### Pregenerate
61-
Underilla is significantly slower than the vanilla generator, as it doesn't relly on noise generation but on reading the reference world's region `nbt` files and analyzing its patterns to 'clone' its surface to a vanilla world. So, if your world is intended for heavy duty in a big server. It's recommended to pre-generate the whole reference world area with a chunk generator plugin, such as [Chunky](https://www.spigotmc.org/resources/chunky.81534/). I'm planning adding a build-in pre-generation system in the future.
61+
Underilla is significantly slower than the vanilla generator, as it doesn't relly on noise generation but on reading the reference world's region `nbt` files and analyzing its patterns to 'clone' its surface to a vanilla world. So, if your world is intended for heavy duty in a big server. It's recommended to pre-generate the whole reference world area with a chunk generator plugin, such as [Chunky](https://hangar.papermc.io/pop4959/Chunky). I'm planning adding a build-in pre-generation system in the future.
62+
To increase generation speed you should edit `worker-threads` in your `config/paper-global.yml` to match your number of CPU cores, else paper won't use all CPU cores aviables. Using your number of core instead of default value usually double speed generation.
6263

6364
### Performances
6465
Huge map generation can takes hours or even days, here is some stats about performance to help you choose your configuration settings.
@@ -76,7 +77,6 @@ For a 50000 * 30000 world, it would take 40 hours to generate with Minecraft van
7677
- Underilla's generation disables Minecraft's chunk blender, which means there will be sharp old-school chunk borders at the edge of the reference world's chunks. This may be tackled by trimming your custom world chunks around the edges to generate blended chunks ahead of time.
7778
- Due to Spigot's generation API, outside the reference world's area, heightmaps are broken, which has an impact on structures. You may work around this by pre-generating the whole reference world area, and then disabling Underilla.
7879
- **Relative strategy only:** Little underground lava and water pockets will translate to odd floating blobs in the final world if they overlap with large caves. Avoid such generation patterns.
79-
- **With kept biome & relative strategy only**: As Underilla need to mix biome between the 2 world biome, it didn't edit Minecraft vanilla generator biome, this generator will places structures based on the seed, not the actual biomes. This results in structures sometimes in totally unrelated biomes. Shipwrecks, monuments and other ocean structures are the most noticeable. To work around this, you can get rid of kept biomes or you may blacklist structures as you wish in the config file, and spawn them manually using `/place` or use a plugin to place them as [WorldPopulatorH](https://github.com/HydrolienF/WorldPopulatorH).
8080

8181
## WorldPainter considerations
8282
If you're going to plug your custom WorldPainter world into Underilla, consider before exporting:
@@ -86,10 +86,17 @@ If you're going to plug your custom WorldPainter world into Underilla, consider
8686
- The Populate layer has no effect. Weather all or none of the terrain will be populated based on the above point.
8787
- If you have custom cave/tunnels layers and want to preserve them during the merge, you'd want to use the Relative merge strategy
8888

89+
## Custom biome
90+
Cave generation on custom biomes is now working. Features (ores, flowers etc) will be placed according to the custom surface world biome but structures won't.
91+
If you have a custom world with custom biomes, you should enable custom biome it in the config.
92+
93+
## Feature fiter
94+
If you want to remove some of the game features, for example the `monster_room` you can create a datapack where you have customine witch feature can spawn in each biome. Underilla will generate feature according to your cusomized biome.
95+
It can also be used to add feature to some biome. For example a quartz_ore feature if your nether is disabled you you still want your builder to have quartz.
8996

9097
## Build
9198
Create a working jar with `./gradlew buildDependents`
9299

93100
## TODO
94-
Build-in pre-generation system.
95-
Allow to generate the 2nd world on the fly.
101+
- Build-in pre-generation system.
102+
- Allow to generate the 2nd world on the fly.

Underilla-Core/build.gradle

-24
This file was deleted.

Underilla-Core/build.gradle.kts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugins {
2+
`java-library`
3+
id("org.sonarqube") version "4.4.1.3373"
4+
}
5+
6+
group = "com.Jkantrell.mc"
7+
version = "1.6.0"
8+
java.sourceCompatibility = JavaVersion.VERSION_21
9+
10+
repositories {
11+
mavenCentral()
12+
mavenLocal()
13+
maven ("https://jitpack.io")
14+
}
15+
16+
17+
dependencies {
18+
// testImplementation platform("org.junit:junit-bom:5.9.1")
19+
// testImplementation("org.junit.jupiter:junit-jupiter")
20+
implementation("org.apache.commons:commons-lang3:3.12.0")
21+
api("com.github.HydrolienF:KntNBT:2.2.2")
22+
}
23+
24+
tasks.test {
25+
useJUnitPlatform()
26+
}
27+
28+
sonar {
29+
properties {
30+
property("sonar.projectKey", "mvndicraft_underilla")
31+
property("sonar.organization", "mvndicraft")
32+
property("sonar.host.url", "https://sonarcloud.io")
33+
}
34+
}
File renamed without changes.

Underilla-Core/src/main/java/com/jkantrell/mc/underilla/core/api/Block.java

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public interface Block {
44

55
boolean isAir();
66
boolean isSolid();
7+
boolean isSolidAndSurfaceBlock();
78
boolean isLiquid();
89
boolean isWaterloggable();
910
void waterlog();

Underilla-Core/src/main/java/com/jkantrell/mc/underilla/core/generation/AbsoluteMerger.java

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.jkantrell.mc.underilla.core.generation;
22

33
import java.util.List;
4-
import com.jkantrell.mc.underilla.core.api.Biome;
54
import com.jkantrell.mc.underilla.core.api.Block;
65
import com.jkantrell.mc.underilla.core.api.ChunkData;
76
import com.jkantrell.mc.underilla.core.reader.ChunkReader;
@@ -16,12 +15,13 @@ class AbsoluteMerger implements Merger {
1615

1716
// FIELDS
1817
private final int height_;
19-
private final List<? extends Biome> preserveBiomes_, ravinBiomes_;
18+
private final List<String> preserveBiomes_;
19+
private final List<String> ravinBiomes_;
2020
private final List<String> keptReferenceWorldBlocks_;
2121
private final int mergeDepth_;
2222

2323
// CONSTRUCTORS
24-
AbsoluteMerger(int height, List<? extends Biome> preserveBiomes, List<? extends Biome> ravinBiomes,
24+
AbsoluteMerger(int height, List<String> preserveBiomes, List<String> ravinBiomes,
2525
List<String> keptReferenceWorldBlocks, int mergeDepth) {
2626
this.height_ = height;
2727
this.preserveBiomes_ = preserveBiomes;
@@ -32,11 +32,6 @@ class AbsoluteMerger implements Merger {
3232

3333

3434
// IMPLEMENTATIONS
35-
// @Override
36-
// public void merge(ChunkReader reader, ChunkData chunkData) {
37-
// this.mergeLand(reader, chunkData);
38-
// // this.mergeBiomes(reader, chunkData); // No need to set biome for chunk. It's done by the generator.
39-
// }
4035
@Override
4136
public void mergeLand(ChunkReader reader, ChunkData chunkData, @Nullable ChunkReader cavesReader) {
4237
long startTime = System.currentTimeMillis();
@@ -101,17 +96,12 @@ public void mergeLand(ChunkReader reader, ChunkData chunkData, @Nullable ChunkRe
10196
/** return the 1st block mergeDepth_ blocks under surface or heigth_ */
10297
private int getLowerBlockToRemove(Reader reader, int x, int z, Block defaultBlock) {
10398
int lbtr = this.height_ + mergeDepth_;
104-
while (!reader.blockAt(x, lbtr, z).orElse(defaultBlock).isSolid() && lbtr > -64) {
99+
while (!reader.blockAt(x, lbtr, z).orElse(defaultBlock).isSolidAndSurfaceBlock() && lbtr > -64) {
105100
lbtr--;
106101
}
107102
return lbtr - mergeDepth_;
108103
}
109104

110-
@Override
111-
public void mergeBiomes(ChunkReader reader, ChunkData chunkData) {
112-
// No need to set biome for chunk. It's done by the generator.
113-
}
114-
115105

116106
// private --------------------------------------------------------------------------------------------------------
117107
/**
@@ -126,11 +116,11 @@ private boolean isCustomWorldOreOutOfVanillaCaves(Block customBlock, Block vanil
126116
}
127117
/** Return true if this biome need to be only custom world */
128118
private boolean isPreservedBiome(ChunkReader reader, Vector<Integer> v) {
129-
return this.preserveBiomes_.contains(reader.biomeAt(v).orElse(null));
119+
return this.preserveBiomes_.contains(reader.biomeAt(v).orElseThrow().getName());
130120
}
131121

132122
private boolean isRavinBiome(ChunkReader reader, Vector<Integer> v) {
133-
return this.ravinBiomes_.contains(reader.biomeAt(v).orElse(null));
123+
return this.ravinBiomes_.contains(reader.biomeAt(v).orElseThrow().getName());
134124
}
135125

136126
/** Return true if all the collumn is air. */

Underilla-Core/src/main/java/com/jkantrell/mc/underilla/core/generation/GenerationConfig.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ public class GenerationConfig {
2121

2222
public List<? extends Biome> transferCavesWorldBiomes = Collections.emptyList();
2323

24-
public MergeStrategy mergeStrategy = MergeStrategy.RELATIVE;
24+
public boolean customBiomeEnabled = false;
25+
26+
public MergeStrategy mergeStrategy = MergeStrategy.SURFACE;
2527

2628
public int mergeUpperLimit = 320;
2729

2830
public int mergeLowerLimit = -64;
2931

3032
public int mergeDepth = 12;
3133

32-
public List<? extends Biome> keptUndergroundBiomes = Collections.emptyList();
33-
3434
public List<String> keptReferenceWorldBlocks = Collections.emptyList();
3535

36-
public List<? extends Biome> preserveBiomes = Collections.emptyList();
36+
public List<String> preserveBiomes = Collections.emptyList();
3737

38-
public List<? extends Biome> ravinBiomes = Collections.emptyList();
38+
public List<String> ravinBiomes = Collections.emptyList();
3939

4040
public int mergeLimit = 22;
4141

@@ -45,6 +45,7 @@ public class GenerationConfig {
4545

4646
public boolean needToMixBiomes() {
4747
// true if we transfer biomes and we have kept underground biomes and we are using relative merge strategy
48-
return this.transferBiomes && !this.keptUndergroundBiomes.isEmpty() && MergeStrategy.RELATIVE.equals(this.mergeStrategy);
48+
// return this.transferBiomes && !this.keptUndergroundBiomes.isEmpty() && MergeStrategy.RELATIVE.equals(this.mergeStrategy);
49+
return false;
4950
}
5051
}

Underilla-Core/src/main/java/com/jkantrell/mc/underilla/core/generation/Generator.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public Generator(WorldReader worldReader, GenerationConfig config) {
3030
this.config_ = config;
3131
this.merger_ = switch (config_.mergeStrategy) {
3232
case RELATIVE -> new RelativeMerger(this.worldReader_, config_.mergeUpperLimit, config_.mergeLowerLimit, config_.mergeDepth,
33-
config_.mergeBlendRange, config_.keptUndergroundBiomes, config_.preserveBiomes, config_.keptReferenceWorldBlocks);
33+
config_.mergeBlendRange, List.of(), config_.preserveBiomes, config_.keptReferenceWorldBlocks);
3434
case SURFACE, ABSOLUTE, NONE -> new AbsoluteMerger(config_.mergeStrategy.equals(MergeStrategy.NONE) ? -64 : config_.mergeLimit,
3535
config_.preserveBiomes, config.ravinBiomes, config_.keptReferenceWorldBlocks,
3636
config_.mergeStrategy.equals(MergeStrategy.SURFACE) ? config_.mergeDepth : 0);
@@ -66,11 +66,11 @@ public void generateSurface(@Nonnull ChunkReader reader, @Nonnull ChunkData chun
6666
this.merger_.mergeLand(reader, chunkData, cavesReader);
6767
// The only configuration where we need to merge biome here is when we want to transfer biomes from the reference world
6868
// & keep underground biomes.
69-
if (config_.needToMixBiomes()) {
70-
long time = System.currentTimeMillis();
71-
this.merger_.mergeBiomes(reader, chunkData);
72-
addTime("mergeBiomes", time);
73-
}
69+
// if (config_.needToMixBiomes()) {
70+
// long time = System.currentTimeMillis();
71+
// this.merger_.mergeBiomes(reader, chunkData);
72+
// addTime("mergeBiomes", time);
73+
// }
7474
}
7575

7676
public void reInsertLiquids(ChunkReader reader, ChunkData chunkData) {

Underilla-Core/src/main/java/com/jkantrell/mc/underilla/core/generation/Merger.java

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ interface Merger {
99

1010
// void merge(ChunkReader reader, ChunkData chunkData);
1111
void mergeLand(@Nonnull ChunkReader reader, @Nonnull ChunkData chunkData, @Nullable ChunkReader cavesReader);
12-
void mergeBiomes(@Nonnull ChunkReader reader, @Nonnull ChunkData chunkData);
1312
}

0 commit comments

Comments
 (0)