mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-20 15:51:11 +00:00
Reformat
This commit is contained in:
+5
-6
@@ -3,9 +3,6 @@ package com.dfsek.terra.lifecycle;
|
||||
import ca.solostudios.strata.Versions;
|
||||
import ca.solostudios.strata.parser.tokenizer.ParseException;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
|
||||
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
|
||||
|
||||
import net.minecraft.MinecraftVersion;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
@@ -45,10 +42,12 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
private int generationThreads;
|
||||
|
||||
public LifecyclePlatform() {
|
||||
generationThreads = getGenerationThreadsWithReflection("com.ishland.c2me.base.common.GlobalExecutors", "GLOBAL_EXECUTOR_PARALLELISM", "C2ME");
|
||||
if (generationThreads == 0) {
|
||||
generationThreads = getGenerationThreadsWithReflection("com.ishland.c2me.base.common.GlobalExecutors",
|
||||
"GLOBAL_EXECUTOR_PARALLELISM", "C2ME");
|
||||
if(generationThreads == 0) {
|
||||
generationThreads = getMoonriseGenerationThreadsWithReflection();
|
||||
} if (generationThreads == 0) {
|
||||
}
|
||||
if(generationThreads == 0) {
|
||||
generationThreads = 1;
|
||||
}
|
||||
CommonPlatform.initialize(this);
|
||||
|
||||
+2
-2
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.lifecycle.mixin;
|
||||
|
||||
import com.dfsek.terra.mod.util.SeedHack;
|
||||
|
||||
import net.minecraft.registry.RegistryEntryLookup;
|
||||
import net.minecraft.util.math.noise.DoublePerlinNoiseSampler;
|
||||
import net.minecraft.world.biome.source.util.MultiNoiseUtil.MultiNoiseSampler;
|
||||
@@ -12,8 +14,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.dfsek.terra.mod.util.SeedHack;
|
||||
|
||||
|
||||
/**
|
||||
* Hack to map noise sampler to seeds
|
||||
|
||||
-3
@@ -1,8 +1,5 @@
|
||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
import com.dfsek.terra.mod.ModPlatform;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.resource.ResourcePackManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
+19
-27
@@ -1,16 +1,15 @@
|
||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
import com.dfsek.terra.mod.ModPlatform;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
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.registry.RegistryWrapper;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.MultiNoiseBiomeSourceParameterList;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
@@ -24,57 +23,50 @@ 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.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.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
||||
import com.dfsek.terra.lifecycle.util.LifecycleUtil;
|
||||
import com.dfsek.terra.lifecycle.util.RegistryHack;
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
import com.dfsek.terra.mod.ModPlatform;
|
||||
|
||||
|
||||
@Mixin(RegistryLoader.class)
|
||||
public class RegistryLoaderMixin {
|
||||
|
||||
@Unique
|
||||
private static final AtomicBoolean LOADING_DYNAMIC_REGISTRIES = new AtomicBoolean(false);
|
||||
@Shadow
|
||||
@Final
|
||||
private static Logger LOGGER;
|
||||
|
||||
@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) {
|
||||
@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(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V",
|
||||
ordinal = 1
|
||||
)
|
||||
)
|
||||
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 (LOADING_DYNAMIC_REGISTRIES.getAndSet(false)) {
|
||||
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(LOADING_DYNAMIC_REGISTRIES.getAndSet(false)) {
|
||||
ModPlatform platform = CommonPlatform.get();
|
||||
platform.getRawConfigRegistry().clear();
|
||||
MutableRegistry<Biome> biomes = extractRegistry(registriesList, RegistryKeys.BIOME).orElseThrow();
|
||||
|
||||
+6
-2
@@ -19,10 +19,14 @@ public class SaveLoadingMixin {
|
||||
"Ljava/util/concurrent/CompletableFuture;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/DataPackContents;reload(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/CombinedDynamicRegistries;Ljava/util/List;Lnet/minecraft/resource/featuretoggle/FeatureSet;Lnet/minecraft/server/command/CommandManager$RegistrationEnvironment;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"),
|
||||
target = "Lnet/minecraft/server/DataPackContents;reload(Lnet/minecraft/resource/ResourceManager;" +
|
||||
"Lnet/minecraft/registry/CombinedDynamicRegistries;Ljava/util/List;Lnet/minecraft/resource/featuretoggle/FeatureSet;" +
|
||||
"Lnet/minecraft/server/command/CommandManager$RegistrationEnvironment;ILjava/util/concurrent/Executor;" +
|
||||
"Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"),
|
||||
index = 1
|
||||
)
|
||||
private static CombinedDynamicRegistries<ServerDynamicRegistryType> grabManager(CombinedDynamicRegistries<ServerDynamicRegistryType> dynamicRegistries) {
|
||||
private static CombinedDynamicRegistries<ServerDynamicRegistryType> grabManager(
|
||||
CombinedDynamicRegistries<ServerDynamicRegistryType> dynamicRegistries) {
|
||||
MinecraftUtil.registerFlora(dynamicRegistries.getCombinedRegistryManager().getOrThrow(RegistryKeys.BIOME));
|
||||
return dynamicRegistries;
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,7 +1,5 @@
|
||||
package com.dfsek.terra.lifecycle.util;
|
||||
|
||||
import com.dfsek.terra.mod.util.BiomeUtil;
|
||||
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
@@ -21,6 +19,7 @@ import com.dfsek.terra.mod.config.PreLoadCompatibilityOptions;
|
||||
import com.dfsek.terra.mod.config.ProtoPlatformBiome;
|
||||
import com.dfsek.terra.mod.config.VanillaBiomeProperties;
|
||||
import com.dfsek.terra.mod.mixin.access.VillagerTypeAccessor;
|
||||
import com.dfsek.terra.mod.util.BiomeUtil;
|
||||
import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
|
||||
|
||||
@@ -51,7 +50,7 @@ public final class LifecycleBiomeUtil {
|
||||
Registry<net.minecraft.world.biome.Biome> registry) {
|
||||
RegistryKey<net.minecraft.world.biome.Biome> vanilla = ((ProtoPlatformBiome) biome.getPlatformBiome()).get(registry);
|
||||
|
||||
if (vanilla == null) {
|
||||
if(vanilla == null) {
|
||||
logger.error("""
|
||||
Failed to get Vanilla Biome Regiestry key!
|
||||
Terra Biome ID: {}
|
||||
@@ -65,9 +64,9 @@ public final class LifecycleBiomeUtil {
|
||||
|
||||
|
||||
net.minecraft.world.biome.Biome vanilaBiome = registry.get(vanilla);
|
||||
if (vanilaBiome == null) {
|
||||
if(vanilaBiome == null) {
|
||||
String vanillaBiomeName;
|
||||
if (vanilla != null ) {
|
||||
if(vanilla != null) {
|
||||
vanillaBiomeName = vanilla.getValue().toString();
|
||||
} else {
|
||||
vanillaBiomeName = "NULL";
|
||||
@@ -94,7 +93,8 @@ public final class LifecycleBiomeUtil {
|
||||
minecraftBiome));
|
||||
}
|
||||
|
||||
Map<RegistryKey<net.minecraft.world.biome.Biome>, RegistryKey<VillagerType>> villagerMap = VillagerTypeAccessor.getBiomeTypeToIdMap();
|
||||
Map<RegistryKey<net.minecraft.world.biome.Biome>, RegistryKey<VillagerType>> villagerMap =
|
||||
VillagerTypeAccessor.getBiomeTypeToIdMap();
|
||||
|
||||
villagerMap.put(RegistryKey.of(RegistryKeys.BIOME, identifier),
|
||||
Objects.requireNonNullElse(vanillaBiomeProperties.getVillagerType(),
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.lifecycle.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"NoiseConfigMixin",
|
||||
"RegistryEntryReferenceInvoker",
|
||||
"RegistryMixin",
|
||||
"SimpleRegistryMixin",
|
||||
"lifecycle.MinecraftServerMixin",
|
||||
"lifecycle.RegistryLoaderMixin",
|
||||
"lifecycle.SaveLoadingMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "terra.lifecycle.refmap.json"
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.lifecycle.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"NoiseConfigMixin",
|
||||
"RegistryEntryReferenceInvoker",
|
||||
"RegistryMixin",
|
||||
"SimpleRegistryMixin",
|
||||
"lifecycle.MinecraftServerMixin",
|
||||
"lifecycle.RegistryLoaderMixin",
|
||||
"lifecycle.SaveLoadingMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "terra.lifecycle.refmap.json"
|
||||
}
|
||||
Reference in New Issue
Block a user