mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-12-01 18:34:14 +00:00
Merge branch 'refs/heads/dev/1.21.11' into feat/wyck
This commit is contained in:
commit
c533b5bd1d
37 files changed
+328
-175
No files matched your search
@@ -21,7 +21,7 @@ jobs:
|
|||||||
- name: Set up JDK 21
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@v4.7.1
|
uses: actions/setup-java@v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: '21'
|
java-version: '25'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
||||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import org.gradle.api.Action
|
import org.gradle.api.Action
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.support.serviceOf
|
||||||
|
|
||||||
|
|
||||||
var isPrerelease = false
|
var isPrerelease = false
|
||||||
|
|
||||||
|
|
||||||
fun Project.getGitHash(): String {
|
fun Project.getGitHash(): String {
|
||||||
val stdout = ByteArrayOutputStream()
|
return providers.exec {
|
||||||
exec {
|
|
||||||
commandLine = mutableListOf("git", "rev-parse", "--short", "HEAD")
|
commandLine = mutableListOf("git", "rev-parse", "--short", "HEAD")
|
||||||
standardOutput = stdout
|
}.standardOutput.asText.get().trim()
|
||||||
}
|
|
||||||
return stdout.toString().trim()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.gitClone(name: String) {
|
fun Project.gitClone(name: String) {
|
||||||
val stdout = ByteArrayOutputStream()
|
providers.exec {
|
||||||
exec {
|
|
||||||
commandLine = mutableListOf("git", "clone", name)
|
commandLine = mutableListOf("git", "clone", name)
|
||||||
standardOutput = stdout
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ object Versions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object Fabric {
|
object Fabric {
|
||||||
const val fabricAPI = "0.134.1+${Mod.minecraft}"
|
const val fabricAPI = "0.140.0+${Mod.minecraft}"
|
||||||
const val cloud = "2.0.0-beta.13"
|
const val cloud = "2.0.0-beta.13"
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -42,14 +42,14 @@ object Versions {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
object Mod {
|
object Mod {
|
||||||
const val mixin = "0.16.4+mixin.0.8.7"
|
const val mixin = "0.16.5+mixin.0.8.7"
|
||||||
const val mixinExtras = "0.5.0"
|
const val mixinExtras = "0.5.0"
|
||||||
|
|
||||||
const val minecraft = "1.21.10"
|
const val minecraft = "1.21.11"
|
||||||
const val yarn = "$minecraft+build.1"
|
const val yarn = "$minecraft+build.3"
|
||||||
const val fabricLoader = "0.18.2"
|
const val fabricLoader = "0.18.3"
|
||||||
|
|
||||||
const val architecuryLoom = "1.11.451"
|
const val architecturyLoom = "1.13.463"
|
||||||
const val architecturyPlugin = "3.4.162"
|
const val architecturyPlugin = "3.4.162"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -60,9 +60,9 @@ object Versions {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
object Bukkit {
|
object Bukkit {
|
||||||
const val minecraft = "1.21.10"
|
const val minecraft = "1.21.11-rc3"
|
||||||
const val nms = "$minecraft-R0.1"
|
const val nms = "$minecraft-R0.1"
|
||||||
const val paperBuild = "$nms-20251012.013929-7"
|
const val paperBuild = "$nms-20251208.200020-2"
|
||||||
const val paper = paperBuild
|
const val paper = paperBuild
|
||||||
const val paperLib = "1.0.8"
|
const val paperLib = "1.0.8"
|
||||||
const val reflectionRemapper = "0.1.3"
|
const val reflectionRemapper = "0.1.3"
|
||||||
@@ -96,6 +96,6 @@ object Versions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object Minestom {
|
object Minestom {
|
||||||
const val minestom = "2025.10.04-1.21.8"
|
const val minestom = "2025.12.20c-1.21.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+93
@@ -0,0 +1,93 @@
|
|||||||
|
package com.dfsek.terra.registry;
|
||||||
|
|
||||||
|
import com.google.errorprone.annotations.MustBeClosed;
|
||||||
|
import org.intellij.lang.annotations.Pattern;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A file-discoverable registry that can be extended by system properties
|
||||||
|
* <br>
|
||||||
|
* The main use-case for this is to allow for customized locations of file-system-based key entries,
|
||||||
|
* such as putting config packs into custom locations.
|
||||||
|
* <br>
|
||||||
|
* Two system properties are used to define the search path:
|
||||||
|
* <br>
|
||||||
|
* <code>terra.registry.{searchPathName}.searchPath</code> is a list of "parent folder" paths (like the pack directory) that
|
||||||
|
* will be searched for contained files.
|
||||||
|
* <br>
|
||||||
|
* <code>terra.registry.{searchPathName}.extraPath</code> is a list of files that will be directly evaluated for membership and
|
||||||
|
* as such will be directly treated as members of the registry.
|
||||||
|
* <br>
|
||||||
|
* These system properties are formatted like UNIX-style paths, with each path separated by a colon (':') character.
|
||||||
|
*/
|
||||||
|
public interface ExtensibleRegistry {
|
||||||
|
/**
|
||||||
|
* Get a lowercase search path name for this registry that will get plugged into
|
||||||
|
* <br>
|
||||||
|
* <code>terra.registry.{searchPathName}.searchPath</code>
|
||||||
|
* <br>
|
||||||
|
* and
|
||||||
|
* <br>
|
||||||
|
* <code>terra.registry.{searchPathName}.extraPath</code>
|
||||||
|
*/
|
||||||
|
@Pattern("^[a-z._]+$")
|
||||||
|
String getRegistryName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a path may be a member of this registry heuristically.
|
||||||
|
*
|
||||||
|
* @param path Path to check
|
||||||
|
*
|
||||||
|
* @return True if the path is a member of this registry.
|
||||||
|
*/
|
||||||
|
boolean validatePathIsMember(Path path);
|
||||||
|
|
||||||
|
default @MustBeClosed Stream<Path> getMemberPaths(Path baseSearchPath) {
|
||||||
|
String basePropertyName = "terra.registry." + getRegistryName();
|
||||||
|
|
||||||
|
Stream<Path> searchPath = Stream.concat(
|
||||||
|
parseValidPaths(System.getProperty(basePropertyName + ".search-path")),
|
||||||
|
Stream.of(baseSearchPath)
|
||||||
|
);
|
||||||
|
|
||||||
|
Stream<Path> extraPath = parseValidPaths(System.getProperty(basePropertyName + ".extra-path"));
|
||||||
|
|
||||||
|
return Stream.concat(
|
||||||
|
searchPath
|
||||||
|
.filter(Files::isDirectory)
|
||||||
|
.flatMap(ExtensibleRegistry::listDirectory),
|
||||||
|
extraPath
|
||||||
|
)
|
||||||
|
.filter(this::validatePathIsMember);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<Path> parseValidPaths(@Nullable String paths) {
|
||||||
|
return Stream.ofNullable(paths)
|
||||||
|
.flatMap(p -> Arrays.stream(p.split(":")))
|
||||||
|
.filter(v -> !v.isBlank())
|
||||||
|
.map(v -> {
|
||||||
|
try {
|
||||||
|
return Path.of(v).toAbsolutePath().normalize();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(Objects::nonNull);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<Path> listDirectory(Path dir) {
|
||||||
|
try {
|
||||||
|
return Files.list(dir);
|
||||||
|
} catch(IOException e) {
|
||||||
|
return Stream.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
-2
@@ -29,13 +29,14 @@ import com.dfsek.terra.api.Platform;
|
|||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
import com.dfsek.terra.config.pack.ConfigPackImpl;
|
import com.dfsek.terra.config.pack.ConfigPackImpl;
|
||||||
|
import com.dfsek.terra.registry.ExtensibleRegistry;
|
||||||
import com.dfsek.terra.registry.OpenRegistryImpl;
|
import com.dfsek.terra.registry.OpenRegistryImpl;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to hold config packs
|
* Class to hold config packs
|
||||||
*/
|
*/
|
||||||
public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> implements ExtensibleRegistry {
|
||||||
|
|
||||||
public ConfigRegistry() {
|
public ConfigRegistry() {
|
||||||
super(TypeKey.of(ConfigPack.class));
|
super(TypeKey.of(ConfigPack.class));
|
||||||
@@ -45,7 +46,7 @@ public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
|||||||
Path packsDirectory = platform.getDataFolder().toPath().resolve("packs");
|
Path packsDirectory = platform.getDataFolder().toPath().resolve("packs");
|
||||||
Files.createDirectories(packsDirectory);
|
Files.createDirectories(packsDirectory);
|
||||||
List<Exception> failedLoads = new CopyOnWriteArrayList<>();
|
List<Exception> failedLoads = new CopyOnWriteArrayList<>();
|
||||||
try(Stream<Path> packs = Files.list(packsDirectory)) {
|
try(Stream<Path> packs = getMemberPaths(packsDirectory)) {
|
||||||
packs.parallel().forEach(path -> {
|
packs.parallel().forEach(path -> {
|
||||||
try {
|
try {
|
||||||
ConfigPack pack = new ConfigPackImpl(path, platform);
|
ConfigPack pack = new ConfigPackImpl(path, platform);
|
||||||
@@ -60,6 +61,16 @@ public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRegistryName() {
|
||||||
|
return "config";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validatePathIsMember(Path path) {
|
||||||
|
return Files.isDirectory(path)|| path.getFileName().endsWith(".zip");
|
||||||
|
}
|
||||||
|
|
||||||
public static class PackLoadFailuresException extends Exception {
|
public static class PackLoadFailuresException extends Exception {
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 538998844645186306L;
|
private static final long serialVersionUID = 538998844645186306L;
|
||||||
|
|||||||
+14
-3
@@ -28,6 +28,7 @@ import com.dfsek.terra.api.Platform;
|
|||||||
import com.dfsek.terra.api.config.MetaPack;
|
import com.dfsek.terra.api.config.MetaPack;
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
import com.dfsek.terra.config.pack.MetaPackImpl;
|
import com.dfsek.terra.config.pack.MetaPackImpl;
|
||||||
|
import com.dfsek.terra.registry.ExtensibleRegistry;
|
||||||
import com.dfsek.terra.registry.OpenRegistryImpl;
|
import com.dfsek.terra.registry.OpenRegistryImpl;
|
||||||
import com.dfsek.terra.registry.master.ConfigRegistry.PackLoadFailuresException;
|
import com.dfsek.terra.registry.master.ConfigRegistry.PackLoadFailuresException;
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ import com.dfsek.terra.registry.master.ConfigRegistry.PackLoadFailuresException;
|
|||||||
/**
|
/**
|
||||||
* Class to hold config packs
|
* Class to hold config packs
|
||||||
*/
|
*/
|
||||||
public class MetaConfigRegistry extends OpenRegistryImpl<MetaPack> {
|
public class MetaConfigRegistry extends OpenRegistryImpl<MetaPack> implements ExtensibleRegistry {
|
||||||
|
|
||||||
public MetaConfigRegistry() {
|
public MetaConfigRegistry() {
|
||||||
super(TypeKey.of(MetaPack.class));
|
super(TypeKey.of(MetaPack.class));
|
||||||
@@ -45,8 +46,8 @@ public class MetaConfigRegistry extends OpenRegistryImpl<MetaPack> {
|
|||||||
Path packsDirectory = platform.getDataFolder().toPath().resolve("metapacks");
|
Path packsDirectory = platform.getDataFolder().toPath().resolve("metapacks");
|
||||||
Files.createDirectories(packsDirectory);
|
Files.createDirectories(packsDirectory);
|
||||||
List<IOException> failedLoads = new ArrayList<>();
|
List<IOException> failedLoads = new ArrayList<>();
|
||||||
try(Stream<Path> packs = Files.list(packsDirectory)) {
|
try(Stream<Path> paths = getMemberPaths(packsDirectory)) {
|
||||||
packs.forEach(path -> {
|
paths.forEach(path -> {
|
||||||
try {
|
try {
|
||||||
MetaPack pack = new MetaPackImpl(path, platform, configRegistry);
|
MetaPack pack = new MetaPackImpl(path, platform, configRegistry);
|
||||||
registerChecked(pack.getRegistryKey(), pack);
|
registerChecked(pack.getRegistryKey(), pack);
|
||||||
@@ -59,4 +60,14 @@ public class MetaConfigRegistry extends OpenRegistryImpl<MetaPack> {
|
|||||||
throw new PackLoadFailuresException(failedLoads);
|
throw new PackLoadFailuresException(failedLoads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRegistryName() {
|
||||||
|
return "metaconfig";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validatePathIsMember(Path path) {
|
||||||
|
return Files.isDirectory(path) || path.getFileName().endsWith(".zip");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionSha256Sum=845952a9d6afa783db70bb3b0effaae45ae5542ca2bb7929619e8af49cb634cf
|
distributionSha256Sum=72f44c9f8ebcb1af43838f45ee5c4aa9c5444898b3468ab3f4af7b6076c5bc3f
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright © 2015 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH="\\\"\\\""
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -172,7 +171,6 @@ fi
|
|||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if "$cygwin" || "$msys" ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
@@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-2
@@ -70,11 +70,10 @@ goto fail
|
|||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%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" %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.dfsek.terra.bukkit.util.VersionUtil;
|
|||||||
|
|
||||||
|
|
||||||
public interface NMSInitializer {
|
public interface NMSInitializer {
|
||||||
List<String> SUPPORTED_VERSIONS = List.of("v1.21.9", "v1.21.10");
|
List<String> SUPPORTED_VERSIONS = List.of("v1.21.11");
|
||||||
String MINECRAFT_VERSION = VersionUtil.getMinecraftVersionInfo().toString();
|
String MINECRAFT_VERSION = VersionUtil.getMinecraftVersionInfo().toString();
|
||||||
String TERRA_PACKAGE = NMSInitializer.class.getPackageName();
|
String TERRA_PACKAGE = NMSInitializer.class.getPackageName();
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import net.minecraft.core.HolderSet.Named;
|
|||||||
import net.minecraft.core.MappedRegistry;
|
import net.minecraft.core.MappedRegistry;
|
||||||
import net.minecraft.core.RegistrationInfo;
|
import net.minecraft.core.RegistrationInfo;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
import net.minecraft.world.entity.npc.villager.VillagerType;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -34,7 +34,7 @@ import com.dfsek.terra.registry.master.ConfigRegistry;
|
|||||||
public class AwfulBukkitHacks {
|
public class AwfulBukkitHacks {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AwfulBukkitHacks.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(AwfulBukkitHacks.class);
|
||||||
|
|
||||||
private static final Map<ResourceLocation, List<ResourceLocation>> terraBiomeMap = new HashMap<>();
|
private static final Map<Identifier, List<Identifier>> terraBiomeMap = new HashMap<>();
|
||||||
|
|
||||||
public static void registerBiomes(ConfigRegistry configRegistry) {
|
public static void registerBiomes(ConfigRegistry configRegistry) {
|
||||||
try {
|
try {
|
||||||
@@ -50,7 +50,7 @@ public class AwfulBukkitHacks {
|
|||||||
BukkitPlatformBiome platformBiome = (BukkitPlatformBiome) biome.getPlatformBiome();
|
BukkitPlatformBiome platformBiome = (BukkitPlatformBiome) biome.getPlatformBiome();
|
||||||
|
|
||||||
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
|
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
|
||||||
ResourceLocation vanillaMinecraftKey = ResourceLocation.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(),
|
Identifier vanillaMinecraftKey = Identifier.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(),
|
||||||
vanillaBukkitKey.getKey());
|
vanillaBukkitKey.getKey());
|
||||||
|
|
||||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||||
@@ -58,7 +58,7 @@ public class AwfulBukkitHacks {
|
|||||||
Biome platform = NMSBiomeInjector.createBiome(biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value(),
|
Biome platform = NMSBiomeInjector.createBiome(biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value(),
|
||||||
vanillaBiomeProperties);
|
vanillaBiomeProperties);
|
||||||
|
|
||||||
ResourceLocation delegateMinecraftKey = ResourceLocation.fromNamespaceAndPath("terra",
|
Identifier delegateMinecraftKey = Identifier.fromNamespaceAndPath("terra",
|
||||||
NMSBiomeInjector.createBiomeID(pack, key));
|
NMSBiomeInjector.createBiomeID(pack, key));
|
||||||
NamespacedKey delegateBukkitKey = NamespacedKey.fromString(delegateMinecraftKey.toString());
|
NamespacedKey delegateBukkitKey = NamespacedKey.fromString(delegateMinecraftKey.toString());
|
||||||
ResourceKey<Biome> delegateKey = ResourceKey.create(Registries.BIOME, delegateMinecraftKey);
|
ResourceKey<Biome> delegateKey = ResourceKey.create(Registries.BIOME, delegateMinecraftKey);
|
||||||
@@ -75,7 +75,7 @@ public class AwfulBukkitHacks {
|
|||||||
Objects.requireNonNullElse(vanillaBiomeProperties.getVillagerType(),
|
Objects.requireNonNullElse(vanillaBiomeProperties.getVillagerType(),
|
||||||
villagerMap.getOrDefault(delegateKey, VillagerType.PLAINS)));
|
villagerMap.getOrDefault(delegateKey, VillagerType.PLAINS)));
|
||||||
|
|
||||||
terraBiomeMap.computeIfAbsent(vanillaMinecraftKey, i -> new ArrayList<>()).add(delegateKey.location());
|
terraBiomeMap.computeIfAbsent(vanillaMinecraftKey, i -> new ArrayList<>()).add(delegateKey.identifier());
|
||||||
|
|
||||||
LOGGER.debug("Registered biome: " + delegateKey);
|
LOGGER.debug("Registered biome: " + delegateKey);
|
||||||
} catch(NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
} catch(NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||||
@@ -100,8 +100,8 @@ public class AwfulBukkitHacks {
|
|||||||
tb -> NMSBiomeInjector.getEntry(biomeRegistry, tb).ifPresentOrElse(
|
tb -> NMSBiomeInjector.getEntry(biomeRegistry, tb).ifPresentOrElse(
|
||||||
terra -> {
|
terra -> {
|
||||||
LOGGER.debug("{} (vanilla for {}): {}",
|
LOGGER.debug("{} (vanilla for {}): {}",
|
||||||
vanilla.unwrapKey().orElseThrow().location(),
|
vanilla.unwrapKey().orElseThrow().identifier(),
|
||||||
terra.unwrapKey().orElseThrow().location(),
|
terra.unwrapKey().orElseThrow().identifier(),
|
||||||
vanilla.tags().toList());
|
vanilla.tags().toList());
|
||||||
vanilla.tags()
|
vanilla.tags()
|
||||||
.forEach(tag -> collect
|
.forEach(tag -> collect
|
||||||
|
|||||||
+42
-37
@@ -2,7 +2,8 @@ package com.dfsek.terra.bukkit.nms;
|
|||||||
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.Identifier;
|
||||||
|
import net.minecraft.world.attribute.EnvironmentAttributes;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeGenerationSettings;
|
import net.minecraft.world.level.biome.BiomeGenerationSettings;
|
||||||
import net.minecraft.world.level.biome.BiomeSpecialEffects;
|
import net.minecraft.world.level.biome.BiomeSpecialEffects;
|
||||||
@@ -17,7 +18,7 @@ import com.dfsek.terra.bukkit.nms.config.VanillaBiomeProperties;
|
|||||||
|
|
||||||
public class NMSBiomeInjector {
|
public class NMSBiomeInjector {
|
||||||
|
|
||||||
public static <T> Optional<Holder<T>> getEntry(Registry<T> registry, ResourceLocation identifier) {
|
public static <T> Optional<Holder<T>> getEntry(Registry<T> registry, Identifier identifier) {
|
||||||
return registry.getOptional(identifier)
|
return registry.getOptional(identifier)
|
||||||
.flatMap(registry::getResourceKey)
|
.flatMap(registry::getResourceKey)
|
||||||
.flatMap(registry::get);
|
.flatMap(registry::get);
|
||||||
@@ -29,55 +30,59 @@ public class NMSBiomeInjector {
|
|||||||
|
|
||||||
BiomeSpecialEffects.Builder effects = new BiomeSpecialEffects.Builder();
|
BiomeSpecialEffects.Builder effects = new BiomeSpecialEffects.Builder();
|
||||||
|
|
||||||
effects.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()))
|
// TODO: Migrate to EnvironmentAttributes
|
||||||
.waterColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterColor(), vanilla.getWaterColor()))
|
// builder.setAttribute(EnvironmentAttributes.FOG_COLOR, Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getAttributes().get(EnvironmentAttributes.FOG_COLOR)))
|
||||||
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
|
|
||||||
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
|
// effects.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()));
|
||||||
|
effects.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(),
|
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(),
|
||||||
vanilla.getSpecialEffects().getGrassColorModifier()))
|
vanilla.getSpecialEffects().grassColorModifier()));
|
||||||
.backgroundMusicVolume(Objects.requireNonNullElse(vanillaBiomeProperties.getMusicVolume(), vanilla.getBackgroundMusicVolume()));
|
// .backgroundMusicVolume(Objects.requireNonNullElse(vanillaBiomeProperties.getMusicVolume(), vanilla.getBackgroundMusicVolume()));
|
||||||
|
|
||||||
if(vanillaBiomeProperties.getGrassColor() == null) {
|
if(vanillaBiomeProperties.getGrassColor() == null) {
|
||||||
vanilla.getSpecialEffects().getGrassColorOverride().ifPresent(effects::grassColorOverride);
|
vanilla.getSpecialEffects().grassColorOverride().ifPresent(effects::grassColorOverride);
|
||||||
} else {
|
} else {
|
||||||
effects.grassColorOverride(vanillaBiomeProperties.getGrassColor());
|
effects.grassColorOverride(vanillaBiomeProperties.getGrassColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vanillaBiomeProperties.getFoliageColor() == null) {
|
if(vanillaBiomeProperties.getFoliageColor() == null) {
|
||||||
vanilla.getSpecialEffects().getFoliageColorOverride().ifPresent(effects::foliageColorOverride);
|
vanilla.getSpecialEffects().foliageColorOverride().ifPresent(effects::foliageColorOverride);
|
||||||
} else {
|
} else {
|
||||||
effects.foliageColorOverride(vanillaBiomeProperties.getFoliageColor());
|
effects.foliageColorOverride(vanillaBiomeProperties.getFoliageColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vanillaBiomeProperties.getParticleConfig() == null) {
|
// TODO
|
||||||
vanilla.getSpecialEffects().getAmbientParticleSettings().ifPresent(effects::ambientParticle);
|
// if(vanillaBiomeProperties.getParticleConfig() == null) {
|
||||||
} else {
|
// vanilla.getSpecialEffects().getAmbientParticleSettings().ifPresent(effects::ambientParticle);
|
||||||
effects.ambientParticle(vanillaBiomeProperties.getParticleConfig());
|
// } else {
|
||||||
}
|
// effects.ambientParticle(vanillaBiomeProperties.getParticleConfig());
|
||||||
|
// }
|
||||||
|
|
||||||
if(vanillaBiomeProperties.getLoopSound() == null) {
|
// if(vanillaBiomeProperties.getLoopSound() == null) {
|
||||||
vanilla.getSpecialEffects().getAmbientLoopSoundEvent().ifPresent(effects::ambientLoopSound);
|
// vanilla.getSpecialEffects().getAmbientLoopSoundEvent().ifPresent(effects::ambientLoopSound);
|
||||||
} else {
|
// } else {
|
||||||
RegistryFetcher.soundEventRegistry().get(vanillaBiomeProperties.getLoopSound().location()).ifPresent(effects::ambientLoopSound);
|
// RegistryFetcher.soundEventRegistry().get(vanillaBiomeProperties.getLoopSound().location()).ifPresent(effects::ambientLoopSound);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(vanillaBiomeProperties.getMoodSound() == null) {
|
// if(vanillaBiomeProperties.getMoodSound() == null) {
|
||||||
vanilla.getSpecialEffects().getAmbientMoodSettings().ifPresent(effects::ambientMoodSound);
|
// vanilla.getSpecialEffects().getAmbientMoodSettings().ifPresent(effects::ambientMoodSound);
|
||||||
} else {
|
// } else {
|
||||||
effects.ambientMoodSound(vanillaBiomeProperties.getMoodSound());
|
// effects.ambientMoodSound(vanillaBiomeProperties.getMoodSound());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(vanillaBiomeProperties.getAdditionsSound() == null) {
|
// if(vanillaBiomeProperties.getAdditionsSound() == null) {
|
||||||
vanilla.getSpecialEffects().getAmbientAdditionsSettings().ifPresent(effects::ambientAdditionsSound);
|
// vanilla.getSpecialEffects().getAmbientAdditionsSettings().ifPresent(effects::ambientAdditionsSound);
|
||||||
} else {
|
// } else {
|
||||||
effects.ambientAdditionsSound(vanillaBiomeProperties.getAdditionsSound());
|
// effects.ambientAdditionsSound(vanillaBiomeProperties.getAdditionsSound());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(vanillaBiomeProperties.getMusic() == null) {
|
// if(vanillaBiomeProperties.getMusic() == null) {
|
||||||
vanilla.getSpecialEffects().getBackgroundMusic().ifPresent(effects::backgroundMusic);
|
// vanilla.getSpecialEffects().getBackgroundMusic().ifPresent(effects::backgroundMusic);
|
||||||
} else {
|
// } else {
|
||||||
effects.backgroundMusic(vanillaBiomeProperties.getMusic());
|
// effects.backgroundMusic(vanillaBiomeProperties.getMusic());
|
||||||
}
|
// }
|
||||||
|
|
||||||
builder.hasPrecipitation(Objects.requireNonNullElse(vanillaBiomeProperties.getPrecipitation(), vanilla.hasPrecipitation()));
|
builder.hasPrecipitation(Objects.requireNonNullElse(vanillaBiomeProperties.getPrecipitation(), vanilla.hasPrecipitation()));
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ package com.dfsek.terra.bukkit.nms;
|
|||||||
|
|
||||||
import com.dfsek.tectonic.api.TypeRegistry;
|
import com.dfsek.tectonic.api.TypeRegistry;
|
||||||
import com.dfsek.tectonic.api.exception.LoadException;
|
import com.dfsek.tectonic.api.exception.LoadException;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.sounds.Music;
|
import net.minecraft.sounds.Music;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
import net.minecraft.world.attribute.AmbientParticle;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.MobCategory;
|
import net.minecraft.world.entity.MobCategory;
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
import net.minecraft.world.attribute.AmbientAdditionsSettings;
|
||||||
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
import net.minecraft.world.attribute.AmbientMoodSettings;
|
||||||
import net.minecraft.world.level.biome.AmbientMoodSettings;
|
import net.minecraft.world.entity.npc.villager.VillagerType;
|
||||||
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
|
||||||
import net.minecraft.world.level.biome.Biome.Precipitation;
|
import net.minecraft.world.level.biome.Biome.Precipitation;
|
||||||
import net.minecraft.world.level.biome.Biome.TemperatureModifier;
|
import net.minecraft.world.level.biome.Biome.TemperatureModifier;
|
||||||
import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier;
|
import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier;
|
||||||
@@ -52,8 +52,8 @@ public class NMSPlatform extends PlatformImpl {
|
|||||||
public void register(TypeRegistry registry) {
|
public void register(TypeRegistry registry) {
|
||||||
super.register(registry);
|
super.register(registry);
|
||||||
registry.registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker))
|
registry.registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker))
|
||||||
.registerLoader(ResourceLocation.class, (type, o, loader, depthTracker) -> {
|
.registerLoader(Identifier.class, (type, o, loader, depthTracker) -> {
|
||||||
ResourceLocation identifier = ResourceLocation.tryParse((String) o);
|
Identifier identifier = Identifier.tryParse((String) o);
|
||||||
if(identifier == null)
|
if(identifier == null)
|
||||||
throw new LoadException("Invalid identifier: " + o, depthTracker);
|
throw new LoadException("Invalid identifier: " + o, depthTracker);
|
||||||
return identifier;
|
return identifier;
|
||||||
@@ -67,7 +67,7 @@ public class NMSPlatform extends PlatformImpl {
|
|||||||
(type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase(
|
(type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase(
|
||||||
Locale.ROOT)))
|
Locale.ROOT)))
|
||||||
.registerLoader(MobCategory.class, (type, o, loader, depthTracker) -> MobCategory.valueOf((String) o))
|
.registerLoader(MobCategory.class, (type, o, loader, depthTracker) -> MobCategory.valueOf((String) o))
|
||||||
.registerLoader(AmbientParticleSettings.class, BiomeParticleConfigTemplate::new)
|
.registerLoader(AmbientParticle.class, BiomeParticleConfigTemplate::new)
|
||||||
.registerLoader(SoundEvent.class, SoundEventTemplate::new)
|
.registerLoader(SoundEvent.class, SoundEventTemplate::new)
|
||||||
.registerLoader(AmbientMoodSettings.class, BiomeMoodSoundTemplate::new)
|
.registerLoader(AmbientMoodSettings.class, BiomeMoodSoundTemplate::new)
|
||||||
.registerLoader(AmbientAdditionsSettings.class, BiomeAdditionsSoundTemplate::new)
|
.registerLoader(AmbientAdditionsSettings.class, BiomeAdditionsSoundTemplate::new)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import net.minecraft.core.MappedRegistry;
|
|||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
import net.minecraft.world.entity.npc.villager.VillagerType;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.StructureManager;
|
import net.minecraft.world.level.StructureManager;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
|||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
import net.minecraft.world.attribute.AmbientAdditionsSettings;
|
||||||
|
|
||||||
|
|
||||||
public class BiomeAdditionsSoundTemplate implements ObjectTemplate<AmbientAdditionsSettings> {
|
public class BiomeAdditionsSoundTemplate implements ObjectTemplate<AmbientAdditionsSettings> {
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
|||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.level.biome.AmbientMoodSettings;
|
import net.minecraft.world.attribute.AmbientMoodSettings;
|
||||||
|
|
||||||
|
|
||||||
public class BiomeMoodSoundTemplate implements ObjectTemplate<AmbientMoodSettings> {
|
public class BiomeMoodSoundTemplate implements ObjectTemplate<AmbientMoodSettings> {
|
||||||
|
|||||||
+4
-4
@@ -8,12 +8,12 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|||||||
import net.minecraft.commands.arguments.ParticleArgument;
|
import net.minecraft.commands.arguments.ParticleArgument;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
import net.minecraft.world.attribute.AmbientParticle;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
||||||
public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientParticleSettings> {
|
public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientParticle> {
|
||||||
@Value("particle")
|
@Value("particle")
|
||||||
@Default
|
@Default
|
||||||
private String particle = null;
|
private String particle = null;
|
||||||
@@ -23,13 +23,13 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientPartic
|
|||||||
private Float probability = 0.1f;
|
private Float probability = 0.1f;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AmbientParticleSettings get() {
|
public AmbientParticle get() {
|
||||||
if(particle == null) {
|
if(particle == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new AmbientParticleSettings(ParticleArgument.readParticle(new StringReader(particle),
|
return new AmbientParticle(ParticleArgument.readParticle(new StringReader(particle),
|
||||||
HolderLookup.Provider.create(Stream.of(BuiltInRegistries.PARTICLE_TYPE))), probability);
|
HolderLookup.Provider.create(Stream.of(BuiltInRegistries.PARTICLE_TYPE))), probability);
|
||||||
} catch(CommandSyntaxException e) {
|
} catch(CommandSyntaxException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
+2
-2
@@ -4,14 +4,14 @@ 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.annotations.Value;
|
||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
|
||||||
|
|
||||||
public class EntityTypeTemplate implements ObjectTemplate<EntityType<?>> {
|
public class EntityTypeTemplate implements ObjectTemplate<EntityType<?>> {
|
||||||
@Value("id")
|
@Value("id")
|
||||||
@Default
|
@Default
|
||||||
private ResourceLocation id = null;
|
private Identifier id = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityType<?> get() {
|
public EntityType<?> get() {
|
||||||
|
|||||||
+2
-2
@@ -3,14 +3,14 @@ package com.dfsek.terra.bukkit.nms.config;
|
|||||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
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.annotations.Value;
|
||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
|
||||||
|
|
||||||
public class SoundEventTemplate implements ObjectTemplate<SoundEvent> {
|
public class SoundEventTemplate implements ObjectTemplate<SoundEvent> {
|
||||||
@Value("id")
|
@Value("id")
|
||||||
@Default
|
@Default
|
||||||
private ResourceLocation id = null;
|
private Identifier id = null;
|
||||||
|
|
||||||
@Value("distance-to-travel")
|
@Value("distance-to-travel")
|
||||||
@Default
|
@Default
|
||||||
|
|||||||
+6
-6
@@ -6,10 +6,10 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
|||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.sounds.Music;
|
import net.minecraft.sounds.Music;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
import net.minecraft.world.entity.npc.villager.VillagerType;
|
||||||
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
import net.minecraft.world.attribute.AmbientAdditionsSettings;
|
||||||
import net.minecraft.world.level.biome.AmbientMoodSettings;
|
import net.minecraft.world.attribute.AmbientMoodSettings;
|
||||||
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
import net.minecraft.world.attribute.AmbientParticle;
|
||||||
import net.minecraft.world.level.biome.Biome.TemperatureModifier;
|
import net.minecraft.world.level.biome.Biome.TemperatureModifier;
|
||||||
import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier;
|
import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier;
|
||||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||||
@@ -52,7 +52,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
|
|
||||||
@Value("particles")
|
@Value("particles")
|
||||||
@Default
|
@Default
|
||||||
private AmbientParticleSettings particleConfig = null;
|
private AmbientParticle particleConfig = null;
|
||||||
|
|
||||||
@Value("climate.precipitation")
|
@Value("climate.precipitation")
|
||||||
@Default
|
@Default
|
||||||
@@ -130,7 +130,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
return grassColorModifier;
|
return grassColorModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AmbientParticleSettings getParticleConfig() {
|
public AmbientParticle getParticleConfig() {
|
||||||
return particleConfig;
|
return particleConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -5,14 +5,14 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
|||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
import net.minecraft.world.entity.npc.villager.VillagerType;
|
||||||
|
|
||||||
|
|
||||||
public class VillagerTypeTemplate implements ObjectTemplate<ResourceKey<VillagerType>> {
|
public class VillagerTypeTemplate implements ObjectTemplate<ResourceKey<VillagerType>> {
|
||||||
@Value("id")
|
@Value("id")
|
||||||
@Default
|
@Default
|
||||||
private ResourceLocation id = null;
|
private Identifier id = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceKey<VillagerType> get() {
|
public ResourceKey<VillagerType> get() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecturyLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,3 +9,7 @@ dependencies {
|
|||||||
tasks.named("jar") {
|
tasks.named("jar") {
|
||||||
finalizedBy("installAddonsIntoDefaultJar")
|
finalizedBy("installAddonsIntoDefaultJar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
|
options.release = 25
|
||||||
|
}
|
||||||
@@ -20,6 +20,10 @@ tasks.withType<Jar> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
|
options.release = 25
|
||||||
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClass.set(javaMainClass)
|
mainClass.set(javaMainClass)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -7,6 +7,8 @@ import net.kyori.adventure.util.RGBLike;
|
|||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.instance.Instance;
|
import net.minestom.server.instance.Instance;
|
||||||
import net.minestom.server.sound.SoundEvent;
|
import net.minestom.server.sound.SoundEvent;
|
||||||
|
import net.minestom.server.world.attribute.AmbientParticle;
|
||||||
|
import net.minestom.server.world.attribute.AmbientSounds;
|
||||||
import net.minestom.server.world.biome.BiomeEffects;
|
import net.minestom.server.world.biome.BiomeEffects;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -82,9 +84,9 @@ public final class TerraMinestomPlatform extends AbstractPlatform {
|
|||||||
(TypeLoader<EntityType>) (annotatedType, o, configLoader, depthTracker) -> new MinestomEntityType((String) o))
|
(TypeLoader<EntityType>) (annotatedType, o, configLoader, depthTracker) -> new MinestomEntityType((String) o))
|
||||||
.registerLoader(BlockState.class,
|
.registerLoader(BlockState.class,
|
||||||
(TypeLoader<BlockState>) (annotatedType, o, configLoader, depthTracker) -> worldHandle.createBlockState((String) o))
|
(TypeLoader<BlockState>) (annotatedType, o, configLoader, depthTracker) -> worldHandle.createBlockState((String) o))
|
||||||
.registerLoader(BiomeEffects.Particle.class, BiomeParticleConfigTemplate::new)
|
.registerLoader(AmbientParticle.class, BiomeParticleConfigTemplate::new)
|
||||||
.registerLoader(BiomeEffects.MoodSound.class, BiomeMoodSoundTemplate::new)
|
.registerLoader(AmbientSounds.Mood.class, BiomeMoodSoundTemplate::new)
|
||||||
.registerLoader(BiomeEffects.AdditionsSound.class, BiomeAdditionsSoundTemplate::new)
|
.registerLoader(AmbientSounds.Additions.class, BiomeAdditionsSoundTemplate::new)
|
||||||
.registerLoader(SoundEvent.class, SoundEventTemplate::new);
|
.registerLoader(SoundEvent.class, SoundEventTemplate::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+19
-20
@@ -5,6 +5,7 @@ import net.minestom.server.MinecraftServer;
|
|||||||
import net.minestom.server.color.Color;
|
import net.minestom.server.color.Color;
|
||||||
import net.minestom.server.registry.DynamicRegistry;
|
import net.minestom.server.registry.DynamicRegistry;
|
||||||
import net.minestom.server.registry.RegistryKey;
|
import net.minestom.server.registry.RegistryKey;
|
||||||
|
import net.minestom.server.world.attribute.EnvironmentAttribute;
|
||||||
import net.minestom.server.world.biome.Biome;
|
import net.minestom.server.world.biome.Biome;
|
||||||
import net.minestom.server.world.biome.BiomeEffects;
|
import net.minestom.server.world.biome.BiomeEffects;
|
||||||
import org.intellij.lang.annotations.Subst;
|
import org.intellij.lang.annotations.Subst;
|
||||||
@@ -27,6 +28,11 @@ public class MinestomUserDefinedBiomeFactory implements BiomeFactory {
|
|||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <T> void applyAttributeIfNotNull(Biome.Builder biomeBuilder, EnvironmentAttribute<T> attribute, T value) {
|
||||||
|
if (value == null) return;
|
||||||
|
biomeBuilder.setAttribute(attribute, value);
|
||||||
|
}
|
||||||
|
|
||||||
@Subst("value")
|
@Subst("value")
|
||||||
protected static String createBiomeID(ConfigPack pack, String biomeId) {
|
protected static String createBiomeID(ConfigPack pack, String biomeId) {
|
||||||
return pack.getID().toLowerCase() + "/" + biomeId.toLowerCase(Locale.ROOT);
|
return pack.getID().toLowerCase() + "/" + biomeId.toLowerCase(Locale.ROOT);
|
||||||
@@ -41,32 +47,25 @@ public class MinestomUserDefinedBiomeFactory implements BiomeFactory {
|
|||||||
Key key = Key.key("terra", createBiomeID(pack, source.getID()));
|
Key key = Key.key("terra", createBiomeID(pack, source.getID()));
|
||||||
|
|
||||||
BiomeEffects.Builder effectsBuilder = BiomeEffects.builder()
|
BiomeEffects.Builder effectsBuilder = BiomeEffects.builder()
|
||||||
.fogColor(mergeNullable(properties.getFogColor(), parentEffects.fogColor()))
|
|
||||||
.skyColor(mergeNullable(properties.getSkyColor(), parentEffects.skyColor()))
|
|
||||||
.waterColor(mergeNullable(properties.getWaterColor(), parentEffects.waterColor()))
|
.waterColor(mergeNullable(properties.getWaterColor(), parentEffects.waterColor()))
|
||||||
.waterFogColor(mergeNullable(properties.getWaterFogColor(), parentEffects.waterFogColor()))
|
|
||||||
.foliageColor(mergeNullable(properties.getFoliageColor(), parentEffects.foliageColor()))
|
.foliageColor(mergeNullable(properties.getFoliageColor(), parentEffects.foliageColor()))
|
||||||
.grassColor(mergeNullable(properties.getGrassColor(), parentEffects.grassColor()))
|
.grassColor(mergeNullable(properties.getGrassColor(), parentEffects.grassColor()))
|
||||||
.grassColorModifier(mergeNullable(properties.getGrassColorModifier(), parentEffects.grassColorModifier()))
|
.grassColorModifier(mergeNullable(properties.getGrassColorModifier(), parentEffects.grassColorModifier()));
|
||||||
.biomeParticle(mergeNullable(properties.getParticleConfig(), parentEffects.biomeParticle()))
|
|
||||||
.ambientSound(mergeNullable(properties.getLoopSound(), parentEffects.ambientSound()))
|
|
||||||
.moodSound(mergeNullable(properties.getMoodSound(), parentEffects.moodSound()))
|
|
||||||
.additionsSound(mergeNullable(properties.getAdditionsSound(), parentEffects.additionsSound()))
|
|
||||||
// TODO music
|
|
||||||
.music(parentEffects.music())
|
|
||||||
.musicVolume(parentEffects.musicVolume());
|
|
||||||
|
|
||||||
if(effectsBuilder.build().equals(BiomeEffects.PLAINS_EFFECTS)) {
|
Biome.Builder targetBuilder = Biome.builder()
|
||||||
effectsBuilder.fogColor(new Color(0xC0D8FE)); // circumvent a minestom bug
|
|
||||||
}
|
|
||||||
|
|
||||||
Biome target = Biome.builder()
|
|
||||||
.downfall(mergeNullable(properties.getDownfall(), parent.downfall()))
|
.downfall(mergeNullable(properties.getDownfall(), parent.downfall()))
|
||||||
.hasPrecipitation(mergeNullable(properties.getPrecipitation(), parent.hasPrecipitation()))
|
.precipitation(mergeNullable(properties.getPrecipitation(), parent.hasPrecipitation()))
|
||||||
.temperature(mergeNullable(properties.getTemperature(), parent.temperature()))
|
.temperature(mergeNullable(properties.getTemperature(), parent.temperature()))
|
||||||
.temperatureModifier(mergeNullable(properties.getTemperatureModifier(), parent.temperatureModifier()))
|
.effects(effectsBuilder.build());
|
||||||
.effects(effectsBuilder.build())
|
|
||||||
.build();
|
applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.FOG_COLOR, properties.getFogColor());
|
||||||
|
applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.SKY_COLOR, properties.getSkyColor());
|
||||||
|
applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.WATER_FOG_COLOR, properties.getWaterFogColor());
|
||||||
|
applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.AMBIENT_PARTICLES, properties.getParticleConfig());
|
||||||
|
applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.AMBIENT_SOUNDS, properties.getAmbientSoundConfig());
|
||||||
|
// TODO music
|
||||||
|
|
||||||
|
Biome target = targetBuilder.build();
|
||||||
|
|
||||||
RegistryKey<Biome> registryKey = MinecraftServer.getBiomeRegistry().register(key, target);
|
RegistryKey<Biome> registryKey = MinecraftServer.getBiomeRegistry().register(key, target);
|
||||||
return new UserDefinedBiome(key, registryKey, source.getID(), target);
|
return new UserDefinedBiome(key, registryKey, source.getID(), target);
|
||||||
|
|||||||
+4
-3
@@ -4,10 +4,11 @@ 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.annotations.Value;
|
||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import net.minestom.server.sound.SoundEvent;
|
import net.minestom.server.sound.SoundEvent;
|
||||||
|
import net.minestom.server.world.attribute.AmbientSounds;
|
||||||
import net.minestom.server.world.biome.BiomeEffects;
|
import net.minestom.server.world.biome.BiomeEffects;
|
||||||
|
|
||||||
|
|
||||||
public class BiomeAdditionsSoundTemplate implements ObjectTemplate<BiomeEffects.AdditionsSound> {
|
public class BiomeAdditionsSoundTemplate implements ObjectTemplate<AmbientSounds.Additions> {
|
||||||
@Value("sound")
|
@Value("sound")
|
||||||
@Default
|
@Default
|
||||||
private SoundEvent sound = null;
|
private SoundEvent sound = null;
|
||||||
@@ -17,8 +18,8 @@ public class BiomeAdditionsSoundTemplate implements ObjectTemplate<BiomeEffects.
|
|||||||
private Double soundChance = null;
|
private Double soundChance = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeEffects.AdditionsSound get() {
|
public AmbientSounds.Additions get() {
|
||||||
if(sound == null) return null;
|
if(sound == null) return null;
|
||||||
return new BiomeEffects.AdditionsSound(sound, soundChance);
|
return new AmbientSounds.Additions(sound, soundChance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-3
@@ -4,10 +4,11 @@ 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.annotations.Value;
|
||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import net.minestom.server.sound.SoundEvent;
|
import net.minestom.server.sound.SoundEvent;
|
||||||
|
import net.minestom.server.world.attribute.AmbientSounds;
|
||||||
import net.minestom.server.world.biome.BiomeEffects;
|
import net.minestom.server.world.biome.BiomeEffects;
|
||||||
|
|
||||||
|
|
||||||
public class BiomeMoodSoundTemplate implements ObjectTemplate<BiomeEffects.MoodSound> {
|
public class BiomeMoodSoundTemplate implements ObjectTemplate<AmbientSounds.Mood> {
|
||||||
@Value("sound")
|
@Value("sound")
|
||||||
@Default
|
@Default
|
||||||
private SoundEvent sound = null;
|
private SoundEvent sound = null;
|
||||||
@@ -25,9 +26,9 @@ public class BiomeMoodSoundTemplate implements ObjectTemplate<BiomeEffects.MoodS
|
|||||||
private Double soundExtraDistance = null;
|
private Double soundExtraDistance = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeEffects.MoodSound get() {
|
public AmbientSounds.Mood get() {
|
||||||
if(sound == null) return null;
|
if(sound == null) return null;
|
||||||
return new BiomeEffects.MoodSound(
|
return new AmbientSounds.Mood(
|
||||||
sound,
|
sound,
|
||||||
soundCultivationTicks,
|
soundCultivationTicks,
|
||||||
soundSpawnRange,
|
soundSpawnRange,
|
||||||
|
|||||||
+37
-10
@@ -3,12 +3,17 @@ package com.dfsek.terra.minestom.config;
|
|||||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
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.annotations.Value;
|
||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
|
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||||
|
import net.minestom.server.adventure.MinestomAdventure;
|
||||||
|
import net.minestom.server.codec.Transcoder;
|
||||||
import net.minestom.server.particle.Particle;
|
import net.minestom.server.particle.Particle;
|
||||||
import net.minestom.server.world.biome.BiomeEffects;
|
import net.minestom.server.world.attribute.AmbientParticle;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeEffects.Particle> {
|
|
||||||
|
public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientParticle> {
|
||||||
@Value("particle")
|
@Value("particle")
|
||||||
@Default
|
@Default
|
||||||
private String particle = null;
|
private String particle = null;
|
||||||
@@ -18,22 +23,44 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeEffects.
|
|||||||
private Float probability = null;
|
private Float probability = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeEffects.Particle get() {
|
public AmbientParticle get() {
|
||||||
if(particle == null || probability == null) {
|
if(particle == null || probability == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] parts = particle.split("\\{");
|
String[] parts = particle.split("\\{");
|
||||||
Particle parsedParticle = Particle.fromKey(parts[0]);
|
String key = parts[0];
|
||||||
|
Particle parsedParticle = Particle.fromKey(key);
|
||||||
if(parts.length > 1) {
|
if(parts.length > 1) {
|
||||||
LoggerFactory.getLogger(BiomeParticleConfigTemplate.class).warn("Particle {} has additional data, particle will be ignored.",
|
int start = particle.indexOf("{");
|
||||||
particle);
|
String dataString = particle.substring(start);
|
||||||
return null;
|
parsedParticle = parseAdditionalParticleData(dataString, key);
|
||||||
|
if (parsedParticle == null) return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BiomeEffects.Particle(
|
return new AmbientParticle(
|
||||||
probability,
|
parsedParticle,
|
||||||
parsedParticle
|
probability
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Particle parseAdditionalParticleData(String dataString, String key) {
|
||||||
|
CompoundBinaryTag nbt = null;
|
||||||
|
Particle parsedParticle;
|
||||||
|
try {
|
||||||
|
nbt = MinestomAdventure.NBT_CODEC.decode(dataString);
|
||||||
|
// transform minecraft:x{a:"b"} into {type:"minecraft:x", a:"b"} as described in Particle.CODEC
|
||||||
|
nbt = nbt.putString("type", key);
|
||||||
|
parsedParticle = Particle.CODEC.decode(Transcoder.NBT, nbt).orElseThrow();
|
||||||
|
} catch(Exception e) {
|
||||||
|
String nbtString = "null";
|
||||||
|
try {
|
||||||
|
nbtString = (nbt == null ? "null" : MinestomAdventure.NBT_CODEC.encode(nbt));
|
||||||
|
} catch(IOException _) { }
|
||||||
|
LoggerFactory.getLogger(BiomeParticleConfigTemplate.class).warn(
|
||||||
|
"Failed to decode particle from '" + particle + "', nbt: '" + nbtString + "'. This particle will be ignored.", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return parsedParticle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+17
-15
@@ -5,12 +5,16 @@ 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.annotations.Value;
|
||||||
import net.kyori.adventure.util.RGBLike;
|
import net.kyori.adventure.util.RGBLike;
|
||||||
import net.minestom.server.sound.SoundEvent;
|
import net.minestom.server.sound.SoundEvent;
|
||||||
|
import net.minestom.server.world.attribute.AmbientParticle;
|
||||||
|
import net.minestom.server.world.attribute.AmbientSounds;
|
||||||
import net.minestom.server.world.biome.Biome.TemperatureModifier;
|
import net.minestom.server.world.biome.Biome.TemperatureModifier;
|
||||||
import net.minestom.server.world.biome.BiomeEffects;
|
import net.minestom.server.world.biome.BiomeEffects;
|
||||||
import net.minestom.server.world.biome.BiomeEffects.GrassColorModifier;
|
import net.minestom.server.world.biome.BiomeEffects.GrassColorModifier;
|
||||||
|
|
||||||
import com.dfsek.terra.api.properties.Properties;
|
import com.dfsek.terra.api.properties.Properties;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||||
@Value("colors.grass")
|
@Value("colors.grass")
|
||||||
@@ -43,7 +47,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
|
|
||||||
@Value("particles")
|
@Value("particles")
|
||||||
@Default
|
@Default
|
||||||
private BiomeEffects.Particle particleConfig = null;
|
private AmbientParticle particleConfig = null;
|
||||||
|
|
||||||
@Value("climate.precipitation")
|
@Value("climate.precipitation")
|
||||||
@Default
|
@Default
|
||||||
@@ -67,11 +71,11 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
|
|
||||||
@Value("sound.mood-sound")
|
@Value("sound.mood-sound")
|
||||||
@Default
|
@Default
|
||||||
private BiomeEffects.MoodSound moodSound = null;
|
private AmbientSounds.Mood moodSound = null;
|
||||||
|
|
||||||
@Value("sound.additions-sound")
|
@Value("sound.additions-sound")
|
||||||
@Default
|
@Default
|
||||||
private BiomeEffects.AdditionsSound additionsSound = null;
|
private AmbientSounds.Additions additionsSound = null;
|
||||||
|
|
||||||
// @Value("sound.music")
|
// @Value("sound.music")
|
||||||
// @Default
|
// @Default
|
||||||
@@ -105,8 +109,9 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
return grassColorModifier;
|
return grassColorModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeEffects.Particle getParticleConfig() {
|
public List<AmbientParticle> getParticleConfig() {
|
||||||
return particleConfig;
|
if (particleConfig == null) return null;
|
||||||
|
return List.of(particleConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getPrecipitation() {
|
public Boolean getPrecipitation() {
|
||||||
@@ -125,15 +130,12 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
return downfall;
|
return downfall;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundEvent getLoopSound() {
|
public AmbientSounds getAmbientSoundConfig() {
|
||||||
return loopSound;
|
List<AmbientSounds.Additions> additions = additionsSound == null ? List.of() : List.of(additionsSound);
|
||||||
}
|
return new AmbientSounds(
|
||||||
|
loopSound,
|
||||||
public BiomeEffects.MoodSound getMoodSound() {
|
moodSound,
|
||||||
return moodSound;
|
additions
|
||||||
}
|
);
|
||||||
|
|
||||||
public BiomeEffects.AdditionsSound getAdditionsSound() {
|
|
||||||
return additionsSound;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecturyLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ dependencies {
|
|||||||
|
|
||||||
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||||
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||||
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecturyLoom}")
|
||||||
|
|
||||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ import net.minecraft.sound.MusicSound;
|
|||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.village.VillagerType;
|
import net.minecraft.village.VillagerType;
|
||||||
|
import net.minecraft.world.attribute.AmbientParticle;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.Biome.Precipitation;
|
import net.minecraft.world.biome.Biome.Precipitation;
|
||||||
import net.minecraft.world.biome.Biome.TemperatureModifier;
|
import net.minecraft.world.biome.Biome.TemperatureModifier;
|
||||||
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
|
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
|
||||||
import net.minecraft.world.biome.BiomeParticleConfig;
|
|
||||||
import net.minecraft.world.biome.SpawnSettings;
|
import net.minecraft.world.biome.SpawnSettings;
|
||||||
import net.minecraft.world.biome.source.MultiNoiseBiomeSourceParameterList;
|
import net.minecraft.world.biome.source.MultiNoiseBiomeSourceParameterList;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
@@ -87,7 +87,7 @@ public abstract class ModPlatform extends AbstractPlatform {
|
|||||||
.registerLoader(TemperatureModifier.class,
|
.registerLoader(TemperatureModifier.class,
|
||||||
(type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase()))
|
(type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase()))
|
||||||
.registerLoader(SpawnGroup.class, (type, o, loader, depthTracker) -> SpawnGroup.valueOf((String) o))
|
.registerLoader(SpawnGroup.class, (type, o, loader, depthTracker) -> SpawnGroup.valueOf((String) o))
|
||||||
.registerLoader(BiomeParticleConfig.class, BiomeParticleConfigTemplate::new)
|
.registerLoader(AmbientParticle.class, BiomeParticleConfigTemplate::new)
|
||||||
.registerLoader(SoundEvent.class, SoundEventTemplate::new)
|
.registerLoader(SoundEvent.class, SoundEventTemplate::new)
|
||||||
.registerLoader(BiomeMoodSound.class, BiomeMoodSoundTemplate::new)
|
.registerLoader(BiomeMoodSound.class, BiomeMoodSoundTemplate::new)
|
||||||
.registerLoader(BiomeAdditionsSound.class, BiomeAdditionsSoundTemplate::new)
|
.registerLoader(BiomeAdditionsSound.class, BiomeAdditionsSoundTemplate::new)
|
||||||
|
|||||||
+4
-5
@@ -8,12 +8,11 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|||||||
import net.minecraft.command.argument.ParticleEffectArgumentType;
|
import net.minecraft.command.argument.ParticleEffectArgumentType;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.registry.RegistryWrapper;
|
import net.minecraft.registry.RegistryWrapper;
|
||||||
import net.minecraft.world.biome.BiomeParticleConfig;
|
import net.minecraft.world.attribute.AmbientParticle;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
||||||
public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeParticleConfig> {
|
public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientParticle> {
|
||||||
@Value("particle")
|
@Value("particle")
|
||||||
@Default
|
@Default
|
||||||
private String particle = null;
|
private String particle = null;
|
||||||
@@ -23,13 +22,13 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeParticle
|
|||||||
private Float probability = 0.1f;
|
private Float probability = 0.1f;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeParticleConfig get() {
|
public AmbientParticle get() {
|
||||||
if(particle == null) {
|
if(particle == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new BiomeParticleConfig(
|
return new AmbientParticle(
|
||||||
ParticleEffectArgumentType.readParameters(new StringReader(particle),
|
ParticleEffectArgumentType.readParameters(new StringReader(particle),
|
||||||
RegistryWrapper.WrapperLookup.of(Stream.of(Registries.PARTICLE_TYPE))),
|
RegistryWrapper.WrapperLookup.of(Stream.of(Registries.PARTICLE_TYPE))),
|
||||||
probability);
|
probability);
|
||||||
|
|||||||
+3
-3
@@ -9,9 +9,9 @@ import net.minecraft.sound.BiomeMoodSound;
|
|||||||
import net.minecraft.sound.MusicSound;
|
import net.minecraft.sound.MusicSound;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.village.VillagerType;
|
import net.minecraft.village.VillagerType;
|
||||||
|
import net.minecraft.world.attribute.AmbientParticle;
|
||||||
import net.minecraft.world.biome.Biome.TemperatureModifier;
|
import net.minecraft.world.biome.Biome.TemperatureModifier;
|
||||||
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
|
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
|
||||||
import net.minecraft.world.biome.BiomeParticleConfig;
|
|
||||||
import net.minecraft.world.biome.SpawnSettings;
|
import net.minecraft.world.biome.SpawnSettings;
|
||||||
|
|
||||||
import com.dfsek.terra.api.properties.Properties;
|
import com.dfsek.terra.api.properties.Properties;
|
||||||
@@ -52,7 +52,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
|
|
||||||
@Value("particles")
|
@Value("particles")
|
||||||
@Default
|
@Default
|
||||||
private BiomeParticleConfig particleConfig = null;
|
private AmbientParticle particleConfig = null;
|
||||||
|
|
||||||
@Value("climate.precipitation")
|
@Value("climate.precipitation")
|
||||||
@Default
|
@Default
|
||||||
@@ -131,7 +131,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
return grassColorModifier;
|
return grassColorModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeParticleConfig getParticleConfig() {
|
public AmbientParticle getParticleConfig() {
|
||||||
return particleConfig;
|
return particleConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -4,7 +4,9 @@ import net.minecraft.world.biome.GenerationSettings;
|
|||||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||||
import org.spongepowered.asm.mixin.Implements;
|
import org.spongepowered.asm.mixin.Implements;
|
||||||
import org.spongepowered.asm.mixin.Interface;
|
import org.spongepowered.asm.mixin.Interface;
|
||||||
|
import org.spongepowered.asm.mixin.Intrinsic;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
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.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
@@ -23,7 +25,7 @@ public class GenerationSettingsFloraFeaturesMixin {
|
|||||||
this.flora = features;
|
this.flora = features;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getFlowerFeatures", cancellable = true, at = @At("HEAD"))
|
@Inject(method = "getFlowerFeatures()Ljava/util/List;", cancellable = true, at = @At("HEAD"))
|
||||||
public void inject(CallbackInfoReturnable<List<ConfiguredFeature<?, ?>>> cir) {
|
public void inject(CallbackInfoReturnable<List<ConfiguredFeature<?, ?>>> cir) {
|
||||||
if(flora != null) {
|
if(flora != null) {
|
||||||
cir.setReturnValue(flora);
|
cir.setReturnValue(flora);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecturyLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ dependencies {
|
|||||||
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||||
compileOnly("io.github.llamalad7:mixinextras-common:${Versions.Mod.mixinExtras}")
|
compileOnly("io.github.llamalad7:mixinextras-common:${Versions.Mod.mixinExtras}")
|
||||||
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||||
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecturyLoom}")
|
||||||
|
|
||||||
implementation(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
implementation(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user