Fix crash on dedicated server
This commit is contained in:
parent
87b644834f
commit
9ebeec6fc2
|
|
@ -1,5 +1,7 @@
|
|||
package org.embeddedt.modernfix.duck;
|
||||
|
||||
import net.minecraft.world.storage.SaveFormat;
|
||||
|
||||
public interface ILevelSave {
|
||||
public void runWorldPersistenceHooks();
|
||||
public void runWorldPersistenceHooks(SaveFormat format);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@ import java.nio.file.Path;
|
|||
public class LevelSaveMixin implements ILevelSave {
|
||||
@Shadow @Final private Path levelPath;
|
||||
|
||||
public void runWorldPersistenceHooks() {
|
||||
SaveFormat saveFormat = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getInstance(), "field_71469_aa");
|
||||
((SaveFormatAccessor)saveFormat).invokeReadLevelData(this.levelPath.toFile(), (file, dataFixer) -> {
|
||||
public void runWorldPersistenceHooks(SaveFormat format) {
|
||||
((SaveFormatAccessor)format).invokeReadLevelData(this.levelPath.toFile(), (file, dataFixer) -> {
|
||||
try {
|
||||
CompoundNBT compoundTag = CompressedStreamTools.readCompressed(file);
|
||||
net.minecraftforge.fml.WorldPersistenceHooks.handleWorldDataLoad((SaveFormat.LevelSave)(Object)this, new DummyServerConfiguration(), compoundTag);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.storage.SaveFormat;
|
|||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.embeddedt.modernfix.ModernFixClient;
|
||||
import org.embeddedt.modernfix.duck.ILevelSave;
|
||||
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;
|
||||
|
|
@ -25,6 +26,8 @@ import java.util.function.Function;
|
|||
public abstract class MinecraftMixin {
|
||||
@Shadow public abstract Minecraft.PackManager makeServerStem(DynamicRegistries.Impl dynamicRegistries, Function<SaveFormat.LevelSave, DatapackCodec> worldStorageToDatapackFunction, Function4<SaveFormat.LevelSave, DynamicRegistries.Impl, IResourceManager, DatapackCodec, IServerConfiguration> quadFunction, boolean vanillaOnly, SaveFormat.LevelSave worldStorage) throws InterruptedException, ExecutionException;
|
||||
|
||||
@Shadow @Final private SaveFormat levelSource;
|
||||
|
||||
@Redirect(method = "loadLevel(Ljava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/DynamicRegistries;builtin()Lnet/minecraft/util/registry/DynamicRegistries$Impl;"))
|
||||
private DynamicRegistries.Impl useNullRegistry() {
|
||||
return null;
|
||||
|
|
@ -35,7 +38,7 @@ public abstract class MinecraftMixin {
|
|||
if(!creating) {
|
||||
ModernFix.LOGGER.warn("Skipping first reload, this is still experimental");
|
||||
ModernFix.runningFirstInjection = true;
|
||||
((ILevelSave)levelSave).runWorldPersistenceHooks();
|
||||
((ILevelSave)levelSave).runWorldPersistenceHooks(levelSource);
|
||||
ModernFix.runningFirstInjection = false;
|
||||
return null;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user