From bb7c413280e2c152fdae6ff188a9c08c56dd2752 Mon Sep 17 00:00:00 2001 From: GWYOG Date: Fri, 31 Mar 2017 15:15:38 +0800 Subject: Fix the weighted chance issue in Vein Stat Plungins Each world (rather than all worlds) should have its own weight chance of veins. --- .../plugin/gregtech5/PluginGT5VeinStat.java | 34 ++++++++++++++++++++-- .../plugin/gregtech6/PluginGT6VeinStat.java | 24 +++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) (limited to 'src/main/java/pers/gwyog/gtneioreplugin/plugin') diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java index 4967999870..fd9eb314ad 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java @@ -121,8 +121,8 @@ public class PluginGT5VeinStat extends PluginGT5Base { GuiDraw.drawString(I18n.format("gtnop.gui.nei.betweenOre") + ": " + getGTOreLocalizedName(oreLayer.betweenMeta), 2, 57, 0x404040, false); GuiDraw.drawString(I18n.format("gtnop.gui.nei.sporadicOre") + ": " + getGTOreLocalizedName(oreLayer.sporadicMeta), 2, 70, 0x404040, false); GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 83, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + oreLayer.weightedChance, 2, 96, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd, oreLayer.genMoon, oreLayer.genMars), 2, 109, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd, oreLayer.genMoon, oreLayer.genMars), 2, 96, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + getWeightedChance(oreLayer.randomWeight, oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd, oreLayer.genMoon, oreLayer.genMars), 2, 109, 0x404040, false); if (GT5OreLayerHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreLayer.restrictBiome), 2, 122, 0x404040, false); GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); } @@ -134,6 +134,36 @@ public class PluginGT5VeinStat extends PluginGT5Base { return I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name"); } + public String getWeightedChance(int randomWeight, boolean genOverworld, boolean genNether, boolean genEnd, boolean genMoon, boolean genMars) { + String weightedChance = ""; + if (genOverworld && GT5OreLayerHelper.weightPerWorld[0] != 0) { + if (!weightedChance.isEmpty()) + weightedChance += ", "; + weightedChance += String.format("%.2f%%", (100.0f*randomWeight)/GT5OreLayerHelper.weightPerWorld[0]); + } + if (genNether && GT5OreLayerHelper.weightPerWorld[1] != 0) { + if (!weightedChance.isEmpty()) + weightedChance += ", "; + weightedChance += String.format("%.2f%%", (100.0f*randomWeight)/GT5OreLayerHelper.weightPerWorld[1]); + } + if (genEnd && GT5OreLayerHelper.weightPerWorld[2] != 0) { + if (!weightedChance.isEmpty()) + weightedChance += ", "; + weightedChance += String.format("%.2f%%", (100.0f*randomWeight)/GT5OreLayerHelper.weightPerWorld[2]); + } + if (genMoon && GT5OreLayerHelper.weightPerWorld[3] != 0) { + if (!weightedChance.isEmpty()) + weightedChance += ", "; + weightedChance += String.format("%.2f%%", (100.0f*randomWeight)/GT5OreLayerHelper.weightPerWorld[3]); + } + if (genMars && GT5OreLayerHelper.weightPerWorld[4] != 0) { + if (!weightedChance.isEmpty()) + weightedChance += ", "; + weightedChance += String.format("%.2f%%", (100.0f*randomWeight)/GT5OreLayerHelper.weightPerWorld[4]); + } + return weightedChance; + } + @Override public String getOutputId() { return "GTOrePluginVein"; diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6VeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6VeinStat.java index 82714dd374..88bc814af4 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6VeinStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6VeinStat.java @@ -112,8 +112,8 @@ public class PluginGT6VeinStat extends PluginGT6Base { GuiDraw.drawString(I18n.format("gtnop.gui.nei.betweenOre") + ": " + getLocalizedOreName(oreLayer.betweenMeta), 2, 57, 0x404040, false); GuiDraw.drawString(I18n.format("gtnop.gui.nei.sporadicOre") + ": " + getLocalizedOreName(oreLayer.sporadicMeta), 2, 70, 0x404040, false); GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 83, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + oreLayer.weightedChance, 2, 96, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd, false, false), 2, 109, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd, false, false), 2, 96, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + getWeightedChance(oreLayer.randomWeight, oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd), 2, 109, 0x404040, false); GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); } @@ -124,6 +124,26 @@ public class PluginGT6VeinStat extends PluginGT6Base { return I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name"); } + public String getWeightedChance(int randomWeight, boolean genOverworld, boolean genNether, boolean genEnd) { + String weightedChance = ""; + if (genOverworld && GT6OreLayerHelper.weightPerWorld[0] != 0) { + if (!weightedChance.isEmpty()) + weightedChance += ", "; + weightedChance += String.format("%.2f%%", (100.0f*randomWeight)/GT6OreLayerHelper.weightPerWorld[0]); + } + if (genNether && GT6OreLayerHelper.weightPerWorld[1] != 0) { + if (!weightedChance.isEmpty()) + weightedChance += ", "; + weightedChance += String.format("%.2f%%", (100.0f*randomWeight)/GT6OreLayerHelper.weightPerWorld[1]); + } + if (genEnd && GT6OreLayerHelper.weightPerWorld[2] != 0) { + if (!weightedChance.isEmpty()) + weightedChance += ", "; + weightedChance += String.format("%.2f%%", (100.0f*randomWeight)/GT6OreLayerHelper.weightPerWorld[2]); + } + return weightedChance; + } + @Override public String getOutputId() { return "GTOrePluginVein"; -- cgit