From b63f5f4a8fd72587aa0e450a7823fc1b0ffe65d8 Mon Sep 17 00:00:00 2001 From: Zoe Gidiere Date: Wed, 18 Sep 2024 12:43:41 -0600 Subject: [PATCH 1/2] Reformat --- .../src/main/kotlin/DistributionConfig.kt | 3 +- .../v2/config/BiomePipelineTemplate.java | 2 +- .../pipeline/api/delegate/SelfDelegate.java | 4 +- .../config/BiomePipelineTemplate.java | 2 +- .../config/BiomeProviderTemplate.java | 2 +- .../generation/NoiseChunkGenerator3D.java | 6 +-- .../commands/addons/AddonsCommandAddon.java | 6 +-- .../structure/StructureCommandAddon.java | 14 ++--- .../dfsek/terra/addons/noise/NoiseAddon.java | 39 +++----------- .../templates/ImageSamplerTemplate.java | 9 ++-- .../noise/SaltedNoiseFunction2.java | 3 +- .../noise/SaltedNoiseFunction3.java | 3 +- .../feature/FeatureGenerationStage.java | 2 +- .../addons/terrascript/parser/ParserUtil.java | 8 +-- .../command/arguments/RegistryArgument.java | 25 +++++---- .../platform/CommandRegistrationEvent.java | 4 +- .../api/util/reflection/ReflectionUtil.java | 4 +- .../event/FunctionalEventHandlerImpl.java | 17 +++--- .../com/dfsek/terra/bukkit/BukkitEntity.java | 6 +-- .../dfsek/terra/bukkit/TerraBukkitPlugin.java | 10 ++-- .../bukkit/handles/BukkitWorldHandle.java | 5 +- .../dfsek/terra/bukkit/nms/Initializer.java | 5 +- .../dfsek/terra/bukkit/util/VersionUtil.java | 2 +- .../bukkit/nms/v1_21/AwfulBukkitHacks.java | 4 +- .../bukkit/nms/v1_21/NMSBiomeProvider.java | 8 +-- .../bukkit/nms/v1_21/NMSInjectListener.java | 4 +- .../java/com/dfsek/terra/mod/ModPlatform.java | 52 +++++++++---------- .../config/BiomeParticleConfigTemplate.java | 3 +- .../mod/config/SpawnSettingsTemplate.java | 2 +- .../terra/mod/config/SpawnTypeConfig.java | 6 +-- .../MinecraftChunkGeneratorWrapper.java | 2 - .../mod/generation/TerraBiomeSource.java | 1 - .../terra/mod/handle/MinecraftItemHandle.java | 5 +- .../mod/handle/MinecraftWorldHandle.java | 5 +- .../entity/MobSpawnerBlockEntityMixin.java | 5 +- .../terra/block/state/BlockStateMixin.java | 1 - .../terra/inventory/item/ItemStackMixin.java | 11 ++-- .../inventory/meta/EnchantmentMixin.java | 10 ++-- .../inventory/meta/ItemStackMetaMixin.java | 6 +-- .../terra/world/ChunkRegionMixin.java | 9 ++-- .../lifecycle/DataPackContentsMixin.java | 1 + .../com/dfsek/terra/mod/util/PresetUtil.java | 5 +- .../terra/lifecycle/LifecycleEntryPoint.java | 4 +- .../mixin/lifecycle/RegistryLoaderMixin.java | 49 ++++++----------- .../mixin/lifecycle/SaveLoadingMixin.java | 8 ++- 45 files changed, 163 insertions(+), 219 deletions(-) diff --git a/buildSrc/src/main/kotlin/DistributionConfig.kt b/buildSrc/src/main/kotlin/DistributionConfig.kt index 12ebd8376..0a1c2d060 100644 --- a/buildSrc/src/main/kotlin/DistributionConfig.kt +++ b/buildSrc/src/main/kotlin/DistributionConfig.kt @@ -27,7 +27,8 @@ fun Project.configureDistribution() { group = "terra" doFirst { file("${buildDir}/resources/main/packs/").deleteRecursively() - val defaultPackUrl = URL("https://github.com/PolyhedralDev/TerraOverworldConfig/releases/download/" + Versions.Terra.overworldConfig + "/default.zip") + val defaultPackUrl = + URL("https://github.com/PolyhedralDev/TerraOverworldConfig/releases/download/" + Versions.Terra.overworldConfig + "/default.zip") downloadPack(defaultPackUrl, project) } } diff --git a/common/addons/biome-provider-pipeline-v2/src/main/java/com/dfsek/terra/addons/biome/pipeline/v2/config/BiomePipelineTemplate.java b/common/addons/biome-provider-pipeline-v2/src/main/java/com/dfsek/terra/addons/biome/pipeline/v2/config/BiomePipelineTemplate.java index 937a1b7df..75ffb8d65 100644 --- a/common/addons/biome-provider-pipeline-v2/src/main/java/com/dfsek/terra/addons/biome/pipeline/v2/config/BiomePipelineTemplate.java +++ b/common/addons/biome-provider-pipeline-v2/src/main/java/com/dfsek/terra/addons/biome/pipeline/v2/config/BiomePipelineTemplate.java @@ -29,7 +29,7 @@ public class BiomePipelineTemplate implements ObjectTemplate { @Default @Description(""" The resolution at which to sample biomes. - + Larger values are quadratically faster, but produce lower quality results. For example, a value of 3 would sample every 3 blocks.""") protected @Meta int resolution = 1; diff --git a/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/api/delegate/SelfDelegate.java b/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/api/delegate/SelfDelegate.java index 6b62818d2..c6762334a 100644 --- a/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/api/delegate/SelfDelegate.java +++ b/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/api/delegate/SelfDelegate.java @@ -1,10 +1,10 @@ package com.dfsek.terra.addons.biome.pipeline.api.delegate; +import com.dfsek.terra.api.world.biome.Biome; + import java.util.Collections; import java.util.Set; -import com.dfsek.terra.api.world.biome.Biome; - final class SelfDelegate implements BiomeDelegate { public static final SelfDelegate INSTANCE = new SelfDelegate(); diff --git a/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/config/BiomePipelineTemplate.java b/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/config/BiomePipelineTemplate.java index 491f019ba..1566de524 100644 --- a/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/config/BiomePipelineTemplate.java +++ b/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/config/BiomePipelineTemplate.java @@ -28,7 +28,7 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate { @Description(""" The initial size of biome chunks. This value must be at least 2. This is not the final size of biome chunks. Final chunks will be much larger. - + It is recommended to keep biome chunks' final size in the range of [50, 300] to prevent performance issues. To calculate the size of biome chunks, simply take initial-size and for each expand stage, multiply the running value by 2 diff --git a/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/config/BiomeProviderTemplate.java b/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/config/BiomeProviderTemplate.java index f42fd7c20..93f84e80a 100644 --- a/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/config/BiomeProviderTemplate.java +++ b/common/addons/biome-provider-pipeline/src/main/java/com/dfsek/terra/addons/biome/pipeline/config/BiomeProviderTemplate.java @@ -22,7 +22,7 @@ public abstract class BiomeProviderTemplate implements ObjectTemplate>> NOISE_SAMPLER_TOKEN = new TypeKey<>() { diff --git a/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/config/templates/ImageSamplerTemplate.java b/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/config/templates/ImageSamplerTemplate.java index c7359426c..5503533d4 100644 --- a/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/config/templates/ImageSamplerTemplate.java +++ b/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/config/templates/ImageSamplerTemplate.java @@ -8,15 +8,16 @@ package com.dfsek.terra.addons.noise.config.templates; import com.dfsek.tectonic.api.config.template.annotations.Value; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.awt.image.BufferedImage; import com.dfsek.terra.addons.noise.samplers.ImageSampler; import com.dfsek.terra.api.config.meta.Meta; import com.dfsek.terra.api.noise.NoiseSampler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.image.BufferedImage; + @SuppressWarnings({ "unused", "FieldMayBeFinal" }) public class ImageSamplerTemplate extends SamplerTemplate { diff --git a/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/paralithic/noise/SaltedNoiseFunction2.java b/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/paralithic/noise/SaltedNoiseFunction2.java index 2e8f72929..41ddd1247 100644 --- a/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/paralithic/noise/SaltedNoiseFunction2.java +++ b/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/paralithic/noise/SaltedNoiseFunction2.java @@ -3,11 +3,10 @@ import com.dfsek.paralithic.functions.dynamic.Context; import com.dfsek.paralithic.functions.dynamic.DynamicFunction; import com.dfsek.paralithic.node.Statefulness; +import org.jetbrains.annotations.NotNull; import com.dfsek.terra.api.noise.NoiseSampler; -import org.jetbrains.annotations.NotNull; - public class SaltedNoiseFunction2 implements DynamicFunction { private final NoiseSampler gen; diff --git a/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/paralithic/noise/SaltedNoiseFunction3.java b/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/paralithic/noise/SaltedNoiseFunction3.java index 5dc483d5c..d4549127c 100644 --- a/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/paralithic/noise/SaltedNoiseFunction3.java +++ b/common/addons/config-noise-function/src/main/java/com/dfsek/terra/addons/noise/paralithic/noise/SaltedNoiseFunction3.java @@ -3,11 +3,10 @@ import com.dfsek.paralithic.functions.dynamic.Context; import com.dfsek.paralithic.functions.dynamic.DynamicFunction; import com.dfsek.paralithic.node.Statefulness; +import org.jetbrains.annotations.NotNull; import com.dfsek.terra.api.noise.NoiseSampler; -import org.jetbrains.annotations.NotNull; - public class SaltedNoiseFunction3 implements DynamicFunction { private final NoiseSampler gen; diff --git a/common/addons/generation-stage-feature/src/main/java/com/dfsek/terra/addons/generation/feature/FeatureGenerationStage.java b/common/addons/generation-stage-feature/src/main/java/com/dfsek/terra/addons/generation/feature/FeatureGenerationStage.java index 123107d15..11a1e3ca7 100644 --- a/common/addons/generation-stage-feature/src/main/java/com/dfsek/terra/addons/generation/feature/FeatureGenerationStage.java +++ b/common/addons/generation-stage-feature/src/main/java/com/dfsek/terra/addons/generation/feature/FeatureGenerationStage.java @@ -62,7 +62,7 @@ public void populate(ProtoWorld world) { world.getBiomeProvider() .getColumn( tx + (doBlending ? (int) (blendSampler.noise(seed, tx, tz) * blendAmplitude) : 0), - tz + (doBlending ? (int) (blendSampler.noise(seed+1, tx, tz) * blendAmplitude) : 0), + tz + (doBlending ? (int) (blendSampler.noise(seed + 1, tx, tz) * blendAmplitude) : 0), world) .forRanges(resolution, (min, max, biome) -> { for(int subChunkX = 0; subChunkX < resolution; subChunkX++) { diff --git a/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/parser/ParserUtil.java b/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/parser/ParserUtil.java index 4fc805a8f..b982b0979 100644 --- a/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/parser/ParserUtil.java +++ b/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/parser/ParserUtil.java @@ -7,15 +7,15 @@ package com.dfsek.terra.addons.terrascript.parser; +import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException; +import com.dfsek.terra.addons.terrascript.parser.lang.Returnable; +import com.dfsek.terra.addons.terrascript.tokenizer.Token; + import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException; -import com.dfsek.terra.addons.terrascript.parser.lang.Returnable; -import com.dfsek.terra.addons.terrascript.tokenizer.Token; - public class ParserUtil { diff --git a/common/api/src/main/java/com/dfsek/terra/api/command/arguments/RegistryArgument.java b/common/api/src/main/java/com/dfsek/terra/api/command/arguments/RegistryArgument.java index 91d6b56b9..8e15c18ce 100644 --- a/common/api/src/main/java/com/dfsek/terra/api/command/arguments/RegistryArgument.java +++ b/common/api/src/main/java/com/dfsek/terra/api/command/arguments/RegistryArgument.java @@ -2,6 +2,15 @@ import io.leangen.geantyref.TypeToken; import org.checkerframework.checker.nullness.qual.NonNull; +import org.incendo.cloud.component.CommandComponent; +import org.incendo.cloud.component.DefaultValue; +import org.incendo.cloud.context.CommandContext; +import org.incendo.cloud.context.CommandInput; +import org.incendo.cloud.parser.ArgumentParseResult; +import org.incendo.cloud.parser.ArgumentParser; +import org.incendo.cloud.parser.ParserDescriptor; +import org.incendo.cloud.suggestion.Suggestion; +import org.incendo.cloud.suggestion.SuggestionProvider; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -13,16 +22,6 @@ import com.dfsek.terra.api.registry.key.RegistryKey; import com.dfsek.terra.api.util.reflection.TypeKey; -import org.incendo.cloud.component.CommandComponent; -import org.incendo.cloud.component.DefaultValue; -import org.incendo.cloud.context.CommandContext; -import org.incendo.cloud.context.CommandInput; -import org.incendo.cloud.parser.ArgumentParseResult; -import org.incendo.cloud.parser.ArgumentParser; -import org.incendo.cloud.parser.ParserDescriptor; -import org.incendo.cloud.suggestion.Suggestion; -import org.incendo.cloud.suggestion.SuggestionProvider; - public class RegistryArgument { @@ -49,17 +48,17 @@ public static Builder builder(String name, Function CommandComponent of(String name, Function, Registry> registryFunction, - TypeKey registryType) { + TypeKey registryType) { return RegistryArgument.builder(name, registryFunction, registryType).build(); } public static CommandComponent optional(String name, Function, Registry> registryFunction, - TypeKey registryType) { + TypeKey registryType) { return RegistryArgument.builder(name, registryFunction, registryType).optional().build(); } public static CommandComponent optional(String name, Function, Registry> registryFunction, - TypeKey registryType, DefaultValue defaultKey) { + TypeKey registryType, DefaultValue defaultKey) { return RegistryArgument.builder(name, registryFunction, registryType).optional(defaultKey).build(); } diff --git a/common/api/src/main/java/com/dfsek/terra/api/event/events/platform/CommandRegistrationEvent.java b/common/api/src/main/java/com/dfsek/terra/api/event/events/platform/CommandRegistrationEvent.java index 3ad041c9b..80088ff6d 100644 --- a/common/api/src/main/java/com/dfsek/terra/api/event/events/platform/CommandRegistrationEvent.java +++ b/common/api/src/main/java/com/dfsek/terra/api/event/events/platform/CommandRegistrationEvent.java @@ -1,10 +1,10 @@ package com.dfsek.terra.api.event.events.platform; +import org.incendo.cloud.CommandManager; + import com.dfsek.terra.api.command.CommandSender; import com.dfsek.terra.api.event.events.Event; -import org.incendo.cloud.CommandManager; - public class CommandRegistrationEvent implements Event { private final CommandManager commandManager; diff --git a/common/api/src/main/java/com/dfsek/terra/api/util/reflection/ReflectionUtil.java b/common/api/src/main/java/com/dfsek/terra/api/util/reflection/ReflectionUtil.java index 6b0c8fd28..2583b9ab6 100644 --- a/common/api/src/main/java/com/dfsek/terra/api/util/reflection/ReflectionUtil.java +++ b/common/api/src/main/java/com/dfsek/terra/api/util/reflection/ReflectionUtil.java @@ -30,11 +30,11 @@ public final class ReflectionUtil { private static final Unsafe UNSAFE; static { - try{ + try { final Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe"); unsafeField.setAccessible(true); UNSAFE = (Unsafe) unsafeField.get(null); - } catch(NoSuchFieldException | IllegalAccessException e){ + } catch(NoSuchFieldException | IllegalAccessException e) { throw new RuntimeException(e); } } diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/event/FunctionalEventHandlerImpl.java b/common/implementation/base/src/main/java/com/dfsek/terra/event/FunctionalEventHandlerImpl.java index 67f984646..a35bf9366 100644 --- a/common/implementation/base/src/main/java/com/dfsek/terra/event/FunctionalEventHandlerImpl.java +++ b/common/implementation/base/src/main/java/com/dfsek/terra/event/FunctionalEventHandlerImpl.java @@ -17,17 +17,6 @@ package com.dfsek.terra.event; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import com.dfsek.terra.api.addon.BaseAddon; import com.dfsek.terra.api.event.events.Event; import com.dfsek.terra.api.event.events.FailThroughEvent; @@ -36,6 +25,12 @@ import com.dfsek.terra.api.event.functional.FunctionalEventHandler; import com.dfsek.terra.api.util.reflection.TypeKey; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Type; +import java.util.*; + public class FunctionalEventHandlerImpl implements FunctionalEventHandler { private static final Logger logger = LoggerFactory.getLogger(FunctionalEventHandlerImpl.class); diff --git a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/BukkitEntity.java b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/BukkitEntity.java index 6df268180..98f44e2ec 100644 --- a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/BukkitEntity.java +++ b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/BukkitEntity.java @@ -17,14 +17,14 @@ package com.dfsek.terra.bukkit; -import io.papermc.lib.PaperLib; -import org.bukkit.Location; - import com.dfsek.terra.api.entity.Entity; import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.world.ServerWorld; import com.dfsek.terra.bukkit.world.BukkitAdapter; +import io.papermc.lib.PaperLib; +import org.bukkit.Location; + public class BukkitEntity implements Entity { private final org.bukkit.entity.Entity entity; diff --git a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/TerraBukkitPlugin.java b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/TerraBukkitPlugin.java index 8c392dba1..e3bc1d837 100644 --- a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/TerraBukkitPlugin.java +++ b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/TerraBukkitPlugin.java @@ -79,7 +79,7 @@ public void onEnable() { } catch(Exception e) { // This should never happen. logger.error(""" TERRA HAS BEEN DISABLED - + Errors occurred while registering commands. Please report this to Terra. """.strip(), e); @@ -102,13 +102,13 @@ private LegacyPaperCommandManager getCommandSenderPaperCommandMan BukkitAdapter::adapt )); - if (commandManager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) { + if(commandManager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) { commandManager.registerBrigadier(); final CloudBrigadierManager brigManager = commandManager.brigadierManager(); if(brigManager != null) { brigManager.setNativeNumberSuggestions(false); } - } else if (commandManager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) { + } else if(commandManager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) { commandManager.registerAsynchronousCompletions(); } @@ -181,7 +181,7 @@ private boolean doVersionCheck() { logger.warn(""" You are using Mohist, so we will not give you any support for issues that may arise. Since you enabled the "IKnowMohistCausesLotsOfIssuesButIWillUseItAnyways" flag, we won't disable Terra. But be warned. - + > I felt a great disturbance in the JVM, as if millions of plugins suddenly cried out in stack traces and were suddenly silenced. > I fear something terrible has happened. > - Astrash @@ -194,7 +194,7 @@ private boolean doVersionCheck() { @Override public @Nullable ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id) { - if (id == null || id.trim().equals("")) { return null; } + if(id == null || id.trim().equals("")) { return null; } return new BukkitChunkGeneratorWrapper(generatorMap.computeIfAbsent(worldName, name -> { ConfigPack pack = platform.getConfigRegistry().getByID(id).orElseThrow( () -> new IllegalArgumentException("No such config pack \"" + id + "\"")); diff --git a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/handles/BukkitWorldHandle.java b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/handles/BukkitWorldHandle.java index c6113bbd7..97f932c81 100644 --- a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/handles/BukkitWorldHandle.java +++ b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/handles/BukkitWorldHandle.java @@ -61,8 +61,9 @@ public BukkitWorldHandle() { @Override public @NotNull EntityType getEntity(@NotNull String id) { - if (!id.contains(":")) { //TODO: remove in 7.0 - String newid = "minecraft:" + id.toLowerCase();; + if(!id.contains(":")) { //TODO: remove in 7.0 + String newid = "minecraft:" + id.toLowerCase(); + ; logger.warn( "Translating " + id + " to " + newid + ". In 1.20.3 entity parsing was reworked" + ". You are advised to perform this rename in your config backs as this translation will be removed in the next major " + diff --git a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/nms/Initializer.java b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/nms/Initializer.java index 3f7375bc4..fc28e4bc3 100644 --- a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/nms/Initializer.java +++ b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/nms/Initializer.java @@ -1,11 +1,10 @@ package com.dfsek.terra.bukkit.nms; -import com.dfsek.terra.bukkit.util.VersionUtil; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.dfsek.terra.bukkit.PlatformImpl; +import com.dfsek.terra.bukkit.util.VersionUtil; public interface Initializer { @@ -16,7 +15,7 @@ static boolean init(PlatformImpl platform) { Logger logger = LoggerFactory.getLogger(Initializer.class); try { String packageVersion = NMS; - if (NMS.equals("v1_21_1")) { + if(NMS.equals("v1_21_1")) { packageVersion = "v1_21"; } diff --git a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/util/VersionUtil.java b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/util/VersionUtil.java index 6a8c662e0..3f32b6be2 100644 --- a/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/util/VersionUtil.java +++ b/platforms/bukkit/common/src/main/java/com/dfsek/terra/bukkit/util/VersionUtil.java @@ -112,7 +112,7 @@ public String toString() { if(major == -1 && minor == -1 && patch == -1) return "Unknown"; - if (patch >= 0) { + if(patch >= 0) { return String.format("v%d.%d.%d", major, minor, patch); } else { return String.format("v%d.%d", major, minor); diff --git a/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/AwfulBukkitHacks.java b/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/AwfulBukkitHacks.java index fc5cc0367..42d683394 100644 --- a/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/AwfulBukkitHacks.java +++ b/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/AwfulBukkitHacks.java @@ -10,7 +10,6 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.biome.Biome; import org.bukkit.NamespacedKey; import org.slf4j.Logger; @@ -42,7 +41,8 @@ public static void registerBiomes(ConfigRegistry configRegistry) { try { BukkitPlatformBiome platformBiome = (BukkitPlatformBiome) biome.getPlatformBiome(); NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey(); - ResourceLocation vanillaMinecraftKey = ResourceLocation.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(), vanillaBukkitKey.getKey()); + ResourceLocation vanillaMinecraftKey = ResourceLocation.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(), + vanillaBukkitKey.getKey()); Biome platform = NMSBiomeInjector.createBiome(biome, Objects.requireNonNull(biomeRegistry.get(vanillaMinecraftKey))); ResourceKey delegateKey = ResourceKey.create( diff --git a/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/NMSBiomeProvider.java b/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/NMSBiomeProvider.java index 18184144f..8abe26a51 100644 --- a/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/NMSBiomeProvider.java +++ b/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/NMSBiomeProvider.java @@ -37,10 +37,10 @@ protected Stream> collectPossibleBiomes() { @Override protected @NotNull MapCodec codec() { return MapCodec.assumeMapUnsafe(BiomeSource.CODEC); -// return MapCodec.unit(null); -// BuiltInRegistries.BIOME_SOURCE.byNameCodec().dispatchMap(this::codec, Function.identity()); -// BuiltInRegistries.BIOME_SOURCE.byNameCodec().dispatchStable(BiomeSource::codec, Function.identity()); -// return BiomeSource.CODEC; + // return MapCodec.unit(null); + // BuiltInRegistries.BIOME_SOURCE.byNameCodec().dispatchMap(this::codec, Function.identity()); + // BuiltInRegistries.BIOME_SOURCE.byNameCodec().dispatchStable(BiomeSource::codec, Function.identity()); + // return BiomeSource.CODEC; } @Override diff --git a/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/NMSInjectListener.java b/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/NMSInjectListener.java index b471faa88..927b019ed 100644 --- a/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/NMSInjectListener.java +++ b/platforms/bukkit/nms/v1_21/src/main/java/com/dfsek/terra/bukkit/nms/v1_21/NMSInjectListener.java @@ -1,12 +1,9 @@ package com.dfsek.terra.bukkit.nms.v1_21; -import com.dfsek.terra.api.util.reflection.ReflectionUtil; - import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.status.WorldGenContext; -import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.event.EventHandler; @@ -20,6 +17,7 @@ import java.util.concurrent.locks.ReentrantLock; import com.dfsek.terra.api.config.ConfigPack; +import com.dfsek.terra.api.util.reflection.ReflectionUtil; import com.dfsek.terra.bukkit.generator.BukkitChunkGeneratorWrapper; diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/ModPlatform.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/ModPlatform.java index 308f7913c..09681f6b6 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/ModPlatform.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/ModPlatform.java @@ -68,32 +68,32 @@ public void registerWorldTypes(BiConsumer registerFunct public void register(TypeRegistry registry) { super.register(registry); registry.registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker)) - .registerLoader(Identifier.class, (type, o, loader, depthTracker) -> { - Identifier identifier = Identifier.tryParse((String) o); - if(identifier == null) - throw new LoadException("Invalid identifier: " + o, depthTracker); - return identifier; - }) - .registerLoader(Precipitation.class, (type, o, loader, depthTracker) -> Precipitation.valueOf(((String) o).toUpperCase( - Locale.ROOT))) - .registerLoader(GrassColorModifier.class, - (type, o, loader, depthTracker) -> GrassColorModifier.valueOf(((String) o).toUpperCase( - Locale.ROOT))) - .registerLoader(GrassColorModifier.class, - (type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase( - Locale.ROOT))) - .registerLoader(SpawnGroup.class,(type, o, loader, depthTracker) -> SpawnGroup.valueOf((String) o)) - .registerLoader(BiomeParticleConfig.class, BiomeParticleConfigTemplate::new) - .registerLoader(SoundEvent.class, SoundEventTemplate::new) - .registerLoader(BiomeMoodSound.class, BiomeMoodSoundTemplate::new) - .registerLoader(BiomeAdditionsSound.class, BiomeAdditionsSoundTemplate::new) - .registerLoader(MusicSound.class, MusicSoundTemplate::new) - .registerLoader(EntityType.class, EntityTypeTemplate::new) - .registerLoader(SpawnCostConfig.class, SpawnCostConfig::new) - .registerLoader(SpawnEntry.class, SpawnEntryTemplate::new) - .registerLoader(SpawnTypeConfig.class, SpawnTypeConfig::new) - .registerLoader(SpawnSettings.class, SpawnSettingsTemplate::new) - .registerLoader(VillagerType.class, VillagerTypeTemplate::new); + .registerLoader(Identifier.class, (type, o, loader, depthTracker) -> { + Identifier identifier = Identifier.tryParse((String) o); + if(identifier == null) + throw new LoadException("Invalid identifier: " + o, depthTracker); + return identifier; + }) + .registerLoader(Precipitation.class, (type, o, loader, depthTracker) -> Precipitation.valueOf(((String) o).toUpperCase( + Locale.ROOT))) + .registerLoader(GrassColorModifier.class, + (type, o, loader, depthTracker) -> GrassColorModifier.valueOf(((String) o).toUpperCase( + Locale.ROOT))) + .registerLoader(GrassColorModifier.class, + (type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase( + Locale.ROOT))) + .registerLoader(SpawnGroup.class, (type, o, loader, depthTracker) -> SpawnGroup.valueOf((String) o)) + .registerLoader(BiomeParticleConfig.class, BiomeParticleConfigTemplate::new) + .registerLoader(SoundEvent.class, SoundEventTemplate::new) + .registerLoader(BiomeMoodSound.class, BiomeMoodSoundTemplate::new) + .registerLoader(BiomeAdditionsSound.class, BiomeAdditionsSoundTemplate::new) + .registerLoader(MusicSound.class, MusicSoundTemplate::new) + .registerLoader(EntityType.class, EntityTypeTemplate::new) + .registerLoader(SpawnCostConfig.class, SpawnCostConfig::new) + .registerLoader(SpawnEntry.class, SpawnEntryTemplate::new) + .registerLoader(SpawnTypeConfig.class, SpawnTypeConfig::new) + .registerLoader(SpawnSettings.class, SpawnSettingsTemplate::new) + .registerLoader(VillagerType.class, VillagerTypeTemplate::new); } private ProtoPlatformBiome parseBiome(String id, DepthTracker tracker) throws LoadException { diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/BiomeParticleConfigTemplate.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/BiomeParticleConfigTemplate.java index 3bc4474b6..457566444 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/BiomeParticleConfigTemplate.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/BiomeParticleConfigTemplate.java @@ -28,7 +28,8 @@ public BiomeParticleConfig get() { try { return new BiomeParticleConfig( - ParticleEffectArgumentType.readParameters(new StringReader(particle), (RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE.getReadOnlyWrapper()), + ParticleEffectArgumentType.readParameters(new StringReader(particle), + (RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE.getReadOnlyWrapper()), probability); } catch(CommandSyntaxException e) { throw new RuntimeException(e); diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/SpawnSettingsTemplate.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/SpawnSettingsTemplate.java index 86e9de007..a0e8932e5 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/SpawnSettingsTemplate.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/SpawnSettingsTemplate.java @@ -28,7 +28,7 @@ public SpawnSettings get() { SpawnSettings.Builder builder = new SpawnSettings.Builder(); for(SpawnTypeConfig spawn : spawns) { SpawnGroup group = spawn.getGroup(); - for (SpawnEntry entry : spawn.getEntry()) { + for(SpawnEntry entry : spawn.getEntry()) { builder.spawn(group, entry); } } diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/SpawnTypeConfig.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/SpawnTypeConfig.java index b18c87e62..0eba7ca67 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/SpawnTypeConfig.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/config/SpawnTypeConfig.java @@ -13,15 +13,15 @@ public class SpawnTypeConfig implements ObjectTemplate { @Value("group") @Default private SpawnGroup group = null; - + @Value("entries") @Default private List entry = null; - + public SpawnGroup getGroup() { return group; } - + public List getEntry() { return entry; } diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/generation/MinecraftChunkGeneratorWrapper.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/generation/MinecraftChunkGeneratorWrapper.java index c73ad3f3b..46f5601de 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/generation/MinecraftChunkGeneratorWrapper.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/generation/MinecraftChunkGeneratorWrapper.java @@ -17,7 +17,6 @@ package com.dfsek.terra.mod.generation; -import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -49,7 +48,6 @@ import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; import com.dfsek.terra.api.config.ConfigPack; import com.dfsek.terra.api.world.biome.generation.BiomeProvider; diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/generation/TerraBiomeSource.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/generation/TerraBiomeSource.java index 533a8c98b..81651ece8 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/generation/TerraBiomeSource.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/generation/TerraBiomeSource.java @@ -17,7 +17,6 @@ package com.dfsek.terra.mod.generation; -import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.world.biome.Biome; diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftItemHandle.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftItemHandle.java index e9a5f5ae4..c9ef02f37 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftItemHandle.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftItemHandle.java @@ -21,10 +21,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.argument.ItemStackArgumentType; -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; @@ -67,6 +65,7 @@ public Enchantment getEnchantment(String id) { @Override public Set getEnchantments() { - return CommonPlatform.get().enchantmentRegistry().stream().map(enchantment -> (Enchantment) (Object) enchantment).collect(Collectors.toSet()); + return CommonPlatform.get().enchantmentRegistry().stream().map(enchantment -> (Enchantment) (Object) enchantment).collect( + Collectors.toSet()); } } diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftWorldHandle.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftWorldHandle.java index 3b5e1fe49..c36744d18 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftWorldHandle.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftWorldHandle.java @@ -64,8 +64,9 @@ public class MinecraftWorldHandle implements WorldHandle { @Override public @NotNull EntityType getEntity(@NotNull String id) { - if (!id.contains(":")) { //TODO: remove in 7.0 - String newid = "minecraft:" + id.toLowerCase();; + if(!id.contains(":")) { //TODO: remove in 7.0 + String newid = "minecraft:" + id.toLowerCase(); + ; logger.warn( "Translating " + id + " to " + newid + ". In 1.20.3 entity parsing was reworked" + ". You are advised to perform this rename in your config packs as this translation will be removed in the next major " + diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/block/entity/MobSpawnerBlockEntityMixin.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/block/entity/MobSpawnerBlockEntityMixin.java index caf918d1d..15e8fab34 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/block/entity/MobSpawnerBlockEntityMixin.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/block/entity/MobSpawnerBlockEntityMixin.java @@ -48,7 +48,8 @@ private MobSpawnerBlockEntityMixin(BlockEntityType type, BlockPos pos, BlockS @Shadow public abstract MobSpawnerLogic getLogic(); -//method_46408 + + //method_46408 @Shadow public abstract void setEntityType(net.minecraft.entity.EntityType entityType, Random random); @@ -59,7 +60,7 @@ private MobSpawnerBlockEntityMixin(BlockEntityType type, BlockPos pos, BlockS public void terra$setSpawnedType(@NotNull EntityType creatureType) { Random rand; - if (hasWorld()) { + if(hasWorld()) { rand = world.getRandom(); } else { rand = Random.create(); diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/block/state/BlockStateMixin.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/block/state/BlockStateMixin.java index 9ecb3eccc..4243bf942 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/block/state/BlockStateMixin.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/block/state/BlockStateMixin.java @@ -1,7 +1,6 @@ package com.dfsek.terra.mod.mixin.implementations.terra.block.state; -import com.google.common.collect.ImmutableMap; import com.mojang.serialization.MapCodec; import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap; import net.minecraft.block.AbstractBlock.AbstractBlockState; diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/item/ItemStackMixin.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/item/ItemStackMixin.java index 70177be1f..76121f64b 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/item/ItemStackMixin.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/item/ItemStackMixin.java @@ -17,13 +17,10 @@ package com.dfsek.terra.mod.mixin.implementations.terra.inventory.item; -import net.minecraft.component.Component; import net.minecraft.component.ComponentChanges; import net.minecraft.component.ComponentMap; import net.minecraft.component.ComponentMapImpl; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Interface; @@ -38,6 +35,10 @@ @Mixin(ItemStack.class) @Implements(@Interface(iface = com.dfsek.terra.api.inventory.ItemStack.class, prefix = "terra$")) public abstract class ItemStackMixin { + @Shadow + @Final + private ComponentMapImpl components; + @Shadow public abstract int getCount(); @@ -53,10 +54,6 @@ public abstract class ItemStackMixin { @Shadow public abstract ComponentMap getComponents(); - @Shadow - @Final - private ComponentMapImpl components; - public int terra$getAmount() { return getCount(); } diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/meta/EnchantmentMixin.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/meta/EnchantmentMixin.java index dd7cfbce0..8f58fb9d8 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/meta/EnchantmentMixin.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/meta/EnchantmentMixin.java @@ -17,10 +17,7 @@ package com.dfsek.terra.mod.mixin.implementations.terra.inventory.meta; -import com.dfsek.terra.mod.CommonPlatform; - import net.minecraft.enchantment.Enchantment; -import net.minecraft.registry.Registries; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.entry.RegistryEntryList; import org.spongepowered.asm.mixin.Final; @@ -32,6 +29,7 @@ import java.util.Objects; import com.dfsek.terra.api.inventory.ItemStack; +import com.dfsek.terra.mod.CommonPlatform; import static net.minecraft.enchantment.Enchantment.canBeCombined; @@ -39,13 +37,13 @@ @Mixin(Enchantment.class) @Implements(@Interface(iface = com.dfsek.terra.api.inventory.item.Enchantment.class, prefix = "terra$")) public abstract class EnchantmentMixin { - @Shadow - public abstract boolean isAcceptableItem(net.minecraft.item.ItemStack stack); - @Shadow @Final private RegistryEntryList exclusiveSet; + @Shadow + public abstract boolean isAcceptableItem(net.minecraft.item.ItemStack stack); + @SuppressWarnings("ConstantConditions") public boolean terra$canEnchantItem(ItemStack itemStack) { return isAcceptableItem((net.minecraft.item.ItemStack) (Object) itemStack); diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/meta/ItemStackMetaMixin.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/meta/ItemStackMetaMixin.java index a3bcf54df..91a487d0b 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/meta/ItemStackMetaMixin.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/inventory/meta/ItemStackMetaMixin.java @@ -19,9 +19,6 @@ import net.minecraft.component.type.ItemEnchantmentsComponent; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtList; -import net.minecraft.registry.Registries; import net.minecraft.registry.entry.RegistryEntry; import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Interface; @@ -49,7 +46,8 @@ public abstract class ItemStackMetaMixin { @Shadow public abstract void addEnchantment(RegistryEntry enchantment, int level); - public void terra$addEnchantment(Enchantment enchantment, int level) { ; + public void terra$addEnchantment(Enchantment enchantment, int level) { + ; addEnchantment(RegistryEntry.of((net.minecraft.enchantment.Enchantment) (Object) enchantment), level); } diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ChunkRegionMixin.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ChunkRegionMixin.java index 7ae5441d0..70a62ae79 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ChunkRegionMixin.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ChunkRegionMixin.java @@ -17,8 +17,6 @@ package com.dfsek.terra.mod.mixin.implementations.terra.world; -import com.dfsek.terra.mod.mixin.invoke.FluidBlockInvoker; - import net.minecraft.block.FluidBlock; import net.minecraft.fluid.Fluid; import net.minecraft.util.collection.BoundedRegionArray; @@ -27,7 +25,6 @@ import net.minecraft.world.WorldAccess; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkGenerationStep; -import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.tick.MultiTickScheduler; import net.minecraft.world.tick.OrderedTick; import org.spongepowered.asm.mixin.Final; @@ -40,8 +37,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.List; - import com.dfsek.terra.api.block.entity.BlockEntity; import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.config.ConfigPack; @@ -52,6 +47,7 @@ import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator; import com.dfsek.terra.api.world.chunk.generation.ProtoWorld; import com.dfsek.terra.mod.generation.MinecraftChunkGeneratorWrapper; +import com.dfsek.terra.mod.mixin.invoke.FluidBlockInvoker; import com.dfsek.terra.mod.util.MinecraftUtil; @@ -78,7 +74,8 @@ public abstract class ChunkRegionMixin { @Inject(at = @At("RETURN"), - method = "(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/collection/BoundedRegionArray;Lnet/minecraft/world/chunk/ChunkGenerationStep;Lnet/minecraft/world/chunk/Chunk;)V") + method = "(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/collection/BoundedRegionArray;" + + "Lnet/minecraft/world/chunk/ChunkGenerationStep;Lnet/minecraft/world/chunk/Chunk;)V") public void injectConstructor(net.minecraft.server.world.ServerWorld world, BoundedRegionArray chunks, ChunkGenerationStep generationStep, Chunk centerPos, CallbackInfo ci) { this.terra$config = ((ServerWorld) world).getPack(); diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/lifecycle/DataPackContentsMixin.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/lifecycle/DataPackContentsMixin.java index 305f7f024..680c1833c 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/lifecycle/DataPackContentsMixin.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/lifecycle/DataPackContentsMixin.java @@ -22,6 +22,7 @@ public class DataPackContentsMixin { @Shadow @Final private ReloadableRegistries.Lookup reloadableRegistries; + /* * #refresh populates all tags in the registries */ diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/util/PresetUtil.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/util/PresetUtil.java index de147c509..32c19a405 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/util/PresetUtil.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/util/PresetUtil.java @@ -45,8 +45,9 @@ public static Pair createDefault(ConfigPack pack, ModPl .orElseThrow(); - Identifier generatorID = Identifier.tryParse("terra:" + pack.getID().toLowerCase(Locale.ROOT) + "/" + pack.getNamespace().toLowerCase( - Locale.ROOT)); + Identifier generatorID = Identifier.tryParse( + "terra:" + pack.getID().toLowerCase(Locale.ROOT) + "/" + pack.getNamespace().toLowerCase( + Locale.ROOT)); PRESETS.add(generatorID); diff --git a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/LifecycleEntryPoint.java b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/LifecycleEntryPoint.java index 65d86febf..0cbfa77b4 100644 --- a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/LifecycleEntryPoint.java +++ b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/LifecycleEntryPoint.java @@ -20,8 +20,8 @@ public static void initialize(String modName, LifecyclePlatform platform) { FabricServerCommandManager manager = new FabricServerCommandManager<>( ExecutionCoordinator.simpleCoordinator(), SenderMapper.create( - serverCommandSource -> (CommandSender) serverCommandSource, - commandSender -> (ServerCommandSource) commandSender) + serverCommandSource -> (CommandSender) serverCommandSource, + commandSender -> (ServerCommandSource) commandSender) ); diff --git a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/RegistryLoaderMixin.java b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/RegistryLoaderMixin.java index a5d2a9bde..b1ff48396 100644 --- a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/RegistryLoaderMixin.java +++ b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/RegistryLoaderMixin.java @@ -1,15 +1,13 @@ package com.dfsek.terra.lifecycle.mixin.lifecycle; -import com.mojang.datafixers.util.Pair; import net.minecraft.enchantment.Enchantment; -import net.minecraft.registry.DynamicRegistryManager; -import net.minecraft.registry.DynamicRegistryManager.Immutable; import net.minecraft.registry.MutableRegistry; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryLoader; import net.minecraft.registry.RegistryLoader.Loader; +import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.MultiNoiseBiomeSourceParameterList; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.WorldPreset; @@ -20,7 +18,6 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import java.util.List; @@ -31,8 +28,6 @@ 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 { @@ -40,21 +35,10 @@ public class RegistryLoaderMixin { @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> entries, CallbackInfoReturnable cir) { -// entries.forEach((loader) -> { -// Registry registry = loader.registry(); -// } + @Redirect( - method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", + method = "load(Lnet/minecraft/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", @@ -62,20 +46,19 @@ public class RegistryLoaderMixin { ) ) private static void grabManager(List> instance, Consumer> 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 dimensionTypes = extractRegistry(instance, RegistryKeys.DIMENSION_TYPE).orElseThrow(); - MutableRegistry worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow(); - MutableRegistry chunkGeneratorSettings = extractRegistry(instance, - RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow(); - MutableRegistry multiNoiseBiomeSourceParameterLists = extractRegistry(instance, - RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow(); - MutableRegistry enchantments = extractRegistry(instance, RegistryKeys.ENCHANTMENT).orElseThrow(); + if(!initialized) { + MutableRegistry biomes = extractRegistry(instance, RegistryKeys.BIOME).orElseThrow(); + MutableRegistry dimensionTypes = extractRegistry(instance, RegistryKeys.DIMENSION_TYPE).orElseThrow(); + MutableRegistry worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow(); + MutableRegistry chunkGeneratorSettings = extractRegistry(instance, + RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow(); + MutableRegistry multiNoiseBiomeSourceParameterLists = extractRegistry(instance, + RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow(); + MutableRegistry enchantments = extractRegistry(instance, RegistryKeys.ENCHANTMENT).orElseThrow(); - LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists, enchantments); - LifecycleUtil.initialize(biomes, worldPresets); - }); + LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists, + enchantments); + LifecycleUtil.initialize(biomes, worldPresets); initialized = true; } instance.forEach(consumer); diff --git a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/SaveLoadingMixin.java b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/SaveLoadingMixin.java index 0bf675fc2..89490ef41 100644 --- a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/SaveLoadingMixin.java +++ b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/SaveLoadingMixin.java @@ -13,10 +13,14 @@ @Mixin(SaveLoading.class) public class SaveLoadingMixin { @ModifyArg( - method = "load(Lnet/minecraft/server/SaveLoading$ServerConfig;Lnet/minecraft/server/SaveLoading$LoadContextSupplier;Lnet/minecraft/server/SaveLoading$SaveApplierFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", + method = "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/registry/RegistryLoader;loadFromResource(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;" ), + 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 registryManager) { From 06457bf3ced441619bc9ac0994b7842dc33ea323 Mon Sep 17 00:00:00 2001 From: Zoe Gidiere Date: Wed, 18 Sep 2024 15:43:31 -0600 Subject: [PATCH 2/2] some fixes --- .../com/dfsek/terra/mod/mixin/invoke/FluidBlockInvoker.java | 2 +- .../src/main/resources/terra.common.mixins.json | 1 + .../lifecycle/mixin/lifecycle/MinecraftServerMixin.java | 6 ++++++ .../lifecycle/mixin/lifecycle/RegistryLoaderMixin.java | 4 +++- .../java/com/dfsek/terra/lifecycle/util/LifecycleUtil.java | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/invoke/FluidBlockInvoker.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/invoke/FluidBlockInvoker.java index a6b50409c..620d03ec1 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/invoke/FluidBlockInvoker.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/invoke/FluidBlockInvoker.java @@ -10,5 +10,5 @@ @Mixin(FluidBlock.class) public interface FluidBlockInvoker { @Invoker("getFluidState") - public FluidState invokeGetFluidState(BlockState state); + FluidState invokeGetFluidState(BlockState state); } diff --git a/platforms/mixin-common/src/main/resources/terra.common.mixins.json b/platforms/mixin-common/src/main/resources/terra.common.mixins.json index f8d0718e4..e25cb7da4 100644 --- a/platforms/mixin-common/src/main/resources/terra.common.mixins.json +++ b/platforms/mixin-common/src/main/resources/terra.common.mixins.json @@ -36,6 +36,7 @@ "implementations.terra.inventory.meta.ItemStackMetaMixin", "implementations.terra.world.ChunkRegionMixin", "implementations.terra.world.ServerWorldMixin", + "invoke.FluidBlockInvoker", "lifecycle.DataPackContentsMixin" ], "client": [ diff --git a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/MinecraftServerMixin.java b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/MinecraftServerMixin.java index 25ac340d0..63a8b8170 100644 --- a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/MinecraftServerMixin.java +++ b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/MinecraftServerMixin.java @@ -16,6 +16,7 @@ import com.dfsek.terra.lifecycle.LifecyclePlatform; +import static com.dfsek.terra.lifecycle.util.LifecycleUtil.initialized; @Mixin(MinecraftServer.class) public class MinecraftServerMixin { @@ -29,4 +30,9 @@ private void injectConstructor(Thread serverThread, LevelStorage.Session session WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo ci) { LifecyclePlatform.setServer((MinecraftServer) (Object) this); } + + @Inject(method = "shutdown()V", at = @At("RETURN")) + private void injectShutdown(CallbackInfo ci) { + initialized = false; + } } diff --git a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/RegistryLoaderMixin.java b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/RegistryLoaderMixin.java index b1ff48396..739c084f3 100644 --- a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/RegistryLoaderMixin.java +++ b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/mixin/lifecycle/RegistryLoaderMixin.java @@ -28,10 +28,12 @@ import com.dfsek.terra.lifecycle.util.LifecycleUtil; import com.dfsek.terra.lifecycle.util.RegistryHack; +import static com.dfsek.terra.lifecycle.util.LifecycleUtil.initialized; + @Mixin(RegistryLoader.class) public class RegistryLoaderMixin { - private static boolean initialized = false; + @Shadow @Final private static Logger LOGGER; diff --git a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/util/LifecycleUtil.java b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/util/LifecycleUtil.java index a251bedbd..28346a6eb 100644 --- a/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/util/LifecycleUtil.java +++ b/platforms/mixin-lifecycle/src/main/java/com/dfsek/terra/lifecycle/util/LifecycleUtil.java @@ -12,6 +12,7 @@ public final class LifecycleUtil { + public static boolean initialized = false; private LifecycleUtil() { }