예제 #1
0
        private void blockIDShiftNum_ValueChanged(object sender, EventArgs e)
        {
            selectedModInfo.BlockIDShiftNum = (int)blockIDShiftNum.Value;
            if (!CheckConflictID(selectedModInfo, new List <string>(modList.Items.OfType <string>()), fNbt.NbtQuery.Get <fNbt.NbtList>(levelNbt.RootTag, "//FML/ItemData")))         //(fNbt.NbtList)levelNbt.RootTag["FML"]["ItemData"]))
            {
                blockIDShiftNum.Value++;
            }

            useBlockIDText.Text = selectedModInfo.GetBlockNumberIDListString();
            useItemIDText.Text  = selectedModInfo.GetItemNumberIDListString();

            updateLevelDatButton.Enabled = true;
        }
예제 #2
0
        private void UpdateModInfo(string modId)
        {
            if (string.IsNullOrWhiteSpace(modId) || levelNbt == null)
            {
                return;
            }

            idMisalignmentFixButton.Visible = false;
            updateLevelDatButton.Enabled    = false;

            try
            {
                selectedModInfo = new ModInfo(modId, fNbt.NbtQuery.Get <fNbt.NbtList>(levelNbt.RootTag, "//FML/ItemData"));               //(fNbt.NbtList)levelNbt.RootTag["FML"]["ItemData"]);
            }
            catch (KeyNotFoundException)
            {
                MessageBox.Show("1.7より前のバージョンのlevel.datを読み込んだ可能性があります。");

                inputPath.Text = "";
                return;
            }
            useIDText_TextChanged(useBlockIDText, null);
            useBlockIDText.Text = selectedModInfo.GetBlockNumberIDListString();
            useIDText_TextChanged(useItemIDText, null);
            useItemIDText.Text = selectedModInfo.GetItemNumberIDListString();

            ModInfo allInfo = new ModInfo("", fNbt.NbtQuery.Get <fNbt.NbtList>(levelNbt.RootTag, "//FML/ItemData"));           //(fNbt.NbtList)levelNbt.RootTag["FML"]["ItemData"]);

            // ブロックIDのずらせる範囲を簡易調整
            blockIDShiftNum.Value = 0;
            if (selectedModInfo.BlockIDs.Count > 0)
            {
                blockIDShiftNum.Maximum = 4095 - selectedModInfo.GetBlockNumberIDList().Max();
            }
            else
            {
                blockIDShiftNum.Maximum = 0;
            }
            List <int> allBlockNumID = allInfo.BlockIDs.Values.ToList();

            allBlockNumID.Sort();
            if (selectedModInfo.BlockIDs.Count > 0)
            {
                blockIDShiftNum.Minimum = allBlockNumID[allBlockNumID.IndexOf(selectedModInfo.GetBlockNumberIDList().Min()) - 1] - allBlockNumID[allBlockNumID.IndexOf(selectedModInfo.GetBlockNumberIDList().Min())] + 1;
            }
            else
            {
                blockIDShiftNum.Minimum = 0;
            }

            // アイテムIDのずらせる範囲を簡易調整
            itemIDShiftNum.Value = 0;
            if (selectedModInfo.ItemIDs.Count > 0)
            {
                itemIDShiftNum.Minimum = 4096 - selectedModInfo.GetItemNumberIDList().Min((a) =>
                {
                    // ブロックIDに含まれている物と4096未満のアイテムIDを最小値計算に利用しない(バグ有り処理)
                    if (selectedModInfo.BlockIDs.Values.Contains(a) || a < 4096)
                    {
                        return(32000);
                    }
                    else
                    {
                        return(a);
                    }
                });
                itemIDShiftNum.Maximum = 32000 - selectedModInfo.GetItemNumberIDList().Max();
            }
            else
            {
                itemIDShiftNum.Minimum = itemIDShiftNum.Maximum = 0;
            }

            foreach (var checkID in selectedModInfo.GetBlockAndItemIDList())
            {
                if (checkID.Value[0] != checkID.Value[1])
                {
                    if (!idMisalignmentFixButton.Visible)
                    {
                        MessageBox.Show("ブロックIDとアイテムIDの不一致を検出しました。\n簡易修正機能を有効化します。");
                    }
                    idMisalignmentFixButton.Enabled = true;
                    idMisalignmentFixButton.Visible = true;

                    System.Diagnostics.Trace.WriteLine("[IDMisalignment-Checker] " + checkID.Key + " = B:" + checkID.Value[0] + ", I:" + checkID.Value[1]);
                }
            }

            return;
        }