From d0d4ccf77a32674218f00f0421dda0ad25cf3679 Mon Sep 17 00:00:00 2001 From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:34:38 -0700 Subject: [PATCH] Add integration for SkyBlock Builder --- src/main/java/thedarkcolour/exdeorum/asm/ASMHooks.java | 7 +++++++ .../java/thedarkcolour/exdeorum/client/ClientHandler.java | 4 ++-- src/main/java/thedarkcolour/exdeorum/compat/ModIds.java | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/thedarkcolour/exdeorum/asm/ASMHooks.java b/src/main/java/thedarkcolour/exdeorum/asm/ASMHooks.java index 00bf154b..558dca99 100644 --- a/src/main/java/thedarkcolour/exdeorum/asm/ASMHooks.java +++ b/src/main/java/thedarkcolour/exdeorum/asm/ASMHooks.java @@ -19,10 +19,14 @@ package thedarkcolour.exdeorum.asm; import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPresets; import net.minecraft.world.level.levelgen.structure.Structure; +import net.neoforged.fml.ModList; +import thedarkcolour.exdeorum.compat.ModIds; import thedarkcolour.exdeorum.config.EConfig; import thedarkcolour.exdeorum.registry.EWorldPresets; import thedarkcolour.exdeorum.voidworld.VoidChunkGenerator; @@ -62,6 +66,9 @@ public final class ASMHooks { * where {@code WorldPresets.NORMAL} is used in the line that looks like {@code WorldPresets.NORMAL.location().toString()} */ public static ResourceKey overrideDefaultWorldPreset() { + if (ModList.get().isLoaded(ModIds.SKYBLOCK_BUILDER)) { + return ResourceKey.create(Registries.WORLD_PRESET, new ResourceLocation(ModIds.SKYBLOCK_BUILDER, "skyblock")); + } return EConfig.COMMON.setVoidWorldAsDefault.get() ? EWorldPresets.VOID_WORLD : WorldPresets.NORMAL; } } diff --git a/src/main/java/thedarkcolour/exdeorum/client/ClientHandler.java b/src/main/java/thedarkcolour/exdeorum/client/ClientHandler.java index f4cd58e8..63b06da6 100644 --- a/src/main/java/thedarkcolour/exdeorum/client/ClientHandler.java +++ b/src/main/java/thedarkcolour/exdeorum/client/ClientHandler.java @@ -36,6 +36,7 @@ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; import net.neoforged.neoforge.client.event.*; import net.neoforged.neoforge.common.NeoForge; import thedarkcolour.exdeorum.ExDeorum; +import thedarkcolour.exdeorum.asm.ASMHooks; import thedarkcolour.exdeorum.client.screen.MechanicalHammerScreen; import thedarkcolour.exdeorum.client.screen.MechanicalSieveScreen; import thedarkcolour.exdeorum.client.ter.*; @@ -45,7 +46,6 @@ import thedarkcolour.exdeorum.recipe.RecipeUtil; import thedarkcolour.exdeorum.registry.EBlockEntities; import thedarkcolour.exdeorum.registry.EFluids; import thedarkcolour.exdeorum.registry.EMenus; -import thedarkcolour.exdeorum.registry.EWorldPresets; import java.io.IOException; @@ -138,7 +138,7 @@ public class ClientHandler { if (EConfig.CLIENT.setVoidWorldAsDefault.get() && EConfig.COMMON.setVoidWorldAsDefault.get()) { if (event.getNewScreen() instanceof CreateWorldScreen screen) { var ctx = screen.getUiState().getSettings(); - screen.getUiState().setWorldType(new WorldCreationUiState.WorldTypeEntry(ctx.worldgenLoadContext().registryOrThrow(Registries.WORLD_PRESET).getHolder(EWorldPresets.VOID_WORLD).orElse(null))); + screen.getUiState().setWorldType(new WorldCreationUiState.WorldTypeEntry(ctx.worldgenLoadContext().registryOrThrow(Registries.WORLD_PRESET).getHolder(ASMHooks.overrideDefaultWorldPreset()).orElse(null))); } } } diff --git a/src/main/java/thedarkcolour/exdeorum/compat/ModIds.java b/src/main/java/thedarkcolour/exdeorum/compat/ModIds.java index daab1e8b..694b3b4b 100644 --- a/src/main/java/thedarkcolour/exdeorum/compat/ModIds.java +++ b/src/main/java/thedarkcolour/exdeorum/compat/ModIds.java @@ -48,4 +48,5 @@ public class ModIds { public static final String INVENTORY_SORTER = "inventorysorter"; public static final String REI_PC = "rei_plugin_compatibilities"; public static final String CYCLIC = "cyclic"; + public static final String SKYBLOCK_BUILDER = "skyblockbuilder"; }