diff --git a/src/main/java/mods/bio/gttweaker/GTTweaker.java b/src/main/java/mods/bio/gttweaker/GTTweaker.java index 37668c2..4c3ec45 100644 --- a/src/main/java/mods/bio/gttweaker/GTTweaker.java +++ b/src/main/java/mods/bio/gttweaker/GTTweaker.java @@ -129,6 +129,8 @@ public void onModInit2(FMLInitializationEvent aEvent) { MineTweakerAPI.registerClass(CTIOreDictExpansion.class); MineTweakerAPI.registerClass(CTIItemStackExpansion.class); MineTweakerAPI.registerClass(CTMaterial.class); + MineTweakerAPI.registerClass(CTMaterialData.class); + MineTweakerAPI.registerClass(CTMaterialStack.class); MineTweakerAPI.registerClass(CTPrefix.class); MineTweakerAPI.registerBracketHandler(new CTRecipeMapBracketHandler()); MineTweakerAPI.registerBracketHandler(new CTPrefixBracketHandler()); diff --git a/src/main/java/mods/bio/gttweaker/oredict/CTMaterialData.java b/src/main/java/mods/bio/gttweaker/oredict/CTMaterialData.java index ca9e4e1..a22a048 100644 --- a/src/main/java/mods/bio/gttweaker/oredict/CTMaterialData.java +++ b/src/main/java/mods/bio/gttweaker/oredict/CTMaterialData.java @@ -1,5 +1,52 @@ package mods.bio.gttweaker.oredict; +import gregapi.oredict.OreDictItemData; +import stanhebben.zenscript.annotations.ZenClass; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@ZenClass("mods.gregtech.oredict.MaterialData") public class CTMaterialData { + private final OreDictItemData backingData; + public CTMaterialStack material(){ + return new CTMaterialStack(backingData.mMaterial); + } + public CTPrefix prefix(){ + return new CTPrefix(backingData.mPrefix); + } + private List byProducts(){ + return Arrays.stream(backingData.mByProducts).map(CTMaterialStack::new).collect(Collectors.toList()); + } + + public CTMaterialData(OreDictItemData backingData) { + this.backingData = backingData; + } + /** + * @return a very JSON like CTMaterialData Representation tough it's not ready for json parsing at all + * but is human readable. + * { + * MainMaterial: * amount U , + * ByProducts: [ + * 1: * amount U, + * 2 : * amount U, + * 3: * amount U + * ] + * } + * + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + if(material() != null) builder.append("{MainMaterial:").append(material()); + else builder.append("{NULL"); + List list = byProducts(); + if(!list.isEmpty()) builder.append(",ByProducts:["); + list.forEach(s->builder.append(String.format("%d: %s,",list.indexOf(s),s))); + if (!list.isEmpty()) builder.reverse().deleteCharAt(0).reverse().append("]}"); + return builder.toString(); + } } diff --git a/src/main/java/mods/bio/gttweaker/oredict/CTMaterialStack.java b/src/main/java/mods/bio/gttweaker/oredict/CTMaterialStack.java new file mode 100644 index 0000000..99e34c1 --- /dev/null +++ b/src/main/java/mods/bio/gttweaker/oredict/CTMaterialStack.java @@ -0,0 +1,34 @@ +package mods.bio.gttweaker.oredict; + +import gregapi.oredict.OreDictMaterialStack; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenGetter; + +import static mods.bio.gttweaker.oredict.CTUnifier.U; + +@ZenClass("mods.gregtech.MaterialStack") +public class CTMaterialStack { + private final OreDictMaterialStack _backingStack; + + @ZenGetter + public CTMaterial material(){ + return new CTMaterial(_backingStack.mMaterial); + } + + public long amount(){ + return _backingStack.mAmount; + } + + public CTMaterialStack(OreDictMaterialStack backingStack) { + _backingStack = backingStack; + } + + /** + * @return * amount U + */ + @Override + public String toString() { + // NOTE THAT THIS IS NOT VALID IN ZS + return String.format("%s * %f U",material(),((double)amount())/ U()); + } +}