diff --git a/src/main/java/mods/bio/gttweaker/command/GTCommand.java b/src/main/java/mods/bio/gttweaker/command/GTCommand.java index 10e4c75..519d195 100644 --- a/src/main/java/mods/bio/gttweaker/command/GTCommand.java +++ b/src/main/java/mods/bio/gttweaker/command/GTCommand.java @@ -11,8 +11,7 @@ import minetweaker.api.minecraft.MineTweakerMC; import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; -import mods.bio.gttweaker.mods.gregtech.oredict.CTMaterial; -import mods.bio.gttweaker.mods.gregtech.oredict.CTPrefix; +import mods.bio.gttweaker.mods.gregtech.oredict.CTMaterialData; import org.apache.commons.lang3.StringUtils; import javax.annotation.Nullable; @@ -52,32 +51,32 @@ private static void HAND(String[] arguments, IPlayer player) { // TODO Implement GT Hand recipe for held item IItemStack item = player.getCurrentItem(); if (item != null) { - OreDictItemData data = OreDictManager.INSTANCE.getAssociation(MineTweakerMC.getItemStack(item),true); + CTMaterialData data = CTMaterialData.association(item); if(data!=null){ - List list = new ArrayList<>(); - list.add("============================="); - list.add("== OP: " + new CTPrefix(data.mPrefix)); - list.add("== MT: "+ new CTMaterial(data.mMaterial.mMaterial)); - list.add("== UNI: " + MineTweakerMC.getIItemStack(data.getStack(1))); - list.add("** MineTweaker **"); - list.add("== IOreDict: "); - list.add("== IItemStack: "+item); - list.add("============================="); - list.forEach(player::sendChat); - list.forEach(MineTweakerAPI::logCommand); - // copy the into inventory - // copies the into clipboard - if(arguments.length < 2) - player.sendChat("Supply additional flags \"ore\" and \"item\" to copy the IOreDict and IItemStack into your clipboard respectively."); - if(arguments.length > 1 && Objects.equals(arguments[1],"ore")){ - player.sendChat("" + " was coppied to your clipboard"); - copyToClipboard(""); - } - else if(arguments.length > 1 && Objects.equals(arguments[1],"item")) { - player.sendChat(MineTweakerMC.getIItemStack(data.getStack(1)).toString() +" was coppied to your clipboard"); - //player.sendChat("use /minetweaker gt6 hand {ore} , In Order to get the enrty"); - copyToClipboard(MineTweakerMC.getIItemStack(data.getStack(1)).toString()); - } + List list = new ArrayList<>(); + list.add("============================="); + list.add("== OP: " + data.prefix()); + list.add("== MT: "+ data.material()); + list.add("== UNI: " + MineTweakerMC.getIItemStack(data.backingData.getStack(1))); + list.add("** MineTweaker **"); + list.add("== IOreDict: "); + list.add("== IItemStack: "+item); + list.add("============================="); + list.forEach(player::sendChat); + list.forEach(MineTweakerAPI::logCommand); + // copy the into inventory + // copies the into clipboard + if(arguments.length < 2) + player.sendChat("Supply additional flags \"ore\" and \"item\" to copy the IOreDict and IItemStack into your clipboard respectively."); + if(arguments.length > 1 && Objects.equals(arguments[1],"ore")){ + player.sendChat("" + " was coppied to your clipboard"); + copyToClipboard(""); + } + else if(arguments.length > 1 && Objects.equals(arguments[1],"item")) { + player.sendChat(MineTweakerMC.getIItemStack(data.backingData.getStack(1)).toString() +" was coppied to your clipboard"); + //player.sendChat("use /minetweaker gt6 hand {ore} , In Order to get the enrty"); + copyToClipboard(MineTweakerMC.getIItemStack(data.backingData.getStack(1)).toString()); + } }else player.sendChat("Item { "+item+ "} dose not contain GT associated data!"); } else player.sendChat("No item was found"); } diff --git a/src/main/java/mods/bio/gttweaker/mods/gregtech/oredict/CTMaterialData.java b/src/main/java/mods/bio/gttweaker/mods/gregtech/oredict/CTMaterialData.java index c804ddd..802712f 100644 --- a/src/main/java/mods/bio/gttweaker/mods/gregtech/oredict/CTMaterialData.java +++ b/src/main/java/mods/bio/gttweaker/mods/gregtech/oredict/CTMaterialData.java @@ -1,18 +1,25 @@ package mods.bio.gttweaker.mods.gregtech.oredict; import gregapi.oredict.OreDictItemData; +import gregapi.oredict.OreDictManager; import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IItemStack; +import minetweaker.api.minecraft.MineTweakerMC; +import minetweaker.api.oredict.IOreDictEntry; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenGetter; +import stanhebben.zenscript.annotations.ZenMethod; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import static gregapi.data.CS.F; + @ZenClass("mods.gregtech.oredict.MaterialData") public class CTMaterialData { - private final OreDictItemData backingData; + public final OreDictItemData backingData; @ZenGetter public CTMaterialStack material(){ if(backingData.mMaterial != null) return new CTMaterialStack(backingData.mMaterial); @@ -41,8 +48,27 @@ public List materials(){ return list; } - public CTMaterialData(OreDictItemData backingData) { + private CTMaterialData(OreDictItemData backingData) { this.backingData = backingData; + if(backingData==null) { + MineTweakerAPI.logError("Material Data cannot be null",new NullPointerException("Not a valid Material Data.")); + } + } + + @ZenMethod + public static CTMaterialData association(IItemStack item){ + OreDictItemData data = OreDictManager.INSTANCE.getAssociation(MineTweakerMC.getItemStack(item),F); + if(data!=null) return new CTMaterialData(data); + MineTweakerAPI.logError(item + " dose not have a GT Association!"); + return null; + } + + @ZenMethod + public static CTMaterialData association(IOreDictEntry ore){ + OreDictItemData data = OreDictManager.INSTANCE.getAutomaticItemData(ore.getName()); + if(data!=null) return new CTMaterialData(data); + MineTweakerAPI.logError(ore + " dose not have a GT Association!"); + return null; } /** diff --git a/src/main/java/mods/bio/gttweaker/mods/minetweaker/CTIItemStackExpansion.java b/src/main/java/mods/bio/gttweaker/mods/minetweaker/CTIItemStackExpansion.java index 3707373..4e0e231 100644 --- a/src/main/java/mods/bio/gttweaker/mods/minetweaker/CTIItemStackExpansion.java +++ b/src/main/java/mods/bio/gttweaker/mods/minetweaker/CTIItemStackExpansion.java @@ -28,12 +28,14 @@ public static boolean removeMaterialData(IItemStack aIItemStack) { return CTUnifier.removeRecyclingCT(aIItemStack); } + @ZenGetter + public static CTMaterialData association(IItemStack iItemStack){ + return CTMaterialData.association(iItemStack); + } + @ZenGetter public static CTMaterialData data(IItemStack iItemStack){ - OreDictItemData data = OreDictManager.INSTANCE.getAssociation_(MineTweakerMC.getItemStack(iItemStack), false); - if(data!=null) return new CTMaterialData(data); - MineTweakerAPI.logError(String.format("%s dose not contain any gt material data", iItemStack)); - return null; + return association(iItemStack); } @ZenGetter diff --git a/src/main/java/mods/bio/gttweaker/mods/minetweaker/CTIOreDictExpansion.java b/src/main/java/mods/bio/gttweaker/mods/minetweaker/CTIOreDictExpansion.java index 12d0ba5..4b57664 100644 --- a/src/main/java/mods/bio/gttweaker/mods/minetweaker/CTIOreDictExpansion.java +++ b/src/main/java/mods/bio/gttweaker/mods/minetweaker/CTIOreDictExpansion.java @@ -4,6 +4,7 @@ import minetweaker.api.item.IItemStack; import minetweaker.api.oredict.IOreDictEntry; import mods.bio.gttweaker.mods.gregtech.oredict.CTMaterial; +import mods.bio.gttweaker.mods.gregtech.oredict.CTMaterialData; import mods.bio.gttweaker.mods.gregtech.oredict.CTPrefix; import mods.bio.gttweaker.mods.gregtech.oredict.CTUnifier; import stanhebben.zenscript.annotations.ZenExpansion; @@ -29,4 +30,14 @@ public static CTPrefix prefix(IOreDictEntry oreDictEntry){ public static long amount(IOreDictEntry oreDictEntry){ return prefix(oreDictEntry).amount(); } + + @ZenGetter + public static CTMaterialData association(IOreDictEntry oreDictEntry){ + return CTMaterialData.association(oreDictEntry); + } + + @ZenGetter + public static CTMaterialData data(IOreDictEntry oreDictEntry){ + return association(oreDictEntry); + } }