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.RenderType;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.event.config.ModConfigEvent;
|
||||
|
|
@ -53,6 +55,8 @@ public class ClientHandler {
|
|||
// 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 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) {
|
||||
var fmlBus = NeoForge.EVENT_BUS;
|
||||
|
|
@ -136,8 +140,18 @@ public class ClientHandler {
|
|||
// Sets Ex Deorum world type as default
|
||||
private static void onScreenOpen(ScreenEvent.Opening event) {
|
||||
if (event.getNewScreen() instanceof CreateWorldScreen screen && EConfig.COMMON.setVoidWorldAsDefault.get()) {
|
||||
var ctx = screen.getUiState().getSettings();
|
||||
screen.getUiState().setWorldType(new WorldCreationUiState.WorldTypeEntry(ctx.worldgenLoadContext().registryOrThrow(Registries.WORLD_PRESET).getHolder(ASMHooks.overrideDefaultWorldPreset()).orElse(null)));
|
||||
var uiState = screen.getUiState();
|
||||
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