parent
f94adc9225
commit
6fbe0146c2
@ -9,4 +9,9 @@ import java.io.IOException;
|
|||||||
public interface SaveFormatBridge {
|
public interface SaveFormatBridge {
|
||||||
|
|
||||||
SaveFormat.LevelSave bridge$getLevelSave(String saveName, RegistryKey<Dimension> world) throws IOException;
|
SaveFormat.LevelSave bridge$getLevelSave(String saveName, RegistryKey<Dimension> world) throws IOException;
|
||||||
|
|
||||||
|
interface LevelSaveBridge {
|
||||||
|
|
||||||
|
void bridge$setDimType(RegistryKey<Dimension> typeKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,6 +71,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -415,6 +416,7 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
|
|||||||
if (!((WorldBridge) serverWorld).bridge$getWorld().getKeepSpawnInMemory()) {
|
if (!((WorldBridge) serverWorld).bridge$getWorld().getKeepSpawnInMemory()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.forceTicks = true;
|
||||||
LOGGER.info("Preparing start region for dimension {}", serverWorld.getDimensionKey().getLocation());
|
LOGGER.info("Preparing start region for dimension {}", serverWorld.getDimensionKey().getLocation());
|
||||||
BlockPos blockpos = serverWorld.getSpawnPoint();
|
BlockPos blockpos = serverWorld.getSpawnPoint();
|
||||||
listener.start(new ChunkPos(blockpos));
|
listener.start(new ChunkPos(blockpos));
|
||||||
@ -453,6 +455,11 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
|
|||||||
this.bridge$drainQueuedTasks();
|
this.bridge$drainQueuedTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "save", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;func_241755_D_()Lnet/minecraft/world/server/ServerWorld;"))
|
||||||
|
private void arclight$skipSave(boolean suppressLog, boolean flush, boolean forced, CallbackInfoReturnable<Boolean> cir, boolean flag) {
|
||||||
|
cir.setReturnValue(flag);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author IzzelAliz
|
* @author IzzelAliz
|
||||||
* @reason our branding, no one should fuck this up
|
* @reason our branding, no one should fuck this up
|
||||||
|
|||||||
@ -216,10 +216,17 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "save", at = @At(value = "JUMP", ordinal = 0, opcode = Opcodes.IFNULL))
|
@Inject(method = "save", at = @At(value = "JUMP", ordinal = 0, opcode = Opcodes.IFNULL))
|
||||||
public void arclight$worldSave(IProgressUpdate progress, boolean flush, boolean skipSave, CallbackInfo ci) {
|
private void arclight$worldSaveEvent(IProgressUpdate progress, boolean flush, boolean skipSave, CallbackInfo ci) {
|
||||||
Bukkit.getPluginManager().callEvent(new WorldSaveEvent(bridge$getWorld()));
|
Bukkit.getPluginManager().callEvent(new WorldSaveEvent(bridge$getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "save", at = @At("RETURN"))
|
||||||
|
private void arclight$saveLevelDat(IProgressUpdate progress, boolean flush, boolean skipSave, CallbackInfo ci) {
|
||||||
|
this.$$worldDataServer.setWorldBorderSerializer(this.getWorldBorder().getSerializer());
|
||||||
|
this.$$worldDataServer.setCustomBossEventData(this.shadow$getServer().getCustomBossEvents().write());
|
||||||
|
this.convertable.saveLevel(this.shadow$getServer().field_240767_f_, this.$$worldDataServer, this.shadow$getServer().getPlayerList().getHostPlayerData());
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "onChunkUnloading", at = @At("HEAD"))
|
@Inject(method = "onChunkUnloading", at = @At("HEAD"))
|
||||||
public void arclight$closeOnChunkUnloading(Chunk chunkIn, CallbackInfo ci) {
|
public void arclight$closeOnChunkUnloading(Chunk chunkIn, CallbackInfo ci) {
|
||||||
for (TileEntity tileentity : chunkIn.getTileEntityMap().values()) {
|
for (TileEntity tileentity : chunkIn.getTileEntityMap().values()) {
|
||||||
|
|||||||
@ -17,7 +17,9 @@ public abstract class SaveFormatMixin implements SaveFormatBridge {
|
|||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
public SaveFormat.LevelSave getLevelSave(String saveName, RegistryKey<Dimension> world) throws IOException {
|
public SaveFormat.LevelSave getLevelSave(String saveName, RegistryKey<Dimension> world) throws IOException {
|
||||||
return getLevelSave(saveName);
|
SaveFormat.LevelSave save = getLevelSave(saveName);
|
||||||
|
((LevelSaveBridge) save).bridge$setDimType(world);
|
||||||
|
return save;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock
|
// mock
|
||||||
|
|||||||
@ -0,0 +1,40 @@
|
|||||||
|
package io.izzel.arclight.common.mixin.core.world.storage;
|
||||||
|
|
||||||
|
import io.izzel.arclight.common.bridge.world.storage.SaveFormatBridge;
|
||||||
|
import net.minecraft.util.RegistryKey;
|
||||||
|
import net.minecraft.world.Dimension;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.storage.SaveFormat;
|
||||||
|
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 org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
@Mixin(SaveFormat.LevelSave.class)
|
||||||
|
public class SaveFormat_LevelSaveMixin implements SaveFormatBridge.LevelSaveBridge {
|
||||||
|
|
||||||
|
@Shadow @Final public Path saveDir;
|
||||||
|
|
||||||
|
private RegistryKey<Dimension> dimensionType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bridge$setDimType(RegistryKey<Dimension> typeKey) {
|
||||||
|
this.dimensionType = typeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "getDimensionFolder", cancellable = true, at = @At("HEAD"))
|
||||||
|
private void arclight$useActualType(RegistryKey<World> dimensionKey, CallbackInfoReturnable<File> cir) {
|
||||||
|
if (dimensionType == Dimension.OVERWORLD) {
|
||||||
|
cir.setReturnValue(this.saveDir.toFile());
|
||||||
|
} else if (dimensionType == Dimension.THE_NETHER) {
|
||||||
|
cir.setReturnValue(new File(this.saveDir.toFile(), "DIM-1"));
|
||||||
|
} else if (dimensionType == Dimension.THE_END) {
|
||||||
|
cir.setReturnValue(new File(this.saveDir.toFile(), "DIM1"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -432,6 +432,7 @@
|
|||||||
"world.storage.MapData_MapInfoMixin",
|
"world.storage.MapData_MapInfoMixin",
|
||||||
"world.storage.MapDataMixin",
|
"world.storage.MapDataMixin",
|
||||||
"world.storage.PlayerDataMixin",
|
"world.storage.PlayerDataMixin",
|
||||||
|
"world.storage.SaveFormat_LevelSaveMixin",
|
||||||
"world.storage.SaveFormatMixin",
|
"world.storage.SaveFormatMixin",
|
||||||
"world.storage.ServerWorldInfoMixin"
|
"world.storage.ServerWorldInfoMixin"
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user