[Fix] World Recreation crashes for worlds with betterx customizations
This commit is contained in:
parent
c680b19655
commit
15fbf88147
2 changed files with 14 additions and 6 deletions
|
@ -28,6 +28,9 @@ public abstract class CreateWorldScreen_Mixin {
|
|||
@Shadow
|
||||
public abstract WorldCreationUiState getUiState();
|
||||
|
||||
@Shadow
|
||||
private boolean recreated;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void wt_init(
|
||||
Minecraft minecraft,
|
||||
|
@ -50,6 +53,6 @@ public abstract class CreateWorldScreen_Mixin {
|
|||
@Inject(method = "createNewWorldDirectory", at = @At("RETURN"))
|
||||
void wt_createNewWorld(CallbackInfoReturnable<Optional<LevelStorageSource.LevelStorageAccess>> cir) {
|
||||
WorldBootstrap.InGUI.registryReadyOnNewWorld(this.getUiState().getSettings());
|
||||
WorldBootstrap.InGUI.setupNewWorld(cir.getReturnValue(), this.getUiState());
|
||||
WorldBootstrap.InGUI.setupNewWorld(cir.getReturnValue(), this.getUiState(), this.recreated);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,8 @@ public class WorldBootstrap {
|
|||
|
||||
public static void setupNewWorld(
|
||||
Optional<LevelStorageSource.LevelStorageAccess> levelStorageAccess,
|
||||
WorldCreationUiState uiState
|
||||
WorldCreationUiState uiState,
|
||||
boolean recreated
|
||||
) {
|
||||
|
||||
if (levelStorageAccess.isPresent()) {
|
||||
|
@ -172,7 +173,8 @@ public class WorldBootstrap {
|
|||
Holder<WorldPreset> newPreset = setupNewWorldCommon(
|
||||
levelStorageAccess.get(),
|
||||
currentPreset,
|
||||
uiState.getSettings().selectedDimensions()
|
||||
uiState.getSettings().selectedDimensions(),
|
||||
recreated
|
||||
);
|
||||
if (newPreset != null && newPreset != currentPreset) {
|
||||
uiState.setWorldType(new WorldCreationUiState.WorldTypeEntry(newPreset));
|
||||
|
@ -186,11 +188,14 @@ public class WorldBootstrap {
|
|||
static Holder<WorldPreset> setupNewWorldCommon(
|
||||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
Holder<WorldPreset> currentPreset,
|
||||
WorldDimensions worldDims
|
||||
WorldDimensions worldDims,
|
||||
boolean recreated
|
||||
) {
|
||||
final WorldDimensions dimensions;
|
||||
if (currentPreset.value() instanceof TogetherWorldPreset t) {
|
||||
if (currentPreset != null && currentPreset.value() instanceof TogetherWorldPreset t) {
|
||||
dimensions = t.getWorldDimensions();
|
||||
} else if (recreated) {
|
||||
dimensions = worldDims;
|
||||
} else {
|
||||
dimensions = TogetherWorldPreset.getWorldDimensions(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);
|
||||
}
|
||||
|
@ -250,7 +255,7 @@ public class WorldBootstrap {
|
|||
) {
|
||||
try {
|
||||
var levelStorageAccess = levelSource.createAccess(levelID);
|
||||
InGUI.setupNewWorldCommon(levelStorageAccess, worldPreset, worldDims);
|
||||
InGUI.setupNewWorldCommon(levelStorageAccess, worldPreset, worldDims, false);
|
||||
levelStorageAccess.close();
|
||||
} catch (Exception e) {
|
||||
WorldsTogether.LOGGER.error("Failed to initialize data in world", e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue