working 1.20.6

This commit is contained in:
Zoe Gidiere 2024-09-17 16:34:30 -06:00
parent 73047284c8
commit 664d1a3191
33 changed files with 167 additions and 119 deletions

View File

@ -15,6 +15,7 @@ allprojects {
tasks.withType<JavaCompile>().configureEach { tasks.withType<JavaCompile>().configureEach {
options.isFork = true options.isFork = true
options.isIncremental = true options.isIncremental = true
options.release.set(21)
} }
tasks.withType<Test>().configureEach { tasks.withType<Test>().configureEach {
@ -44,7 +45,7 @@ afterEvaluate {
} }
project(":platforms:bukkit:common").configureDistribution() project(":platforms:bukkit:common").configureDistribution()
forSubProjects(":common:addons") { forSubProjects(":common:addons") {
apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "com.gradleup.shadow")
tasks.named("build") { tasks.named("build") {
finalizedBy(tasks.named("shadowJar")) finalizedBy(tasks.named("shadowJar"))

View File

@ -16,11 +16,11 @@ repositories {
dependencies { dependencies {
//TODO Allow pulling from Versions.kt //TODO Allow pulling from Versions.kt
implementation("com.github.johnrengelman", "shadow", "8.1.1") implementation("com.gradleup.shadow", "shadow-gradle-plugin", "8.3.1")
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "1.7.1") implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "1.7.2")
implementation("org.ow2.asm", "asm", "9.7") implementation("org.ow2.asm", "asm", "9.7")
implementation("org.ow2.asm", "asm-tree", "9.7") implementation("org.ow2.asm", "asm-tree", "9.7")
implementation("com.dfsek.tectonic", "common", "4.2.1") implementation("com.dfsek.tectonic", "common", "4.2.1")
implementation("org.yaml", "snakeyaml", "2.2") implementation("org.yaml", "snakeyaml", "2.3")
} }

View File

@ -48,6 +48,9 @@ fun Project.configureDependencies() {
maven("https://jitpack.io") { maven("https://jitpack.io") {
name = "JitPack" name = "JitPack"
} }
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
name = "Sonatype Snapshots"
}
} }
dependencies { dependencies {

View File

@ -21,7 +21,7 @@ import kotlin.io.path.exists
fun Project.configureDistribution() { fun Project.configureDistribution() {
apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "com.gradleup.shadow")
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") { val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
group = "terra" group = "terra"

View File

@ -8,23 +8,23 @@ object Versions {
const val paralithic = "0.7.1" const val paralithic = "0.7.1"
const val strata = "1.3.2" const val strata = "1.3.2"
const val cloud = "2.0.0-rc.2" const val cloud = "2.0.0"
const val cloudPaper = "2.0.0-beta.9" const val cloudPaper = "2.0.0-beta.10"
const val cloudFabric = "2.0.0-beta.7" const val cloudFabric = "2.0.0-beta.9"
const val caffeine = "3.1.8" const val caffeine = "3.1.8"
const val slf4j = "2.0.13" const val slf4j = "2.0.16"
object Internal { object Internal {
const val shadow = "8.1.1" const val shadow = "8.3.1"
const val apacheText = "1.12.0" const val apacheText = "1.12.0"
const val apacheIO = "2.16.1" const val apacheIO = "2.16.1"
const val guava = "33.1.0-jre" const val guava = "33.3.0-jre"
const val asm = "9.7" const val asm = "9.7"
const val snakeYml = "2.2" const val snakeYml = "2.3"
const val jetBrainsAnnotations = "24.1.0" const val jetBrainsAnnotations = "24.1.0"
const val junit = "5.10.2" const val junit = "5.11.0"
} }
} }
@ -38,14 +38,14 @@ object Versions {
// } // }
object Mod { object Mod {
const val mixin = "0.12.5+mixin.0.8.5" const val mixin = "0.15.3+mixin.0.8.7"
const val minecraft = "1.20.6" const val minecraft = "1.20.6"
const val yarn = "$minecraft+build.1" const val yarn = "$minecraft+build.1"
const val fabricLoader = "0.15.10" const val fabricLoader = "0.16.5"
const val architecuryLoom = "1.6.395" const val architecuryLoom = "1.7.413"
const val architecturyPlugin = "3.4.155" const val architecturyPlugin = "3.4.159"
} }
// //
// object Forge { // object Forge {
@ -54,14 +54,14 @@ object Versions {
// } // }
object Bukkit { object Bukkit {
const val minecraft = "1.21" const val minecraft = "1.21.1"
const val paperBuild = "$minecraft-R0.1-SNAPSHOT" const val paperBuild = "$minecraft-R0.1-20240917.151311-80"
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.1" const val reflectionRemapper = "0.1.1"
const val paperDevBundle = paperBuild const val paperDevBundle = paperBuild
const val runPaper = "2.3.0" const val runPaper = "2.3.1"
const val paperWeight = "1.7.1" const val paperWeight = "1.7.2"
} }
// //
@ -73,6 +73,6 @@ object Versions {
// //
object CLI { object CLI {
const val nbt = "6.1" const val nbt = "6.1"
const val logback = "1.4.14" const val logback = "1.5.8"
} }
} }

Binary file not shown.

View File

@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

2
gradlew vendored
View File

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.

20
gradlew.bat vendored
View File

@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail

View File

@ -2,12 +2,6 @@ plugins {
id("xyz.jpenilla.run-paper") version Versions.Bukkit.runPaper id("xyz.jpenilla.run-paper") version Versions.Bukkit.runPaper
} }
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
name = "Sonatype"
}
}
dependencies { dependencies {
shaded(project(":platforms:bukkit:common")) shaded(project(":platforms:bukkit:common"))
shaded(project(":platforms:bukkit:nms:v1_21", configuration = "reobf")) shaded(project(":platforms:bukkit:nms:v1_21", configuration = "reobf"))

View File

@ -1,9 +1,5 @@
apply(plugin = "io.papermc.paperweight.userdev") apply(plugin = "io.papermc.paperweight.userdev")
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies { dependencies {
api(project(":platforms:bukkit:common")) api(project(":platforms:bukkit:common"))
paperDevBundle(Versions.Bukkit.paperDevBundle) paperDevBundle(Versions.Bukkit.paperDevBundle)

View File

@ -10,6 +10,7 @@ import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.item.ItemStack;
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;

View File

@ -10,12 +10,6 @@ architectury {
loader("fabric") loader("fabric")
} }
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
name = "Sonatype Snapshots"
}
}
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) shadedApi(project(":common:implementation:base"))
@ -51,10 +45,6 @@ loom {
addonDir(project.file("./run/config/Terra/addons"), tasks.named("configureLaunch").get()) addonDir(project.file("./run/config/Terra/addons"), tasks.named("configureLaunch").get())
tasks { tasks {
compileJava {
options.release.set(17)
}
remapJar { remapJar {
dependsOn("installAddons") dependsOn("installAddons")

View File

@ -26,9 +26,9 @@
"terra.common.mixins.json" "terra.common.mixins.json"
], ],
"depends": { "depends": {
"fabricloader": ">=0.15.1", "fabricloader": ">=0.16.5",
"java": ">=17", "java": ">=21",
"minecraft": ">=1.20.4", "minecraft": ">=1.20.6",
"fabric": "*" "fabric": "*"
} }
} }

View File

@ -2,7 +2,7 @@
"required": true, "required": true,
"minVersion": "0.8", "minVersion": "0.8",
"package": "com.dfsek.terra.fabric.mixin", "package": "com.dfsek.terra.fabric.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_21",
"mixins": [ "mixins": [
], ],
"client": [ "client": [

View File

@ -2,7 +2,7 @@
"required": true, "required": true,
"minVersion": "0.8", "minVersion": "0.8",
"package": "com.dfsek.terra.forge.mixin", "package": "com.dfsek.terra.forge.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_21",
"mixins": [ "mixins": [
"lifecycle.NoiseConfigMixin" "lifecycle.NoiseConfigMixin"
], ],

View File

@ -25,10 +25,13 @@ import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.RegistryWrapper.Impl;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.dfsek.terra.api.handle.ItemHandle; import com.dfsek.terra.api.handle.ItemHandle;
import com.dfsek.terra.api.inventory.Item; import com.dfsek.terra.api.inventory.Item;
@ -43,8 +46,13 @@ public class MinecraftItemHandle implements ItemHandle {
try { try {
return (Item) new ItemStackArgumentType(new CommandRegistryAccess() { return (Item) new ItemStackArgumentType(new CommandRegistryAccess() {
@Override @Override
public <T> RegistryWrapper<T> createWrapper(RegistryKey<? extends Registry<T>> registryRef) { public Stream<RegistryKey<? extends Registry<?>>> streamAllRegistryKeys() {
return CommonPlatform.get().getServer().getRegistryManager().getWrapperOrThrow(registryRef); 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));
} }
}).parse(new StringReader(data)).getItem(); }).parse(new StringReader(data)).getItem();
} catch(CommandSyntaxException e) { } catch(CommandSyntaxException e) {

View File

@ -50,7 +50,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
public abstract MobSpawnerLogic getLogic(); public abstract MobSpawnerLogic getLogic();
@Shadow @Shadow
public abstract void setEntityType(net.minecraft.entity.EntityType<?> entityType, Random random); public abstract void method_46408(net.minecraft.entity.EntityType<?> entityType, Random random);
public EntityType terra$getSpawnedType() { public EntityType terra$getSpawnedType() {
return (EntityType) Registries.ENTITY_TYPE.get( return (EntityType) Registries.ENTITY_TYPE.get(
@ -64,7 +64,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
} else { } else {
rand = Random.create(); rand = Random.create();
} }
setEntityType((net.minecraft.entity.EntityType<?>) creatureType, rand); method_46408((net.minecraft.entity.EntityType<?>) creatureType, rand);
} }
public int terra$getDelay() { public int terra$getDelay() {

View File

@ -30,7 +30,7 @@ import com.dfsek.terra.api.inventory.ItemStack;
@Implements(@Interface(iface = com.dfsek.terra.api.inventory.Item.class, prefix = "terra$")) @Implements(@Interface(iface = com.dfsek.terra.api.inventory.Item.class, prefix = "terra$"))
public abstract class ItemMixin { public abstract class ItemMixin {
@Shadow @Shadow
public abstract int getMaxDamage(); public abstract net.minecraft.item.ItemStack getDefaultStack();
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public ItemStack terra$newItemStack(int amount) { public ItemStack terra$newItemStack(int amount) {
@ -38,6 +38,7 @@ public abstract class ItemMixin {
} }
public double terra$getMaxDurability() { public double terra$getMaxDurability() {
return getMaxDamage(); //TODO verify this is correct
return getDefaultStack().getMaxDamage();
} }
} }

View File

@ -17,9 +17,15 @@
package com.dfsek.terra.mod.mixin.implementations.terra.inventory.item; 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.component.DataComponentType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
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.Intrinsic;
@ -46,7 +52,11 @@ public abstract class ItemStackMixin {
public abstract boolean isDamageable(); public abstract boolean isDamageable();
@Shadow @Shadow
public abstract void setNbt(@Nullable NbtCompound tag); public abstract ComponentMap getComponents();
@Shadow
@Final
private ComponentMapImpl components;
public int terra$getAmount() { public int terra$getAmount() {
return getCount(); return getCount();
@ -66,7 +76,13 @@ public abstract class ItemStackMixin {
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public void terra$setItemMeta(ItemMeta meta) { public void terra$setItemMeta(ItemMeta meta) {
setNbt(((ItemStack) (Object) meta).getNbt()); 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());
} }
@Intrinsic @Intrinsic

View File

@ -17,6 +17,7 @@
package com.dfsek.terra.mod.mixin.implementations.terra.inventory.meta; package com.dfsek.terra.mod.mixin.implementations.terra.inventory.meta;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtList;
@ -42,7 +43,7 @@ public abstract class ItemStackMetaMixin {
public abstract boolean hasEnchantments(); public abstract boolean hasEnchantments();
@Shadow @Shadow
public abstract NbtList getEnchantments(); public abstract ItemEnchantmentsComponent getEnchantments();
@Shadow @Shadow
public abstract void addEnchantment(net.minecraft.enchantment.Enchantment enchantment, int level); public abstract void addEnchantment(net.minecraft.enchantment.Enchantment enchantment, int level);
@ -56,9 +57,10 @@ public abstract class ItemStackMetaMixin {
if(!hasEnchantments()) return Collections.emptyMap(); if(!hasEnchantments()) return Collections.emptyMap();
Map<Enchantment, Integer> map = new HashMap<>(); Map<Enchantment, Integer> map = new HashMap<>();
getEnchantments().forEach(enchantment -> { ItemEnchantmentsComponent enchantments = getEnchantments();
NbtCompound eTag = (NbtCompound) enchantment; enchantments.getEnchantments().forEach(enchantment -> {
map.put((Enchantment) Registries.ENCHANTMENT.get(eTag.getInt("id")), eTag.getInt("lvl")); net.minecraft.enchantment.Enchantment enchantmentValue = enchantment.value();
map.put((Enchantment) enchantmentValue, enchantments.getLevel(enchantmentValue));
}); });
return map; return map;
} }

View File

@ -17,6 +17,8 @@
package com.dfsek.terra.mod.mixin.implementations.terra.world; 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.block.FluidBlock;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -88,7 +90,7 @@ public abstract class ChunkRegionMixin {
((ChunkRegion) (Object) this).setBlockState(pos, (net.minecraft.block.BlockState) data, physics ? 3 : 1042); ((ChunkRegion) (Object) this).setBlockState(pos, (net.minecraft.block.BlockState) data, physics ? 3 : 1042);
if(physics && ((net.minecraft.block.BlockState) data).getBlock() instanceof FluidBlock) { if(physics && ((net.minecraft.block.BlockState) data).getBlock() instanceof FluidBlock) {
fluidTickScheduler.scheduleTick( fluidTickScheduler.scheduleTick(
OrderedTick.create(((FluidBlock) ((net.minecraft.block.BlockState) data).getBlock()).getFluidState( OrderedTick.create((((FluidBlockInvoker) ((net.minecraft.block.BlockState) data).getBlock())).invokeGetFluidState(
(net.minecraft.block.BlockState) data).getFluid(), pos)); (net.minecraft.block.BlockState) data).getFluid(), pos));
} }
} }

View File

@ -0,0 +1,14 @@
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);
}

View File

@ -3,9 +3,12 @@ package com.dfsek.terra.mod.mixin.lifecycle;
import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.ReloadableRegistries;
import net.minecraft.server.DataPackContents; import net.minecraft.server.DataPackContents;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; 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.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -16,11 +19,15 @@ import com.dfsek.terra.mod.util.TagUtil;
@Mixin(DataPackContents.class) @Mixin(DataPackContents.class)
public class DataPackContentsMixin { public class DataPackContentsMixin {
@Shadow
@Final
private ReloadableRegistries.Lookup reloadableRegistries;
/* /*
* #refresh populates all tags in the registries * #refresh populates all tags in the registries
*/ */
@Inject(method = "refresh(Lnet/minecraft/registry/DynamicRegistryManager;)V", at = @At("RETURN")) @Inject(method = "refresh()V", at = @At("RETURN"))
private void injectReload(DynamicRegistryManager dynamicRegistryManager, CallbackInfo ci) { private void injectReload(CallbackInfo ci) {
DynamicRegistryManager.Immutable dynamicRegistryManager = this.reloadableRegistries.getRegistryManager();
TagUtil.registerWorldPresetTags(dynamicRegistryManager.get(RegistryKeys.WORLD_PRESET)); TagUtil.registerWorldPresetTags(dynamicRegistryManager.get(RegistryKeys.WORLD_PRESET));
Registry<Biome> biomeRegistry = dynamicRegistryManager.get(RegistryKeys.BIOME); Registry<Biome> biomeRegistry = dynamicRegistryManager.get(RegistryKeys.BIOME);

View File

@ -1,4 +1,4 @@
accessWidener v1 named accessWidener v1 named
accessible class net/minecraft/world/biome/Biome$Weather accessible class net/minecraft/world/biome/Biome$Weather
accessible class net/minecraft/world/gen/WorldPresets$Registrar accessible class net/minecraft/world/gen/WorldPresets$Registrar
accessible method net/minecraft/block/FluidBlock getFluidState (Lnet/minecraft/block/BlockState;)Lnet/minecraft/fluid/FluidState accessible class net/minecraft/registry/RegistryLoader$Loader

View File

@ -2,7 +2,7 @@
"required": true, "required": true,
"minVersion": "0.8", "minVersion": "0.8",
"package": "com.dfsek.terra.mod.mixin", "package": "com.dfsek.terra.mod.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_21",
"mixins": [ "mixins": [
"access.BiomeAccessor", "access.BiomeAccessor",
"access.MobSpawnerLogicAccessor", "access.MobSpawnerLogicAccessor",

View File

@ -30,10 +30,6 @@ loom {
} }
tasks { tasks {
compileJava {
options.release.set(17)
}
remapJar { remapJar {
inputFile.set(shadowJar.get().archiveFile) inputFile.set(shadowJar.get().archiveFile)
} }

View File

@ -1,6 +1,8 @@
package com.dfsek.terra.lifecycle; package com.dfsek.terra.lifecycle;
import net.minecraft.server.command.ServerCommandSource; 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.incendo.cloud.fabric.FabricServerCommandManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -16,9 +18,10 @@ public final class LifecycleEntryPoint {
logger.info("Initializing Terra {} mod...", modName); logger.info("Initializing Terra {} mod...", modName);
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>( FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
CommandExecutionCoordinator.simpleCoordinator(), ExecutionCoordinator.simpleCoordinator(),
SenderMapper.create(
serverCommandSource -> (CommandSender) serverCommandSource, serverCommandSource -> (CommandSender) serverCommandSource,
commandSender -> (ServerCommandSource) commandSender commandSender -> (ServerCommandSource) commandSender)
); );

View File

@ -69,7 +69,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
if(server != null) { if(server != null) {
BiomeUtil.registerBiomes(server.getRegistryManager().get(RegistryKeys.BIOME)); BiomeUtil.registerBiomes(server.getRegistryManager().get(RegistryKeys.BIOME));
server.reloadResources(server.getDataPackManager().getNames()).exceptionally(throwable -> { server.reloadResources(server.getDataPackManager().getEnabledIds()).exceptionally(throwable -> {
LOGGER.warn("Failed to execute reload", throwable); LOGGER.warn("Failed to execute reload", throwable);
return null; return null;
}).join(); }).join();

View File

@ -1,11 +1,14 @@
package com.dfsek.terra.lifecycle.mixin.lifecycle; package com.dfsek.terra.lifecycle.mixin.lifecycle;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.DynamicRegistryManager.Immutable;
import net.minecraft.registry.MutableRegistry; import net.minecraft.registry.MutableRegistry;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryLoader; import net.minecraft.registry.RegistryLoader;
import net.minecraft.registry.RegistryLoader.Loader;
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;
import net.minecraft.world.gen.WorldPreset; import net.minecraft.world.gen.WorldPreset;
@ -14,7 +17,9 @@ import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; 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.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.List; import java.util.List;
@ -25,48 +30,61 @@ import com.dfsek.terra.lifecycle.LifecyclePlatform;
import com.dfsek.terra.lifecycle.util.LifecycleUtil; import com.dfsek.terra.lifecycle.util.LifecycleUtil;
import com.dfsek.terra.lifecycle.util.RegistryHack; import com.dfsek.terra.lifecycle.util.RegistryHack;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RegistryLoader.class) @Mixin(RegistryLoader.class)
public class RegistryLoaderMixin { public class RegistryLoaderMixin {
private static boolean initialized = false;
@Shadow @Shadow
@Final @Final
private static Logger LOGGER; 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( @Redirect(
method = "load(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)" + method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
"Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
at = @At( at = @At(
value = "INVOKE", value = "INVOKE",
target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V", target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V",
ordinal = 1 // we want right after the first forEach ordinal = 1 // we want right after the first forEach
) )
) )
private static void grabManager(List<Pair<MutableRegistry<?>, Object>> instance, Consumer<Pair<MutableRegistry<?>, Object>> consumer) { private static void grabManager(List<RegistryLoader.Loader<?>> instance, Consumer<? super Loader<?>> consumer) {
instance.forEach(mutableRegistryObjectPair -> LOGGER.debug("{}: {} entries", if (!initialized) {
mutableRegistryObjectPair.getFirst().toString(), extractRegistry(instance, RegistryKeys.BIOME).ifPresent(
mutableRegistryObjectPair.getFirst().size()) 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();
extractRegistry(instance, RegistryKeys.BIOME).ifPresent( MutableRegistry<WorldPreset> worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow();
biomes -> { // this redirect triggers twice, second time only with dimension registry. don't try extraction second time MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(instance,
MutableRegistry<DimensionType> dimensionTypes = extractRegistry(instance, RegistryKeys.DIMENSION_TYPE).orElseThrow(); RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
MutableRegistry<WorldPreset> worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow(); MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(instance, RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists); LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists);
LifecycleUtil.initialize(biomes, worldPresets); LifecycleUtil.initialize(biomes, worldPresets);
}); });
initialized = true;
}
instance.forEach(consumer); instance.forEach(consumer);
} }
@Unique
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static <T> Optional<MutableRegistry<T>> extractRegistry(List<Pair<MutableRegistry<?>, Object>> instance, private static <T> Optional<MutableRegistry<T>> extractRegistry(List<RegistryLoader.Loader<?>> instance,
RegistryKey<Registry<T>> key) { RegistryKey<Registry<T>> key) {
List<? extends MutableRegistry<?>> matches = instance List<? extends MutableRegistry<?>> matches = instance
.stream() .stream().map(RegistryLoader.Loader::registry)
.map(Pair::getFirst)
.filter(r -> r.getKey().equals(key)) .filter(r -> r.getKey().equals(key))
.toList(); .toList();
if(matches.size() > 1) { if(matches.size() > 1) {
@ -74,7 +92,7 @@ public class RegistryLoaderMixin {
} else if(matches.isEmpty()) { } else if(matches.isEmpty()) {
return Optional.empty(); return Optional.empty();
} }
MutableRegistry<T> registry = (MutableRegistry<T>) matches.get(0); MutableRegistry<T> registry = (MutableRegistry<T>) matches.getFirst();
((RegistryHack) registry).terra_bind(); ((RegistryHack) registry).terra_bind();
return Optional.of(registry); return Optional.of(registry);
} }

View File

@ -13,18 +13,14 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
@Mixin(SaveLoading.class) @Mixin(SaveLoading.class)
public class SaveLoadingMixin { public class SaveLoadingMixin {
@ModifyArg( @ModifyArg(
method = "method_42097(Lnet/minecraft/registry/DynamicRegistryManager$Immutable;" + 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;",
"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( at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lnet/minecraft/server/DataPackContents;refresh(Lnet/minecraft/registry/DynamicRegistryManager;)V" target = "Lnet/minecraft/registry/RegistryLoader;loadFromResource(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;" ),
), index = 1
index = 0
) )
private static DynamicRegistryManager grabManager(DynamicRegistryManager in) { private static DynamicRegistryManager grabManager(DynamicRegistryManager registryManager) {
MinecraftUtil.registerFlora(in.get(RegistryKeys.BIOME)); MinecraftUtil.registerFlora(registryManager.get(RegistryKeys.BIOME));
return in; return registryManager;
} }
} }

View File

@ -2,7 +2,7 @@
"required": true, "required": true,
"minVersion": "0.8", "minVersion": "0.8",
"package": "com.dfsek.terra.lifecycle.mixin", "package": "com.dfsek.terra.lifecycle.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_21",
"mixins": [ "mixins": [
"NoiseConfigMixin", "NoiseConfigMixin",
"RegistryEntryReferenceInvoker", "RegistryEntryReferenceInvoker",

View File

@ -2,7 +2,7 @@
"required": true, "required": true,
"minVersion": "0.8", "minVersion": "0.8",
"package": "com.dfsek.terra.quilt.mixin", "package": "com.dfsek.terra.quilt.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_21",
"mixins": [ "mixins": [
], ],
"client": [ "client": [