ZotCoreLoader

- исправлено получение runtimeId для BlockState
- исправлено не правильное определение id для блоков из дампа иннера
This commit is contained in:
Reider745
2023-11-23 20:06:16 +03:00
parent 12b5c9b3fb
commit 180abd1c77
2 changed files with 5 additions and 9 deletions
@@ -79,23 +79,19 @@ public class GlobalBlockPalette implements HookClass {
for (Object elem : json) { for (Object elem : json) {
final JSONObject e = (JSONObject) elem; final JSONObject e = (JSONObject) elem;
//BlockStateRegistry.registerState(e); final int legacyId = e.getInt("newId");
if(e.toString().split("null").length != 1)
throw new RuntimeException("Пиздуй ищи причину null в дампе!\n"+e);
final int legacyId = e.getInt("oldId");
final int legacyData = e.getInt("data"); final int legacyData = e.getInt("data");
final JSONObject states = e.getJSONObject("states");
if(legacyId > 8000) if(legacyId > 8000)
throw new IOException("Ты чё еблан? Какова хуя в дампе блок с id "+legacyId); throw new IOException("Ты чё еблан? Какова хуя в дампе блок с id "+legacyId);
final long hash = computeStateHash(e.getInt("newId"), e.getJSONObject("states"), stateIdByName); final long hash = computeStateHash(legacyId, states, stateIdByName);
if (stateHashToLegacyIdData.containsKey(hash)) if (stateHashToLegacyIdData.containsKey(hash))
throw new RuntimeException("hash collision: " + hash + " "+e); throw new RuntimeException("hash collision: " + hash + " "+e);
debug_hash.put(hash, e); debug_hash.put(hash, e);
BlockStateRegisters.addState(hash, e.getJSONObject("states")); BlockStateRegisters.addState(hash, states);
// log.info(e.getString("nameId") + legacyId + ":" + legacyData + " -> " + hash);
stateHashToLegacyIdData.put(hash, (legacyId << 16) | legacyData); stateHashToLegacyIdData.put(hash, (legacyId << 16) | legacyData);
} }
}catch (Exception e){ }catch (Exception e){
@@ -39,7 +39,7 @@ public class BlockState {
this.data = meta.getDamage(); this.data = meta.getDamage();
}else }else
this.data = 0; this.data = 0;
this.runtimeId = GlobalBlockPalette.getOrCreateRuntimeId(id, data); this.runtimeId = GlobalBlockPalette.getOrCreateRuntimeId(InnerCoreServer.PROTOCOL, id, data);
} }
public BlockState(int id, Map<?, Integer> map) { public BlockState(int id, Map<?, Integer> map) {