aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util/item
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/item')
-rw-r--r--src/Java/gtPlusPlus/core/util/item/ItemUtils.java (renamed from src/Java/gtPlusPlus/core/util/item/UtilsItems.java)315
1 files changed, 175 insertions, 140 deletions
diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java
index 197482f1ae..69d909f294 100644
--- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java
+++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java
@@ -1,39 +1,27 @@
package gtPlusPlus.core.util.item;
import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
-import gtPlusPlus.core.block.base.BasicBlock.BlockTypes;
-import gtPlusPlus.core.block.base.BlockBaseModular;
import gtPlusPlus.core.item.ModItems;
import gtPlusPlus.core.item.base.BasicSpawnEgg;
-import gtPlusPlus.core.item.base.bolts.BaseItemBolt;
import gtPlusPlus.core.item.base.dusts.BaseItemDust;
import gtPlusPlus.core.item.base.dusts.BaseItemDustUnique;
-import gtPlusPlus.core.item.base.gears.BaseItemGear;
-import gtPlusPlus.core.item.base.ingots.BaseItemIngot;
-import gtPlusPlus.core.item.base.ingots.BaseItemIngotHot;
-import gtPlusPlus.core.item.base.plates.BaseItemPlate;
-import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble;
-import gtPlusPlus.core.item.base.rings.BaseItemRing;
-import gtPlusPlus.core.item.base.rods.BaseItemRod;
-import gtPlusPlus.core.item.base.rods.BaseItemRodLong;
-import gtPlusPlus.core.item.base.rotors.BaseItemRotor;
-import gtPlusPlus.core.item.base.screws.BaseItemScrew;
+import gtPlusPlus.core.item.base.dusts.decimal.BaseItemCentidust;
+import gtPlusPlus.core.item.base.dusts.decimal.BaseItemDecidust;
import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase;
+import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.fluid.FluidUtils;
import gtPlusPlus.core.util.materials.MaterialUtils;
import gtPlusPlus.core.util.wrapper.var;
-import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plates;
import java.util.ArrayList;
import java.util.List;
-import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
@@ -41,7 +29,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.registry.GameRegistry;
-public class UtilsItems {
+public class ItemUtils {
public static ItemStack getSimpleStack(Item x){
return getSimpleStack(x, 1);
@@ -64,6 +52,23 @@ public class UtilsItems {
}
}
+ public static ItemStack getIC2Cell(String S){
+ ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+S, 1);
+
+ if (moreTemp == null){
+ int cellID = 0;
+ ItemStack temp =GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, cellID);
+ return temp != null ? temp : null;
+ }
+
+ return moreTemp;
+ }
+
+ public static ItemStack getIC2Cell(int meta){
+ ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, meta);
+ return temp != null ? temp : null;
+ }
+
public static void getItemForOreDict(String FQRN, String oreDictName, String itemName, int meta){
try {
@@ -85,10 +90,10 @@ public class UtilsItems {
Utils.LOG_ERROR(itemName+" not found. [NULL]");
}
}
-
+
public static void addItemToOreDictionary(ItemStack stack, String oreDictName){
try {
- GT_OreDictUnificator.registerOre(oreDictName, stack);
+ GT_OreDictUnificator.registerOre(oreDictName, stack);
} catch (NullPointerException e) {
Utils.LOG_ERROR(stack.getDisplayName()+" not registered. [NULL]");
}
@@ -168,12 +173,12 @@ public class UtilsItems {
ItemStack temp;
if (fqrn.toLowerCase().contains(oreDict.toLowerCase())){
String sanitizedName = fqrn.replace(oreDict, "");
- temp = UtilsItems.getItemStack(sanitizedName, stackSize);
+ temp = ItemUtils.getItemStack(sanitizedName, stackSize);
return temp;
}
String[] fqrnSplit = fqrn.split(":");
if(fqrnSplit[2] == null){fqrnSplit[2] = "0";}
- temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(fqrnSplit[2]), stackSize);
+ temp = ItemUtils.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(fqrnSplit[2]), stackSize);
return temp;
}
@@ -212,25 +217,12 @@ public class UtilsItems {
return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size);
}*/
- public static Item getItemInPlayersHand(){
- Minecraft mc = Minecraft.getMinecraft();
- Item heldItem = null;
-
- try{heldItem = mc.thePlayer.getHeldItem().getItem();
- }catch(NullPointerException e){return null;}
-
- if (heldItem != null){
- return heldItem;
- }
-
- return null;
- }
public static void generateSpawnEgg(String entityModID, String parSpawnName, int colourEgg, int colourOverlay){
Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay).setUnlocalizedName("spawn_egg_"+parSpawnName.toLowerCase()).setTextureName(CORE.MODID+":spawn_egg");
GameRegistry.registerItem(itemSpawnEgg, "spawnEgg"+parSpawnName);
}
-
+
public static ItemStack[] validItemsForOreDict(String oredictName){
List<?> validNames = MaterialUtils.oreDictValuesForEntry(oredictName);
@@ -244,138 +236,170 @@ public class UtilsItems {
public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, int amount){
ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName);
if (!oreDictList.isEmpty()){
- ItemStack returnValue = oreDictList.get(0).copy();
- returnValue.stackSize = amount;
- return returnValue;
+ ItemStack returnValue = oreDictList.get(0).copy();
+ returnValue.stackSize = amount;
+ return returnValue;
}
- return getSimpleStack(ModItems.AAA_Broken, amount);
+ return getSimpleStack(ModItems.AAA_Broken, amount);
}
-
+
public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, int amount){
ItemStack returnValue = getItemStackOfAmountFromOreDict(oredictName, amount);
-
+
if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() || returnValue.getItem() != ModItems.AAA_Broken){
- return returnValue;
- }
- Utils.LOG_INFO(oredictName+" was not valid.");
- return null;
- }
-
- public static void generateItemsFromMaterial(Material matInfo){
-
- String unlocalizedName = matInfo.getUnlocalizedName();
- String materialName = matInfo.getLocalizedName();
- short[] C = matInfo.getRGBA();
- int Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]);
- boolean hotIngot = matInfo.requiresBlastFurnace();
- int materialTier = matInfo.vTier; //TODO
-
- if (materialTier > 10 || materialTier <= 0){
- materialTier = 2;
- }
-
-
-
- int sRadiation = 0;
- if (isRadioactive(materialName)){
- sRadiation = getRadioactivityLevel(materialName);
- }
-
- if (sRadiation >= 1){
- Item temp;
- Block tempBlock;
- tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.STANDARD, Colour);
- temp = new BaseItemIngot("itemIngot"+unlocalizedName, materialName, Colour, sRadiation);
-
- temp = new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, sRadiation);
- temp = new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, sRadiation);
- temp = new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, sRadiation);
-
- temp = new BaseItemPlate("itemPlate"+unlocalizedName, materialName, Colour, materialTier, sRadiation);
- temp = new BaseItemRod(matInfo, sRadiation);
- temp = new BaseItemRodLong(matInfo, sRadiation);
- }
-
- else {
- Item temp;
- Block tempBlock;
- tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.STANDARD, Colour);
- tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.FRAME, Colour);
- temp = new BaseItemIngot("itemIngot"+unlocalizedName, materialName, Colour, sRadiation);
- if (hotIngot){
- Item tempIngot = temp;
- temp = new BaseItemIngotHot("itemHotIngot"+unlocalizedName, materialName, UtilsItems.getSimpleStack(tempIngot, 1), materialTier);
+ return returnValue;
+ }
+ Utils.LOG_INFO(oredictName+" was not valid.");
+ return null;
+ }
+
+ public static ItemStack getItemStackOfAmountFromOreDictNoBrokenExcluding(String excludeModName, String oredictName, int amount){
+ ItemStack returnValue = getItemStackOfAmountFromOreDict(oredictName, amount);
+
+ if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() || returnValue.getItem() != ModItems.AAA_Broken){
+ if (returnValue.getClass().toString().toLowerCase().contains(excludeModName.toLowerCase())){
+ ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName);
+ if (!oreDictList.isEmpty()){
+ returnValue = oreDictList.get(1).copy();
+ returnValue.stackSize = amount;
+ return returnValue;
}
- temp = new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, sRadiation);
- temp = new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, sRadiation);
- temp = new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, sRadiation);
-
- temp = new BaseItemPlate("itemPlate"+unlocalizedName, materialName, Colour, materialTier, sRadiation);
- temp = new BaseItemPlateDouble("itemPlateDouble"+unlocalizedName, materialName, Colour, materialTier, sRadiation);
- temp = new BaseItemBolt(matInfo);
- temp = new BaseItemRod(matInfo, sRadiation);
- temp = new BaseItemRodLong(matInfo, sRadiation);
- temp = new BaseItemRing(matInfo);
- temp = new BaseItemScrew(matInfo);
- temp = new BaseItemRotor("itemRotor"+unlocalizedName, materialName, Colour);
- temp = new BaseItemGear(matInfo);
- }
-
- RecipeGen_Plates.generateRecipes(matInfo);
-
- FluidUtils.generateFluid(matInfo, 1);
-
+ }
+ else {
+ ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName);
+ if (!oreDictList.isEmpty()){
+ returnValue = oreDictList.get(1).copy();
+ returnValue.stackSize = amount;
+ return returnValue;
+ }
+ }
+ return returnValue;
+ }
+ Utils.LOG_INFO(oredictName+" was not valid.");
+ return null;
}
-
+
public static Item[] generateDusts(String unlocalizedName, String materialName, int materialTier, Material matInfo, int Colour){
int radioactive = getRadioactivityLevel(materialName);
Item[] output = {
- new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, radioactive),
- new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, radioactive),
- new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, radioactive)};
+ new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, radioactive),
+ new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, radioactive),
+ new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, radioactive)};
return output;
}
-
+
public static Item[] generateSpecialUseDusts(String unlocalizedName, String materialName, int Colour){
Item[] output = {
- new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, Colour, "Dust"),
- new BaseItemDustUnique("itemDustSmall"+unlocalizedName, materialName, Colour, "Small"),
- new BaseItemDustUnique("itemDustTiny"+unlocalizedName, materialName, Colour, "Tiny")};
+ new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, Colour, "Dust"),
+ new BaseItemDustUnique("itemDustSmall"+unlocalizedName, materialName, Colour, "Small"),
+ new BaseItemDustUnique("itemDustTiny"+unlocalizedName, materialName, Colour, "Tiny")};
return output;
}
-
+
public static MultiPickaxeBase generateMultiPick(boolean GT_Durability, Materials material){
ToolMaterial customMaterial = Utils.generateMaterialFromGT(material);
- Utils.LOG_INFO("Generating a Multi-Pick out of "+material.name());
+ Utils.LOG_WARNING("Generating a Multi-Pick out of "+material.name());
short[] rgb;
rgb = material.getRGBA();
int dur = customMaterial.getMaxUses();
- Utils.LOG_INFO("Determined durability for "+material.name()+" is "+dur);
+ Utils.LOG_WARNING("Determined durability for "+material.name()+" is "+dur);
if (GT_Durability){
dur = material.mDurability*100;
- Utils.LOG_INFO("Using gregtech durability value, "+material.name()+" is now "+dur+".");
+ Utils.LOG_WARNING("Using gregtech durability value, "+material.name()+" is now "+dur+".");
}
else if (dur <= 0){
dur = material.mDurability;
- Utils.LOG_INFO("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability.");
+ Utils.LOG_WARNING("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability.");
}
-
+
if (dur <= 0){
- Utils.LOG_INFO("Still too low, "+material.name()+" will now go unused.");
+ Utils.LOG_WARNING("Still too low, "+material.name()+" will now go unused.");
return null;
}
-
+
MultiPickaxeBase MP_Redstone = new MultiPickaxeBase(
material.name()+" Multipick",
(customMaterial),
dur,
Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2])
);
-
- return MP_Redstone;
-
+
+ if (MP_Redstone.isValid){
+ return MP_Redstone;
+ }
+ return null;
+
+ }
+
+ public static MultiSpadeBase generateMultiShovel(boolean GT_Durability, Materials material){
+ ToolMaterial customMaterial = Utils.generateMaterialFromGT(material);
+ Utils.LOG_WARNING("Generating a Multi-Shovel out of "+material.name());
+ short[] rgb;
+ rgb = material.getRGBA();
+ int dur = customMaterial.getMaxUses();
+ Utils.LOG_WARNING("Determined durability for "+material.name()+" is "+dur);
+ if (GT_Durability){
+ dur = material.mDurability*100;
+ Utils.LOG_WARNING("Using gregtech durability value, "+material.name()+" is now "+dur+".");
+ }
+ else if (dur <= 0){
+ dur = material.mDurability;
+ Utils.LOG_WARNING("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability.");
+ }
+
+ if (dur <= 0){
+ Utils.LOG_WARNING("Still too low, "+material.name()+" will now go unused.");
+ return null;
+ }
+
+ MultiSpadeBase MP_Redstone = new MultiSpadeBase(
+ material.name()+" Multishovel",
+ (customMaterial),
+ dur,
+ Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2])
+ );
+
+ if (MP_Redstone.isValid){
+ return MP_Redstone;
+ }
+ return null;
+
+ }
+
+ public static BaseItemDecidust generateDecidust(Materials material){
+ if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null){
+ Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material);
+ if (placeholder != null)
+ generateDecidust(placeholder);
+ }
+ return null;
}
-
+
+ public static BaseItemDecidust generateDecidust(Material material){
+ if (material.getDust(1) != null && MaterialUtils.hasValidRGBA(material.getRGBA())){
+ BaseItemDecidust Decidust = new BaseItemDecidust(material);
+ return Decidust;
+ }
+ return null;
+ }
+
+ public static BaseItemCentidust generateCentidust(Materials material){
+ if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null){
+ Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material);
+ if (placeholder != null)
+ generateCentidust(placeholder);
+ }
+ return null;
+ }
+
+ public static BaseItemCentidust generateCentidust(Material material){
+ if (material.getDust(1) != null && MaterialUtils.hasValidRGBA(material.getRGBA())){
+ BaseItemCentidust Centidust = new BaseItemCentidust(material);
+ return Centidust;
+ }
+ return null;
+ }
+
public static boolean isRadioactive(String materialName){
int sRadiation = 0;
if (materialName.toLowerCase().contains("uranium")){
@@ -392,7 +416,7 @@ public class UtilsItems {
}
return false;
}
-
+
public static int getRadioactivityLevel(String materialName){
int sRadiation = 0;
if (materialName.toLowerCase().contains("uranium")){
@@ -406,17 +430,24 @@ public class UtilsItems {
}
return sRadiation;
}
-
+
public static String getArrayStackNames(ItemStack[] aStack){
String itemNames = "Item Array: ";
for (ItemStack alph : aStack){
- String temp = itemNames;
- itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize;
+
+ if (alph != null){
+ String temp = itemNames;
+ itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize;
+ }
+ else {
+ String temp = itemNames;
+ itemNames = temp + ", " + "null" + " x" + "0";
+ }
}
return itemNames;
-
+
}
-
+
public static String[] getArrayStackNamesAsArray(ItemStack[] aStack){
String[] itemNames = {};
int arpos = 0;
@@ -425,9 +456,9 @@ public class UtilsItems {
arpos++;
}
return itemNames;
-
+
}
-
+
public static String getFluidArrayStackNames(FluidStack[] aStack){
String itemNames = "Fluid Array: ";
for (FluidStack alph : aStack){
@@ -435,7 +466,11 @@ public class UtilsItems {
itemNames = temp + ", " + alph.getFluid().getName() + " x" + alph.amount;
}
return itemNames;
-
+
+ }
+
+ public static ItemStack getGregtechCircuit(int Meta){
+ return ItemUtils.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", Meta, 0);
}
}