@Override public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName) { byte[] allData = Bytes.concat(partials); GameData.initializeServerGate(1); try { NBTTagCompound serverList = CompressedStreamTools.func_74792_a(allData); NBTTagList list = serverList.func_74761_m("List"); Set<ItemData> itemData = GameData.buildWorldItemData(list); GameData.validateWorldSave(itemData); MapDifference<Integer, ItemData> serverDifference = GameData.gateWorldLoadingForValidation(); if (serverDifference!=null) { FMLCommonHandler.instance().disconnectIDMismatch(serverDifference, netHandler, network); } } catch (IOException e) { } }
@Override public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName) { byte[] allData = Bytes.concat(partials); GameData.initializeServerGate(1); try { NBTTagCompound serverList = CompressedStreamTools.decompress(allData); NBTTagList list = serverList.getTagList("List"); Set<ItemData> itemData = GameData.buildWorldItemData(list); GameData.validateWorldSave(itemData); MapDifference<Integer, ItemData> serverDifference = GameData.gateWorldLoadingForValidation(); if (serverDifference!=null) { FMLCommonHandler.instance().disconnectIDMismatch(serverDifference, netHandler, network); } } catch (IOException e) { } }
/** * Dump ore dictionary */ public static void dumpOreDict() { Map<Integer, ItemData> idMap = ReflectionHelper.getPrivateValue(GameData.class, null, "idMap"); List<String> oreNames = Arrays.asList(OreDictionary.getOreNames()); Collections.sort(oreNames); for (String oreName : oreNames) { StringBuffer sb = new StringBuffer(); sb.append("ore: " + oreName + ": "); ArrayList<ItemStack> oreItems = OreDictionary.getOres(oreName); for (ItemStack oreItem : oreItems) { ItemData itemData = idMap.get(oreItem.itemID); String modID = itemData.getModId(); sb.append(oreItem.itemID + ":" + oreItem.getItemDamage() + "=" + modID + ", "); } System.out.println(sb); } }
public static void buildmodIdItemIdHashMap() { NBTTagList itemDataList = new NBTTagList(); GameData.writeItemData(itemDataList); for (int i = 0; i < itemDataList.tagCount(); i++) { ItemData data = new ItemData((NBTTagCompound) itemDataList.tagAt(i)); modIdItemIdMapping.put(data.getItemId(), data.getModId()); } }
@Override public void disconnectIDMismatch(MapDifference<Integer, ItemData> s, NetHandler toKill, INetworkManager mgr) { boolean criticalMismatch = !s.entriesOnlyOnLeft().isEmpty(); for (Entry<Integer, ValueDifference<ItemData>> mismatch : s.entriesDiffering().entrySet()) { ValueDifference<ItemData> vd = mismatch.getValue(); if (!vd.leftValue().mayDifferByOrdinal(vd.rightValue())) { criticalMismatch = true; } } if (!criticalMismatch) { // We'll carry on with this connection, and just log a message instead return; } // Nuke the connection ((NetClientHandler)toKill).func_72553_e(); // Stop GuiConnecting GuiConnecting.forceTermination((GuiConnecting)client.field_71462_r); // pulse the network manager queue to clear cruft mgr.func_74428_b(); // Nuke the world client client.func_71403_a((WorldClient)null); // Show error screen warnIDMismatch(s, false); }
@Override public void disconnectIDMismatch(MapDifference<Integer, ItemData> s, NetHandler toKill, INetworkManager mgr) { boolean criticalMismatch = !s.entriesOnlyOnLeft().isEmpty(); for (Entry<Integer, ValueDifference<ItemData>> mismatch : s.entriesDiffering().entrySet()) { ValueDifference<ItemData> vd = mismatch.getValue(); if (!vd.leftValue().mayDifferByOrdinal(vd.rightValue())) { criticalMismatch = true; } } if (!criticalMismatch) { // We'll carry on with this connection, and just log a message instead return; } // Nuke the connection ((NetClientHandler)toKill).disconnect(); // Stop GuiConnecting GuiConnecting.forceTermination((GuiConnecting)client.currentScreen); // pulse the network manager queue to clear cruft mgr.processReadPackets(); // Nuke the world client client.loadWorld((WorldClient)null); // Show error screen warnIDMismatch(s, false); }
/** * Arguments: World foldername, World ingame name, WorldSettings */ public void launchIntegratedServer(String par1Str, String par2Str, WorldSettings par3WorldSettings) { this.loadWorld((WorldClient)null); System.gc(); ISaveHandler isavehandler = this.saveLoader.getSaveLoader(par1Str, false); WorldInfo worldinfo = isavehandler.loadWorldInfo(); if (worldinfo == null && par3WorldSettings != null) { worldinfo = new WorldInfo(par3WorldSettings, par1Str); isavehandler.saveWorldInfo(worldinfo); } if (par3WorldSettings == null) { par3WorldSettings = new WorldSettings(worldinfo); } this.statFileWriter.readStat(StatList.startGameStat, 1); GameData.initializeServerGate(2); this.theIntegratedServer = new IntegratedServer(this, par1Str, par2Str, par3WorldSettings); this.theIntegratedServer.startServerThread(); MapDifference<Integer, ItemData> idDifferences = GameData.gateWorldLoadingForValidation(); if (idDifferences!=null) { FMLClientHandler.instance().warnIDMismatch(idDifferences, true); } else { GameData.releaseGate(true); continueWorldLoading(); } }
public void warnIDMismatch(MapDifference<Integer, ItemData> idDifferences, boolean mayContinue) { GuiIdMismatchScreen mismatch = new GuiIdMismatchScreen(idDifferences, mayContinue); client.func_71373_a(mismatch); }
@Override public void disconnectIDMismatch(MapDifference<Integer, ItemData> s, NetHandler handler, INetworkManager mgr) { }
public void disconnectIDMismatch(MapDifference<Integer, ItemData> serverDifference, NetHandler toKill, INetworkManager network) { sidedDelegate.disconnectIDMismatch(serverDifference, toKill, network); }
public void warnIDMismatch(MapDifference<Integer, ItemData> idDifferences, boolean mayContinue) { GuiIdMismatchScreen mismatch = new GuiIdMismatchScreen(idDifferences, mayContinue); client.displayGuiScreen(mismatch); }
void disconnectIDMismatch(MapDifference<Integer, ItemData> s, NetHandler toKill, INetworkManager mgr);