mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-05-20 16:50:28 +00:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85b6dcc891 | |||
| 29691dfb4d | |||
| 81eab13ce1 | |||
| 68d5b22ca4 | |||
| 40b8c85c75 | |||
| 63367e5f03 | |||
| 1d95e7a87d | |||
| b2e21d8b70 | |||
| 4041239b03 | |||
| 280699bbce | |||
| 6984dc29d0 | |||
| bd253ea5d2 | |||
| d743d7d1df | |||
| 238a7954a7 | |||
| c2319ca4ab | |||
| 95172bfa7e | |||
| 124dbc8836 | |||
| 8706340584 | |||
| 9a9f90aa0d | |||
| 20a5bfdd0f | |||
| 4fee8cdb24 | |||
| 70de38ffcb | |||
| 6722d22f72 | |||
| c5526c86a2 | |||
| 84fa72f96c | |||
| cc5258ce73 | |||
| 748e027282 | |||
| bf6612edd0 | |||
| d90a4200fe | |||
| af9fb211a8 | |||
| e4395cec83 | |||
| bab8923f1e | |||
| b4068e6c59 | |||
| b143c72d0e | |||
| 5f5e70970b | |||
| ec812ef5fb | |||
| 85826071cb | |||
| c4f093210a | |||
| f14d22b264 | |||
| 016961c19c | |||
| 9f3e225b62 | |||
| c95df25d30 | |||
| 0adca3c227 | |||
| 782b300d1f | |||
| 967a4a0b2b | |||
| d3df5e56c3 | |||
| dabc2359b3 |
@@ -17,16 +17,16 @@ jobs:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
|
||||
uses: actions/setup-java@v4.7.1
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
|
||||
- uses: burrunan/gradle-cache-action@03c71a8ba93d670980695505f48f49daf43704a6
|
||||
- uses: burrunan/gradle-cache-action@v3.0.1
|
||||
name: Build Terra
|
||||
with:
|
||||
# Specifies arguments for Gradle execution
|
||||
@@ -44,4 +44,4 @@ jobs:
|
||||
# Properties are passed as -Pname=value
|
||||
properties: |
|
||||
kotlin.js.compiler=ir
|
||||
kotlin.parallel.tasks.in.project=true
|
||||
kotlin.parallel.tasks.in.project=true
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
preRelease(true)
|
||||
|
||||
versionProjects(":common:api", version("6.6.1"))
|
||||
versionProjects(":common:implementation", version("6.6.1"))
|
||||
versionProjects(":platforms", version("6.6.1"))
|
||||
versionProjects(":common:api", version("6.6.4"))
|
||||
versionProjects(":common:implementation", version("6.6.4"))
|
||||
versionProjects(":platforms", version("6.6.4"))
|
||||
|
||||
|
||||
allprojects {
|
||||
|
||||
@@ -6,6 +6,12 @@ plugins {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven("https://maven.solo-studios.ca/releases") {
|
||||
name = "Solo Studios"
|
||||
}
|
||||
maven("https://maven.solo-studios.ca/snapshots") {
|
||||
name = "Solo Studios"
|
||||
}
|
||||
maven("https://repo.codemc.org/repository/maven-public") {
|
||||
name = "CodeMC"
|
||||
}
|
||||
@@ -16,11 +22,11 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
//TODO Allow pulling from Versions.kt
|
||||
implementation("com.gradleup.shadow", "shadow-gradle-plugin", "8.3.1")
|
||||
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "1.7.2")
|
||||
implementation("com.gradleup.shadow", "shadow-gradle-plugin", "8.3.6")
|
||||
|
||||
implementation("org.ow2.asm", "asm", "9.7")
|
||||
implementation("org.ow2.asm", "asm-tree", "9.7")
|
||||
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "2.0.0-beta.17")
|
||||
implementation("org.ow2.asm", "asm", "9.8")
|
||||
implementation("org.ow2.asm", "asm-tree", "9.8")
|
||||
implementation("com.dfsek.tectonic", "common", "4.2.1")
|
||||
implementation("org.yaml", "snakeyaml", "2.3")
|
||||
implementation("org.yaml", "snakeyaml", "2.4")
|
||||
}
|
||||
@@ -30,6 +30,12 @@ fun Project.configureDependencies() {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven("https://maven.solo-studios.ca/releases") {
|
||||
name = "Solo Studios"
|
||||
}
|
||||
maven("https://maven.solo-studios.ca/snapshots") {
|
||||
name = "Solo Studios"
|
||||
}
|
||||
maven("https://maven.fabricmc.net/") {
|
||||
name = "FabricMC"
|
||||
}
|
||||
@@ -60,11 +66,14 @@ fun Project.configureDependencies() {
|
||||
maven("https://storehouse.okaeri.eu/repository/maven-public/") {
|
||||
name = "Okaeri"
|
||||
}
|
||||
maven("https://repo.onarandombox.com/multiverse-releases") {
|
||||
name = "onarandombox"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation("org.junit.jupiter", "junit-jupiter-api", Versions.Libraries.Internal.junit)
|
||||
testImplementation("org.junit.jupiter", "junit-jupiter-engine", Versions.Libraries.Internal.junit)
|
||||
testImplementation("org.junit.jupiter", "junit-jupiter", Versions.Libraries.Internal.junit)
|
||||
"testRuntimeOnly"("org.junit.platform", "junit-platform-launcher")
|
||||
compileOnly("org.jetbrains", "annotations", Versions.Libraries.Internal.jetBrainsAnnotations)
|
||||
|
||||
compileOnly("com.google.guava", "guava", Versions.Libraries.Internal.guava)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
object Versions {
|
||||
object Terra {
|
||||
const val overworldConfig = "v1.3.4"
|
||||
const val overworldConfig = "v1.5.2"
|
||||
}
|
||||
|
||||
object Libraries {
|
||||
@@ -10,26 +10,26 @@ object Versions {
|
||||
|
||||
const val cloud = "2.0.0"
|
||||
|
||||
const val caffeine = "3.1.8"
|
||||
const val caffeine = "3.2.1"
|
||||
|
||||
const val slf4j = "2.0.16"
|
||||
const val slf4j = "2.0.17"
|
||||
|
||||
object Internal {
|
||||
const val shadow = "8.3.3"
|
||||
const val apacheText = "1.12.0"
|
||||
const val apacheIO = "2.17.0"
|
||||
const val guava = "33.3.1-jre"
|
||||
const val asm = "9.7.1"
|
||||
const val snakeYml = "2.3"
|
||||
const val jetBrainsAnnotations = "26.0.1"
|
||||
const val junit = "5.11.3"
|
||||
const val shadow = "8.3.6"
|
||||
const val apacheText = "1.13.1"
|
||||
const val apacheIO = "2.19.0"
|
||||
const val guava = "33.4.8-jre"
|
||||
const val asm = "9.8"
|
||||
const val snakeYml = "2.4"
|
||||
const val jetBrainsAnnotations = "26.0.2"
|
||||
const val junit = "5.13.1"
|
||||
const val nbt = "6.1"
|
||||
}
|
||||
}
|
||||
|
||||
object Fabric {
|
||||
const val fabricAPI = "0.118.0+${Mod.minecraft}"
|
||||
const val cloud = "2.0.0-beta.9"
|
||||
const val fabricAPI = "0.127.0+${Mod.minecraft}"
|
||||
const val cloud = "2.0.0-beta.10"
|
||||
}
|
||||
//
|
||||
// object Quilt {
|
||||
@@ -38,14 +38,15 @@ object Versions {
|
||||
// }
|
||||
|
||||
object Mod {
|
||||
const val mixin = "0.15.3+mixin.0.8.7"
|
||||
const val mixin = "0.15.5+mixin.0.8.7"
|
||||
const val mixinExtras = "0.4.1"
|
||||
|
||||
const val minecraft = "1.21.4"
|
||||
const val yarn = "$minecraft+build.8"
|
||||
const val fabricLoader = "0.16.10"
|
||||
const val minecraft = "1.21.6"
|
||||
const val yarn = "$minecraft+build.1"
|
||||
const val fabricLoader = "0.16.14"
|
||||
|
||||
const val architecuryLoom = "1.7.413"
|
||||
const val architecturyPlugin = "3.4.159"
|
||||
const val architecuryLoom = "1.10.431"
|
||||
const val architecturyPlugin = "3.4.161"
|
||||
|
||||
}
|
||||
//
|
||||
@@ -55,18 +56,19 @@ object Versions {
|
||||
// }
|
||||
|
||||
object Bukkit {
|
||||
const val minecraft = "1.21.4"
|
||||
const val paperBuild = "$minecraft-R0.1-20241211.212446-17"
|
||||
const val minecraft = "1.21.6-R0.1"
|
||||
const val paperBuild = "$minecraft-20250617.170821-8"
|
||||
const val paper = paperBuild
|
||||
const val paperLib = "1.0.8"
|
||||
const val reflectionRemapper = "0.1.1"
|
||||
const val reflectionRemapper = "0.1.2"
|
||||
const val paperDevBundle = paperBuild
|
||||
const val runPaper = "2.3.1"
|
||||
const val paperWeight = "1.7.2"
|
||||
const val paperWeight = "2.0.0-beta.17"
|
||||
const val cloud = "2.0.0-beta.10"
|
||||
const val multiverse = "5.0.2"
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// object Sponge {
|
||||
// const val sponge = "9.0.0-SNAPSHOT"
|
||||
// const val mixin = "0.8.2"
|
||||
@@ -74,18 +76,18 @@ object Versions {
|
||||
// }
|
||||
//
|
||||
object CLI {
|
||||
const val logback = "1.5.8"
|
||||
const val picocli = "4.7.6"
|
||||
const val logback = "1.5.18"
|
||||
const val picocli = "4.7.7"
|
||||
}
|
||||
|
||||
object Allay {
|
||||
const val api = "0.2.0"
|
||||
const val gson = "2.12.1"
|
||||
const val api = "0.4.1"
|
||||
const val gson = "2.13.1"
|
||||
const val mappings = "3626653"
|
||||
const val mappingsGenerator = "366618e"
|
||||
}
|
||||
|
||||
object Minestom {
|
||||
const val minestom = "187931e50b"
|
||||
const val minestom = "1_21_6-c3ccee696b"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ dependencies {
|
||||
api("ca.solo-studios", "strata", Versions.Libraries.strata)
|
||||
compileOnlyApi("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
|
||||
testImplementation("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
|
||||
|
||||
api("org.incendo", "cloud-core", Versions.Libraries.cloud)
|
||||
|
||||
api("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
|
||||
|
||||
@@ -31,6 +31,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@@ -327,6 +329,28 @@ public abstract class AbstractPlatform implements Platform {
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
private static final String moonrise = "Moonrise";
|
||||
public static int getMoonriseGenerationThreadsWithReflection() {
|
||||
try {
|
||||
Class<?> prioritisedThreadPoolClazz = Class.forName("ca.spottedleaf.concurrentutil.executor.thread.PrioritisedThreadPool");
|
||||
Method getCoreThreadsMethod = prioritisedThreadPoolClazz.getDeclaredMethod("getCoreThreads");
|
||||
getCoreThreadsMethod.setAccessible(true);
|
||||
Class<?> moonriseCommonClazz = Class.forName("ca.spottedleaf.moonrise.common.util.MoonriseCommon");
|
||||
Object pool = moonriseCommonClazz.getDeclaredField("WORKER_POOL").get(null);
|
||||
int threads = ((Thread[]) getCoreThreadsMethod.invoke(pool)).length;
|
||||
logger.info("{} found, setting {} generation threads.", moonrise, threads);
|
||||
return threads;
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.info("{} not found.", moonrise);
|
||||
} catch (NoSuchMethodException | NoSuchFieldException e) {
|
||||
logger.warn("{} found, but field/method not found this probably means {0} has changed its code and " +
|
||||
"Terra has not updated to reflect that.", moonrise);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
logger.error("Failed to access thread values in {}, assuming 1 generation thread.", moonrise, e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
||||
for(File dir : Objects.requireNonNull(packsFolder.listFiles(File::isDirectory))) {
|
||||
try {
|
||||
load(dir, platform);
|
||||
} catch(ConfigException e) {
|
||||
} catch(RuntimeException e) {
|
||||
logger.error("Error loading config pack {}", dir.getName(), e);
|
||||
valid = false;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
||||
try {
|
||||
logger.info("Loading ZIP archive: {}", zip.getName());
|
||||
load(new ZipFile(zip), platform);
|
||||
} catch(IOException | ConfigException e) {
|
||||
} catch(IOException | RuntimeException e) {
|
||||
logger.error("Error loading config pack {}", zip.getName(), e);
|
||||
valid = false;
|
||||
}
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
distributionSha256Sum=845952a9d6afa783db70bb3b0effaae45ae5542ca2bb7929619e8af49cb634cf
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -86,8 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -115,7 +114,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -206,7 +205,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
@@ -214,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+2
-2
@@ -70,11 +70,11 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.allaymc.api.block.type.BlockStateSafeGetter;
|
||||
import org.allaymc.api.block.type.BlockTypes;
|
||||
import org.allaymc.api.item.type.ItemType;
|
||||
import org.allaymc.api.item.type.ItemTypeSafeGetter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
@@ -38,7 +38,7 @@ public record AllayItemStack(ItemStack allayItemStack) implements com.dfsek.terr
|
||||
allayItemStack.addEnchantment(enchantment.getType(), enchantment.getLevel());
|
||||
}
|
||||
allayItemStack.setLore(targetItem.getLore());
|
||||
allayItemStack.setDurability(targetItem.getDurability());
|
||||
allayItemStack.setDamage(targetItem.getDamage());
|
||||
allayItemStack.setCustomName(targetItem.getCustomName());
|
||||
allayItemStack.setMeta(targetItem.getMeta());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev")
|
||||
id("xyz.jpenilla.run-paper") version Versions.Bukkit.runPaper
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Required for :platforms:bukkit:runDevBundleServer task
|
||||
paperweight.paperDevBundle(Versions.Bukkit.paperDevBundle)
|
||||
|
||||
shaded(project(":platforms:bukkit:common"))
|
||||
shaded(project(":platforms:bukkit:nms:v1_21_3", configuration = "reobf"))
|
||||
shaded(project(":platforms:bukkit:nms:v1_21_6"))
|
||||
shaded("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||
}
|
||||
|
||||
@@ -26,6 +30,11 @@ tasks {
|
||||
minecraftVersion(Versions.Bukkit.minecraft)
|
||||
dependsOn(shadowJar)
|
||||
pluginJars(shadowJar.get().archiveFile)
|
||||
|
||||
downloadPlugins {
|
||||
modrinth("viaversion", "5.3.2")
|
||||
modrinth("viabackwards", "5.3.2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ dependencies {
|
||||
|
||||
compileOnly("io.papermc.paper", "paper-api", Versions.Bukkit.paper)
|
||||
|
||||
compileOnly("org.mvplugins.multiverse.core", "multiverse-core", Versions.Bukkit.multiverse)
|
||||
|
||||
shadedApi("io.papermc", "paperlib", Versions.Bukkit.paperLib)
|
||||
|
||||
shadedApi("com.google.guava", "guava", Versions.Libraries.Internal.guava)
|
||||
|
||||
@@ -57,7 +57,7 @@ public class PlatformImpl extends AbstractPlatform {
|
||||
private int generationThreads;
|
||||
|
||||
public PlatformImpl(TerraBukkitPlugin plugin) {
|
||||
generationThreads = getGenerationThreadsWithReflection("ca.spottedleaf.moonrise.common.util.MoonriseCommon", "WORKER_THREADS", "Moonrise");
|
||||
generationThreads = getMoonriseGenerationThreadsWithReflection();
|
||||
if (generationThreads == 0) {
|
||||
generationThreads = 1;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new CommonListener(), this); // Register master event listener
|
||||
Bukkit.getPluginManager().registerEvents(new CommonListener(platform), this); // Register master event listener
|
||||
PaperUtil.checkPaper(this);
|
||||
}
|
||||
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.dfsek.terra.bukkit.hooks;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.registry.key.Keyed;
|
||||
|
||||
import org.mvplugins.multiverse.core.MultiverseCoreApi;
|
||||
import org.mvplugins.multiverse.core.world.generators.GeneratorPlugin;
|
||||
import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
|
||||
import org.mvplugins.multiverse.external.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public final class MultiverseGeneratorPluginHook implements GeneratorPlugin {
|
||||
|
||||
private final Platform platform;
|
||||
|
||||
public MultiverseGeneratorPluginHook(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<String> suggestIds(@Nullable String s) {
|
||||
return platform.getConfigRegistry().entries().stream()
|
||||
.map(Keyed::getID)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Collection<String> getExampleUsages() {
|
||||
return platform.getConfigRegistry()
|
||||
.entries()
|
||||
.stream()
|
||||
.map(Keyed::getID)
|
||||
.map("/mv create example_world NORMAL -g Terra:%s"::formatted)
|
||||
.limit(5) // reasonable amount
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getInfoLink() {
|
||||
return "https://terra.polydev.org/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getPluginName() {
|
||||
return "Terra";
|
||||
}
|
||||
|
||||
public static void register(Platform platform) {
|
||||
MultiverseCoreApi.get().getGeneratorProvider()
|
||||
.registerGeneratorPlugin(new MultiverseGeneratorPluginHook(platform));
|
||||
}
|
||||
}
|
||||
+26
-1
@@ -17,13 +17,38 @@
|
||||
|
||||
package com.dfsek.terra.bukkit.listeners;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.bukkit.hooks.MultiverseGeneratorPluginHook;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Listener for events on all implementations.
|
||||
*/
|
||||
public class CommonListener implements Listener {
|
||||
public CommonListener() {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CommonListener.class);
|
||||
private final Platform platform;
|
||||
|
||||
public CommonListener(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if(event.getPlugin().getName().equals("Multiverse-Core")) {
|
||||
try {
|
||||
Class.forName("org.mvplugins.multiverse.core.MultiverseCoreApi");
|
||||
MultiverseGeneratorPluginHook.register(platform);
|
||||
} catch(ClassNotFoundException e) {
|
||||
logger.debug("Multiverse v5 is not installed.");
|
||||
} catch(IllegalStateException e) {
|
||||
logger.error("Failed to register Terra generator plugin to multiverse.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ public interface Initializer {
|
||||
private static Initializer constructInitializer() {
|
||||
try {
|
||||
String packageVersion = NMS;
|
||||
if (NMS.equals("v1_21_4")) {
|
||||
packageVersion = "v1_21_3";
|
||||
if (NMS.equals("v1_21_5")) {
|
||||
packageVersion = "v1_21_6";
|
||||
}
|
||||
|
||||
Class<?> initializerClass = Class.forName(TERRA_PACKAGE + "." + packageVersion + ".NMSInitializer");
|
||||
|
||||
@@ -2,7 +2,7 @@ name: "Terra"
|
||||
main: "com.dfsek.terra.bukkit.TerraBukkitPlugin"
|
||||
version: "@VERSION@"
|
||||
load: "STARTUP"
|
||||
authors: [ "dfsek", "duplexsystem", "Astrash", "solonovamax", "Sancires", "Aureus", "RogueShade" ]
|
||||
authors: [ "dfsek", "duplexsystem", "Astrash", "solonovamax", "Sancires", "Aureus", "RogueShade", "OakLoaf" ]
|
||||
website: "@WIKI@"
|
||||
api-version: "1.21.1"
|
||||
description: "@DESCRIPTION@"
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
apply(plugin = "io.papermc.paperweight.userdev")
|
||||
|
||||
dependencies {
|
||||
api(project(":platforms:bukkit:common"))
|
||||
paperDevBundle(Versions.Bukkit.paperDevBundle)
|
||||
implementation("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||
}
|
||||
|
||||
tasks {
|
||||
assemble {
|
||||
dependsOn("reobfJar")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":platforms:bukkit:common"))
|
||||
paperweight.paperDevBundle(Versions.Bukkit.paperDevBundle)
|
||||
implementation("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import com.dfsek.terra.bukkit.nms.v1_21_3.config.VanillaBiomeProperties;
|
||||
import com.dfsek.terra.bukkit.nms.v1_21_6.config.VanillaBiomeProperties;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Holder.Reference;
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.bukkit.BukkitAddon;
|
||||
import com.dfsek.terra.bukkit.PlatformImpl;
|
||||
import com.dfsek.terra.bukkit.nms.v1_21_3.config.VanillaBiomeProperties;
|
||||
import com.dfsek.terra.bukkit.nms.v1_21_6.config.VanillaBiomeProperties;
|
||||
|
||||
|
||||
public class NMSAddon extends BukkitAddon {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
+4
-5
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
@@ -12,7 +12,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.bukkit.nms.v1_21_3.config.VanillaBiomeProperties;
|
||||
import com.dfsek.terra.bukkit.nms.v1_21_6.config.VanillaBiomeProperties;
|
||||
|
||||
|
||||
public class NMSBiomeInjector {
|
||||
@@ -33,9 +33,8 @@ public class NMSBiomeInjector {
|
||||
.waterColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterColor(), vanilla.getWaterColor()))
|
||||
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
|
||||
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
|
||||
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getSpecialEffects().getGrassColorModifier()));
|
||||
// .grassColorOverride(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColor(), vanilla.getSpecialEffects().getGrassColorOverride().orElseGet(() -> Reflection.BIOME.invokeGrassColorFromTexture(vanilla))))
|
||||
// .foliageColorOverride(Objects.requireNonNullElse(vanillaBiomeProperties.getFoliageColor(), vanilla.getFoliageColor()));
|
||||
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getSpecialEffects().getGrassColorModifier()))
|
||||
.backgroundMusicVolume(Objects.requireNonNullElse(vanillaBiomeProperties.getMusicVolume(), vanilla.getBackgroundMusicVolume()));
|
||||
|
||||
if(vanillaBiomeProperties.getGrassColor() == null) {
|
||||
vanilla.getSpecialEffects().getGrassColorOverride().ifPresent(effects::grassColorOverride);
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.core.Holder;
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -116,10 +116,10 @@ public class NMSChunkGeneratorDelegate extends ChunkGenerator {
|
||||
if(noise > threshold) {
|
||||
chunk.setBlockState(new BlockPos(x, y, z), ((CraftBlockData) ((BukkitBlockState) delegate
|
||||
.getPalette(x + xi, y, z + zi, world, biomeProvider)
|
||||
.get(depth, x + xi, y, z + zi, world.getSeed())).getHandle()).getState(), false);
|
||||
.get(depth, x + xi, y, z + zi, world.getSeed())).getHandle()).getState(), 0);
|
||||
depth++;
|
||||
} else if(noise < airThreshold) {
|
||||
chunk.setBlockState(new BlockPos(x, y, z), Blocks.AIR.defaultBlockState(), false);
|
||||
chunk.setBlockState(new BlockPos(x, y, z), Blocks.AIR.defaultBlockState(), 0);
|
||||
} else {
|
||||
depth = 0;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import com.dfsek.terra.bukkit.BukkitAddon;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Holder.Reference;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
+12
-4
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
|
||||
|
||||
public class SpawnEntryTemplate implements ObjectTemplate<SpawnerData> {
|
||||
public class SpawnEntryConfig implements ObjectTemplate<SpawnEntryConfig> {
|
||||
@Value("type")
|
||||
@Default
|
||||
private EntityType<?> type = null;
|
||||
@@ -23,9 +23,17 @@ public class SpawnEntryTemplate implements ObjectTemplate<SpawnerData> {
|
||||
@Value("max-group-size")
|
||||
@Default
|
||||
private Integer maxGroupSize = null;
|
||||
|
||||
public Integer getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public SpawnerData getSpawnerData() {
|
||||
return new SpawnerData(type, minGroupSize, maxGroupSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnerData get() {
|
||||
return new SpawnerData(type, weight, minGroupSize, maxGroupSize);
|
||||
public SpawnEntryConfig get() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
@@ -6,7 +6,6 @@ import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -33,8 +32,8 @@ public class SpawnSettingsTemplate implements ObjectTemplate<MobSpawnSettings> {
|
||||
MobSpawnSettings.Builder builder = new MobSpawnSettings.Builder();
|
||||
for(SpawnTypeConfig spawn : spawns) {
|
||||
MobCategory group = spawn.getGroup();
|
||||
for(SpawnerData entry : spawn.getEntries()) {
|
||||
builder.addSpawn(group, entry);
|
||||
for(SpawnEntryConfig entry : spawn.getEntries()) {
|
||||
builder.addSpawn(group, entry.getWeight(), entry.getSpawnerData());
|
||||
}
|
||||
}
|
||||
for(SpawnCostConfig cost : costs) {
|
||||
+3
-4
@@ -1,11 +1,10 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
|
||||
|
||||
public class SpawnTypeConfig implements ObjectTemplate<SpawnTypeConfig> {
|
||||
@@ -15,13 +14,13 @@ public class SpawnTypeConfig implements ObjectTemplate<SpawnTypeConfig> {
|
||||
|
||||
@Value("entries")
|
||||
@Default
|
||||
private List<SpawnerData> entries = null;
|
||||
private List<SpawnEntryConfig> entries = null;
|
||||
|
||||
public MobCategory getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public List<SpawnerData> getEntries() {
|
||||
public List<SpawnEntryConfig> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
+17
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
@@ -38,6 +38,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
@Default
|
||||
private Integer foliageColor = null;
|
||||
|
||||
@Value("colors.dry-foliage")
|
||||
@Default
|
||||
private Integer dryFoliageColor = null;
|
||||
|
||||
@Value("colors.sky")
|
||||
@Default
|
||||
private Integer skyColor = null;
|
||||
@@ -82,6 +86,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
@Default
|
||||
private Music music = null;
|
||||
|
||||
@Value("sound.music-volume")
|
||||
@Default
|
||||
private Float musicVolume = null;
|
||||
|
||||
@Value("spawning")
|
||||
@Default
|
||||
private MobSpawnSettings spawnSettings = null;
|
||||
@@ -98,6 +106,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
return foliageColor;
|
||||
}
|
||||
|
||||
public Integer getDryFoliageColor() {
|
||||
return dryFoliageColor;
|
||||
}
|
||||
|
||||
public Integer getGrassColor() {
|
||||
return grassColor;
|
||||
}
|
||||
@@ -154,6 +166,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
return music;
|
||||
}
|
||||
|
||||
public Float getMusicVolume() {
|
||||
return musicVolume;
|
||||
}
|
||||
|
||||
public MobSpawnSettings getSpawnSettings() {
|
||||
return spawnSettings;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_3.config;
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_6.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
@@ -26,7 +26,9 @@ dependencies {
|
||||
|
||||
modImplementation("net.fabricmc:fabric-loader:${Versions.Mod.fabricLoader}")
|
||||
|
||||
modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud)
|
||||
modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud) {
|
||||
exclude("me.lucko", "fabric-permissions-api")
|
||||
}
|
||||
include("org.incendo", "cloud-fabric", Versions.Fabric.cloud)
|
||||
|
||||
modRuntimeOnly("net.fabricmc.fabric-api", "fabric-api", Versions.Fabric.fabricAPI)
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"solonovamax",
|
||||
"Sancires",
|
||||
"Aureus",
|
||||
"RogueShade"
|
||||
"RogueShade",
|
||||
"OakLoaf"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "@WIKI@",
|
||||
@@ -34,7 +35,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.16.10",
|
||||
"java": ">=21",
|
||||
"minecraft": ">=1.21.4",
|
||||
"minecraft": ">=1.21.6",
|
||||
"fabric": "*"
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public final class MinestomPlatform extends AbstractPlatform {
|
||||
if(world.generator() instanceof MinestomChunkGeneratorWrapper wrapper) {
|
||||
getConfigRegistry().get(wrapper.getPack().getRegistryKey()).ifPresent(pack -> {
|
||||
wrapper.setPack(pack);
|
||||
LOGGER.info("Replaced pack in chunk generator for instance {}", world.getUniqueId());
|
||||
LOGGER.info("Replaced pack in chunk generator for instance {}", world.getUuid());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -7,9 +7,9 @@ import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.PlatformBiome;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import net.minestom.server.world.biome.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class MinestomBiomeLoader implements TypeLoader<PlatformBiome> {
|
||||
public PlatformBiome load(@NotNull AnnotatedType annotatedType, @NotNull Object o, @NotNull ConfigLoader configLoader,
|
||||
DepthTracker depthTracker) throws LoadException {
|
||||
String id = (String) o;
|
||||
NamespaceID biomeID = NamespaceID.from(id);
|
||||
Key biomeID = Key.key(id);
|
||||
Biome biome = biomeRegistry.get(biomeID);
|
||||
if(biome == null) throw new LoadException("Biome %s does not exist in registry".formatted(id), depthTracker);
|
||||
return new MinestomBiome(biome);
|
||||
|
||||
+7
-1
@@ -4,11 +4,17 @@ import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.minestom.api.BlockEntityFactory;
|
||||
|
||||
import net.minestom.server.coordinate.BlockVec;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
||||
|
||||
public class DefaultBlockEntityFactory implements BlockEntityFactory {
|
||||
private final Instance instance;
|
||||
public DefaultBlockEntityFactory(Instance instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockVec position) {
|
||||
return null;
|
||||
return new MinestomBlockEntity(instance, position);
|
||||
}
|
||||
}
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.dfsek.terra.minestom.block;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import net.minestom.server.coordinate.BlockVec;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
|
||||
public class MinestomBlockEntity implements BlockEntity {
|
||||
private final Instance instance;
|
||||
private final BlockVec position;
|
||||
private final Vector3 positionVec;
|
||||
|
||||
public MinestomBlockEntity(Instance instance, BlockVec position) {
|
||||
this.instance = instance;
|
||||
this.position = position;
|
||||
this.positionVec = Vector3.of(position.blockX(), position.blockY(), position.blockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean applyPhysics) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 getPosition() {
|
||||
return positionVec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return position.blockX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return position.blockY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return position.blockZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState() {
|
||||
return new MinestomBlockState(instance.getBlock(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getHandle() {
|
||||
return instance.getBlock(position);
|
||||
}
|
||||
}
|
||||
+9
-24
@@ -1,15 +1,14 @@
|
||||
package com.dfsek.terra.minestom.block;
|
||||
|
||||
import net.minestom.server.instance.block.Block;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.Property;
|
||||
|
||||
import net.minestom.server.instance.block.Block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class MinestomBlockState implements BlockState {
|
||||
private final Block block;
|
||||
@@ -23,24 +22,10 @@ public class MinestomBlockState implements BlockState {
|
||||
}
|
||||
|
||||
public MinestomBlockState(String data) {
|
||||
if(!data.contains("[")) {
|
||||
block = Block.fromNamespaceId(data);
|
||||
return;
|
||||
block = Block.fromState(data);
|
||||
if (block == null) {
|
||||
throw new IllegalArgumentException("Invalid block state: " + data);
|
||||
}
|
||||
|
||||
String[] split = data.split("\\[");
|
||||
String namespaceId = split[0];
|
||||
String properties = split[1].substring(0, split[1].length() - 1);
|
||||
Block block = Block.fromNamespaceId(namespaceId);
|
||||
HashMap<String, String> propertiesMap = new HashMap<>();
|
||||
|
||||
for(String property : properties.split(",")) {
|
||||
String[] kv = property.split("=");
|
||||
propertiesMap.put(kv[0].strip(), kv[1].strip());
|
||||
}
|
||||
|
||||
assert block != null;
|
||||
this.block = block.withProperties(propertiesMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,7 +55,7 @@ public class MinestomBlockState implements BlockState {
|
||||
|
||||
@Override
|
||||
public String getAsString(boolean properties) {
|
||||
String name = block.namespace().asString();
|
||||
String name = block.key().asString();
|
||||
if(!properties || block.properties().isEmpty()) {
|
||||
return name;
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class MinestomEntityType implements com.dfsek.terra.api.entity.EntityType
|
||||
private final EntityType delegate;
|
||||
|
||||
public MinestomEntityType(String id) {
|
||||
delegate = EntityType.fromNamespaceId(id);
|
||||
delegate = EntityType.fromKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+15
-15
@@ -5,47 +5,47 @@ import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
|
||||
import java.util.Objects;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.registry.RegistryKey;
|
||||
|
||||
|
||||
public class MinestomEnchantment implements Enchantment {
|
||||
private final net.minestom.server.item.enchant.Enchantment delegate;
|
||||
private final String id;
|
||||
private final net.minestom.server.item.enchant.Enchantment registryItem;
|
||||
private final RegistryKey<net.minestom.server.item.enchant.Enchantment> id;
|
||||
private static final DynamicRegistry<net.minestom.server.item.enchant.Enchantment> enchantmentRegistry =
|
||||
MinecraftServer.getEnchantmentRegistry();
|
||||
|
||||
public MinestomEnchantment(net.minestom.server.item.enchant.Enchantment delegate) {
|
||||
this.delegate = delegate;
|
||||
id = Objects.requireNonNull(delegate.registry()).raw();
|
||||
public MinestomEnchantment(RegistryKey<net.minestom.server.item.enchant.Enchantment> id) {
|
||||
this.id = id;
|
||||
this.registryItem = enchantmentRegistry.get(id);
|
||||
}
|
||||
|
||||
public MinestomEnchantment(String id) {
|
||||
this.delegate = MinecraftServer.getEnchantmentRegistry().get(NamespaceID.from(id));
|
||||
this.id = id;
|
||||
this(RegistryKey.unsafeOf(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEnchantItem(ItemStack itemStack) {
|
||||
return delegate.supportedItems().contains((Material) itemStack.getType().getHandle());
|
||||
return registryItem.supportedItems().contains((Material) itemStack.getType().getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conflictsWith(Enchantment other) {
|
||||
return delegate.exclusiveSet().contains(NamespaceID.from(((MinestomEnchantment) other).id));
|
||||
return registryItem.exclusiveSet().contains(((MinestomEnchantment) other).id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return id;
|
||||
return id.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return delegate.maxLevel();
|
||||
return registryItem.maxLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minestom.server.item.enchant.Enchantment getHandle() {
|
||||
return delegate;
|
||||
return registryItem;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,6 +23,6 @@ public class MinestomItemHandle implements ItemHandle {
|
||||
|
||||
@Override
|
||||
public Set<Enchantment> getEnchantments() {
|
||||
return MinecraftServer.getEnchantmentRegistry().values().stream().map(MinestomEnchantment::new).collect(Collectors.toSet());
|
||||
return MinecraftServer.getEnchantmentRegistry().keys().stream().map(MinestomEnchantment::new).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -6,11 +6,11 @@ import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.item.ItemComponent;
|
||||
import net.minestom.server.component.DataComponents;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.component.EnchantmentList;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.registry.DynamicRegistry.Key;
|
||||
import net.minestom.server.registry.RegistryKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -47,11 +47,10 @@ public class MinestomItemStack implements com.dfsek.terra.api.inventory.ItemStac
|
||||
@Override
|
||||
public ItemMeta getItemMeta() {
|
||||
HashMap<Enchantment, Integer> enchantments = new HashMap<>();
|
||||
EnchantmentList enchantmentList = base.get(ItemComponent.ENCHANTMENTS);
|
||||
EnchantmentList enchantmentList = base.get(DataComponents.ENCHANTMENTS);
|
||||
if(enchantmentList != null) {
|
||||
enchantmentList.enchantments().forEach((enchantmentKey, integer) -> {
|
||||
enchantments.put(
|
||||
new MinestomEnchantment(Objects.requireNonNull(MinecraftServer.getEnchantmentRegistry().get(enchantmentKey))), integer);
|
||||
enchantments.put(new MinestomEnchantment(enchantmentKey), integer);
|
||||
});
|
||||
}
|
||||
return new MinestomItemMeta(enchantments);
|
||||
@@ -59,7 +58,7 @@ public class MinestomItemStack implements com.dfsek.terra.api.inventory.ItemStac
|
||||
|
||||
@Override
|
||||
public void setItemMeta(ItemMeta meta) {
|
||||
HashMap<Key<net.minestom.server.item.enchant.Enchantment>, Integer> enchantments = new HashMap<>();
|
||||
HashMap<RegistryKey<net.minestom.server.item.enchant.Enchantment>, Integer> enchantments = new HashMap<>();
|
||||
DynamicRegistry<net.minestom.server.item.enchant.Enchantment> registry = MinecraftServer.getEnchantmentRegistry();
|
||||
meta.getEnchantments().forEach((key, value) -> {
|
||||
MinestomEnchantment enchantment = (MinestomEnchantment) key;
|
||||
@@ -67,6 +66,6 @@ public class MinestomItemStack implements com.dfsek.terra.api.inventory.ItemStac
|
||||
});
|
||||
|
||||
EnchantmentList list = new EnchantmentList(enchantments);
|
||||
base = base.with(ItemComponent.ENCHANTMENTS, list);
|
||||
base = base.with(DataComponents.ENCHANTMENTS, list);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class MinestomMaterial implements Item {
|
||||
}
|
||||
|
||||
public MinestomMaterial(String id) {
|
||||
this.delegate = Material.fromNamespaceId(id);
|
||||
this.delegate = Material.fromKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-2
@@ -22,9 +22,12 @@ public class TerraMinestomWorldBuilder {
|
||||
private ConfigPack pack;
|
||||
private long seed = new Random().nextLong();
|
||||
private EntityFactory entityFactory = new DefaultEntityFactory();
|
||||
private BlockEntityFactory blockEntityFactory = new DefaultBlockEntityFactory();
|
||||
private BlockEntityFactory blockEntityFactory;
|
||||
|
||||
private TerraMinestomWorldBuilder(Instance instance) { this.instance = instance; }
|
||||
private TerraMinestomWorldBuilder(Instance instance) {
|
||||
this.instance = instance;
|
||||
this.blockEntityFactory = new DefaultBlockEntityFactory(instance);
|
||||
}
|
||||
|
||||
public static TerraMinestomWorldBuilder from(Instance instance) {
|
||||
return new TerraMinestomWorldBuilder(instance);
|
||||
|
||||
@@ -44,7 +44,7 @@ import com.dfsek.terra.mod.config.MusicSoundTemplate;
|
||||
import com.dfsek.terra.mod.config.ProtoPlatformBiome;
|
||||
import com.dfsek.terra.mod.config.SoundEventTemplate;
|
||||
import com.dfsek.terra.mod.config.SpawnCostConfig;
|
||||
import com.dfsek.terra.mod.config.SpawnEntryTemplate;
|
||||
import com.dfsek.terra.mod.config.SpawnEntryConfig;
|
||||
import com.dfsek.terra.mod.config.SpawnSettingsTemplate;
|
||||
import com.dfsek.terra.mod.config.SpawnTypeConfig;
|
||||
import com.dfsek.terra.mod.config.VillagerTypeTemplate;
|
||||
@@ -90,7 +90,7 @@ public abstract class ModPlatform extends AbstractPlatform {
|
||||
.registerLoader(MusicSound.class, MusicSoundTemplate::new)
|
||||
.registerLoader(EntityType.class, EntityTypeTemplate::new)
|
||||
.registerLoader(SpawnCostConfig.class, SpawnCostConfig::new)
|
||||
.registerLoader(SpawnEntry.class, SpawnEntryTemplate::new)
|
||||
.registerLoader(SpawnEntry.class, SpawnEntryConfig::new)
|
||||
.registerLoader(SpawnTypeConfig.class, SpawnTypeConfig::new)
|
||||
.registerLoader(SpawnSettings.class, SpawnSettingsTemplate::new)
|
||||
.registerLoader(VillagerType.class, VillagerTypeTemplate::new);
|
||||
|
||||
+6
-2
@@ -7,7 +7,7 @@ import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
|
||||
|
||||
|
||||
public class SpawnEntryTemplate implements ObjectTemplate<SpawnEntry> {
|
||||
public class SpawnEntryConfig implements ObjectTemplate<SpawnEntry> {
|
||||
@Value("type")
|
||||
@Default
|
||||
private EntityType<?> type = null;
|
||||
@@ -24,8 +24,12 @@ public class SpawnEntryTemplate implements ObjectTemplate<SpawnEntry> {
|
||||
@Default
|
||||
private Integer maxGroupSize = null;
|
||||
|
||||
public Integer getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnEntry get() {
|
||||
return new SpawnEntry(type, weight, minGroupSize, maxGroupSize);
|
||||
return new SpawnEntry(type, minGroupSize, maxGroupSize);
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -5,7 +5,6 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -28,8 +27,8 @@ public class SpawnSettingsTemplate implements ObjectTemplate<SpawnSettings> {
|
||||
SpawnSettings.Builder builder = new SpawnSettings.Builder();
|
||||
for(SpawnTypeConfig spawn : spawns) {
|
||||
SpawnGroup group = spawn.getGroup();
|
||||
for(SpawnEntry entry : spawn.getEntry()) {
|
||||
builder.spawn(group, entry);
|
||||
for(SpawnEntryConfig entry : spawn.getEntry()) {
|
||||
builder.spawn(group, entry.getWeight(), entry.get());
|
||||
}
|
||||
}
|
||||
for(SpawnCostConfig cost : costs) {
|
||||
|
||||
+2
-3
@@ -4,7 +4,6 @@ import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,13 +15,13 @@ public class SpawnTypeConfig implements ObjectTemplate<SpawnTypeConfig> {
|
||||
|
||||
@Value("entries")
|
||||
@Default
|
||||
private List<SpawnEntry> entry = null;
|
||||
private List<SpawnEntryConfig> entry = null;
|
||||
|
||||
public SpawnGroup getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public List<SpawnEntry> getEntry() {
|
||||
public List<SpawnEntryConfig> getEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
+20
-2
@@ -3,6 +3,7 @@ package com.dfsek.terra.mod.config;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.sound.BiomeAdditionsSound;
|
||||
import net.minecraft.sound.BiomeMoodSound;
|
||||
import net.minecraft.sound.MusicSound;
|
||||
@@ -37,6 +38,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
@Default
|
||||
private Integer foliageColor = null;
|
||||
|
||||
@Value("colors.dry-foliage")
|
||||
@Default
|
||||
private Integer dryFoliageColor = null;
|
||||
|
||||
@Value("colors.sky")
|
||||
@Default
|
||||
private Integer skyColor = null;
|
||||
@@ -81,13 +86,18 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
@Default
|
||||
private MusicSound music = null;
|
||||
|
||||
@Value("sound.music-volume")
|
||||
@Default
|
||||
private Float musicVolume = null;
|
||||
|
||||
@Value("spawning")
|
||||
@Default
|
||||
private SpawnSettings spawnSettings = null;
|
||||
|
||||
@Value("villager-type")
|
||||
@Default
|
||||
private VillagerType villagerType = null;
|
||||
private
|
||||
RegistryKey<VillagerType> villagerType = null;
|
||||
|
||||
public Integer getGrassColor() {
|
||||
return grassColor;
|
||||
@@ -109,6 +119,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
return foliageColor;
|
||||
}
|
||||
|
||||
public Integer getDryFoliageColor() {
|
||||
return dryFoliageColor;
|
||||
}
|
||||
|
||||
public Integer getSkyColor() {
|
||||
return skyColor;
|
||||
}
|
||||
@@ -153,11 +167,15 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
return music;
|
||||
}
|
||||
|
||||
public Float getMusicVolume() {
|
||||
return musicVolume;
|
||||
}
|
||||
|
||||
public SpawnSettings getSpawnSettings() {
|
||||
return spawnSettings;
|
||||
}
|
||||
|
||||
public VillagerType getVillagerType() {
|
||||
public RegistryKey<VillagerType> getVillagerType() {
|
||||
return villagerType;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -4,17 +4,19 @@ import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.village.VillagerType;
|
||||
|
||||
|
||||
public class VillagerTypeTemplate implements ObjectTemplate<VillagerType> {
|
||||
public class VillagerTypeTemplate implements ObjectTemplate<RegistryKey<VillagerType>> {
|
||||
@Value("id")
|
||||
@Default
|
||||
private Identifier id = null;
|
||||
private String id = null;
|
||||
|
||||
@Override
|
||||
public VillagerType get() {
|
||||
return Registries.VILLAGER_TYPE.getEntry(id).orElseThrow().value();
|
||||
public RegistryKey<VillagerType> get() {
|
||||
return RegistryKey.of(RegistryKeys.VILLAGER_TYPE, Identifier.ofVanilla(id));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -140,10 +140,10 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
if(noise > threshold) {
|
||||
chunk.setBlockState(new BlockPos(x, y, z), (BlockState) delegate
|
||||
.getPalette(x + xi, y, z + zi, world, biomeProvider)
|
||||
.get(depth, x + xi, y, z + zi, world.getSeed()), false);
|
||||
.get(depth, x + xi, y, z + zi, world.getSeed()), 0);
|
||||
depth++;
|
||||
} else if(noise < airThreshold) {
|
||||
chunk.setBlockState(new BlockPos(x, y, z), Blocks.AIR.getDefaultState(), false);
|
||||
chunk.setBlockState(new BlockPos(x, y, z), Blocks.AIR.getDefaultState(), 0);
|
||||
} else {
|
||||
depth = 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import java.util.Map;
|
||||
@Mixin(VillagerType.class)
|
||||
public interface VillagerTypeAccessor {
|
||||
@Accessor("BIOME_TO_TYPE")
|
||||
static Map<RegistryKey<Biome>, VillagerType> getBiomeTypeToIdMap() {
|
||||
static Map<RegistryKey<Biome>, RegistryKey<VillagerType>> getBiomeTypeToIdMap() {
|
||||
throw new AssertionError("Untransformed Accessor!");
|
||||
}
|
||||
}
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.dfsek.terra.mod.mixin.fix;
|
||||
|
||||
import net.minecraft.entity.passive.BeeEntity.MoveToFlowerGoal;
|
||||
import net.minecraft.entity.passive.BeeEntity.MoveToHiveGoal;
|
||||
import net.minecraft.util.math.random.CheckedRandom;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
|
||||
|
||||
/**
|
||||
* Bees spawning uses world.random without synchronization. This causes issues when spawning bees during world generation.
|
||||
*/
|
||||
@Mixin({
|
||||
MoveToHiveGoal.class,
|
||||
MoveToFlowerGoal.class
|
||||
})
|
||||
public class BeeMoveGoalsUnsynchronizedRandomAccessFix {
|
||||
@Redirect(method = "<init>",
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;random:Lnet/minecraft/util/math/random/Random;"))
|
||||
public Random redirectRandomAccess(World instance) {
|
||||
return new CheckedRandom(CommonPlatform.get().getServer().getTicks()); // replace with new random seeded by tick time.
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -55,7 +55,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
|
||||
public EntityType terra$getSpawnedType() {
|
||||
return (EntityType) Registries.ENTITY_TYPE.getEntry(
|
||||
Identifier.tryParse(((MobSpawnerLogicAccessor) getLogic()).getSpawnEntry().getNbt().getString("id"))).orElseThrow();
|
||||
Identifier.tryParse(((MobSpawnerLogicAccessor) getLogic()).getSpawnEntry().getNbt().getString("id").orElseThrow())).orElseThrow();
|
||||
}
|
||||
|
||||
public void terra$setSpawnedType(@NotNull EntityType creatureType) {
|
||||
|
||||
+3
-3
@@ -47,11 +47,11 @@ public abstract class WorldChunkMixin {
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
public abstract net.minecraft.block.BlockState setBlockState(BlockPos pos, net.minecraft.block.BlockState state, boolean moved);
|
||||
public abstract net.minecraft.block.BlockState setBlockState(BlockPos pos, net.minecraft.block.BlockState state, int flags);
|
||||
|
||||
public void terra$setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
||||
BlockPos blockPos = new BlockPos(x, y, z);
|
||||
setBlockState(blockPos, (net.minecraft.block.BlockState) data, false);
|
||||
setBlockState(blockPos, (net.minecraft.block.BlockState) data, 0);
|
||||
if(physics) {
|
||||
net.minecraft.block.BlockState state = ((net.minecraft.block.BlockState) data);
|
||||
if(state.isLiquid()) {
|
||||
@@ -65,7 +65,7 @@ public abstract class WorldChunkMixin {
|
||||
|
||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
||||
((net.minecraft.world.chunk.Chunk) (Object) this).setBlockState(new BlockPos(x, y, z), (net.minecraft.block.BlockState) blockState,
|
||||
false);
|
||||
0);
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public abstract class ProtoChunkMixin {
|
||||
|
||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
||||
((net.minecraft.world.chunk.Chunk) (Object) this).setBlockState(new BlockPos(x, y, z), (net.minecraft.block.BlockState) blockState,
|
||||
false);
|
||||
0);
|
||||
}
|
||||
|
||||
public @NotNull BlockState terra$getBlock(int x, int y, int z) {
|
||||
|
||||
@@ -35,9 +35,25 @@ public class BiomeUtil {
|
||||
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
|
||||
.grassColorModifier(
|
||||
Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getEffects().getGrassColorModifier()))
|
||||
.grassColor(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColor(),
|
||||
vanilla.getEffects().getGrassColor().orElseGet(() -> ((BiomeInvoker) ((Object) vanilla)).invokeGetDefaultGrassColor())))
|
||||
.foliageColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFoliageColor(), vanilla.getFoliageColor()));
|
||||
.musicVolume(Objects.requireNonNullElse(vanillaBiomeProperties.getMusicVolume(), vanilla.getMusicVolume()));
|
||||
|
||||
if(vanillaBiomeProperties.getGrassColor() == null) {
|
||||
vanilla.getEffects().getGrassColor().ifPresent(effects::grassColor);
|
||||
} else {
|
||||
effects.grassColor(vanillaBiomeProperties.getGrassColor());
|
||||
}
|
||||
|
||||
if(vanillaBiomeProperties.getFoliageColor() == null) {
|
||||
vanilla.getEffects().getFoliageColor().ifPresent(effects::foliageColor);
|
||||
} else {
|
||||
effects.foliageColor(vanillaBiomeProperties.getFoliageColor());
|
||||
}
|
||||
|
||||
if(vanillaBiomeProperties.getDryFoliageColor() == null) {
|
||||
vanilla.getEffects().getDryFoliageColor().ifPresent(effects::dryFoliageColor);
|
||||
} else {
|
||||
effects.dryFoliageColor(vanillaBiomeProperties.getDryFoliageColor());
|
||||
}
|
||||
|
||||
if(vanillaBiomeProperties.getParticleConfig() == null) {
|
||||
vanilla.getEffects().getParticleConfig().ifPresent(effects::particleConfig);
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:snowy_taiga"
|
||||
]
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:old_growth_pine_taiga"
|
||||
]
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:old_growth_spruce_taiga"
|
||||
]
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:taiga"
|
||||
]
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"#minecraft:is_jungle"
|
||||
]
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:grove"
|
||||
]
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"#minecraft:is_savanna"
|
||||
]
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"#minecraft:is_badlands"
|
||||
]
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:forest"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"assets": {
|
||||
"angry": "minecraft:entity/wolf/wolf_ashen_angry",
|
||||
"tame": "minecraft:entity/wolf/wolf_ashen_tame",
|
||||
"wild": "minecraft:entity/wolf/wolf_ashen"
|
||||
},
|
||||
"spawn_conditions": [
|
||||
{
|
||||
"condition": {
|
||||
"type": "minecraft:biome",
|
||||
"biomes": "#c:has_wolf_variant/ashen"
|
||||
},
|
||||
"priority": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"assets": {
|
||||
"angry": "minecraft:entity/wolf/wolf_black_angry",
|
||||
"tame": "minecraft:entity/wolf/wolf_black_tame",
|
||||
"wild": "minecraft:entity/wolf/wolf_black"
|
||||
},
|
||||
"spawn_conditions": [
|
||||
{
|
||||
"condition": {
|
||||
"type": "minecraft:biome",
|
||||
"biomes": "#c:has_wolf_variant/black"
|
||||
},
|
||||
"priority": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"assets": {
|
||||
"angry": "minecraft:entity/wolf/wolf_chestnut_angry",
|
||||
"tame": "minecraft:entity/wolf/wolf_chestnut_tame",
|
||||
"wild": "minecraft:entity/wolf/wolf_chestnut"
|
||||
},
|
||||
"spawn_conditions": [
|
||||
{
|
||||
"condition": {
|
||||
"type": "minecraft:biome",
|
||||
"biomes": "#c:has_wolf_variant/chestnut"
|
||||
},
|
||||
"priority": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"assets": {
|
||||
"angry": "minecraft:entity/wolf/wolf_angry",
|
||||
"tame": "minecraft:entity/wolf/wolf_tame",
|
||||
"wild": "minecraft:entity/wolf/wolf"
|
||||
},
|
||||
"spawn_conditions": [
|
||||
{
|
||||
"condition": {
|
||||
"type": "minecraft:biome",
|
||||
"biomes": "#c:has_wolf_variant/pale"
|
||||
},
|
||||
"priority": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"assets": {
|
||||
"angry": "minecraft:entity/wolf/wolf_rusty_angry",
|
||||
"tame": "minecraft:entity/wolf/wolf_rusty_tame",
|
||||
"wild": "minecraft:entity/wolf/wolf_rusty"
|
||||
},
|
||||
"spawn_conditions": [
|
||||
{
|
||||
"condition": {
|
||||
"type": "minecraft:biome",
|
||||
"biomes": "#c:has_wolf_variant/rusty"
|
||||
},
|
||||
"priority": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"assets": {
|
||||
"angry": "minecraft:entity/wolf/wolf_snowy_angry",
|
||||
"tame": "minecraft:entity/wolf/wolf_snowy_tame",
|
||||
"wild": "minecraft:entity/wolf/wolf_snowy"
|
||||
},
|
||||
"spawn_conditions": [
|
||||
{
|
||||
"condition": {
|
||||
"type": "minecraft:biome",
|
||||
"biomes": "#c:has_wolf_variant/snowy"
|
||||
},
|
||||
"priority": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"assets": {
|
||||
"angry": "minecraft:entity/wolf/wolf_spotted_angry",
|
||||
"tame": "minecraft:entity/wolf/wolf_spotted_tame",
|
||||
"wild": "minecraft:entity/wolf/wolf_spotted"
|
||||
},
|
||||
"spawn_conditions": [
|
||||
{
|
||||
"condition": {
|
||||
"type": "minecraft:biome",
|
||||
"biomes": "#c:has_wolf_variant/spotted"
|
||||
},
|
||||
"priority": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"assets": {
|
||||
"angry": "minecraft:entity/wolf/wolf_striped_angry",
|
||||
"tame": "minecraft:entity/wolf/wolf_striped_tame",
|
||||
"wild": "minecraft:entity/wolf/wolf_striped"
|
||||
},
|
||||
"spawn_conditions": [
|
||||
{
|
||||
"condition": {
|
||||
"type": "minecraft:biome",
|
||||
"biomes": "#c:has_wolf_variant/striped"
|
||||
},
|
||||
"priority": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"assets": {
|
||||
"angry": "minecraft:entity/wolf/wolf_woods_angry",
|
||||
"tame": "minecraft:entity/wolf/wolf_woods_tame",
|
||||
"wild": "minecraft:entity/wolf/wolf_woods"
|
||||
},
|
||||
"spawn_conditions": [
|
||||
{
|
||||
"condition": {
|
||||
"type": "minecraft:biome",
|
||||
"biomes": "#c:has_wolf_variant/woods"
|
||||
},
|
||||
"priority": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -9,7 +9,6 @@
|
||||
"access.StateAccessor",
|
||||
"access.StructureAccessorAccessor",
|
||||
"access.VillagerTypeAccessor",
|
||||
"fix.BeeMoveGoalsUnsynchronizedRandomAccessFix",
|
||||
"fix.NetherFossilOptimization",
|
||||
"implementations.compat.GenerationSettingsFloraFeaturesMixin",
|
||||
"implementations.terra.BiomeMixin",
|
||||
|
||||
@@ -7,6 +7,7 @@ dependencies {
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||
compileOnly("io.github.llamalad7:mixinextras-common:${Versions.Mod.mixinExtras}")
|
||||
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
||||
|
||||
@@ -18,6 +19,7 @@ dependencies {
|
||||
modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud) {
|
||||
exclude("net.fabricmc")
|
||||
exclude("net.fabricmc.fabric-api")
|
||||
exclude("me.lucko", "fabric-permissions-api")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
public LifecyclePlatform() {
|
||||
generationThreads = getGenerationThreadsWithReflection("com.ishland.c2me.base.common.GlobalExecutors", "GLOBAL_EXECUTOR_PARALLELISM", "C2ME");
|
||||
if (generationThreads == 0) {
|
||||
generationThreads = getGenerationThreadsWithReflection("ca.spottedleaf.moonrise.common.util.MoonriseCommon", "WORKER_THREADS", "Moonrise");
|
||||
generationThreads = getMoonriseGenerationThreadsWithReflection();
|
||||
} if (generationThreads == 0) {
|
||||
generationThreads = 1;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
|
||||
super.platformAddon().forEach(addons::add);
|
||||
|
||||
String mcVersion = MinecraftVersion.CURRENT.getName();
|
||||
String mcVersion = MinecraftVersion.CURRENT.name();
|
||||
try {
|
||||
addons.add(new EphemeralAddon(Versions.parseVersion(mcVersion), "minecraft"));
|
||||
} catch(ParseException e) {
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
|
||||
import com.dfsek.terra.mod.ModPlatform;
|
||||
|
||||
import net.minecraft.client.gui.screen.world.CreateWorldScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static com.dfsek.terra.lifecycle.util.LifecycleUtil.initialized;
|
||||
|
||||
|
||||
@Mixin(CreateWorldScreen.class)
|
||||
public class CreateWorldScreenMixin {
|
||||
@Inject(method = "onCloseScreen()V", at = @At("HEAD"))
|
||||
public void onClose(CallbackInfo ci) {
|
||||
ModPlatform platform = CommonPlatform.get();
|
||||
platform.getRawConfigRegistry().clear();
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
-9
@@ -19,8 +19,6 @@ import java.net.Proxy;
|
||||
|
||||
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
||||
|
||||
import static com.dfsek.terra.lifecycle.util.LifecycleUtil.initialized;
|
||||
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServerMixin {
|
||||
@@ -34,11 +32,4 @@ public class MinecraftServerMixin {
|
||||
WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo ci) {
|
||||
LifecyclePlatform.setServer((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "shutdown()V", at = @At("RETURN"))
|
||||
private void injectShutdown(CallbackInfo ci) {
|
||||
ModPlatform platform = CommonPlatform.get();
|
||||
platform.getRawConfigRegistry().clear();
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
+42
-15
@@ -1,5 +1,8 @@
|
||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
import com.dfsek.terra.mod.ModPlatform;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.registry.MutableRegistry;
|
||||
import net.minecraft.registry.Registry;
|
||||
@@ -7,6 +10,7 @@ import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.RegistryLoader;
|
||||
import net.minecraft.registry.RegistryLoader.Loader;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.MultiNoiseBiomeSourceParameterList;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
@@ -18,18 +22,33 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Coerce;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Coerce;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.RegistryLoader;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
||||
import com.dfsek.terra.lifecycle.util.LifecycleUtil;
|
||||
import com.dfsek.terra.lifecycle.util.RegistryHack;
|
||||
|
||||
import static com.dfsek.terra.lifecycle.util.LifecycleUtil.initialized;
|
||||
|
||||
|
||||
@Mixin(RegistryLoader.class)
|
||||
public class RegistryLoaderMixin {
|
||||
@@ -38,31 +57,39 @@ public class RegistryLoaderMixin {
|
||||
@Final
|
||||
private static Logger LOGGER;
|
||||
|
||||
@Redirect(
|
||||
@Unique
|
||||
private static final AtomicBoolean LOADING_DYNAMIC_REGISTRIES = new AtomicBoolean(false);
|
||||
|
||||
@Inject(method = "loadFromResource(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", at = @At("HEAD"))
|
||||
private static void loadFromResources(ResourceManager resourceManager, List<RegistryWrapper.Impl<?>> registries, List<RegistryLoader.Entry<?>> entries, CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir) {
|
||||
LOADING_DYNAMIC_REGISTRIES.set(entries.stream().anyMatch(entry -> entry.key() == RegistryKeys.BIOME));
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Ljava/util/List;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V",
|
||||
ordinal = 1 // we want right after the first forEach
|
||||
)
|
||||
ordinal = 1
|
||||
)
|
||||
)
|
||||
private static void grabManager(List<RegistryLoader.Loader<?>> instance, Consumer<? super Loader<?>> consumer) {
|
||||
if(!initialized) {
|
||||
MutableRegistry<Biome> biomes = extractRegistry(instance, RegistryKeys.BIOME).orElseThrow();
|
||||
MutableRegistry<DimensionType> dimensionTypes = extractRegistry(instance, RegistryKeys.DIMENSION_TYPE).orElseThrow();
|
||||
MutableRegistry<WorldPreset> worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow();
|
||||
MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(instance,
|
||||
private static void beforeFreeze(@Coerce Object loadable, List<RegistryWrapper.Impl<?>> wrappers, List<RegistryLoader.Entry<?>> entries, CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir, @Local(ordinal = 2) List<RegistryLoader.Loader<?>> registriesList) {
|
||||
if (LOADING_DYNAMIC_REGISTRIES.getAndSet(false)) {
|
||||
ModPlatform platform = CommonPlatform.get();
|
||||
platform.getRawConfigRegistry().clear();
|
||||
MutableRegistry<Biome> biomes = extractRegistry(registriesList, RegistryKeys.BIOME).orElseThrow();
|
||||
MutableRegistry<DimensionType> dimensionTypes = extractRegistry(registriesList, RegistryKeys.DIMENSION_TYPE).orElseThrow();
|
||||
MutableRegistry<WorldPreset> worldPresets = extractRegistry(registriesList, RegistryKeys.WORLD_PRESET).orElseThrow();
|
||||
MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(registriesList,
|
||||
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
|
||||
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
|
||||
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(registriesList,
|
||||
RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
|
||||
MutableRegistry<Enchantment> enchantments = extractRegistry(instance, RegistryKeys.ENCHANTMENT).orElseThrow();
|
||||
MutableRegistry<Enchantment> enchantments = extractRegistry(registriesList, RegistryKeys.ENCHANTMENT).orElseThrow();
|
||||
|
||||
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists,
|
||||
enchantments);
|
||||
LifecycleUtil.initialize(biomes, worldPresets);
|
||||
initialized = true;
|
||||
}
|
||||
instance.forEach(consumer);
|
||||
}
|
||||
|
||||
@Unique
|
||||
|
||||
+24
-2
@@ -51,13 +51,35 @@ public final class LifecycleBiomeUtil {
|
||||
Registry<net.minecraft.world.biome.Biome> registry) {
|
||||
RegistryKey<net.minecraft.world.biome.Biome> vanilla = ((ProtoPlatformBiome) biome.getPlatformBiome()).get(registry);
|
||||
|
||||
if (vanilla == null) {
|
||||
logger.error("""
|
||||
Failed to get Vanilla Biome Regiestry key!
|
||||
Terra Biome ID: {}
|
||||
Vanilla Biome: {}""", biome.getID(), biome.getPlatformBiome());
|
||||
}
|
||||
|
||||
if(pack.getContext().get(PreLoadCompatibilityOptions.class).useVanillaBiomes()) {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(registry.getEntry(registry.get(vanilla)));
|
||||
} else {
|
||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
|
||||
net.minecraft.world.biome.Biome minecraftBiome = BiomeUtil.createBiome(Objects.requireNonNull(registry.get(vanilla)),
|
||||
|
||||
net.minecraft.world.biome.Biome vanilaBiome = registry.get(vanilla);
|
||||
if (vanilaBiome == null) {
|
||||
String vanillaBiomeName;
|
||||
if (vanilla != null ) {
|
||||
vanillaBiomeName = vanilla.getValue().toString();
|
||||
} else {
|
||||
vanillaBiomeName = "NULL";
|
||||
}
|
||||
logger.error("""
|
||||
Failed to get Vanilla Biome!
|
||||
Terra Biome ID: {}
|
||||
Vanilla Biome: {}""", biome.getID(), vanillaBiomeName);
|
||||
return;
|
||||
}
|
||||
|
||||
net.minecraft.world.biome.Biome minecraftBiome = BiomeUtil.createBiome(Objects.requireNonNull(vanilaBiome),
|
||||
vanillaBiomeProperties);
|
||||
|
||||
Identifier identifier = Identifier.of("terra", BiomeUtil.createBiomeID(pack, id));
|
||||
@@ -72,7 +94,7 @@ public final class LifecycleBiomeUtil {
|
||||
minecraftBiome));
|
||||
}
|
||||
|
||||
Map<RegistryKey<net.minecraft.world.biome.Biome>, VillagerType> villagerMap = VillagerTypeAccessor.getBiomeTypeToIdMap();
|
||||
Map<RegistryKey<net.minecraft.world.biome.Biome>, RegistryKey<VillagerType>> villagerMap = VillagerTypeAccessor.getBiomeTypeToIdMap();
|
||||
|
||||
villagerMap.put(RegistryKey.of(RegistryKeys.BIOME, identifier),
|
||||
Objects.requireNonNullElse(vanillaBiomeProperties.getVillagerType(),
|
||||
|
||||
-2
@@ -12,8 +12,6 @@ import com.dfsek.terra.mod.CommonPlatform;
|
||||
|
||||
|
||||
public final class LifecycleUtil {
|
||||
public static boolean initialized = false;
|
||||
|
||||
private LifecycleUtil() {
|
||||
|
||||
}
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
"lifecycle.RegistryLoaderMixin",
|
||||
"lifecycle.SaveLoadingMixin"
|
||||
],
|
||||
"client": [
|
||||
"lifecycle.CreateWorldScreenMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
"injectors": {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user