Fix overriding Superflat world type
This commit is contained in:
parent
a02e7c4bc6
commit
6d7245b8ee
|
|
@ -26,9 +26,11 @@ import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
|
||||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import net.minecraft.client.renderer.ShaderInstance;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Unit;
|
import net.minecraft.util.Unit;
|
||||||
|
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.neoforged.fml.ModList;
|
import net.neoforged.fml.ModList;
|
||||||
import net.neoforged.fml.event.config.ModConfigEvent;
|
import net.neoforged.fml.event.config.ModConfigEvent;
|
||||||
|
|
@ -53,6 +55,8 @@ public class ClientHandler {
|
||||||
// Used for the composting recipe category in JEI
|
// Used for the composting recipe category in JEI
|
||||||
public static final ResourceLocation OAK_BARREL_COMPOSTING = new ResourceLocation(ExDeorum.ID, "item/oak_barrel_composting");
|
public static final ResourceLocation OAK_BARREL_COMPOSTING = new ResourceLocation(ExDeorum.ID, "item/oak_barrel_composting");
|
||||||
public static boolean isInVoidWorld;
|
public static boolean isInVoidWorld;
|
||||||
|
// This is used to prevent Ex Deorum from resetting world type when trying to configure Superflat, Single Biome, etc.
|
||||||
|
public static Holder<WorldPreset> originalDefaultWorldPreset;
|
||||||
|
|
||||||
public static void register(IEventBus modBus) {
|
public static void register(IEventBus modBus) {
|
||||||
var fmlBus = NeoForge.EVENT_BUS;
|
var fmlBus = NeoForge.EVENT_BUS;
|
||||||
|
|
@ -136,8 +140,18 @@ public class ClientHandler {
|
||||||
// Sets Ex Deorum world type as default
|
// Sets Ex Deorum world type as default
|
||||||
private static void onScreenOpen(ScreenEvent.Opening event) {
|
private static void onScreenOpen(ScreenEvent.Opening event) {
|
||||||
if (event.getNewScreen() instanceof CreateWorldScreen screen && EConfig.COMMON.setVoidWorldAsDefault.get()) {
|
if (event.getNewScreen() instanceof CreateWorldScreen screen && EConfig.COMMON.setVoidWorldAsDefault.get()) {
|
||||||
var ctx = screen.getUiState().getSettings();
|
var uiState = screen.getUiState();
|
||||||
screen.getUiState().setWorldType(new WorldCreationUiState.WorldTypeEntry(ctx.worldgenLoadContext().registryOrThrow(Registries.WORLD_PRESET).getHolder(ASMHooks.overrideDefaultWorldPreset()).orElse(null)));
|
var originalPreset = uiState.getWorldType().preset();
|
||||||
|
|
||||||
|
if (originalPreset != null) {
|
||||||
|
if (originalDefaultWorldPreset == null) {
|
||||||
|
originalDefaultWorldPreset = originalPreset;
|
||||||
|
}
|
||||||
|
if (originalDefaultWorldPreset.unwrapKey().equals(originalPreset.unwrapKey())) {
|
||||||
|
var voidWorldPreset = uiState.getSettings().worldgenLoadContext().registryOrThrow(Registries.WORLD_PRESET).getHolder(ASMHooks.overrideDefaultWorldPreset()).orElse(null);
|
||||||
|
uiState.setWorldType(new WorldCreationUiState.WorldTypeEntry(voidWorldPreset));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user