ZotCoreLoader

- исправлено сохранение
This commit is contained in:
Reider745
2023-11-18 15:06:30 +03:00
parent 30eaa475e3
commit 58e0b6db5f
4 changed files with 12 additions and 4 deletions
@@ -3,6 +3,7 @@ package com.reider745.hooks;
import android.util.Pair;
import cn.nukkit.Server;
import cn.nukkit.block.BlockID;
import cn.nukkit.nbt.tag.CompoundTag;
import cn.nukkit.network.protocol.ProtocolInfo;
import cn.nukkit.utils.MainLogger;
import com.google.common.io.ByteStreams;
@@ -149,6 +150,11 @@ public class GlobalBlockPalette implements HookClass {
return runtimeIdToLegacy.get(runtimeId);
}
@Inject
public static int getLegacyFullId(int protocol, CompoundTag tag){
throw new RuntimeException("use getLegacyFullId(int, CompoundTag)");
}
@Inject
public static int getOrCreateRuntimeId(int protocol, int id, int meta){
return get(id, meta);
@@ -161,7 +167,6 @@ public class GlobalBlockPalette implements HookClass {
@Inject
public static int getOrCreateRuntimeId(int legacyId){
Server.mvw("GlobalBlockPalette#getOrCreateRuntimeId(int)");
return getOrCreateRuntimeId(ProtocolInfo.CURRENT_PROTOCOL, legacyId >> 4, legacyId & 0xf);
}
@@ -8,7 +8,11 @@ import java.util.List;
public class FileUtils {
public static JSONObject readJSON(File file){
return new JSONObject(file);
try{
return new JSONObject(readFileText(file));
}catch (Exception e){
throw new RuntimeException(e.getCause().toString());
}
}
public static String readFileText(File file) throws Exception {
@@ -80,6 +80,7 @@ public class WorldDataSaver {
break;
}
}
if (json == null) {
json = readJsonWithLockCheck(worldDirectory, "moddata.json", false);
if (json == null) {
@@ -139,7 +140,6 @@ public class WorldDataSaver {
public void logError(String message, SaverState state, Throwable err) {
ICLog.e("Saver", message, err);
errorLog.add(new LoggedSavesError(message, state, err));
}
@@ -64,7 +64,6 @@ public class WorldDataScopeRegistry {
}
public void readAllScopes(JSONObject json, SavesErrorHandler errorHandler, MissingScopeHandler missingScopeHandler) {
System.out.println(json);
for (Map.Entry<String, SaverScope> entry : scopeMap.entrySet()) {
String key = entry.getKey();
Object data = json.opt(key);