diff options
author | GWYOG <jjn1jjn2@163.com> | 2016-11-04 11:11:06 +0800 |
---|---|---|
committer | GWYOG <jjn1jjn2@163.com> | 2016-11-04 11:11:06 +0800 |
commit | b4c82188a714fdef80d9c6627a749a9d0f456695 (patch) | |
tree | d24bc7ca9d1b8f82c0f5bd55e6e9ac8b48283b4e /src | |
parent | 6941633f426323c8c9f41b6846e9c8120c19cc86 (diff) | |
download | GT5-Unofficial-b4c82188a714fdef80d9c6627a749a9d0f456695.tar.gz GT5-Unofficial-b4c82188a714fdef80d9c6627a749a9d0f456695.tar.bz2 GT5-Unofficial-b4c82188a714fdef80d9c6627a749a9d0f456695.zip |
Fix NoSuchFieldError for mRestrictBiome when using old version of GT5
Diffstat (limited to 'src')
5 files changed, 30 insertions, 13 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java index 1dc55c441f..f06e3ae1d9 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java @@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import pers.gwyog.gtneioreplugin.plugin.PluginVeinStat.CachedVeinStatRecipe; import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper; +import pers.gwyog.gtneioreplugin.util.GTSmallOreHelper; import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper.OreLayerWrapper; public class PluginAsteroidStat extends PluginBase { diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java index ba8c39babb..b8432c7c93 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java @@ -33,11 +33,11 @@ public class PluginSmallOreStat extends PluginBase { public CachedSmallOreRecipe(String oreGenName, List<ItemStack> stackList, List<ItemStack> materialDustStackList, List<ItemStack> dropStackList) { this.oreGenName = oreGenName; this.positionedStackSmallOre = new PositionedStack(stackList, 2, 0); - this.positionedStackMaterialDust = new PositionedStack(materialDustStackList, 43, 79); + this.positionedStackMaterialDust = new PositionedStack(materialDustStackList, 43, 79+getRestrictBiomeOffset()); List<PositionedStack> positionedDropStackList = new ArrayList<PositionedStack>(); int i = 1; for (ItemStack stackDrop: dropStackList) - positionedDropStackList.add(new PositionedStack(stackDrop, 43+20*(i%4), 79+16*((i++)/4))); + positionedDropStackList.add(new PositionedStack(stackDrop, 43+20*(i%4), 79+16*((i++)/4)+getRestrictBiomeOffset())); this.positionedDropStackList = positionedDropStackList; } @@ -66,8 +66,8 @@ public class PluginSmallOreStat extends PluginBase { GuiDraw.drawString(I18n.format("gui.nei.genHeight") + ": " + smallOre.worldGenHeightRange, 2, 31, 0x404040, false); GuiDraw.drawString(I18n.format("gui.nei.amount") + ": " + smallOre.amountPerChunk, 2, 44, 0x404040, false); GuiDraw.drawString(I18n.format("gui.nei.worldNames") + ": " + getWorldNameTranslated(smallOre.genOverworld, smallOre.genNether, smallOre.genEnd, smallOre.genMoon, smallOre.genMars), 2, 57, 0x404040, false); - GuiDraw.drawString(I18n.format("gui.nei.restrictBiome") + ": " + getBiomeTranslated(smallOre.restrictBiome), 2, 70, 0x404040, false); - GuiDraw.drawString(I18n.format("gui.nei.chanceDrops") + ": ", 2, 83, 0x404040, false); + if (GTSmallOreHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gui.nei.restrictBiome") + ": " + getBiomeTranslated(smallOre.restrictBiome), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.chanceDrops") + ": ", 2, 83+getRestrictBiomeOffset(), 0x404040, false); GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); } @@ -75,6 +75,10 @@ public class PluginSmallOreStat extends PluginBase { return unlocalizedBiome.equals("None")? I18n.format("biome.none.name"): unlocalizedBiome; } + public int getRestrictBiomeOffset() { + return GTSmallOreHelper.restrictBiomeSupport? 0: -13; + } + public String getWorldNameTranslated(boolean genOverworld, boolean genNether, boolean genEnd, boolean genMoon, boolean genMars) { String worldNameTranslated = ""; if (genOverworld) { diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginVeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginVeinStat.java index f281b3b29e..a2a78b0d35 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginVeinStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginVeinStat.java @@ -124,7 +124,7 @@ public class PluginVeinStat extends PluginBase { GuiDraw.drawString(I18n.format("gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 83, 0x404040, false); GuiDraw.drawString(I18n.format("gui.nei.weightedChance") + ": " + oreLayer.weightedChance, 2, 96, 0x404040, false); GuiDraw.drawString(I18n.format("gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd, oreLayer.genMoon, oreLayer.genMars), 2, 109, 0x404040, false); - GuiDraw.drawString(I18n.format("gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreLayer.restrictBiome), 2, 122, 0x404040, false); + if (GTOreLayerHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreLayer.restrictBiome), 2, 122, 0x404040, false); GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java index e6f9541e9f..40e5c21ea5 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java @@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack; import sun.awt.windows.WWindowPeer; public class GTOreLayerHelper { + public static boolean restrictBiomeSupport = false; public static boolean endAsteroidSupport = false; public static boolean gcBasicSupport = false; public static boolean gcAsteroidSupport = false; @@ -32,6 +33,10 @@ public class GTOreLayerHelper { } catch (ClassNotFoundException e) {} if (clazzGTOreLayer != null) { try { + Field fieldRestrictBiome = clazzGTOreLayer.getField("mRestrictBiome"); + restrictBiomeSupport = true; + } catch (Exception e) {} + try { Field fieldEndAsteroid = clazzGTOreLayer.getField("mEndAsteroid"); endAsteroidSupport = true; } catch (Exception e) {} @@ -72,10 +77,11 @@ public class GTOreLayerHelper { this.sporadicMeta = worldGen.mSporadicMeta; this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; this.weightedChance = String.format("%.2f%%", (100.0f*worldGen.mWeight)/GT_Worldgen_GT_Ore_Layer.sWeight); - this.restrictBiome = worldGen.mRestrictBiome; this.genOverworld = worldGen.mOverworld; this.genNether = worldGen.mNether; this.genEnd = worldGen.mEnd; + if (restrictBiomeSupport) + this.restrictBiome = worldGen.mRestrictBiome; if (GTOreLayerHelper.gcBasicSupport) { this.genMoon = worldGen.mMoon; this.genMars = worldGen.mMars; diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java index 40889e8c11..0a4ac52f07 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java @@ -15,6 +15,7 @@ import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; public class GTSmallOreHelper { + public static boolean restrictBiomeSupport = false; public static boolean gcBasicSupport = false; public static List<ItemStack> smallOreList = new ArrayList<ItemStack>(); public static HashMap<String, SmallOreWrapper> mapSmallOreWrapper = new HashMap<String, SmallOreWrapper>(); @@ -55,14 +56,18 @@ public class GTSmallOreHelper { } private static void checkExtraSupport() { - Class clazzGTOreLayer = null; + Class clazzGTSmallOre = null; try { - clazzGTOreLayer = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); + clazzGTSmallOre = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); } catch (ClassNotFoundException e) {} - if (clazzGTOreLayer != null) { + if (clazzGTSmallOre != null) { try { - Field fieldGCMoon = clazzGTOreLayer.getField("mMoon"); - Field fieldGCMars = clazzGTOreLayer.getField("mMars"); + Field fieldRestrictBiome = clazzGTSmallOre.getField("mRestrictBiome");; + restrictBiomeSupport = true; + } catch (Exception e) {} + try { + Field fieldGCMoon = clazzGTSmallOre.getField("mMoon"); + Field fieldGCMars = clazzGTSmallOre.getField("mMars"); gcBasicSupport = true; } catch (Exception e) {} } @@ -89,11 +94,12 @@ public class GTSmallOreHelper { this.oreMeta = worldGen.mMeta; this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; this.amountPerChunk = worldGen.mAmount; - this.restrictBiome = worldGen.mRestrictBiome; this.genOverworld = worldGen.mOverworld; this.genNether = worldGen.mNether; this.genEnd = worldGen.mEnd; - if (GTOreLayerHelper.gcBasicSupport) { + if (GTSmallOreHelper.restrictBiomeSupport) + this.restrictBiome = worldGen.mRestrictBiome; + if (GTSmallOreHelper.gcBasicSupport) { this.genMoon = worldGen.mMoon; this.genMars = worldGen.mMars; } |