Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.21.1 #8

Merged
merged 21 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: SonarCloud
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'temurin'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonar --info
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[ ![discord-shield][] ][discord-invite]

# Underilla
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.
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.

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.

Expand All @@ -20,20 +20,20 @@ It's original purpose is adding vanilla caves to custom [WorldPainter](https://w
- **None:** No actual vanilla underground noise is generated. `generate_noodle_caves` setting can still be on, to generate noodle caves.
- **Absolute:** A Y coordinate value divides the original world surface and vanilla underground.
- **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.
- **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.
- **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.
- 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.
- 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.
- 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.

## Getting started
### Perquisites

- Java 17.
- Java 21.
- A pre-generated world to use as a reference (Such as a WorldPainter world).
- 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.
- 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.

### Single player or non-Bukkit
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.
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.

### Installation

Expand All @@ -58,7 +58,8 @@ Underilla is currently only implemented as a Spigot plugin, so it runs only on S
**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.

### Pregenerate
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.
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.
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.

### Performances
Huge map generation can takes hours or even days, here is some stats about performance to help you choose your configuration settings.
Expand All @@ -76,7 +77,6 @@ For a 50000 * 30000 world, it would take 40 hours to generate with Minecraft van
- 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.
- 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.
- **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.
- **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).

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

## Custom biome
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.
If you have a custom world with custom biomes, you should enable custom biome it in the config.

## Feature fiter
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.
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.

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

## TODO
Build-in pre-generation system.
Allow to generate the 2nd world on the fly.
- Build-in pre-generation system.
- Allow to generate the 2nd world on the fly.
24 changes: 0 additions & 24 deletions Underilla-Core/build.gradle

This file was deleted.

34 changes: 34 additions & 0 deletions Underilla-Core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
`java-library`
id("org.sonarqube") version "4.4.1.3373"
}

group = "com.Jkantrell.mc"
version = "1.6.0"
java.sourceCompatibility = JavaVersion.VERSION_21

repositories {
mavenCentral()
mavenLocal()
maven ("https://jitpack.io")
}


dependencies {
// testImplementation platform("org.junit:junit-bom:5.9.1")
// testImplementation("org.junit.jupiter:junit-jupiter")
implementation("org.apache.commons:commons-lang3:3.12.0")
api("com.github.HydrolienF:KntNBT:2.2.2")
}

tasks.test {
useJUnitPlatform()
}

