From 92294c1f88884b817fee7cb21db30e469ff78844 Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Sun, 2 Oct 2016 21:39:42 +0200 Subject: [PATCH] MT script parser + metaitem reenabler do now work --- src/main/java/gregtech/GT_Mod.java | 72 +++++++++++++++++ .../java/gregtech/api/enums/OrePrefixes.java | 81 ------------------- .../java/gregtech/common/GT_RecipeAdder.java | 2 +- 3 files changed, 73 insertions(+), 82 deletions(-) diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index e5e6bf94..430fbb45 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -298,7 +298,79 @@ public class GT_Mod implements IGT_Mod { EntityRegistry.registerModEntity(GT_Entity_Arrow.class, "GT_Entity_Arrow", 1, GT_Values.GT, 160, 1, true); EntityRegistry.registerModEntity(GT_Entity_Arrow_Potion.class, "GT_Entity_Arrow_Potion", 2, GT_Values.GT, 160, 1, true); + System.out.println("preReader"); + List oreTags = new ArrayList(); + if(Loader.isModLoaded("MineTweaker3")){ + File globalDir = new File("scripts"); + if (globalDir.exists()){ + List scripts = new ArrayList(); + for (File file : globalDir.listFiles()) { + if (file.getName().endsWith(".zs")) { + try (BufferedReader br = new BufferedReader(new FileReader(file))) { + String line; + while ((line = br.readLine()) != null) { + scripts.add(line); + } + } catch (Exception e) {e.printStackTrace();} + } + } + String pattern1 = "<"; + String pattern2 = ">"; + Pattern p = Pattern.compile(Pattern.quote(pattern1) + "(.*?)" + Pattern.quote(pattern2)); + for(String text : scripts){ + Matcher m = p.matcher(text); + while (m.find()) { + String hit = m.group(1); + if(hit.startsWith("ore:")){ + hit = hit.substring(4); + if(!oreTags.contains(hit)) oreTags.add(hit); + }else if(hit.startsWith("gregtech:gt.metaitem.0")){ + hit = hit.substring(22); + int mIt = Integer.parseInt(hit.substring(0, 1)); + if(mIt>0){ + int meta = 0; + try{ + hit = hit.substring(2); + meta = Integer.parseInt(hit); + }catch(Exception e){System.out.println("parseError: "+hit);} + if(meta>0&&meta<32000){ + int prefix = meta/1000; + int material = meta % 1000; + String tag = ""; + String[] tags = new String[]{}; + if(mIt==1)tags = new String[]{"dustTiny","dustSmall","dust","dustImpure","dustPure","crushed","crushedPurified","crushedCentrifuged","gem","nugget",null,"ingot","ingotHot","ingotDouble","ingotTriple","ingotQuadruple","ingotQuintuple","plate","plateDouble","plateTriple","plateQuadruple","plateQuintuple","plateDense","stick","lens","round","bolt","screw","ring","foil","cell","cellPlasma"}; + if(mIt==2)tags = new String[]{"toolHeadSword", "toolHeadPickaxe", "toolHeadShovel", "toolHeadAxe", "toolHeadHoe", "toolHeadHammer", "toolHeadFile", "toolHeadSaw", "toolHeadDrill", "toolHeadChainsaw", "toolHeadWrench", "toolHeadUniversalSpade", "toolHeadSense", "toolHeadPlow", "toolHeadArrow", "toolHeadBuzzSaw", "turbineBlade", null, null, "wireFine", "gearGtSmall", "rotor", "stickLong", "springSmall", "spring", "arrowGtWood", "arrowGtPlastic", "gemChipped", "gemFlawed", "gemFlawless", "gemExquisite", "gearGt"}; + if(mIt==3)tags = new String[]{"crateGtDust", "crateGtIngot", "crateGtGem", "crateGtPlate"}; + if(tags.length>prefix) tag = tags[prefix]; + if(GregTech_API.sGeneratedMaterials[material]!=null){ + tag += GregTech_API.sGeneratedMaterials[material].mName; + if(!oreTags.contains(tag)) oreTags.add(tag); + }else if(material>0){System.out.println("MaterialDisabled: "+material+" "+m.group(1));} + } + } + } + } + } + } + } + String[] preS = new String[]{"dustTiny","dustSmall","dust","dustImpure","dustPure","crushed","crushedPurified","crushedCentrifuged","gem","nugget","ingot","ingotHot","ingotDouble","ingotTriple","ingotQuadruple","ingotQuintuple","plate","plateDouble","plateTriple","plateQuadruple","plateQuintuple","plateDense","stick","lens","round","bolt","screw","ring","foil","cell","cellPlasma","toolHeadSword", "toolHeadPickaxe", "toolHeadShovel", "toolHeadAxe", "toolHeadHoe", "toolHeadHammer", "toolHeadFile", "toolHeadSaw", "toolHeadDrill", "toolHeadChainsaw", "toolHeadWrench", "toolHeadUniversalSpade", "toolHeadSense", "toolHeadPlow", "toolHeadArrow", "toolHeadBuzzSaw", "turbineBlade", "wireFine", "gearGtSmall", "rotor", "stickLong", "springSmall", "spring", "arrowGtWood", "arrowGtPlastic", "gemChipped", "gemFlawed", "gemFlawless", "gemExquisite", "gearGt","crateGtDust", "crateGtIngot", "crateGtGem", "crateGtPlate"}; + + List mMTTags = new ArrayList(); + for(String test : oreTags){ + if(StringUtils.startsWithAny(test, preS)){ + mMTTags.add(test); + System.out.println("oretag: "+test);}} + + System.out.println("reenableMetaItems"); + for(String reEnable : mMTTags){ + OrePrefixes tPrefix = OrePrefixes.getOrePrefix(reEnable); + if(tPrefix!=null){ + Materials tName = Materials.get(reEnable.replaceFirst(tPrefix.toString(), "")); + if(tName!=null){ + tPrefix.mDisabledItems.remove(tName); + tPrefix.mGeneratedItems.add(tName);}else{System.out.println("noMaterial "+reEnable);} + }else{System.out.println("noPrefix "+reEnable);}} new Enchantment_EnderDamage(); new Enchantment_Radioactivity(); diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index ed37264f..14a75576 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -776,87 +776,6 @@ public enum OrePrefixes { } } } - - System.out.println("preReader"); - List oreTags = new ArrayList(); - if(Loader.isModLoaded("MineTweaker3")){ - File globalDir = new File("scripts"); - if (globalDir.exists()){ - List scripts = new ArrayList(); - for (File file : globalDir.listFiles()) { - if (file.getName().endsWith(".zs")) { - try (BufferedReader br = new BufferedReader(new FileReader(file))) { - String line; - while ((line = br.readLine()) != null) { - scripts.add(line); - } - } catch (Exception e) {e.printStackTrace();} - } - } - String pattern1 = "<"; - String pattern2 = ">"; - - Pattern p = Pattern.compile(Pattern.quote(pattern1) + "(.*?)" + Pattern.quote(pattern2)); - for(String text : scripts){ - Matcher m = p.matcher(text); - while (m.find()) { - String hit = m.group(1); - if(hit.startsWith("ore:")){ - hit = hit.substring(4); - if(!oreTags.contains(hit)) oreTags.add(hit); - }else if(hit.startsWith("gregtech:gt.metaitem.0")){ - hit = hit.substring(22); - int mIt = Integer.parseInt(hit.substring(0, 1)); - if(mIt>0){ - int meta = 0; - try{ - hit = hit.substring(2); - meta = Integer.parseInt(hit); - }catch(Exception e){System.out.println("parseError: "+hit);} - if(meta>0&&meta<32000){ - int prefix = meta/1000; - int material = meta % 1000; - String tag = ""; - String[] tags = new String[]{}; - if(mIt==1)tags = new String[]{"dustTiny","dustSmall","dust","dustImpure","dustPure","crushed","crushedPurified","crushedCentrifuged","gem","nugget",null,"ingot","ingotHot","ingotDouble","ingotTriple","ingotQuadruple","ingotQuintuple","plate","plateDouble","plateTriple","plateQuadruple","plateQuintuple","plateDense","stick","lens","round","bolt","screw","ring","foil","cell","cellPlasma"}; - if(mIt==2)tags = new String[]{"toolHeadSword", "toolHeadPickaxe", "toolHeadShovel", "toolHeadAxe", "toolHeadHoe", "toolHeadHammer", "toolHeadFile", "toolHeadSaw", "toolHeadDrill", "toolHeadChainsaw", "toolHeadWrench", "toolHeadUniversalSpade", "toolHeadSense", "toolHeadPlow", "toolHeadArrow", "toolHeadBuzzSaw", "turbineBlade", null, null, "wireFine", "gearGtSmall", "rotor", "stickLong", "springSmall", "spring", "arrowGtWood", "arrowGtPlastic", "gemChipped", "gemFlawed", "gemFlawless", "gemExquisite", "gearGt"}; - if(mIt==3)tags = new String[]{"crateGtDust", "crateGtIngot", "crateGtGem", "crateGtPlate"}; - if(tags.length>prefix) tag = tags[prefix]; - if(GregTech_API.sGeneratedMaterials[material]!=null){ - tag += GregTech_API.sGeneratedMaterials[material].mName; - if(!oreTags.contains(tag)) oreTags.add(tag); - }else if(material>0){System.out.println("MaterialDisabled: "+material+" "+m.group(1));} - } - } - } - } - } - } - } - String[] preS = new String[]{"dustTiny","dustSmall","dust","dustImpure","dustPure","crushed","crushedPurified","crushedCentrifuged","gem","nugget","ingot","ingotHot","ingotDouble","ingotTriple","ingotQuadruple","ingotQuintuple","plate","plateDouble","plateTriple","plateQuadruple","plateQuintuple","plateDense","stick","lens","round","bolt","screw","ring","foil","cell","cellPlasma","toolHeadSword", "toolHeadPickaxe", "toolHeadShovel", "toolHeadAxe", "toolHeadHoe", "toolHeadHammer", "toolHeadFile", "toolHeadSaw", "toolHeadDrill", "toolHeadChainsaw", "toolHeadWrench", "toolHeadUniversalSpade", "toolHeadSense", "toolHeadPlow", "toolHeadArrow", "toolHeadBuzzSaw", "turbineBlade", "wireFine", "gearGtSmall", "rotor", "stickLong", "springSmall", "spring", "arrowGtWood", "arrowGtPlastic", "gemChipped", "gemFlawed", "gemFlawless", "gemExquisite", "gearGt","crateGtDust", "crateGtIngot", "crateGtGem", "crateGtPlate"}; - - List mMTTags = new ArrayList(); - for(String test : oreTags){ - if(StringUtils.startsWithAny(test, preS)){ - mMTTags.add(test); - System.out.println("oretag: "+test);}} - - System.out.println("reenableMetaItems"); - for(String reEnable : mMTTags){ - OrePrefixes tPrefix = OrePrefixes.getOrePrefix(reEnable); - if(tPrefix!=null){ - Materials tName = Materials.get(reEnable.replaceFirst(tPrefix.toString(), "")); - if(tName!=null){ - tPrefix.mDisabledItems.remove(tName);}else{System.out.println("noMaterial "+reEnable);} - }else{System.out.println("noPrefix "+reEnable);}} - - - - - - - - } public static OrePrefixes getOrePrefix(String aOre) { diff --git a/src/main/java/gregtech/common/GT_RecipeAdder.java b/src/main/java/gregtech/common/GT_RecipeAdder.java index 99781534..88e459a9 100644 --- a/src/main/java/gregtech/common/GT_RecipeAdder.java +++ b/src/main/java/gregtech/common/GT_RecipeAdder.java @@ -205,7 +205,7 @@ public class GT_RecipeAdder if ((aDuration = GregTech_API.sRecipeFile.get("assembling", aOutput1, aDuration)) <= 0) { return false; } - GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.addRecipe(true, new ItemStack[]{aInput1, (ItemStack) (aInput2 == null ? new ItemStack[]{aInput1} : aInput2)}, new ItemStack[]{aOutput1}, null, new FluidStack[]{aFluidInput == null ? null : aFluidInput}, null, aDuration, aEUt, 0); + GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.addRecipe(true, new ItemStack[]{aInput1, (aInput2 == null ? aInput1 : aInput2)}, new ItemStack[]{aOutput1}, null, new FluidStack[]{aFluidInput == null ? null : aFluidInput}, null, aDuration, aEUt, 0); return true; }