mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Dimension't
- Remove code trying to restore from .dat_old, not entirely worth it
This commit is contained in:
parent
42fd2826d7
commit
669435e849
2 changed files with 0 additions and 51 deletions
|
@ -1,50 +0,0 @@
|
|||
package com.simibubi.create.foundation.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import com.simibubi.create.Create;
|
||||
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.saveddata.SavedData;
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(DimensionDataStorage.class)
|
||||
public abstract class DimensionDataStorageMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private File dataFolder;
|
||||
|
||||
@Shadow
|
||||
public abstract CompoundTag readTagFromDisk(String pName, int pLevelVersion) throws IOException;
|
||||
|
||||
@ModifyReturnValue(method = "readSavedData", at = @At(value = "TAIL"))
|
||||
private <T extends SavedData> T create$tryLoadingFromDatOldIfFailedToLoad(T original, Function<CompoundTag, T> loadFunction, String name) {
|
||||
// Try loading old data if it's create's SavedData
|
||||
if (original == null && name.startsWith("create_")) {
|
||||
try {
|
||||
File currentFile = new File(dataFolder, name + ".dat");
|
||||
File oldFile = new File(dataFolder, name + ".dat_old");
|
||||
if (currentFile.exists() && oldFile.exists()) {
|
||||
Create.LOGGER.warn("Trying to restore {}.dat from {}.dat_old", name, name);
|
||||
CompoundTag compoundtag = readTagFromDisk(name, SharedConstants.getCurrentVersion().getDataVersion().getVersion());
|
||||
return loadFunction.apply(compoundtag.getCompound("data"));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Create.LOGGER.error("Error restoring from old saved data: {}", name, exception);
|
||||
}
|
||||
} else {
|
||||
return original;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
"ClientboundMapItemDataPacketMixin",
|
||||
"ContraptionDriverInteractMixin",
|
||||
"CustomItemUseEffectsMixin",
|
||||
"DimensionDataStorageMixin",
|
||||
"EntityMixin",
|
||||
"LavaSwimmingMixin",
|
||||
"MainMixin",
|
||||
|
|
Loading…
Add table
Reference in a new issue