Add integration for SkyBlock Builder

This commit is contained in:
thedarkcolour 2024-04-22 14:34:38 -07:00
parent b3540cdb80
commit d0d4ccf77a
No known key found for this signature in database
GPG Key ID: 86B37B3575FD5976
3 changed files with 10 additions and 2 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.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<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

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

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