mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-01 15:37:24 +00:00
working 1.20.6
This commit is contained in:
parent
73047284c8
commit
664d1a3191
@ -15,6 +15,7 @@ allprojects {
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.isFork = true
|
||||
options.isIncremental = true
|
||||
options.release.set(21)
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
@ -44,7 +45,7 @@ afterEvaluate {
|
||||
}
|
||||
project(":platforms:bukkit:common").configureDistribution()
|
||||
forSubProjects(":common:addons") {
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
apply(plugin = "com.gradleup.shadow")
|
||||
|
||||
tasks.named("build") {
|
||||
finalizedBy(tasks.named("shadowJar"))
|
||||
|
@ -16,11 +16,11 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
//TODO Allow pulling from Versions.kt
|
||||
implementation("com.github.johnrengelman", "shadow", "8.1.1")
|
||||
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "1.7.1")
|
||||
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("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.2")
|
||||
implementation("org.yaml", "snakeyaml", "2.3")
|
||||
}
|
@ -48,6 +48,9 @@ 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.github.johnrengelman.shadow")
|
||||
apply(plugin = "com.gradleup.shadow")
|
||||
|
||||
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
|
||||
group = "terra"
|
||||
|
@ -8,23 +8,23 @@ object Versions {
|
||||
const val paralithic = "0.7.1"
|
||||
const val strata = "1.3.2"
|
||||
|
||||
const val cloud = "2.0.0-rc.2"
|
||||
const val cloudPaper = "2.0.0-beta.9"
|
||||
const val cloudFabric = "2.0.0-beta.7"
|
||||
const val cloud = "2.0.0"
|
||||
const val cloudPaper = "2.0.0-beta.10"
|
||||
const val cloudFabric = "2.0.0-beta.9"
|
||||
|
||||
const val caffeine = "3.1.8"
|
||||
|
||||
const val slf4j = "2.0.13"
|
||||
const val slf4j = "2.0.16"
|
||||
|
||||
object Internal {
|
||||
const val shadow = "8.1.1"
|
||||
const val shadow = "8.3.1"
|
||||
const val apacheText = "1.12.0"
|
||||
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 snakeYml = "2.2"
|
||||
const val snakeYml = "2.3"
|
||||
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 {
|
||||
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 yarn = "$minecraft+build.1"
|
||||
const val fabricLoader = "0.15.10"
|
||||
const val fabricLoader = "0.16.5"
|
||||
|
||||
const val architecuryLoom = "1.6.395"
|
||||
const val architecturyPlugin = "3.4.155"
|
||||
const val architecuryLoom = "1.7.413"
|
||||
const val architecturyPlugin = "3.4.159"
|
||||
}
|
||||
//
|
||||
// object Forge {
|
||||
@ -54,14 +54,14 @@ object Versions {
|
||||
// }
|
||||
|
||||
object Bukkit {
|
||||
const val minecraft = "1.21"
|
||||
const val paperBuild = "$minecraft-R0.1-SNAPSHOT"
|
||||
const val minecraft = "1.21.1"
|
||||
const val paperBuild = "$minecraft-R0.1-20240917.151311-80"
|
||||
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.0"
|
||||
const val paperWeight = "1.7.1"
|
||||
const val runPaper = "2.3.1"
|
||||
const val paperWeight = "1.7.2"
|
||||
}
|
||||
|
||||
//
|
||||
@ -73,6 +73,6 @@ object Versions {
|
||||
//
|
||||
object CLI {
|
||||
const val nbt = "6.1"
|
||||
const val logback = "1.4.14"
|
||||
const val logback = "1.5.8"
|
||||
}
|
||||
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
2
gradlew
vendored
2
gradlew
vendored
@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (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.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
20
gradlew.bat
vendored
20
gradlew.bat
vendored
@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -2,12 +2,6 @@ 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"))
|
||||
|
@ -1,9 +1,5 @@
|
||||
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)
|
||||
|
@ -10,6 +10,7 @@ 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;
|
||||
|
@ -10,12 +10,6 @@ architectury {
|
||||
loader("fabric")
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
|
||||
name = "Sonatype Snapshots"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
@ -51,10 +45,6 @@ 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.15.1",
|
||||
"java": ">=17",
|
||||
"minecraft": ">=1.20.4",
|
||||
"fabricloader": ">=0.16.5",
|
||||
"java": ">=21",
|
||||
"minecraft": ">=1.20.6",
|
||||
"fabric": "*"
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
|
@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.forge.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"lifecycle.NoiseConfigMixin"
|
||||
],
|
||||
|
@ -25,10 +25,13 @@ 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;
|
||||
@ -43,8 +46,13 @@ public class MinecraftItemHandle implements ItemHandle {
|
||||
try {
|
||||
return (Item) new ItemStackArgumentType(new CommandRegistryAccess() {
|
||||
@Override
|
||||
public <T> RegistryWrapper<T> createWrapper(RegistryKey<? extends Registry<T>> registryRef) {
|
||||
return CommonPlatform.get().getServer().getRegistryManager().getWrapperOrThrow(registryRef);
|
||||
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));
|
||||
}
|
||||
}).parse(new StringReader(data)).getItem();
|
||||
} catch(CommandSyntaxException e) {
|
||||
|
@ -50,7 +50,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
public abstract MobSpawnerLogic getLogic();
|
||||
|
||||
@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() {
|
||||
return (EntityType) Registries.ENTITY_TYPE.get(
|
||||
@ -64,7 +64,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
} else {
|
||||
rand = Random.create();
|
||||
}
|
||||
setEntityType((net.minecraft.entity.EntityType<?>) creatureType, rand);
|
||||
method_46408((net.minecraft.entity.EntityType<?>) creatureType, rand);
|
||||
}
|
||||
|
||||
public int terra$getDelay() {
|
||||
|
@ -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 int getMaxDamage();
|
||||
public abstract net.minecraft.item.ItemStack getDefaultStack();
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public ItemStack terra$newItemStack(int amount) {
|
||||
@ -38,6 +38,7 @@ public abstract class ItemMixin {
|
||||
}
|
||||
|
||||
public double terra$getMaxDurability() {
|
||||
return getMaxDamage();
|
||||
//TODO verify this is correct
|
||||
return getDefaultStack().getMaxDamage();
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,15 @@
|
||||
|
||||
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.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;
|
||||
@ -46,7 +52,11 @@ public abstract class ItemStackMixin {
|
||||
public abstract boolean isDamageable();
|
||||
|
||||
@Shadow
|
||||
public abstract void setNbt(@Nullable NbtCompound tag);
|
||||
public abstract ComponentMap getComponents();
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ComponentMapImpl components;
|
||||
|
||||
public int terra$getAmount() {
|
||||
return getCount();
|
||||
@ -66,7 +76,13 @@ public abstract class ItemStackMixin {
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
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
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
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;
|
||||
@ -42,7 +43,7 @@ public abstract class ItemStackMetaMixin {
|
||||
public abstract boolean hasEnchantments();
|
||||
|
||||
@Shadow
|
||||
public abstract NbtList getEnchantments();
|
||||
public abstract ItemEnchantmentsComponent getEnchantments();
|
||||
|
||||
@Shadow
|
||||
public abstract void addEnchantment(net.minecraft.enchantment.Enchantment enchantment, int level);
|
||||
@ -56,9 +57,10 @@ public abstract class ItemStackMetaMixin {
|
||||
if(!hasEnchantments()) return Collections.emptyMap();
|
||||
Map<Enchantment, Integer> map = new HashMap<>();
|
||||
|
||||
getEnchantments().forEach(enchantment -> {
|
||||
NbtCompound eTag = (NbtCompound) enchantment;
|
||||
map.put((Enchantment) Registries.ENCHANTMENT.get(eTag.getInt("id")), eTag.getInt("lvl"));
|
||||
ItemEnchantmentsComponent enchantments = getEnchantments();
|
||||
enchantments.getEnchantments().forEach(enchantment -> {
|
||||
net.minecraft.enchantment.Enchantment enchantmentValue = enchantment.value();
|
||||
map.put((Enchantment) enchantmentValue, enchantments.getLevel(enchantmentValue));
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
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.math.BlockPos;
|
||||
@ -88,7 +90,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(((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));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -3,9 +3,12 @@ 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;
|
||||
@ -16,11 +19,15 @@ 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(Lnet/minecraft/registry/DynamicRegistryManager;)V", at = @At("RETURN"))
|
||||
private void injectReload(DynamicRegistryManager dynamicRegistryManager, CallbackInfo ci) {
|
||||
@Inject(method = "refresh()V", at = @At("RETURN"))
|
||||
private void injectReload(CallbackInfo ci) {
|
||||
DynamicRegistryManager.Immutable dynamicRegistryManager = this.reloadableRegistries.getRegistryManager();
|
||||
TagUtil.registerWorldPresetTags(dynamicRegistryManager.get(RegistryKeys.WORLD_PRESET));
|
||||
|
||||
Registry<Biome> biomeRegistry = dynamicRegistryManager.get(RegistryKeys.BIOME);
|
||||
|
@ -1,4 +1,4 @@
|
||||
accessWidener v1 named
|
||||
accessible class net/minecraft/world/biome/Biome$Weather
|
||||
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
|
@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.mod.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"access.BiomeAccessor",
|
||||
"access.MobSpawnerLogicAccessor",
|
||||
|
@ -30,10 +30,6 @@ loom {
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
options.release.set(17)
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile.set(shadowJar.get().archiveFile)
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.lifecycle;
|
||||
|
||||
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;
|
||||
@ -16,9 +18,10 @@ public final class LifecycleEntryPoint {
|
||||
logger.info("Initializing Terra {} mod...", modName);
|
||||
|
||||
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
ExecutionCoordinator.simpleCoordinator(),
|
||||
SenderMapper.create(
|
||||
serverCommandSource -> (CommandSender) serverCommandSource,
|
||||
commandSender -> (ServerCommandSource) commandSender
|
||||
commandSender -> (ServerCommandSource) commandSender)
|
||||
);
|
||||
|
||||
|
||||
|
@ -69,7 +69,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
|
||||
if(server != null) {
|
||||
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);
|
||||
return null;
|
||||
}).join();
|
||||
|
@ -1,11 +1,14 @@
|
||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||
|
||||
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.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;
|
||||
@ -14,7 +17,9 @@ 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;
|
||||
@ -25,27 +30,38 @@ 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/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)" +
|
||||
"Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
|
||||
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 grabManager(List<Pair<MutableRegistry<?>, Object>> instance, Consumer<Pair<MutableRegistry<?>, Object>> consumer) {
|
||||
instance.forEach(mutableRegistryObjectPair -> LOGGER.debug("{}: {} entries",
|
||||
mutableRegistryObjectPair.getFirst().toString(),
|
||||
mutableRegistryObjectPair.getFirst().size())
|
||||
);
|
||||
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();
|
||||
@ -58,15 +74,17 @@ public class RegistryLoaderMixin {
|
||||
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists);
|
||||
LifecycleUtil.initialize(biomes, worldPresets);
|
||||
});
|
||||
initialized = true;
|
||||
}
|
||||
instance.forEach(consumer);
|
||||
}
|
||||
|
||||
@Unique
|
||||
@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) {
|
||||
List<? extends MutableRegistry<?>> matches = instance
|
||||
.stream()
|
||||
.map(Pair::getFirst)
|
||||
.stream().map(RegistryLoader.Loader::registry)
|
||||
.filter(r -> r.getKey().equals(key))
|
||||
.toList();
|
||||
if(matches.size() > 1) {
|
||||
@ -74,7 +92,7 @@ public class RegistryLoaderMixin {
|
||||
} else if(matches.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
MutableRegistry<T> registry = (MutableRegistry<T>) matches.get(0);
|
||||
MutableRegistry<T> registry = (MutableRegistry<T>) matches.getFirst();
|
||||
((RegistryHack) registry).terra_bind();
|
||||
return Optional.of(registry);
|
||||
}
|
||||
|
@ -13,18 +13,14 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
@Mixin(SaveLoading.class)
|
||||
public class SaveLoadingMixin {
|
||||
@ModifyArg(
|
||||
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;",
|
||||
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;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/DataPackContents;refresh(Lnet/minecraft/registry/DynamicRegistryManager;)V"
|
||||
),
|
||||
index = 0
|
||||
target = "Lnet/minecraft/registry/RegistryLoader;loadFromResource(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;" ),
|
||||
index = 1
|
||||
)
|
||||
private static DynamicRegistryManager grabManager(DynamicRegistryManager in) {
|
||||
MinecraftUtil.registerFlora(in.get(RegistryKeys.BIOME));
|
||||
return in;
|
||||
private static DynamicRegistryManager grabManager(DynamicRegistryManager registryManager) {
|
||||
MinecraftUtil.registerFlora(registryManager.get(RegistryKeys.BIOME));
|
||||
return registryManager;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.lifecycle.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"NoiseConfigMixin",
|
||||
"RegistryEntryReferenceInvoker",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.quilt.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user