sonar {
properties {
property("sonar.projectKey", "mvndicraft_underilla")
property("sonar.organization", "mvndicraft")
property("sonar.host.url", "https://sonarcloud.io")
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public interface Block {

boolean isAir();
boolean isSolid();
boolean isSolidAndSurfaceBlock();
boolean isLiquid();
boolean isWaterloggable();
void waterlog();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.jkantrell.mc.underilla.core.generation;

import java.util.List;
import com.jkantrell.mc.underilla.core.api.Biome;
import com.jkantrell.mc.underilla.core.api.Block;
import com.jkantrell.mc.underilla.core.api.ChunkData;
import com.jkantrell.mc.underilla.core.reader.ChunkReader;
Expand All @@ -16,12 +15,13 @@ class AbsoluteMerger implements Merger {

// FIELDS
private final int height_;
private final List<? extends Biome> preserveBiomes_, ravinBiomes_;
private final List<String> preserveBiomes_;
private final List<String> ravinBiomes_;
private final List<String> keptReferenceWorldBlocks_;
private final int mergeDepth_;

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


// IMPLEMENTATIONS
// @Override
// public void merge(ChunkReader reader, ChunkData chunkData) {
// this.mergeLand(reader, chunkData);
// // this.mergeBiomes(reader, chunkData); // No need to set biome for chunk. It's done by the generator.
// }
@Override
public void mergeLand(ChunkReader reader, ChunkData chunkData, @Nullable ChunkReader cavesReader) {
long startTime = System.currentTimeMillis();
Expand Down Expand Up @@ -101,17 +96,12 @@ public void mergeLand(ChunkReader reader, ChunkData chunkData, @Nullable ChunkRe
/** return the 1st block mergeDepth_ blocks under surface or heigth_ */
private int getLowerBlockToRemove(Reader reader, int x, int z, Block defaultBlock) {
int lbtr = this.height_ + mergeDepth_;
while (!reader.blockAt(x, lbtr, z).orElse(defaultBlock).isSolid() && lbtr > -64) {
while (!reader.blockAt(x, lbtr, z).orElse(defaultBlock).isSolidAndSurfaceBlock() && lbtr > -64) {
lbtr--;
}
return lbtr - mergeDepth_;
}

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


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

private boolean isRavinBiome(ChunkReader reader, Vector<Integer> v) {
return this.ravinBiomes_.contains(reader.biomeAt(v).orElse(null));
return this.ravinBiomes_.contains(reader.biomeAt(v).orElseThrow().getName());
}

/** Return true if all the collumn is air. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ public class GenerationConfig {

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

public MergeStrategy mergeStrategy = MergeStrategy.RELATIVE;
public boolean customBiomeEnabled = false;

public MergeStrategy mergeStrategy = MergeStrategy.SURFACE;

public int mergeUpperLimit = 320;

public int mergeLowerLimit = -64;

public int mergeDepth = 12;

public List<? extends Biome> keptUndergroundBiomes = Collections.emptyList();

public List<String> keptReferenceWorldBlocks = Collections.emptyList();

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

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

public int mergeLimit = 22;

Expand All @@ -45,6 +45,7 @@ public class GenerationConfig {

public boolean needToMixBiomes() {
// true if we transfer biomes and we have kept underground biomes and we are using relative merge strategy
return this.transferBiomes && !this.keptUndergroundBiomes.isEmpty() && MergeStrategy.RELATIVE.equals(this.mergeStrategy);
// return this.transferBiomes && !this.keptUndergroundBiomes.isEmpty() && MergeStrategy.RELATIVE.equals(this.mergeStrategy);
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Generator(WorldReader worldReader, GenerationConfig config) {
this.config_ = config;
this.merger_ = switch (config_.mergeStrategy) {
case RELATIVE -> new RelativeMerger(this.worldReader_, config_.mergeUpperLimit, config_.mergeLowerLimit, config_.mergeDepth,
config_.mergeBlendRange, config_.keptUndergroundBiomes, config_.preserveBiomes, config_.keptReferenceWorldBlocks);
config_.mergeBlendRange, List.of(), config_.preserveBiomes, config_.keptReferenceWorldBlocks);
case SURFACE, ABSOLUTE, NONE -> new AbsoluteMerger(config_.mergeStrategy.equals(MergeStrategy.NONE) ? -64 : config_.mergeLimit,
config_.preserveBiomes, config.ravinBiomes, config_.keptReferenceWorldBlocks,
config_.mergeStrategy.equals(MergeStrategy.SURFACE) ? config_.mergeDepth : 0);
Expand Down Expand Up @@ -66,11 +66,11 @@ public void generateSurface(@Nonnull ChunkReader reader, @Nonnull ChunkData chun
this.merger_.mergeLand(reader, chunkData, cavesReader);
// The only configuration where we need to merge biome here is when we want to transfer biomes from the reference world
// & keep underground biomes.
if (config_.needToMixBiomes()) {
long time = System.currentTimeMillis();
this.merger_.mergeBiomes(reader, chunkData);
addTime("mergeBiomes", time);
}
// if (config_.needToMixBiomes()) {
// long time = System.currentTimeMillis();
// this.merger_.mergeBiomes(reader, chunkData);
// addTime("mergeBiomes", time);
// }
}

public void reInsertLiquids(ChunkReader reader, ChunkData chunkData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ interface Merger {

// void merge(ChunkReader reader, ChunkData chunkData);
void mergeLand(@Nonnull ChunkReader reader, @Nonnull ChunkData chunkData, @Nullable ChunkReader cavesReader);
void mergeBiomes(@Nonnull ChunkReader reader, @Nonnull ChunkData chunkData);
}
Loading
Loading