Compare commits

..

3 Commits

Author SHA1 Message Date
justaureus 8d01059833 Merge pull request #458 from OakLoaf/dev/1.20.6/bukkit
Updated Bukkit to 1.20.6
2024-06-23 18:08:41 -05:00
Oak 500cf3c0b5 Fixed incorrect version formatting 2024-06-19 14:29:03 +01:00
Oak 0507978c87 Revert "Updated bukkit platform to 1.21" 2024-06-18 11:30:02 +01:00
61 changed files with 292 additions and 404 deletions
+1 -2
View File
@@ -15,7 +15,6 @@ allprojects {
tasks.withType<JavaCompile>().configureEach {
options.isFork = true
options.isIncremental = true
options.release.set(21)
}
tasks.withType<Test>().configureEach {
@@ -45,7 +44,7 @@ afterEvaluate {
}
project(":platforms:bukkit:common").configureDistribution()
forSubProjects(":common:addons") {
apply(plugin = "com.gradleup.shadow")
apply(plugin = "com.github.johnrengelman.shadow")
tasks.named("build") {
finalizedBy(tasks.named("shadowJar"))
+3 -3
View File
@@ -16,11 +16,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.github.johnrengelman", "shadow", "8.1.1")
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "1.7.1")
implementation("org.ow2.asm", "asm", "9.7")
implementation("org.ow2.asm", "asm-tree", "9.7")
implementation("com.dfsek.tectonic", "common", "4.2.1")
implementation("org.yaml", "snakeyaml", "2.3")
implementation("org.yaml", "snakeyaml", "2.2")
}
@@ -48,9 +48,6 @@ fun Project.configureDependencies() {
maven("https://jitpack.io") {
name = "JitPack"
}
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
name = "Sonatype Snapshots"
}
}
dependencies {
@@ -21,7 +21,7 @@ import kotlin.io.path.exists
fun Project.configureDistribution() {
apply(plugin = "com.gradleup.shadow")
apply(plugin = "com.github.johnrengelman.shadow")
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
group = "terra"
+19 -21
View File
@@ -8,28 +8,26 @@ object Versions {
const val paralithic = "0.7.1"
const val strata = "1.3.2"
const val cloud = "2.0.0"
const val cloudPaper = "2.0.0-beta.10"
const val cloudFabric = "2.0.0-beta.9"
const val cloud = "1.8.4"
const val caffeine = "3.1.8"
const val slf4j = "2.0.16"
const val slf4j = "2.0.13"
object Internal {
const val shadow = "8.3.1"
const val shadow = "8.1.1"
const val apacheText = "1.12.0"
const val apacheIO = "2.16.1"
const val guava = "33.3.0-jre"
const val guava = "33.1.0-jre"
const val asm = "9.7"
const val snakeYml = "2.3"
const val snakeYml = "2.2"
const val jetBrainsAnnotations = "24.1.0"
const val junit = "5.11.0"
const val junit = "5.10.2"
}
}
object Fabric {
const val fabricAPI = "0.104.0+${Mod.minecraft}"
const val fabricAPI = "0.97.8+${Mod.minecraft}"
}
//
// object Quilt {
@@ -38,14 +36,14 @@ object Versions {
// }
object Mod {
const val mixin = "0.15.3+mixin.0.8.7"
const val mixin = "0.12.5+mixin.0.8.5"
const val minecraft = "1.21.1"
const val yarn = "$minecraft+build.3"
const val fabricLoader = "0.16.5"
const val minecraft = "1.20.6"
const val yarn = "$minecraft+build.1"
const val fabricLoader = "0.15.10"
const val architecuryLoom = "1.7.413"
const val architecturyPlugin = "3.4.159"
const val architecuryLoom = "1.6.395"
const val architecturyPlugin = "3.4.155"
}
//
// object Forge {
@@ -54,14 +52,14 @@ object Versions {
// }
object Bukkit {
const val minecraft = "1.21.1"
const val paperBuild = "$minecraft-R0.1-20240917.151311-80"
const val minecraft = "1.20.6"
const val paperBuild = "$minecraft-R0.1-20240602.222958-107"
const val paper = paperBuild
const val paperLib = "1.0.8"
const val reflectionRemapper = "0.1.1"
const val paperDevBundle = paperBuild
const val runPaper = "2.3.1"
const val paperWeight = "1.7.2"
const val paperDevBundle = "$minecraft-R0.1-20240601.143523-105"
const val runPaper = "2.3.0"
const val paperWeight = "1.7.1"
}
//
@@ -73,6 +71,6 @@ object Versions {
//
object CLI {
const val nbt = "6.1"
const val logback = "1.5.8"
const val logback = "1.4.14"
}
}
@@ -1,5 +1,8 @@
package com.dfsek.terra.addons.commands.addons;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.CommandManager;
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.addon.BaseAddon;
@@ -9,9 +12,6 @@ import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
import com.dfsek.terra.api.inject.annotations.Inject;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.description.Description;
public class AddonsCommandAddon implements AddonInitializer {
@Inject
@@ -30,7 +30,7 @@ public class AddonsCommandAddon implements AddonInitializer {
CommandManager<CommandSender> manager = event.getCommandManager();
manager.command(
manager.commandBuilder("addons", Description.of("List installed Terra addons"))
manager.commandBuilder("addons", ArgumentDescription.of("List installed Terra addons"))
.permission("terra.addons")
.handler(context -> {
StringBuilder addons = new StringBuilder("Installed addons:\n");
@@ -41,7 +41,7 @@ public class AddonsCommandAddon implements AddonInitializer {
.append('@')
.append(addon.getVersion().getFormatted())
.append('\n'));
context.sender().sendMessage(addons.toString());
context.getSender().sendMessage(addons.toString());
})
)
.command(
@@ -61,7 +61,7 @@ public class AddonsCommandAddon implements AddonInitializer {
.append('@')
.append(versions.getFormatted())
.append('\n'));
context.sender().sendMessage(addonInfo.toString());
context.getSender().sendMessage(addonInfo.toString());
})
);
});
@@ -1,7 +1,7 @@
package com.dfsek.terra.addons.commands.packs;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.description.Description;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.CommandManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,7 +35,7 @@ public class PacksCommandAddon implements AddonInitializer {
CommandManager<CommandSender> manager = event.getCommandManager();
manager.command(
manager.commandBuilder("packs", Description.of("List installed config packs"))
manager.commandBuilder("packs", ArgumentDescription.of("List installed config packs"))
.permission("terra.packs")
.handler(context -> {
StringBuilder packs = new StringBuilder("Installed packs:\n");
@@ -43,12 +43,12 @@ public class PacksCommandAddon implements AddonInitializer {
.append(pack.getID())
.append('@')
.append(pack.getVersion().getFormatted()));
context.sender().sendMessage(packs.toString());
context.getSender().sendMessage(packs.toString());
})
)
.command(
manager.commandBuilder("packs")
.literal("info", Description.of("Get information about a pack"))
.literal("info", ArgumentDescription.of("Get information about a pack"))
.permission("terra.packs.info")
.argument(RegistryArgument.of("pack", platform.getConfigRegistry()))
.handler(context -> {
@@ -65,21 +65,21 @@ public class PacksCommandAddon implements AddonInitializer {
.append('@')
.append(versions.getFormatted())
.append('\n'));
context.sender().sendMessage(packInfo.toString());
context.getSender().sendMessage(packInfo.toString());
}))
.command(
manager.commandBuilder("packs")
.literal("reload", Description.of("Reload config packs"))
.literal("reload", ArgumentDescription.of("Reload config packs"))
.permission("terra.packs.reload")
.handler(context -> {
context.sender().sendMessage("Reloading Terra...");
context.getSender().sendMessage("Reloading Terra...");
logger.info("Reloading Terra...");
if(platform.reload()) {
logger.info("Terra reloaded successfully.");
context.sender().sendMessage("Terra reloaded successfully.");
context.getSender().sendMessage("Terra reloaded successfully.");
} else {
logger.error("Terra failed to reload.");
context.sender().sendMessage(
context.getSender().sendMessage(
"Terra failed to reload. See logs for more information.");
}
}));
@@ -1,7 +1,7 @@
package com.dfsek.terra.addons.commands.profiler;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.description.Description;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.CommandManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,24 +33,24 @@ public class ProfilerCommandAddon implements AddonInitializer {
CommandManager<CommandSender> manager = event.getCommandManager();
manager
.command(
manager.commandBuilder("profiler", Description.of("Access the profiler"))
.literal("start", Description.of("Start profiling"), "st")
manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
.literal("start", ArgumentDescription.of("Start profiling"), "st")
.permission("terra.profiler.start")
.handler(context -> {
platform.getProfiler().start();
context.sender().sendMessage("Profiling started.");
context.getSender().sendMessage("Profiling started.");
}))
.command(
manager.commandBuilder("profiler", Description.of("Access the profiler"))
.literal("stop", Description.of("Stop profiling"), "s")
manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
.literal("stop", ArgumentDescription.of("Stop profiling"), "s")
.permission("terra.profiler.stop")
.handler(context -> {
platform.getProfiler().stop();
context.sender().sendMessage("Profiling stopped.");
context.getSender().sendMessage("Profiling stopped.");
}))
.command(
manager.commandBuilder("profiler", Description.of("Access the profiler"))
.literal("query", Description.of("Query profiler results"), "q")
manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
.literal("query", ArgumentDescription.of("Query profiler results"), "q")
.permission("terra.profiler.query")
.handler(context -> {
StringBuilder data = new StringBuilder("Terra Profiler data: \n");
@@ -59,15 +59,15 @@ public class ProfilerCommandAddon implements AddonInitializer {
.append(timings.toString())
.append('\n'));
logger.info(data.toString());
context.sender().sendMessage("Profiling data dumped to console.");
context.getSender().sendMessage("Profiling data dumped to console.");
}))
.command(
manager.commandBuilder("profiler", Description.of("Access the profiler"))
.literal("reset", Description.of("Reset the profiler"), "r")
manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
.literal("reset", ArgumentDescription.of("Reset the profiler"), "r")
.permission("terra.profiler.reset")
.handler(context -> {
platform.getProfiler().reset();
context.sender().sendMessage("Profiler reset.");
context.getSender().sendMessage("Profiler reset.");
}));
});
}
@@ -1,5 +1,11 @@
package com.dfsek.terra.addons.commands.structure;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.CommandManager;
import cloud.commandframework.arguments.standard.EnumArgument;
import cloud.commandframework.arguments.standard.LongArgument;
import cloud.commandframework.context.CommandContext;
import java.util.Random;
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
@@ -16,13 +22,6 @@ import com.dfsek.terra.api.structure.Structure;
import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.util.reflection.TypeKey;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.component.DefaultValue;
import org.incendo.cloud.context.CommandContext;
import org.incendo.cloud.description.Description;
import org.incendo.cloud.parser.standard.EnumParser;
import org.incendo.cloud.parser.standard.LongParser;
public class StructureCommandAddon implements AddonInitializer {
@Inject
@@ -32,7 +31,7 @@ public class StructureCommandAddon implements AddonInitializer {
private BaseAddon addon;
private static Registry<Structure> getStructureRegistry(CommandContext<CommandSender> sender) {
return sender.sender().getEntity().orElseThrow().world().getPack().getRegistry(Structure.class);
return sender.getSender().getEntity().orElseThrow().world().getPack().getRegistry(Structure.class);
}
@Override
@@ -44,16 +43,16 @@ public class StructureCommandAddon implements AddonInitializer {
CommandManager<CommandSender> manager = event.getCommandManager();
manager.command(
manager.commandBuilder("structures", Description.of("Manage or generate structures"))
manager.commandBuilder("structures", ArgumentDescription.of("Manage or generate structures"))
.literal("generate")
.optional(RegistryArgument.builder("structure",
.argument(RegistryArgument.builder("structure",
StructureCommandAddon::getStructureRegistry,
TypeKey.of(Structure.class)))
.optional("seed", LongParser.longParser(), DefaultValue.constant(0L))
.optional("rotation", EnumParser.enumParser(Rotation.class), DefaultValue.constant(Rotation.NONE))
.argument(LongArgument.optional("seed", 0))
.argument(EnumArgument.optional(Rotation.class, "rotation", Rotation.NONE))
.handler(context -> {
Structure structure = context.get("structure");
Entity sender = context.sender().getEntity().orElseThrow();
Entity sender = context.getSender().getEntity().orElseThrow();
structure.generate(
sender.position().toInt(),
sender.world(),
+1 -1
View File
@@ -2,7 +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("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
api("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
@@ -1,10 +1,18 @@
package com.dfsek.terra.api.command.arguments;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
import cloud.commandframework.context.CommandContext;
import io.leangen.geantyref.TypeToken;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.Queue;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -13,33 +21,40 @@ import com.dfsek.terra.api.registry.exception.NoSuchEntryException;
import com.dfsek.terra.api.registry.key.RegistryKey;
import com.dfsek.terra.api.util.reflection.TypeKey;
import org.incendo.cloud.component.CommandComponent;
import org.incendo.cloud.component.DefaultValue;
import org.incendo.cloud.context.CommandContext;
import org.incendo.cloud.context.CommandInput;
import org.incendo.cloud.parser.ArgumentParseResult;
import org.incendo.cloud.parser.ArgumentParser;
import org.incendo.cloud.parser.ParserDescriptor;
import org.incendo.cloud.suggestion.Suggestion;
import org.incendo.cloud.suggestion.SuggestionProvider;
public class RegistryArgument {
public class RegistryArgument<T, R> extends CommandArgument<T, R> {
private RegistryArgument(
boolean required,
@NonNull String name,
Function<CommandContext<T>, Registry<R>> registryFunction,
TypeToken<R> typeToken,
@NonNull String defaultValue,
@Nullable BiFunction<CommandContext<T>, String, List<String>> suggestionsProvider,
@NonNull ArgumentDescription description
) {
super(required,
name,
new RegistryArgumentParser<>(registryFunction),
defaultValue,
typeToken,
suggestionsProvider,
description);
}
public static <T, R> Builder<T, R> builder(String name, Registry<R> registry) {
return new Builder<>(name, registry);
}
public static <T, R> CommandComponent<T> of(String name, Registry<R> registry) {
public static <T, R> CommandArgument<T, R> of(String name, Registry<R> registry) {
return RegistryArgument.<T, R>builder(name, registry).build();
}
public static <T, R> CommandComponent<T> optional(String name, Registry<R> registry) {
return RegistryArgument.<T, R>builder(name, registry).optional().build();
public static <T, R> CommandArgument<T, R> optional(String name, Registry<R> registry) {
return RegistryArgument.<T, R>builder(name, registry).asOptional().build();
}
public static <T, R> CommandComponent<T> optional(String name, Registry<R> registry, DefaultValue<T, R> defaultKey) {
return RegistryArgument.<T, R>builder(name, registry).optional(defaultKey).build();
public static <T, R> CommandArgument<T, R> optional(String name, Registry<R> registry, String defaultKey) {
return RegistryArgument.<T, R>builder(name, registry).asOptionalWithDefault(defaultKey).build();
}
@SuppressWarnings("unchecked")
@@ -48,36 +63,49 @@ public class RegistryArgument {
return new Builder<>(name, registryFunction, (TypeToken<R>) TypeToken.get(registryType.getType()));
}
public static <T, R> CommandComponent<T> of(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
public static <T, R> CommandArgument<T, R> of(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
TypeKey<R> registryType) {
return RegistryArgument.<T, R>builder(name, registryFunction, registryType).build();
}
public static <T, R> CommandComponent<T> optional(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
public static <T, R> CommandArgument<T, R> optional(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
TypeKey<R> registryType) {
return RegistryArgument.builder(name, registryFunction, registryType).optional().build();
return RegistryArgument.builder(name, registryFunction, registryType).asOptional().build();
}
public static <T, R> CommandComponent<T> optional(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
TypeKey<R> registryType, DefaultValue<T, R> defaultKey) {
return RegistryArgument.builder(name, registryFunction, registryType).optional(defaultKey).build();
public static <T, R> CommandArgument<T, R> optional(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
TypeKey<R> registryType, String defaultKey) {
return RegistryArgument.builder(name, registryFunction, registryType).asOptionalWithDefault(defaultKey).build();
}
public static final class Builder<T, R> extends CommandComponent.Builder<T, R> {
public static final class Builder<T, R> extends CommandArgument.Builder<T, R> {
private final Function<CommandContext<T>, Registry<R>> registryFunction;
private final TypeToken<R> typeToken;
@SuppressWarnings("unchecked")
private Builder(@NonNull String name, Registry<R> registry) {
super();
this.name(name);
this.parser(ParserDescriptor.of(
new RegistryArgumentParser<>(commandContext -> registry),
(TypeToken<R>) TypeToken.get(registry.getType().getType())));
super((TypeToken<R>) TypeToken.get(registry.getType().getType()), name);
this.registryFunction = commandContext -> registry;
this.typeToken = (TypeToken<R>) TypeToken.get(registry.getType().getType());
}
private Builder(@NonNull String name, Function<CommandContext<T>, Registry<R>> registryFunction, TypeToken<R> typeToken) {
super();
this.name(name);
this.parser(ParserDescriptor.of(new RegistryArgumentParser<>(registryFunction), typeToken));
super(typeToken, name);
this.typeToken = typeToken;
this.registryFunction = registryFunction;
}
@Override
public @NonNull RegistryArgument<T, R> build() {
return new RegistryArgument<>(
isRequired(),
getName(),
registryFunction,
typeToken,
getDefaultValue(),
getSuggestionsProvider(),
getDefaultDescription()
);
}
}
@@ -91,12 +119,12 @@ public class RegistryArgument {
@Override
public @NonNull ArgumentParseResult<@NonNull R> parse(@NonNull CommandContext<@NonNull T> commandContext,
@NonNull CommandInput commandInput) {
String input = commandInput.readString();
String next = commandInput.peekString();
if(next.equals(":")) {
input += commandInput.readString();
input += commandInput.readString();
@NonNull Queue<@NonNull String> inputQueue) {
String input = inputQueue.remove();
String next = inputQueue.peek();
if(next != null && next.equals(":")) {
input += inputQueue.remove();
input += inputQueue.remove();
}
Registry<R> registry = registryFunction.apply(commandContext);
@@ -118,17 +146,8 @@ public class RegistryArgument {
}
@Override
public @NonNull SuggestionProvider<T> suggestionProvider() {
return new SuggestionProvider<>() {
@Override
public @NonNull CompletableFuture<? extends @NonNull Iterable<? extends @NonNull Suggestion>> suggestionsFuture(
@NonNull CommandContext<T> context, @NonNull CommandInput input) {
// TODO: Verify whether this is correct
return CompletableFuture.completedFuture(registryFunction.apply(context).keys().stream().map(
registryKey -> Suggestion.suggestion(registryKey.toString())).sorted().collect(Collectors.toList()));
}
};
public @NonNull List<@NonNull String> suggestions(@NonNull CommandContext<T> commandContext, @NonNull String input) {
return registryFunction.apply(commandContext).keys().stream().map(RegistryKey::toString).sorted().collect(Collectors.toList());
}
}
}
@@ -1,10 +1,10 @@
package com.dfsek.terra.api.event.events.platform;
import cloud.commandframework.CommandManager;
import com.dfsek.terra.api.command.CommandSender;
import com.dfsek.terra.api.event.events.Event;
import org.incendo.cloud.CommandManager;
public class CommandRegistrationEvent implements Event {
private final CommandManager<CommandSender> commandManager;
@@ -8,7 +8,6 @@
package com.dfsek.terra.api.util.reflection;
import org.jetbrains.annotations.NotNull;
import sun.misc.Unsafe;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
@@ -27,18 +26,6 @@ import java.util.stream.Stream;
public final class ReflectionUtil {
private static final Unsafe UNSAFE;
static {
try{
final Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
unsafeField.setAccessible(true);
UNSAFE = (Unsafe) unsafeField.get(null);
} catch(NoSuchFieldException | IllegalAccessException e){
throw new RuntimeException(e);
}
}
public static Field[] getFields(@NotNull Class<?> type) {
Field[] result = type.getDeclaredFields();
Class<?> parentClass = type.getSuperclass();
@@ -48,14 +35,6 @@ public final class ReflectionUtil {
return result;
}
public static void setFinalField(Object obj, String fieldName, Object value) throws NoSuchFieldException {
Field field = obj.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
long fieldOffset = UNSAFE.objectFieldOffset(field);
UNSAFE.putObject(obj, fieldOffset, value);
}
public static Method[] getMethods(@NotNull Class<?> type) {
Method[] result = type.getDeclaredMethods();
Class<?> parentClass = type.getSuperclass();
Binary file not shown.
+2 -2
View File
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+1 -1
View File
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Vendored
+10 -10
View File
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
+7 -1
View File
@@ -2,9 +2,15 @@ plugins {
id("xyz.jpenilla.run-paper") version Versions.Bukkit.runPaper
}
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
name = "Sonatype"
}
}
dependencies {
shaded(project(":platforms:bukkit:common"))
shaded(project(":platforms:bukkit:nms:v1_21", configuration = "reobf"))
shaded(project(":platforms:bukkit:nms:v1_20_R6", configuration = "reobf"))
shaded("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
}
+1 -1
View File
@@ -11,5 +11,5 @@ dependencies {
shadedApi("com.google.guava", "guava", Versions.Libraries.Internal.guava)
shadedApi("org.incendo", "cloud-paper", Versions.Libraries.cloudPaper)
shadedApi("cloud.commandframework", "cloud-paper", Versions.Libraries.cloud)
}
@@ -17,16 +17,15 @@
package com.dfsek.terra.bukkit;
import cloud.commandframework.brigadier.CloudBrigadierManager;
import cloud.commandframework.bukkit.CloudBukkitCapabilities;
import cloud.commandframework.execution.CommandExecutionCoordinator;
import cloud.commandframework.paper.PaperCommandManager;
import io.papermc.paper.threadedregions.scheduler.AsyncScheduler;
import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler;
import org.bukkit.Bukkit;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.java.JavaPlugin;
import org.incendo.cloud.SenderMapper;
import org.incendo.cloud.brigadier.CloudBrigadierManager;
import org.incendo.cloud.bukkit.CloudBukkitCapabilities;
import org.incendo.cloud.execution.ExecutionCoordinator;
import org.incendo.cloud.paper.LegacyPaperCommandManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
@@ -72,7 +71,7 @@ public class TerraBukkitPlugin extends JavaPlugin {
}
try {
LegacyPaperCommandManager<CommandSender> commandManager = getCommandSenderPaperCommandManager();
PaperCommandManager<CommandSender> commandManager = getCommandSenderPaperCommandManager();
platform.getEventManager().callEvent(new CommandRegistrationEvent(commandManager));
@@ -92,26 +91,22 @@ public class TerraBukkitPlugin extends JavaPlugin {
}
@NotNull
private LegacyPaperCommandManager<CommandSender> getCommandSenderPaperCommandManager() throws Exception {
// TODO: Update to PaperCommandManager
LegacyPaperCommandManager<CommandSender> commandManager = new LegacyPaperCommandManager<>(
this,
ExecutionCoordinator.simpleCoordinator(),
SenderMapper.create(
BukkitAdapter::adapt,
BukkitAdapter::adapt
));
if (commandManager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
private PaperCommandManager<CommandSender> getCommandSenderPaperCommandManager() throws Exception {
PaperCommandManager<CommandSender> commandManager = new PaperCommandManager<>(this,
CommandExecutionCoordinator.simpleCoordinator(),
BukkitAdapter::adapt,
BukkitAdapter::adapt);
if(commandManager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
commandManager.registerBrigadier();
final CloudBrigadierManager<?, ?> brigManager = commandManager.brigadierManager();
if(brigManager != null) {
brigManager.setNativeNumberSuggestions(false);
}
} else if (commandManager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
commandManager.registerAsynchronousCompletions();
}
if(commandManager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
commandManager.registerAsynchronousCompletions();
}
return commandManager;
}
@@ -15,12 +15,7 @@ public interface Initializer {
static boolean init(PlatformImpl platform) {
Logger logger = LoggerFactory.getLogger(Initializer.class);
try {
String packageVersion = NMS;
if (NMS.equals("v1_21_1")) {
packageVersion = "v1_21";
}
Class<?> initializerClass = Class.forName(TERRA_PACKAGE + "." + packageVersion + ".NMSInitializer");
Class<?> initializerClass = Class.forName(TERRA_PACKAGE + "." + NMS + ".NMSInitializer");
try {
Initializer initializer = (Initializer) initializerClass.getConstructor().newInstance();
initializer.initialize(platform);
@@ -77,7 +77,7 @@ public final class VersionUtil {
public static final class MinecraftVersionInfo {
private static final Logger logger = LoggerFactory.getLogger(MinecraftVersionInfo.class);
private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?");
private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)");
private final int major;
private final int minor;
private final int patch;
@@ -97,7 +97,7 @@ public final class VersionUtil {
if(versionMatcher.find()) {
major = Integer.parseInt(versionMatcher.group(1));
minor = Integer.parseInt(versionMatcher.group(2));
patch = versionMatcher.group(3) != null ? Integer.parseInt(versionMatcher.group(3)) : -1;
patch = Integer.parseInt(versionMatcher.group(3));
} else {
logger.warn("Error while parsing minecraft version info. Continuing launch, but setting all versions to -1.");
@@ -112,11 +112,7 @@ public final class VersionUtil {
if(major == -1 && minor == -1 && patch == -1)
return "Unknown";
if (patch >= 0) {
return String.format("v%d.%d.%d", major, minor, patch);
} else {
return String.format("v%d.%d", major, minor);
}
return String.format("v%d.%d.%d", major, minor, patch);
}
public int getMajor() {
@@ -1,5 +1,9 @@
apply(plugin = "io.papermc.paperweight.userdev")
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
api(project(":platforms:bukkit:common"))
paperDevBundle(Versions.Bukkit.paperDevBundle)
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import com.google.common.collect.ImmutableMap;
import net.minecraft.core.Holder;
@@ -10,7 +10,6 @@ import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.biome.Biome;
import org.bukkit.NamespacedKey;
import org.slf4j.Logger;
@@ -42,12 +41,12 @@ public class AwfulBukkitHacks {
try {
BukkitPlatformBiome platformBiome = (BukkitPlatformBiome) biome.getPlatformBiome();
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
ResourceLocation vanillaMinecraftKey = ResourceLocation.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(), vanillaBukkitKey.getKey());
ResourceLocation vanillaMinecraftKey = new ResourceLocation(vanillaBukkitKey.getNamespace(), vanillaBukkitKey.getKey());
Biome platform = NMSBiomeInjector.createBiome(biome, Objects.requireNonNull(biomeRegistry.get(vanillaMinecraftKey)));
ResourceKey<Biome> delegateKey = ResourceKey.create(
Registries.BIOME,
ResourceLocation.fromNamespaceAndPath("terra", NMSBiomeInjector.createBiomeID(pack, key))
new ResourceLocation("terra", NMSBiomeInjector.createBiomeID(pack, key))
);
Reference<Biome> holder = biomeRegistry.register(delegateKey, platform, RegistrationInfo.BUILT_IN);
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.Holder;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
@@ -86,10 +87,10 @@ public class NMSChunkGeneratorDelegate extends ChunkGenerator {
}
@Override
public CompletableFuture<ChunkAccess> fillFromNoise(@NotNull Blender blender,
@NotNull RandomState noiseConfig,
@NotNull StructureManager structureAccessor, @NotNull ChunkAccess chunk) {
return vanilla.fillFromNoise(blender, noiseConfig, structureAccessor, chunk)
public @NotNull CompletableFuture<ChunkAccess> fillFromNoise(@NotNull Executor executor, @NotNull Blender blender,
@NotNull RandomState noiseConfig,
@NotNull StructureManager structureAccessor, @NotNull ChunkAccess chunk) {
return vanilla.fillFromNoise(executor, blender, noiseConfig, structureAccessor, chunk)
.thenApply(c -> {
LevelAccessor level = Reflection.STRUCTURE_MANAGER.getLevel(structureAccessor);
BiomeProvider biomeProvider = pack.getBiomeProvider();
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import org.bukkit.Bukkit;
@@ -1,12 +1,7 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.chunk.status.WorldGenContext;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.EventHandler;
@@ -42,20 +37,8 @@ public class NMSInjectListener implements Listener {
ChunkGenerator vanilla = serverWorld.getChunkSource().getGenerator();
NMSBiomeProvider provider = new NMSBiomeProvider(pack.getBiomeProvider(), craftWorld.getSeed());
ChunkMap chunkMap = serverWorld.getChunkSource().chunkMap;
WorldGenContext worldGenContext = chunkMap.worldGenContext;
try {
ReflectionUtil.setFinalField(chunkMap, "worldGenContext", new WorldGenContext(
worldGenContext.level(),
new NMSChunkGeneratorDelegate(vanilla, pack, provider, craftWorld.getSeed()),
worldGenContext.structureManager(),
worldGenContext.lightEngine(),
worldGenContext.mainThreadMailBox()
));
} catch(NoSuchFieldException e) {
throw new RuntimeException(e);
}
serverWorld.getChunkSource().chunkMap.generator = new NMSChunkGeneratorDelegate(vanilla, pack, provider, craftWorld.getSeed());
LOGGER.info("Successfully injected into world.");
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import net.minecraft.world.level.LevelHeightAccessor;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import net.minecraft.core.Holder;
import net.minecraft.core.Holder.Reference;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21;
package com.dfsek.terra.bukkit.nms.v1_20_6;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
+6 -2
View File
@@ -26,8 +26,8 @@ dependencies {
modImplementation("net.fabricmc:fabric-loader:${Versions.Mod.fabricLoader}")
modImplementation("org.incendo", "cloud-fabric", Versions.Libraries.cloudFabric)
include("org.incendo", "cloud-fabric", Versions.Libraries.cloudFabric)
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
include("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
modRuntimeOnly("net.fabricmc.fabric-api", "fabric-api", Versions.Fabric.fabricAPI)
}
@@ -45,6 +45,10 @@ loom {
addonDir(project.file("./run/config/Terra/addons"), tasks.named("configureLaunch").get())
tasks {
compileJava {
options.release.set(17)
}
remapJar {
dependsOn("installAddons")
@@ -26,9 +26,9 @@
"terra.common.mixins.json"
],
"depends": {
"fabricloader": ">=0.16.5",
"java": ">=21",
"minecraft": ">=1.20.6",
"fabricloader": ">=0.15.1",
"java": ">=17",
"minecraft": ">=1.20.4",
"fabric": "*"
}
}
@@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "com.dfsek.terra.fabric.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
@@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "com.dfsek.terra.forge.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"mixins": [
"lifecycle.NoiseConfigMixin"
],
@@ -3,7 +3,6 @@ package com.dfsek.terra.mod;
import com.dfsek.tectonic.api.TypeRegistry;
import com.dfsek.tectonic.api.depth.DepthTracker;
import com.dfsek.tectonic.api.exception.LoadException;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.registry.Registry;
@@ -117,8 +116,6 @@ public abstract class ModPlatform extends AbstractPlatform {
public abstract Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry();
public abstract Registry<Enchantment> enchantmentRegistry();
@Override
public @NotNull WorldHandle getWorldHandle() {
return worldHandle;
@@ -128,6 +125,4 @@ public abstract class ModPlatform extends AbstractPlatform {
public @NotNull ItemHandle getItemHandle() {
return itemHandle;
}
}
@@ -111,9 +111,10 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
return settings.value().generationShapeConfig().height();
}
@Override
public CompletableFuture<Chunk> populateNoise(Blender blender, NoiseConfig noiseConfig, StructureAccessor structureAccessor,
Chunk chunk) {
public CompletableFuture<Chunk> populateNoise(Executor executor, Blender blender, NoiseConfig noiseConfig,
StructureAccessor structureAccessor, Chunk chunk) {
return CompletableFuture.supplyAsync(() -> {
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
BiomeProvider biomeProvider = pack.getBiomeProvider();
@@ -25,13 +25,10 @@ import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.RegistryWrapper.Impl;
import net.minecraft.util.Identifier;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.dfsek.terra.api.handle.ItemHandle;
import com.dfsek.terra.api.inventory.Item;
@@ -46,13 +43,8 @@ public class MinecraftItemHandle implements ItemHandle {
try {
return (Item) new ItemStackArgumentType(new CommandRegistryAccess() {
@Override
public Stream<RegistryKey<? extends Registry<?>>> streamAllRegistryKeys() {
return CommonPlatform.get().getServer().getRegistryManager().streamAllRegistryKeys();
}
@Override
public <T> Optional<Impl<T>> getOptionalWrapper(RegistryKey<? extends Registry<? extends T>> registryRef) {
return Optional.of(CommonPlatform.get().getServer().getRegistryManager().getWrapperOrThrow(registryRef));
public <T> RegistryWrapper<T> createWrapper(RegistryKey<? extends Registry<T>> registryRef) {
return CommonPlatform.get().getServer().getRegistryManager().getWrapperOrThrow(registryRef);
}
}).parse(new StringReader(data)).getItem();
} catch(CommandSyntaxException e) {
@@ -62,11 +54,11 @@ public class MinecraftItemHandle implements ItemHandle {
@Override
public Enchantment getEnchantment(String id) {
return (Enchantment) (Object) (CommonPlatform.get().enchantmentRegistry().get(Identifier.tryParse(id)));
return (Enchantment) (Registries.ENCHANTMENT.get(Identifier.tryParse(id)));
}
@Override
public Set<Enchantment> getEnchantments() {
return CommonPlatform.get().enchantmentRegistry().stream().map(enchantment -> (Enchantment) (Object) enchantment).collect(Collectors.toSet());
return Registries.ENCHANTMENT.stream().map(enchantment -> (Enchantment) enchantment).collect(Collectors.toSet());
}
}
@@ -48,7 +48,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
@Shadow
public abstract MobSpawnerLogic getLogic();
//method_46408
@Shadow
public abstract void setEntityType(net.minecraft.entity.EntityType<?> entityType, Random random);
@@ -39,14 +39,14 @@ public abstract class EntityMixin {
private BlockPos blockPos;
@Shadow
public abstract void updatePosition(double destX, double destY, double destZ);
public abstract void teleport(double destX, double destY, double destZ);
public Vector3 terra$position() {
return MinecraftAdapter.adapt(blockPos);
}
public void terra$position(Vector3 location) {
updatePosition(location.getX(), location.getY(), location.getZ());
teleport(location.getX(), location.getY(), location.getZ());
}
public ServerWorld terra$world() {
@@ -30,7 +30,7 @@ import com.dfsek.terra.api.inventory.ItemStack;
@Implements(@Interface(iface = com.dfsek.terra.api.inventory.Item.class, prefix = "terra$"))
public abstract class ItemMixin {
@Shadow
public abstract net.minecraft.item.ItemStack getDefaultStack();
public abstract int getMaxDamage();
@SuppressWarnings("ConstantConditions")
public ItemStack terra$newItemStack(int amount) {
@@ -38,7 +38,6 @@ public abstract class ItemMixin {
}
public double terra$getMaxDurability() {
//TODO verify this is correct
return getDefaultStack().getMaxDamage();
return getMaxDamage();
}
}
@@ -17,14 +17,9 @@
package com.dfsek.terra.mod.mixin.implementations.terra.inventory.item;
import net.minecraft.component.Component;
import net.minecraft.component.ComponentChanges;
import net.minecraft.component.ComponentMap;
import net.minecraft.component.ComponentMapImpl;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Intrinsic;
@@ -51,11 +46,7 @@ public abstract class ItemStackMixin {
public abstract boolean isDamageable();
@Shadow
public abstract ComponentMap getComponents();
@Shadow
@Final
private ComponentMapImpl components;
public abstract void setNbt(@Nullable NbtCompound tag);
public int terra$getAmount() {
return getCount();
@@ -75,13 +66,7 @@ public abstract class ItemStackMixin {
@SuppressWarnings("ConstantConditions")
public void terra$setItemMeta(ItemMeta meta) {
ComponentChanges.Builder builder = ComponentChanges.builder();
this.getComponents().getTypes().forEach(builder::remove);
ComponentMap components = ((ItemStack) (Object) meta).getComponents();
components.forEach(builder::add);
this.components.applyChanges(builder.build());
setNbt(((ItemStack) (Object) meta).getNbt());
}
@Intrinsic
@@ -17,13 +17,8 @@
package com.dfsek.terra.mod.mixin.implementations.terra.inventory.meta;
import com.dfsek.terra.mod.CommonPlatform;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.entry.RegistryEntryList;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin;
@@ -33,8 +28,6 @@ import java.util.Objects;
import com.dfsek.terra.api.inventory.ItemStack;
import static net.minecraft.enchantment.Enchantment.canBeCombined;
@Mixin(Enchantment.class)
@Implements(@Interface(iface = com.dfsek.terra.api.inventory.item.Enchantment.class, prefix = "terra$"))
@@ -43,8 +36,7 @@ public abstract class EnchantmentMixin {
public abstract boolean isAcceptableItem(net.minecraft.item.ItemStack stack);
@Shadow
@Final
private RegistryEntryList<Enchantment> exclusiveSet;
public abstract boolean canCombine(Enchantment other);
@SuppressWarnings("ConstantConditions")
public boolean terra$canEnchantItem(ItemStack itemStack) {
@@ -52,10 +44,10 @@ public abstract class EnchantmentMixin {
}
public boolean terra$conflictsWith(com.dfsek.terra.api.inventory.item.Enchantment other) {
return canBeCombined(RegistryEntry.of((Enchantment) (Object) this), RegistryEntry.of((Enchantment) (Object) other));
return !canCombine((Enchantment) other);
}
public String terra$getID() {
return Objects.requireNonNull(CommonPlatform.get().enchantmentRegistry().getId((Enchantment) (Object) this)).toString();
return Objects.requireNonNull(Registries.ENCHANTMENT.getId((Enchantment) (Object) this)).toString();
}
}
@@ -17,12 +17,10 @@
package com.dfsek.terra.mod.mixin.implementations.terra.inventory.meta;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Intrinsic;
@@ -44,13 +42,13 @@ public abstract class ItemStackMetaMixin {
public abstract boolean hasEnchantments();
@Shadow
public abstract ItemEnchantmentsComponent getEnchantments();
public abstract NbtList getEnchantments();
@Shadow
public abstract void addEnchantment(RegistryEntry<net.minecraft.enchantment.Enchantment> enchantment, int level);
public abstract void addEnchantment(net.minecraft.enchantment.Enchantment enchantment, int level);
public void terra$addEnchantment(Enchantment enchantment, int level) { ;
addEnchantment(RegistryEntry.of((net.minecraft.enchantment.Enchantment) (Object) enchantment), level);
public void terra$addEnchantment(Enchantment enchantment, int level) {
addEnchantment((net.minecraft.enchantment.Enchantment) enchantment, level);
}
@Intrinsic(displace = true)
@@ -58,10 +56,9 @@ public abstract class ItemStackMetaMixin {
if(!hasEnchantments()) return Collections.emptyMap();
Map<Enchantment, Integer> map = new HashMap<>();
ItemEnchantmentsComponent enchantments = getEnchantments();
enchantments.getEnchantments().forEach(enchantment -> {
net.minecraft.enchantment.Enchantment enchantmentValue = enchantment.value();
map.put((Enchantment) (Object) enchantmentValue, enchantments.getLevel(RegistryEntry.of(enchantmentValue)));
getEnchantments().forEach(enchantment -> {
NbtCompound eTag = (NbtCompound) enchantment;
map.put((Enchantment) Registries.ENCHANTMENT.get(eTag.getInt("id")), eTag.getInt("lvl"));
});
return map;
}
@@ -17,16 +17,12 @@
package com.dfsek.terra.mod.mixin.implementations.terra.world;
import com.dfsek.terra.mod.mixin.invoke.FluidBlockInvoker;
import net.minecraft.block.FluidBlock;
import net.minecraft.fluid.Fluid;
import net.minecraft.util.collection.BoundedRegionArray;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkGenerationStep;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.tick.MultiTickScheduler;
import net.minecraft.world.tick.OrderedTick;
@@ -78,9 +74,10 @@ public abstract class ChunkRegionMixin {
@Inject(at = @At("RETURN"),
method = "<init>(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/collection/BoundedRegionArray;Lnet/minecraft/world/chunk/ChunkGenerationStep;Lnet/minecraft/world/chunk/Chunk;)V")
public void injectConstructor(net.minecraft.server.world.ServerWorld world, BoundedRegionArray chunks,
ChunkGenerationStep generationStep, Chunk centerPos, CallbackInfo ci) {
method = "<init>(Lnet/minecraft/server/world/ServerWorld;Ljava/util/List;Lnet/minecraft/world/chunk/ChunkStatus;I)V")
public void injectConstructor(net.minecraft.server.world.ServerWorld world, List<net.minecraft.world.chunk.Chunk> list,
ChunkStatus chunkStatus, int i,
CallbackInfo ci) {
this.terra$config = ((ServerWorld) world).getPack();
}
@@ -91,7 +88,7 @@ public abstract class ChunkRegionMixin {
((ChunkRegion) (Object) this).setBlockState(pos, (net.minecraft.block.BlockState) data, physics ? 3 : 1042);
if(physics && ((net.minecraft.block.BlockState) data).getBlock() instanceof FluidBlock) {
fluidTickScheduler.scheduleTick(
OrderedTick.create((((FluidBlockInvoker) ((net.minecraft.block.BlockState) data).getBlock())).invokeGetFluidState(
OrderedTick.create(((FluidBlock) ((net.minecraft.block.BlockState) data).getBlock()).getFluidState(
(net.minecraft.block.BlockState) data).getFluid(), pos));
}
}
@@ -1,14 +0,0 @@
package com.dfsek.terra.mod.mixin.invoke;
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidBlock;
import net.minecraft.fluid.FluidState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(FluidBlock.class)
public interface FluidBlockInvoker {
@Invoker("getFluidState")
public FluidState invokeGetFluidState(BlockState state);
}
@@ -3,12 +3,9 @@ package com.dfsek.terra.mod.mixin.lifecycle;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.ReloadableRegistries;
import net.minecraft.server.DataPackContents;
import net.minecraft.world.biome.Biome;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -19,15 +16,11 @@ import com.dfsek.terra.mod.util.TagUtil;
@Mixin(DataPackContents.class)
public class DataPackContentsMixin {
@Shadow
@Final
private ReloadableRegistries.Lookup reloadableRegistries;
/*
* #refresh populates all tags in the registries
*/
@Inject(method = "refresh()V", at = @At("RETURN"))
private void injectReload(CallbackInfo ci) {
DynamicRegistryManager.Immutable dynamicRegistryManager = this.reloadableRegistries.getRegistryManager();
@Inject(method = "refresh(Lnet/minecraft/registry/DynamicRegistryManager;)V", at = @At("RETURN"))
private void injectReload(DynamicRegistryManager dynamicRegistryManager, CallbackInfo ci) {
TagUtil.registerWorldPresetTags(dynamicRegistryManager.get(RegistryKeys.WORLD_PRESET));
Registry<Biome> biomeRegistry = dynamicRegistryManager.get(RegistryKeys.BIOME);
@@ -45,7 +45,7 @@ public class PresetUtil {
.orElseThrow();
Identifier generatorID = Identifier.tryParse("terra:" + pack.getID().toLowerCase(Locale.ROOT) + "/" + pack.getNamespace().toLowerCase(
Identifier generatorID = Identifier.of("terra", pack.getID().toLowerCase(Locale.ROOT) + "/" + pack.getNamespace().toLowerCase(
Locale.ROOT));
PRESETS.add(generatorID);
@@ -1,4 +1,4 @@
accessWidener v1 named
accessible class net/minecraft/world/biome/Biome$Weather
accessible class net/minecraft/world/gen/WorldPresets$Registrar
accessible class net/minecraft/registry/RegistryLoader$Loader
accessible method net/minecraft/block/FluidBlock getFluidState (Lnet/minecraft/block/BlockState;)Lnet/minecraft/fluid/FluidState
@@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "com.dfsek.terra.mod.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"mixins": [
"access.BiomeAccessor",
"access.MobSpawnerLogicAccessor",
+5 -1
View File
@@ -15,7 +15,7 @@ dependencies {
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
modImplementation("org.incendo", "cloud-fabric", Versions.Libraries.cloudFabric) {
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud) {
exclude("net.fabricmc")
exclude("net.fabricmc.fabric-api")
}
@@ -30,6 +30,10 @@ loom {
}
tasks {
compileJava {
options.release.set(17)
}
remapJar {
inputFile.set(shadowJar.get().archiveFile)
}
@@ -1,9 +1,8 @@
package com.dfsek.terra.lifecycle;
import cloud.commandframework.execution.CommandExecutionCoordinator;
import cloud.commandframework.fabric.FabricServerCommandManager;
import net.minecraft.server.command.ServerCommandSource;
import org.incendo.cloud.SenderMapper;
import org.incendo.cloud.execution.ExecutionCoordinator;
import org.incendo.cloud.fabric.FabricServerCommandManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -18,10 +17,9 @@ public final class LifecycleEntryPoint {
logger.info("Initializing Terra {} mod...", modName);
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
ExecutionCoordinator.simpleCoordinator(),
SenderMapper.create(
CommandExecutionCoordinator.simpleCoordinator(),
serverCommandSource -> (CommandSender) serverCommandSource,
commandSender -> (ServerCommandSource) commandSender)
commandSender -> (ServerCommandSource) commandSender
);
@@ -4,7 +4,6 @@ import ca.solostudios.strata.Versions;
import ca.solostudios.strata.parser.tokenizer.ParseException;
import ca.solostudios.strata.version.Version;
import net.minecraft.MinecraftVersion;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.MinecraftServer;
@@ -35,7 +34,6 @@ public abstract class LifecyclePlatform extends ModPlatform {
private static final AtomicReference<Registry<DimensionType>> DIMENSIONS = new AtomicReference<>();
private static final AtomicReference<Registry<ChunkGeneratorSettings>> SETTINGS = new AtomicReference<>();
private static final AtomicReference<Registry<MultiNoiseBiomeSourceParameterList>> NOISE = new AtomicReference<>();
private static final AtomicReference<Registry<Enchantment>> ENCHANTMENT = new AtomicReference<>();
private static MinecraftServer server;
public LifecyclePlatform() {
@@ -46,13 +44,11 @@ public abstract class LifecyclePlatform extends ModPlatform {
public static void setRegistries(Registry<Biome> biomeRegistry,
Registry<DimensionType> dimensionTypeRegistry,
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry,
Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry,
Registry<Enchantment> enchantmentRegistry) {
Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry) {
BIOMES.set(biomeRegistry);
DIMENSIONS.set(dimensionTypeRegistry);
SETTINGS.set(chunkGeneratorSettingsRegistry);
NOISE.set(multiNoiseBiomeSourceParameterListRegistry);
ENCHANTMENT.set(enchantmentRegistry);
}
@Override
@@ -73,7 +69,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
if(server != null) {
BiomeUtil.registerBiomes(server.getRegistryManager().get(RegistryKeys.BIOME));
server.reloadResources(server.getDataPackManager().getEnabledIds()).exceptionally(throwable -> {
server.reloadResources(server.getDataPackManager().getNames()).exceptionally(throwable -> {
LOGGER.warn("Failed to execute reload", throwable);
return null;
}).join();
@@ -145,10 +141,5 @@ public abstract class LifecyclePlatform extends ModPlatform {
return NOISE.get();
}
@Override
public Registry<Enchantment> enchantmentRegistry() {
return ENCHANTMENT.get();
}
protected abstract Collection<BaseAddon> getPlatformMods();
}
@@ -1,15 +1,11 @@
package com.dfsek.terra.lifecycle.mixin.lifecycle;
import com.mojang.datafixers.util.Pair;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.DynamicRegistryManager.Immutable;
import net.minecraft.registry.MutableRegistry;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryLoader;
import net.minecraft.registry.RegistryLoader.Loader;
import net.minecraft.world.biome.source.MultiNoiseBiomeSourceParameterList;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.WorldPreset;
@@ -18,9 +14,7 @@ import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
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.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.List;
@@ -31,62 +25,48 @@ import com.dfsek.terra.lifecycle.LifecyclePlatform;
import com.dfsek.terra.lifecycle.util.LifecycleUtil;
import com.dfsek.terra.lifecycle.util.RegistryHack;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RegistryLoader.class)
public class RegistryLoaderMixin {
private static boolean initialized = false;
@Shadow
@Final
private static Logger LOGGER;
// @Inject(
// method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Lnet/minecraft/registry/DynamicRegistryManager;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
// )
// )
// private static void grabRegiestry(RegistryLoader.RegistryLoadable loadable, DynamicRegistryManager baseRegistryManager,
// List<RegistryLoader.Entry<?>> entries, CallbackInfoReturnable<Immutable> cir) {
// entries.forEach((loader) -> {
// Registry<?> registry = loader.registry();
// }
@Redirect(
method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
method = "load(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;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
)
)
private static void grabManager(List<RegistryLoader.Loader<?>> instance, Consumer<? super Loader<?>> consumer) {
if (!initialized) {
extractRegistry(instance, RegistryKeys.BIOME).ifPresent(
biomes -> { // this redirect triggers twice, second time only with dimension registry. don't try extraction second time
MutableRegistry<DimensionType> dimensionTypes = extractRegistry(instance, RegistryKeys.DIMENSION_TYPE).orElseThrow();
MutableRegistry<WorldPreset> worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow();
MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(instance,
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
MutableRegistry<Enchantment> enchantments = extractRegistry(instance, RegistryKeys.ENCHANTMENT).orElseThrow();
private static void grabManager(List<Pair<MutableRegistry<?>, Object>> instance, Consumer<Pair<MutableRegistry<?>, Object>> consumer) {
instance.forEach(mutableRegistryObjectPair -> LOGGER.debug("{}: {} entries",
mutableRegistryObjectPair.getFirst().toString(),
mutableRegistryObjectPair.getFirst().size())
);
extractRegistry(instance, RegistryKeys.BIOME).ifPresent(
biomes -> { // this redirect triggers twice, second time only with dimension registry. don't try extraction second time
MutableRegistry<DimensionType> dimensionTypes = extractRegistry(instance, RegistryKeys.DIMENSION_TYPE).orElseThrow();
MutableRegistry<WorldPreset> worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow();
MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(instance,
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists, enchantments);
LifecycleUtil.initialize(biomes, worldPresets);
});
initialized = true;
}
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists);
LifecycleUtil.initialize(biomes, worldPresets);
});
instance.forEach(consumer);
}
@Unique
@SuppressWarnings("unchecked")
private static <T> Optional<MutableRegistry<T>> extractRegistry(List<RegistryLoader.Loader<?>> instance,
private static <T> Optional<MutableRegistry<T>> extractRegistry(List<Pair<MutableRegistry<?>, Object>> instance,
RegistryKey<Registry<T>> key) {
List<? extends MutableRegistry<?>> matches = instance
.stream().map(RegistryLoader.Loader::registry)
.stream()
.map(Pair::getFirst)
.filter(r -> r.getKey().equals(key))
.toList();
if(matches.size() > 1) {
@@ -94,7 +74,7 @@ public class RegistryLoaderMixin {
} else if(matches.isEmpty()) {
return Optional.empty();
}
MutableRegistry<T> registry = (MutableRegistry<T>) matches.getFirst();
MutableRegistry<T> registry = (MutableRegistry<T>) matches.get(0);
((RegistryHack) registry).terra_bind();
return Optional.of(registry);
}
@@ -13,14 +13,18 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
@Mixin(SaveLoading.class)
public class SaveLoadingMixin {
@ModifyArg(
method = "load(Lnet/minecraft/server/SaveLoading$ServerConfig;Lnet/minecraft/server/SaveLoading$LoadContextSupplier;Lnet/minecraft/server/SaveLoading$SaveApplierFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;",
method = "method_42097(Lnet/minecraft/registry/DynamicRegistryManager$Immutable;" +
"Lnet/minecraft/server/SaveLoading$SaveApplierFactory;Lnet/minecraft/resource/LifecycledResourceManager;" +
"Lnet/minecraft/registry/CombinedDynamicRegistries;Lnet/minecraft/server/SaveLoading$LoadContext;" +
"Lnet/minecraft/server/DataPackContents;)Ljava/lang/Object;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/registry/RegistryLoader;loadFromResource(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;" ),
index = 1
target = "Lnet/minecraft/server/DataPackContents;refresh(Lnet/minecraft/registry/DynamicRegistryManager;)V"
),
index = 0
)
private static DynamicRegistryManager grabManager(DynamicRegistryManager registryManager) {
MinecraftUtil.registerFlora(registryManager.get(RegistryKeys.BIOME));
return registryManager;
private static DynamicRegistryManager grabManager(DynamicRegistryManager in) {
MinecraftUtil.registerFlora(in.get(RegistryKeys.BIOME));
return in;
}
}
@@ -58,7 +58,7 @@ public final class BiomeUtil {
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(biome, Objects.requireNonNull(registry.get(vanilla)),
vanillaBiomeProperties);
Identifier identifier = Identifier.of("terra", MinecraftUtil.createBiomeID(pack, id));
Identifier identifier = new Identifier("terra", MinecraftUtil.createBiomeID(pack, id));
if(registry.containsId(identifier)) {
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(MinecraftUtil.getEntry(registry, identifier)
@@ -13,7 +13,7 @@ public final class RegistryUtil {
}
public static void register() {
Registry.register(Registries.CHUNK_GENERATOR, Identifier.of("terra:terra"), Codecs.MINECRAFT_CHUNK_GENERATOR_WRAPPER);
Registry.register(Registries.BIOME_SOURCE, Identifier.of("terra:terra"), Codecs.TERRA_BIOME_SOURCE);
Registry.register(Registries.CHUNK_GENERATOR, new Identifier("terra:terra"), Codecs.MINECRAFT_CHUNK_GENERATOR_WRAPPER);
Registry.register(Registries.BIOME_SOURCE, new Identifier("terra:terra"), Codecs.TERRA_BIOME_SOURCE);
}
}
@@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "com.dfsek.terra.lifecycle.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"mixins": [
"NoiseConfigMixin",
"RegistryEntryReferenceInvoker",
@@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "com.dfsek.terra.quilt.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [