mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 02:20:57 +00:00
Update to 1.21.6 and fix a lot of bugs in fabric impl
This commit is contained in:
@@ -6,6 +6,12 @@ plugins {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
maven("https://maven.solo-studios.ca/releases") {
|
||||||
|
name = "Solo Studios"
|
||||||
|
}
|
||||||
|
maven("https://maven.solo-studios.ca/snapshots") {
|
||||||
|
name = "Solo Studios"
|
||||||
|
}
|
||||||
maven("https://repo.codemc.org/repository/maven-public") {
|
maven("https://repo.codemc.org/repository/maven-public") {
|
||||||
name = "CodeMC"
|
name = "CodeMC"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ fun Project.configureDependencies() {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
maven("https://maven.solo-studios.ca/releases") {
|
||||||
|
name = "Solo Studios"
|
||||||
|
}
|
||||||
|
maven("https://maven.solo-studios.ca/snapshots") {
|
||||||
|
name = "Solo Studios"
|
||||||
|
}
|
||||||
maven("https://maven.fabricmc.net/") {
|
maven("https://maven.fabricmc.net/") {
|
||||||
name = "FabricMC"
|
name = "FabricMC"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ object Versions {
|
|||||||
|
|
||||||
const val cloud = "2.0.0"
|
const val cloud = "2.0.0"
|
||||||
|
|
||||||
const val caffeine = "3.2.0"
|
const val caffeine = "3.2.1"
|
||||||
|
|
||||||
const val slf4j = "2.0.17"
|
const val slf4j = "2.0.17"
|
||||||
|
|
||||||
@@ -22,14 +22,13 @@ object Versions {
|
|||||||
const val asm = "9.8"
|
const val asm = "9.8"
|
||||||
const val snakeYml = "2.4"
|
const val snakeYml = "2.4"
|
||||||
const val jetBrainsAnnotations = "26.0.2"
|
const val jetBrainsAnnotations = "26.0.2"
|
||||||
const val junit = "5.13.0"
|
const val junit = "5.13.1"
|
||||||
const val nbt = "6.1"
|
const val nbt = "6.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object Fabric {
|
object Fabric {
|
||||||
// TODO: Replace "1.21.6 with ${Mod.minecraft}" after 1.21.6 release
|
const val fabricAPI = "0.127.0+${Mod.minecraft}"
|
||||||
const val fabricAPI = "0.126.1+1.21.6"
|
|
||||||
const val cloud = "2.0.0-beta.10"
|
const val cloud = "2.0.0-beta.10"
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -40,8 +39,9 @@ object Versions {
|
|||||||
|
|
||||||
object Mod {
|
object Mod {
|
||||||
const val mixin = "0.15.5+mixin.0.8.7"
|
const val mixin = "0.15.5+mixin.0.8.7"
|
||||||
|
const val mixinExtras = "0.4.1"
|
||||||
|
|
||||||
const val minecraft = "1.21.6-rc1"
|
const val minecraft = "1.21.6"
|
||||||
const val yarn = "$minecraft+build.1"
|
const val yarn = "$minecraft+build.1"
|
||||||
const val fabricLoader = "0.16.14"
|
const val fabricLoader = "0.16.14"
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ object Versions {
|
|||||||
|
|
||||||
object Bukkit {
|
object Bukkit {
|
||||||
const val minecraft = "1.21.6-R0.1"
|
const val minecraft = "1.21.6-R0.1"
|
||||||
const val paperBuild = "$minecraft-20250612.174129-4"
|
const val paperBuild = "$minecraft-20250617.170821-8"
|
||||||
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.2"
|
const val reflectionRemapper = "0.1.2"
|
||||||
@@ -67,7 +67,7 @@ object Versions {
|
|||||||
const val cloud = "2.0.0-beta.10"
|
const val cloud = "2.0.0-beta.10"
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// object Sponge {
|
// object Sponge {
|
||||||
// const val sponge = "9.0.0-SNAPSHOT"
|
// const val sponge = "9.0.0-SNAPSHOT"
|
||||||
// const val mixin = "0.8.2"
|
// const val mixin = "0.8.2"
|
||||||
|
|||||||
@@ -33,9 +33,8 @@ public class NMSBiomeInjector {
|
|||||||
.waterColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterColor(), vanilla.getWaterColor()))
|
.waterColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterColor(), vanilla.getWaterColor()))
|
||||||
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
|
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
|
||||||
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
|
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
|
||||||
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getSpecialEffects().getGrassColorModifier()));
|
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getSpecialEffects().getGrassColorModifier()))
|
||||||
// .grassColorOverride(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColor(), vanilla.getSpecialEffects().getGrassColorOverride().orElseGet(() -> Reflection.BIOME.invokeGrassColorFromTexture(vanilla))))
|
.backgroundMusicVolume(Objects.requireNonNullElse(vanillaBiomeProperties.getMusicVolume(), vanilla.getMusicVolume()));
|
||||||
// .foliageColorOverride(Objects.requireNonNullElse(vanillaBiomeProperties.getFoliageColor(), vanilla.getFoliageColor()));
|
|
||||||
|
|
||||||
if(vanillaBiomeProperties.getGrassColor() == null) {
|
if(vanillaBiomeProperties.getGrassColor() == null) {
|
||||||
vanilla.getSpecialEffects().getGrassColorOverride().ifPresent(effects::grassColorOverride);
|
vanilla.getSpecialEffects().getGrassColorOverride().ifPresent(effects::grassColorOverride);
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
@Default
|
@Default
|
||||||
private Integer foliageColor = null;
|
private Integer foliageColor = null;
|
||||||
|
|
||||||
|
@Value("colors.dry-foliage")
|
||||||
|
@Default
|
||||||
|
private Integer dryFoliageColor = null;
|
||||||
|
|
||||||
@Value("colors.sky")
|
@Value("colors.sky")
|
||||||
@Default
|
@Default
|
||||||
private Integer skyColor = null;
|
private Integer skyColor = null;
|
||||||
@@ -82,6 +86,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
@Default
|
@Default
|
||||||
private Music music = null;
|
private Music music = null;
|
||||||
|
|
||||||
|
@Value("sound.music-volume")
|
||||||
|
@Default
|
||||||
|
private Float musicVolume = null;
|
||||||
|
|
||||||
@Value("spawning")
|
@Value("spawning")
|
||||||
@Default
|
@Default
|
||||||
private MobSpawnSettings spawnSettings = null;
|
private MobSpawnSettings spawnSettings = null;
|
||||||
@@ -98,6 +106,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
return foliageColor;
|
return foliageColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getDryFoliageColor() {
|
||||||
|
return dryFoliageColor;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getGrassColor() {
|
public Integer getGrassColor() {
|
||||||
return grassColor;
|
return grassColor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,10 @@ dependencies {
|
|||||||
|
|
||||||
modImplementation("net.fabricmc:fabric-loader:${Versions.Mod.fabricLoader}")
|
modImplementation("net.fabricmc:fabric-loader:${Versions.Mod.fabricLoader}")
|
||||||
|
|
||||||
// modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud)
|
modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud) {
|
||||||
// include("org.incendo", "cloud-fabric", Versions.Fabric.cloud)
|
exclude("me.lucko", "fabric-permissions-api")
|
||||||
|
}
|
||||||
|
include("org.incendo", "cloud-fabric", Versions.Fabric.cloud)
|
||||||
|
|
||||||
modRuntimeOnly("net.fabricmc.fabric-api", "fabric-api", Versions.Fabric.fabricAPI)
|
modRuntimeOnly("net.fabricmc.fabric-api", "fabric-api", Versions.Fabric.fabricAPI)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
@Default
|
@Default
|
||||||
private Integer foliageColor = null;
|
private Integer foliageColor = null;
|
||||||
|
|
||||||
|
@Value("colors.dry-foliage")
|
||||||
|
@Default
|
||||||
|
private Integer dryFoliageColor = null;
|
||||||
|
|
||||||
@Value("colors.sky")
|
@Value("colors.sky")
|
||||||
@Default
|
@Default
|
||||||
private Integer skyColor = null;
|
private Integer skyColor = null;
|
||||||
@@ -82,6 +86,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
@Default
|
@Default
|
||||||
private MusicSound music = null;
|
private MusicSound music = null;
|
||||||
|
|
||||||
|
@Value("sound.music-volume")
|
||||||
|
@Default
|
||||||
|
private Float musicVolume = null;
|
||||||
|
|
||||||
@Value("spawning")
|
@Value("spawning")
|
||||||
@Default
|
@Default
|
||||||
private SpawnSettings spawnSettings = null;
|
private SpawnSettings spawnSettings = null;
|
||||||
@@ -111,6 +119,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
return foliageColor;
|
return foliageColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getDryFoliageColor() {
|
||||||
|
return dryFoliageColor;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getSkyColor() {
|
public Integer getSkyColor() {
|
||||||
return skyColor;
|
return skyColor;
|
||||||
}
|
}
|
||||||
@@ -155,6 +167,10 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|||||||
return music;
|
return music;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Float getMusicVolume() {
|
||||||
|
return musicVolume;
|
||||||
|
}
|
||||||
|
|
||||||
public SpawnSettings getSpawnSettings() {
|
public SpawnSettings getSpawnSettings() {
|
||||||
return spawnSettings;
|
return spawnSettings;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,25 @@ public class BiomeUtil {
|
|||||||
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
|
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
|
||||||
.grassColorModifier(
|
.grassColorModifier(
|
||||||
Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getEffects().getGrassColorModifier()))
|
Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getEffects().getGrassColorModifier()))
|
||||||
.grassColor(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColor(),
|
.musicVolume(Objects.requireNonNullElse(vanillaBiomeProperties.getMusicVolume(), vanilla.getMusicVolume()));
|
||||||
vanilla.getEffects().getGrassColor().orElseGet(() -> ((BiomeInvoker) ((Object) vanilla)).invokeGetDefaultGrassColor())))
|
|
||||||
.foliageColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFoliageColor(), vanilla.getFoliageColor()));
|
if(vanillaBiomeProperties.getGrassColor() == null) {
|
||||||
|
vanilla.getEffects().getGrassColor().ifPresent(effects::grassColor);
|
||||||
|
} else {
|
||||||
|
effects.grassColor(vanillaBiomeProperties.getGrassColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vanillaBiomeProperties.getFoliageColor() == null) {
|
||||||
|
vanilla.getEffects().getFoliageColor().ifPresent(effects::foliageColor);
|
||||||
|
} else {
|
||||||
|
effects.foliageColor(vanillaBiomeProperties.getFoliageColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vanillaBiomeProperties.getDryFoliageColor() == null) {
|
||||||
|
vanilla.getEffects().getDryFoliageColor().ifPresent(effects::dryFoliageColor);
|
||||||
|
} else {
|
||||||
|
effects.dryFoliageColor(vanillaBiomeProperties.getDryFoliageColor());
|
||||||
|
}
|
||||||
|
|
||||||
if(vanillaBiomeProperties.getParticleConfig() == null) {
|
if(vanillaBiomeProperties.getParticleConfig() == null) {
|
||||||
vanilla.getEffects().getParticleConfig().ifPresent(effects::particleConfig);
|
vanilla.getEffects().getParticleConfig().ifPresent(effects::particleConfig);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ dependencies {
|
|||||||
shadedApi(project(":common:implementation:base"))
|
shadedApi(project(":common:implementation:base"))
|
||||||
|
|
||||||
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||||
|
compileOnly("io.github.llamalad7:mixinextras-common:${Versions.Mod.mixinExtras}")
|
||||||
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||||
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
||||||
|
|
||||||
@@ -15,10 +16,11 @@ dependencies {
|
|||||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||||
|
|
||||||
// modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud) {
|
modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud) {
|
||||||
// exclude("net.fabricmc")
|
exclude("net.fabricmc")
|
||||||
// exclude("net.fabricmc.fabric-api")
|
exclude("net.fabricmc.fabric-api")
|
||||||
// }
|
exclude("me.lucko", "fabric-permissions-api")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import com.dfsek.terra.api.command.CommandSender;
|
|||||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||||
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
//import org.incendo.cloud.SenderMapper;
|
import org.incendo.cloud.SenderMapper;
|
||||||
//import org.incendo.cloud.execution.ExecutionCoordinator;
|
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;
|
||||||
|
|
||||||
@@ -17,16 +17,16 @@ public final class LifecycleEntryPoint {
|
|||||||
public static void initialize(String modName, LifecyclePlatform platform) {
|
public static void initialize(String modName, LifecyclePlatform platform) {
|
||||||
logger.info("Initializing Terra {} mod...", modName);
|
logger.info("Initializing Terra {} mod...", modName);
|
||||||
|
|
||||||
// FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
||||||
// ExecutionCoordinator.simpleCoordinator(),
|
ExecutionCoordinator.simpleCoordinator(),
|
||||||
// SenderMapper.create(
|
SenderMapper.create(
|
||||||
// serverCommandSource -> (CommandSender) serverCommandSource,
|
serverCommandSource -> (CommandSender) serverCommandSource,
|
||||||
// commandSender -> (ServerCommandSource) commandSender)
|
commandSender -> (ServerCommandSource) commandSender)
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
//
|
|
||||||
// manager.brigadierManager().setNativeNumberSuggestions(false);
|
manager.brigadierManager().setNativeNumberSuggestions(false);
|
||||||
//
|
|
||||||
// platform.getEventManager().callEvent(new CommandRegistrationEvent(manager));
|
platform.getEventManager().callEvent(new CommandRegistrationEvent(manager));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
|
||||||
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
|
|
||||||
import com.dfsek.terra.mod.CommonPlatform;
|
|
||||||
|
|
||||||
import com.dfsek.terra.mod.ModPlatform;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.screen.world.CreateWorldScreen;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import static com.dfsek.terra.lifecycle.util.LifecycleUtil.initialized;
|
|
||||||
|
|
||||||
|
|
||||||
@Mixin(CreateWorldScreen.class)
|
|
||||||
public class CreateWorldScreenMixin {
|
|
||||||
@Inject(method = "onCloseScreen()V", at = @At("HEAD"))
|
|
||||||
public void onClose(CallbackInfo ci) {
|
|
||||||
ModPlatform platform = CommonPlatform.get();
|
|
||||||
platform.getRawConfigRegistry().clear();
|
|
||||||
initialized = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -34,11 +34,4 @@ public class MinecraftServerMixin {
|
|||||||
WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo ci) {
|
WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo ci) {
|
||||||
LifecyclePlatform.setServer((MinecraftServer) (Object) this);
|
LifecyclePlatform.setServer((MinecraftServer) (Object) this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "shutdown()V", at = @At("RETURN"))
|
|
||||||
private void injectShutdown(CallbackInfo ci) {
|
|
||||||
ModPlatform platform = CommonPlatform.get();
|
|
||||||
platform.getRawConfigRegistry().clear();
|
|
||||||
initialized = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||||
|
|
||||||
|
import com.dfsek.terra.mod.CommonPlatform;
|
||||||
|
import com.dfsek.terra.mod.ModPlatform;
|
||||||
|
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.registry.MutableRegistry;
|
import net.minecraft.registry.MutableRegistry;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
@@ -7,6 +10,7 @@ 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.registry.RegistryLoader.Loader;
|
||||||
|
import net.minecraft.registry.RegistryWrapper;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
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;
|
||||||
@@ -18,10 +22,27 @@ 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.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Coerce;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Coerce;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import net.minecraft.registry.DynamicRegistryManager;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
import net.minecraft.registry.RegistryLoader;
|
||||||
|
import net.minecraft.registry.RegistryWrapper;
|
||||||
|
import net.minecraft.resource.ResourceManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
||||||
@@ -38,31 +59,39 @@ public class RegistryLoaderMixin {
|
|||||||
@Final
|
@Final
|
||||||
private static Logger LOGGER;
|
private static Logger LOGGER;
|
||||||
|
|
||||||
@Redirect(
|
@Unique
|
||||||
|
private static final AtomicBoolean LOADING_DYNAMIC_REGISTRIES = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
@Inject(method = "loadFromResource(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", at = @At("HEAD"))
|
||||||
|
private static void loadFromResources(ResourceManager resourceManager, List<RegistryWrapper.Impl<?>> registries, List<RegistryLoader.Entry<?>> entries, CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir) {
|
||||||
|
LOADING_DYNAMIC_REGISTRIES.set(entries.stream().anyMatch(entry -> entry.key() == RegistryKeys.BIOME));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Ljava/util/List;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
|
method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Ljava/util/List;Ljava/util/List;)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
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private static void grabManager(List<RegistryLoader.Loader<?>> instance, Consumer<? super Loader<?>> consumer) {
|
private static void beforeFreeze(@Coerce Object loadable, List<RegistryWrapper.Impl<?>> wrappers, List<RegistryLoader.Entry<?>> entries, CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir, @Local(ordinal = 2) List<RegistryLoader.Loader<?>> registriesList) {
|
||||||
if(!initialized) {
|
if (LOADING_DYNAMIC_REGISTRIES.getAndSet(false)) {
|
||||||
MutableRegistry<Biome> biomes = extractRegistry(instance, RegistryKeys.BIOME).orElseThrow();
|
ModPlatform platform = CommonPlatform.get();
|
||||||
MutableRegistry<DimensionType> dimensionTypes = extractRegistry(instance, RegistryKeys.DIMENSION_TYPE).orElseThrow();
|
platform.getRawConfigRegistry().clear();
|
||||||
MutableRegistry<WorldPreset> worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow();
|
MutableRegistry<Biome> biomes = extractRegistry(registriesList, RegistryKeys.BIOME).orElseThrow();
|
||||||
MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(instance,
|
MutableRegistry<DimensionType> dimensionTypes = extractRegistry(registriesList, RegistryKeys.DIMENSION_TYPE).orElseThrow();
|
||||||
|
MutableRegistry<WorldPreset> worldPresets = extractRegistry(registriesList, RegistryKeys.WORLD_PRESET).orElseThrow();
|
||||||
|
MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(registriesList,
|
||||||
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
|
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
|
||||||
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
|
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(registriesList,
|
||||||
RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
|
RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
|
||||||
MutableRegistry<Enchantment> enchantments = extractRegistry(instance, RegistryKeys.ENCHANTMENT).orElseThrow();
|
MutableRegistry<Enchantment> enchantments = extractRegistry(registriesList, RegistryKeys.ENCHANTMENT).orElseThrow();
|
||||||
|
|
||||||
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists,
|
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists,
|
||||||
enchantments);
|
enchantments);
|
||||||
LifecycleUtil.initialize(biomes, worldPresets);
|
LifecycleUtil.initialize(biomes, worldPresets);
|
||||||
initialized = true;
|
|
||||||
}
|
}
|
||||||
instance.forEach(consumer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
"lifecycle.RegistryLoaderMixin",
|
"lifecycle.RegistryLoaderMixin",
|
||||||
"lifecycle.SaveLoadingMixin"
|
"lifecycle.SaveLoadingMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
|
||||||
"lifecycle.CreateWorldScreenMixin"
|
|
||||||
],
|
|
||||||
"server": [
|
"server": [
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ include(":platforms:minestom:example")
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
maven("https://maven.solo-studios.ca/releases") {
|
||||||
|
name = "Solo Studios"
|
||||||
|
}
|
||||||
|
maven("https://maven.solo-studios.ca/snapshots") {
|
||||||
|
name = "Solo Studios"
|
||||||
|
}
|
||||||
maven("https://maven.fabricmc.net") {
|
maven("https://maven.fabricmc.net") {
|
||||||
name = "Fabric Maven"
|
name = "Fabric Maven"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user