Add integration for SkyBlock Builder

This commit is contained in:
thedarkcolour 2024-04-22 13:45:15 -07:00
parent 4ac1bceaf3
commit 655c1aa57f
No known key found for this signature in database
GPG Key ID: 86B37B3575FD5976
3 changed files with 13 additions and 7 deletions

View File

@ -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.minecraftforge.fml.ModList;
import thedarkcolour.exdeorum.compat.ModIds;
import thedarkcolour.exdeorum.config.EConfig;
import thedarkcolour.exdeorum.registry.EWorldPresets;
import thedarkcolour.exdeorum.voidworld.VoidChunkGenerator;
@ -61,6 +65,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<WorldPreset> 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;
}
}

View File

@ -43,6 +43,7 @@ import net.minecraftforge.fml.event.config.ModConfigEvent;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
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.*;
@ -53,7 +54,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;
@ -149,13 +149,11 @@ public class ClientHandler {
}
}
// Sets Ex Deorum world type as default
// Sets Ex Deorum world type as default, or use SkyBlock Builder if it is installed
private static void onScreenOpen(ScreenEvent.Opening event) {
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)));
}
if (event.getNewScreen() instanceof CreateWorldScreen screen) {
var ctx = screen.getUiState().getSettings();
screen.getUiState().setWorldType(new WorldCreationUiState.WorldTypeEntry(ctx.worldgenLoadContext().registryOrThrow(Registries.WORLD_PRESET).getHolder(ASMHooks.overrideDefaultWorldPreset()).orElse(null)));
}
}

View File

@ -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";
}