diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-10-23 07:36:05 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-10-23 07:36:05 +1000 |
commit | 3826cbb1223a25a6d476486d9369d65a22090aec (patch) | |
tree | b176e3752ae9aeadb3bda54ab3757d4acc6f6ff9 /src/Java/gtPlusPlus | |
parent | b123b87177c907951f695d616c31f1d229412e60 (diff) | |
download | GT5-Unofficial-3826cbb1223a25a6d476486d9369d65a22090aec.tar.gz GT5-Unofficial-3826cbb1223a25a6d476486d9369d65a22090aec.tar.bz2 GT5-Unofficial-3826cbb1223a25a6d476486d9369d65a22090aec.zip |
% Massive Material Backend Changes. (Nothing noticeable to players)
+ Added Chemical Compounds to Dust stacks, so you know how to make/use them.
+ As an idea, added Deci and Centi dusts, each representing .10 and point .01 of a full dust. (Probably will remove these, or use them for unique crafting options)
% Moved Radiation data to Material class.
% Created a BaseItemComponent and made all machine components except ingots/dusts utilise it. (Saves boiler-plating 30 lines per class and also it's using OOP for it's real job)
Diffstat (limited to 'src/Java/gtPlusPlus')
21 files changed, 657 insertions, 695 deletions
diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index debf8dbc24..74ea3ed4d3 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -9,6 +9,8 @@ import gtPlusPlus.core.common.compat.COMPAT_Baubles; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.BaseItemBackpack; import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.item.base.dusts.decimal.BaseItemCentidust; +import gtPlusPlus.core.item.base.dusts.decimal.BaseItemDecidust; import gtPlusPlus.core.item.base.foods.BaseItemFood; import gtPlusPlus.core.item.base.foods.BaseItemHotFood; import gtPlusPlus.core.item.base.ingots.BaseItemIngot; @@ -111,6 +113,9 @@ public final class ModItems { public static MultiPickaxeBase MP_GTMATERIAL; public static MultiSpadeBase MS_GTMATERIAL; + + public static BaseItemDecidust itemBaseDecidust; + public static BaseItemCentidust itemBaseCentidust; public static ItemStack FluidCell; @@ -266,7 +271,7 @@ public final class ModItems { dust2LiOH_CaCO3 = UtilsItems.generateSpecialUseDusts("2LiOHCaCO3", "2LiOH & CaCO3 Compound", Utils.rgbtoHexValue(255, 255, 255))[0]; //https://en.wikipedia.org/wiki/Calcium_carbonate //FLiBe Fuel Compounds - dustLi2BeF4 = UtilsItems.generateSpecialUseDusts("Li2BeF4", "Li2BeF4 Fuel Compound", Utils.rgbtoHexValue(255, 255, 255))[0]; //https://en.wikipedia.org/wiki/Calcium_carbonate + dustLi2BeF4 = UtilsItems.generateSpecialUseDusts("Li2BeF4", "Li2BeF4 Fuel Compound", Utils.rgbtoHexValue(255, 255, 255))[0]; //https://en.wikipedia.org/wiki/FLiBe boolean gtStyleTools = LoadedMods.Gregtech; @@ -274,19 +279,21 @@ public final class ModItems { for (Materials m : rm){ MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, m); MS_GTMATERIAL = UtilsItems.generateMultiShovel(gtStyleTools, m); + itemBaseDecidust = UtilsItems.generateDecidust(m); + itemBaseCentidust = UtilsItems.generateCentidust(m); } //EnderIO Resources if (LoadedMods.EnderIO || LOAD_ALL_CONTENT){ Utils.LOG_INFO("EnderIO Found - Loading Resources."); //Item Init - itemPlateSoularium = new BaseItemPlate("itemPlate"+"Soularium", "Soularium", Utils.rgbtoHexValue(95, 90, 54), 2, 0); - itemPlateRedstoneAlloy = new BaseItemPlate("itemPlate"+"RedstoneAlloy", "Redstone Alloy", Utils.rgbtoHexValue(178,34,34), 2, 0); - itemPlateElectricalSteel =new BaseItemPlate("itemPlate"+"ElectricalSteel", "Electrical Steel", Utils.rgbtoHexValue(194, 194, 194), 2, 0); - itemPlatePulsatingIron = new BaseItemPlate("itemPlate"+"PhasedIron", "Pulsating Iron", Utils.rgbtoHexValue(50, 91, 21), 2, 0); - itemPlateEnergeticAlloy = new BaseItemPlate("itemPlate"+"EnergeticAlloy", "Energetic Alloy", Utils.rgbtoHexValue(252, 152, 45), 2, 0); - itemPlateVibrantAlloy = new BaseItemPlate("itemPlate"+"VibrantAlloy", "Vibrant Alloy", Utils.rgbtoHexValue(204, 242, 142), 2, 0); - itemPlateConductiveIron = new BaseItemPlate("itemPlate"+"ConductiveIron", "Conductive Iron", Utils.rgbtoHexValue(164, 109, 100), 2, 0); + itemPlateSoularium = new BaseItemPlate("itemPlate"+"Soularium", "Soularium", new short[]{95, 90, 54}, 2, 0); + itemPlateRedstoneAlloy = new BaseItemPlate("itemPlate"+"RedstoneAlloy", "Redstone Alloy", new short[]{178,34,34}, 2, 0); + itemPlateElectricalSteel =new BaseItemPlate("itemPlate"+"ElectricalSteel", "Electrical Steel", new short[]{194, 194, 194}, 2, 0); + itemPlatePulsatingIron = new BaseItemPlate("itemPlate"+"PhasedIron", "Phased Iron", new short[]{50, 91, 21}, 2, 0); + itemPlateEnergeticAlloy = new BaseItemPlate("itemPlate"+"EnergeticAlloy", "Energetic Alloy", new short[]{252, 152, 45}, 2, 0); + itemPlateVibrantAlloy = new BaseItemPlate("itemPlate"+"VibrantAlloy", "Vibrant Alloy", new short[]{204, 242, 142}, 2, 0); + itemPlateConductiveIron = new BaseItemPlate("itemPlate"+"ConductiveIron", "Conductive Iron", new short[]{164, 109, 100}, 2, 0); } else { @@ -296,9 +303,9 @@ public final class ModItems { if (LoadedMods.Big_Reactors|| LOAD_ALL_CONTENT){ Utils.LOG_INFO("BigReactors Found - Loading Resources."); //Item Init - itemPlateBlutonium = new BaseItemPlate("itemPlate"+"Blutonium", "Blutonium", Utils.rgbtoHexValue(0, 0, 255), 2, 0); - itemPlateCyanite = new BaseItemPlate("itemPlate"+"Cyanite", "Cyanite", Utils.rgbtoHexValue(0, 191, 255), 2, 0); - itemPlateLudicrite = new BaseItemPlate("itemPlate"+"Ludicrite", "Ludicrite", Utils.rgbtoHexValue(167, 5, 179), 2, 0); + itemPlateBlutonium = new BaseItemPlate("itemPlate"+"Blutonium", "Blutonium", new short[]{0, 0, 255}, 2, 0); + itemPlateCyanite = new BaseItemPlate("itemPlate"+"Cyanite", "Cyanite", new short[]{0, 191, 255}, 2, 0); + itemPlateLudicrite = new BaseItemPlate("itemPlate"+"Ludicrite", "Ludicrite", new short[]{167, 5, 179}, 2, 0); } else { @@ -311,7 +318,7 @@ public final class ModItems { try { UtilsItems.getItemForOreDict("Thaumcraft:ItemResource", "ingotVoidMetal", "Void Metal Ingot", 16); - itemPlateVoidMetal = new BaseItemPlate("itemPlate"+"Void", "Void Metal", Utils.rgbtoHexValue(82, 17, 82), 2, 0); + itemPlateVoidMetal = new BaseItemPlate("itemPlate"+"Void", "Void", new short[]{82, 17, 82}, 2, 0); GT_OreDictUnificator.registerOre("plateVoidMetal", new ItemStack(ModItems.itemPlateVoidMetal)); } catch (NullPointerException e){ e.getClass(); @@ -340,7 +347,7 @@ public final class ModItems { if (LoadedMods.PneumaticCraft|| LOAD_ALL_CONTENT){ Utils.LOG_INFO("PneumaticCraft Found - Loading Resources."); //Item Init - itemPlateCompressedIron = new BaseItemPlate("itemPlate"+"CompressedIron", "Compressed Iron", Utils.rgbtoHexValue(128, 128, 128), 2, 0); + itemPlateCompressedIron = new BaseItemPlate("itemPlate"+"CompressedIron", "Compressed Iron", new short[]{128, 128, 128}, 2, 0); } else { Utils.LOG_WARNING("PneumaticCraft not Found - Skipping Resources."); @@ -360,7 +367,7 @@ public final class ModItems { if (LoadedMods.RFTools|| LOAD_ALL_CONTENT){ Utils.LOG_INFO("rfTools Found - Loading Resources."); //Item Init - itemPlateDimensionShard = new BaseItemPlate("itemPlate"+"DimensionShard", "Dimensional Shard", Utils.rgbtoHexValue(170, 230, 230), 2, 0); + itemPlateDimensionShard = new BaseItemPlate("itemPlate"+"DimensionShard", "Dimensional Shard", new short[]{170, 230, 230}, 2, 0); } else { Utils.LOG_WARNING("rfTools not Found - Skipping Resources."); @@ -402,8 +409,8 @@ public final class ModItems { //Special Item Handling Case if (configSwitches.enableAlternativeBatteryAlloy) { - ModItems.itemIngotBatteryAlloy = new BaseItemIngot("itemIngotBatteryAlloy", "Battery Alloy", Utils.rgbtoHexValue(35, 228, 141), 0); - ModItems.itemPlateBatteryAlloy = new BaseItemPlate("itemPlateBatteryAlloy", "Battery Alloy", Utils.rgbtoHexValue(35, 228, 141), 2, 0); + //ModItems.itemIngotBatteryAlloy = new BaseItemIngot("itemIngotBatteryAlloy", "Battery Alloy", new short[]{35, 228, 141}, 0); TODO + ModItems.itemPlateBatteryAlloy = new BaseItemPlate("itemPlateBatteryAlloy", "Battery Alloy", new short[]{35, 228, 141}, 2, 0); } @@ -447,4 +454,4 @@ public final class ModItems { //ItemBlockGtFrameBox = new ItemBlockGtFrameBox(ModBlocks.blockGtFrameSet1); //GameRegistry.registerItem(ItemBlockGtFrameBox, "itemGtFrameBoxSet1"); } -}
\ No newline at end of file +} diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java new file mode 100644 index 0000000000..46a39a5883 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -0,0 +1,151 @@ +package gtPlusPlus.core.item.base; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemComponent extends Item{ + + public final Material componentMaterial; + public final String materialName; + public final String unlocalName; + public final ComponentTypes componentType; + + public BaseItemComponent(Material material, ComponentTypes componentType) { + this.componentMaterial = material; + this.unlocalName = "item"+componentType.COMPONENT_NAME+material.getUnlocalizedName(); + this.materialName = material.getLocalizedName(); + this.componentType = componentType; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalName); + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "item"+componentType.COMPONENT_NAME); + GameRegistry.registerItem(this, unlocalName); + GT_OreDictUnificator.registerOre(componentType.COMPONENT_NAME.toLowerCase()+material.getUnlocalizedName(), UtilsItems.getSimpleStack(this)); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (componentMaterial.getLocalizedName()+componentType.DISPLAY_NAME); + } + + public final String getMaterialName() { + return materialName; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + + if (materialName != null && materialName != "" && !materialName.equals("")){ + + + if (componentType == ComponentTypes.DUST){ + list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); + } + if (componentType == ComponentTypes.INGOT){ + list.add(EnumChatFormatting.GRAY+"A solid ingot of " + materialName + "."); + if (materialName != null && materialName != "" && !materialName.equals("") && unlocalName.toLowerCase().contains("ingothot")){ + list.add(EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.RED+"Very hot! "+EnumChatFormatting.GRAY+" Avoid direct handling.."); + } + } + if (componentType == ComponentTypes.PLATE){ + list.add(EnumChatFormatting.GRAY+"A flat plate of " + materialName + "."); + } + if (componentType == ComponentTypes.PLATEDOUBLE){ + list.add(EnumChatFormatting.GRAY+"A double plate of " + materialName + "."); + } + if (componentType == ComponentTypes.ROD){ + list.add(EnumChatFormatting.GRAY+"A 40cm Rod of " + materialName + "."); + } + if (componentType == ComponentTypes.RODLONG){ + list.add(EnumChatFormatting.GRAY+"A 80cm Rod of " + materialName + "."); + } + if (componentType == ComponentTypes.ROTOR){ + list.add(EnumChatFormatting.GRAY+"A Rotor made out of " + materialName + ". "); + } + if (componentType == ComponentTypes.BOLT){ + list.add(EnumChatFormatting.GRAY+"A small Bolt, constructed from " + materialName + "."); + } + if (componentType == ComponentTypes.SCREW){ + list.add(EnumChatFormatting.GRAY+"A 8mm Screw, fabricated out of some " + materialName + "."); + } + if (componentType == ComponentTypes.GEAR){ + list.add(EnumChatFormatting.GRAY+"A large Gear, constructed from " + materialName + "."); + } + if (componentType == ComponentTypes.RING){ + list.add(EnumChatFormatting.GRAY+"A " + materialName + " Ring."); + } + if (componentMaterial.isRadioactive){ + list.add(CORE.GT_Tooltip_Radioactive); + } + + } + + super.addInformation(stack, aPlayer, list, bool); + } + + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + return componentMaterial.getRgbAsHex(); + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(componentMaterial.vRadioationLevel, world, entityHolding); + } + + + + + + + + + public static enum ComponentTypes { + DUST("Dust", " Dust"), + INGOT("Ingot", " Ingot"), + PLATE("Plate", " Plate"), + PLATEDOUBLE("PlateDouble", " Double Plate"), + ROD("Rod", " Rod"), + RODLONG("RodLong", " Long Rod"), + GEAR("Gear", " Gear"), + SCREW("Screw", " Screw"), + BOLT("Bolt", " Bolt"), + ROTOR("Rotor", " Rotor"), + RING("Ring", " Ring"); + + private String COMPONENT_NAME; + private String DISPLAY_NAME; + private ComponentTypes (final String LocalName, String DisplayName){ + this.COMPONENT_NAME = LocalName; + this.DISPLAY_NAME = DisplayName; + } + + public String getComponent(){ + return COMPONENT_NAME; + } + + public String getName(){ + return DISPLAY_NAME; + } + } + +} + + diff --git a/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java b/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java index 3d56307f39..0bd42e6eac 100644 --- a/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java +++ b/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java @@ -2,80 +2,31 @@ package gtPlusPlus.core.item.base.bolts; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.core.util.math.MathUtils; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import cpw.mods.fml.common.registry.GameRegistry; -public class BaseItemBolt extends Item{ - - final Material boltMaterial; - final String materialName; - final String unlocalName; +public class BaseItemBolt extends BaseItemComponent{ public BaseItemBolt(Material material) { - this.boltMaterial = material; - this.unlocalName = "itemBolt"+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalName); - this.setMaxStackSize(64); - this.setTextureName(CORE.MODID + ":" + "itemBolt"); - GameRegistry.registerItem(this, unlocalName); - GT_OreDictUnificator.registerOre(unlocalName.replace("itemB", "b"), UtilsItems.getSimpleStack(this)); + super(material, BaseItemComponent.ComponentTypes.BOLT); + addExtruderRecipe(); } - @Override - public String getItemStackDisplayName(ItemStack p_77653_1_) { - - return (materialName+ " Bolt"); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (materialName != null && materialName != "" && !materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"A small Bolt, constructed from " + materialName + "."); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return materialName; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (boltMaterial.getRgbAsHex() == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return boltMaterial.getRgbAsHex(); - - } - private void addExtruderRecipe(){ Utils.LOG_WARNING("Adding recipe for "+materialName+" Bolts"); String tempIngot = unlocalName.replace("itemBolt", "ingot"); ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); if (null != tempOutputStack){ GT_Values.RA.addExtruderRecipe(tempOutputStack, - ItemList.Shape_Extruder_Bolt.get(1), + ItemList.Shape_Extruder_Bolt.get(0), UtilsItems.getSimpleStack(this, 8), - (int) Math.max(boltMaterial.getMass() * 2L * 1, 1), - 8 * boltMaterial.vVoltageMultiplier); + (int) Math.max(componentMaterial.getMass() * 2L * 1, 1), + 8 * componentMaterial.vVoltageMultiplier); } - } } diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java index f16355593b..be020b7d05 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -113,6 +113,9 @@ public class BaseItemDust extends Item{ if (sRadiation > 0){ list.add(CORE.GT_Tooltip_Radioactive); } + if (dustInfo != null){ + list.add(dustInfo.vChemicalFormula); + } //} super.addInformation(stack, aPlayer, list, bool); } diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java b/src/Java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java new file mode 100644 index 0000000000..0faa781fd9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java @@ -0,0 +1,56 @@ +package gtPlusPlus.core.item.base.dusts.decimal; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemCentidust extends Item{ + + final Material dustMaterial; + final String materialName; + final String unlocalName; + + public BaseItemCentidust(Material material) { + this.dustMaterial = material; + this.unlocalName = "itemCentidust"+material.getUnlocalizedName(); + this.materialName = material.getLocalizedName(); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalName); + this.setMaxStackSize(10); + this.setTextureName(CORE.MODID + ":" + "itemCentidust"); //TODO + GameRegistry.registerItem(this, unlocalName); + //GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Centidust"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"1% of a " + materialName + " dust pile."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + return dustMaterial.getRgbAsHex(); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java b/src/Java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java new file mode 100644 index 0000000000..afb9eef473 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java @@ -0,0 +1,56 @@ +package gtPlusPlus.core.item.base.dusts.decimal; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemDecidust extends Item{ + + final Material dustMaterial; + final String materialName; + final String unlocalName; + + public BaseItemDecidust(Material material) { + this.dustMaterial = material; + this.unlocalName = "itemDecidust"+material.getUnlocalizedName(); + this.materialName = material.getLocalizedName(); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalName); + this.setMaxStackSize(10); + this.setTextureName(CORE.MODID + ":" + "itemDecidust"); //TODO + GameRegistry.registerItem(this, unlocalName); + //GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Decidust"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"10% of a " + materialName + " dust pile."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + return dustMaterial.getRgbAsHex(); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java b/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java index 47ce5b7815..56784e8530 100644 --- a/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java +++ b/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java @@ -2,79 +2,29 @@ package gtPlusPlus.core.item.base.gears; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.core.util.math.MathUtils; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import cpw.mods.fml.common.registry.GameRegistry; -public class BaseItemGear extends Item{ - - final Material gearMaterial; - final String materialName; - final String unlocalName; +public class BaseItemGear extends BaseItemComponent{ public BaseItemGear(Material material) { - this.gearMaterial = material; - this.unlocalName = "itemGear"+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalName); - this.setMaxStackSize(64); - this.setTextureName(CORE.MODID + ":" + "itemGear"); - GameRegistry.registerItem(this, unlocalName); - GT_OreDictUnificator.registerOre(unlocalName.replace("itemG", "g"), UtilsItems.getSimpleStack(this)); + super(material, BaseItemComponent.ComponentTypes.GEAR); addExtruderRecipe(); } - @Override - public String getItemStackDisplayName(ItemStack p_77653_1_) { - - return (gearMaterial.getLocalizedName()+ " Gear"); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (materialName != null && materialName != "" && !materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"A large Gear, constructed from " + materialName + "."); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return materialName; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (gearMaterial.getRgbAsHex() == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return gearMaterial.getRgbAsHex(); - - } - private void addExtruderRecipe(){ Utils.LOG_WARNING("Adding recipe for "+materialName+" Gears"); - ItemStack tempOutputStack = gearMaterial.getIngot(8); + ItemStack tempOutputStack = componentMaterial.getIngot(8); if (null != tempOutputStack){ - GT_Values.RA.addExtruderRecipe( tempOutputStack, - ItemList.Shape_Extruder_Gear.get(1), + ItemList.Shape_Extruder_Gear.get(0), UtilsItems.getSimpleStack(this), - (int) Math.max(gearMaterial.getMass() * 5L, 1), - 8 * gearMaterial.vVoltageMultiplier); + (int) Math.max(componentMaterial.getMass() * 5L, 1), + 8 * componentMaterial.vVoltageMultiplier); } } diff --git a/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java index 103198a395..3d1153eb6a 100644 --- a/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java +++ b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java @@ -1,92 +1,19 @@ package gtPlusPlus.core.item.base.plates; -import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.materials.MaterialUtils; -import java.util.List; +public class BaseItemPlate extends BaseItemComponent{ -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import cpw.mods.fml.common.registry.GameRegistry; - -public class BaseItemPlate extends Item{ - - protected int colour; - protected String materialName; - protected String unlocalName; - private int mTier; - - public BaseItemPlate(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { - setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalizedName); - this.unlocalName = unlocalizedName; - this.setMaxStackSize(64); - this.setTextureName(CORE.MODID + ":" + "itemPlate"); - this.colour = colour; - this.mTier = tier; - this.materialName = materialName; - this.sRadiation = sRadioactivity; - GameRegistry.registerItem(this, unlocalizedName); - GT_OreDictUnificator.registerOre(unlocalName.replace("itemP", "p"), UtilsItems.getSimpleStack(this)); - //addBendingRecipe(); - } - - @Override - public String getItemStackDisplayName(ItemStack p_77653_1_) { - - return (materialName+ " Plate"); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (materialName != null && materialName != "" && !materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"A flat plate of " + materialName + "."); - } - if (sRadiation > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - } - super.addInformation(stack, aPlayer, list, bool); + public BaseItemPlate(Material material) { + super(material, BaseItemComponent.ComponentTypes.PLATE); } - - public final String getMaterialName() { - return materialName; + + public BaseItemPlate(String unlocalizedName, String materialName, short[] colour, int tier, int sRadioactivity) { + this(MaterialUtils.generateQuickMaterial(materialName, new short[]{colour[0], colour[1], colour[2], 0}, sRadioactivity)); } - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return colour; - - } - protected final int sRadiation; - @Override - public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { - Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); - } - - private void addBendingRecipe(){ - Utils.LOG_WARNING("Adding recipe for "+materialName+" Plates"); - String tempIngot = unlocalName.replace("itemPlate", "ingot"); - ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); - if (null != tempOutputStack){ - GT_Values.RA.addBenderRecipe(tempOutputStack, - UtilsItems.getSimpleStack(this), - 14*mTier*20, - 64*mTier); - } - } } diff --git a/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java index e6bfc1253a..ce8bbe8191 100644 --- a/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java +++ b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java @@ -1,126 +1,18 @@ package gtPlusPlus.core.item.base.plates; -import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.core.util.math.MathUtils; - -import java.util.List; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import cpw.mods.fml.common.registry.GameRegistry; - -public class BaseItemPlateDouble extends Item{ - protected int colour; - protected String materialName; - protected String unlocalName; - private int mTier; +public class BaseItemPlateDouble extends BaseItemComponent{ - public BaseItemPlateDouble(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { - setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalizedName); - this.unlocalName = unlocalizedName; + public BaseItemPlateDouble(Material material) { + super(material, BaseItemComponent.ComponentTypes.PLATEDOUBLE); this.setMaxStackSize(32); - this.setTextureName(CORE.MODID + ":" + "itemPlateDouble"); - this.colour = colour; - this.mTier = tier; - this.materialName = materialName; - this.sRadiation = sRadioactivity; - GameRegistry.registerItem(this, unlocalizedName); - GT_OreDictUnificator.registerOre(unlocalName.replace("itemP", "p"), UtilsItems.getSimpleStack(this)); - //addBendingRecipe(); - //addCraftingRecipe(); } @Override public String getItemStackDisplayName(ItemStack p_77653_1_) { - return ("Double "+materialName+ " Plate"); } - - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (materialName != null && materialName != "" && !materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"A double plate of " + materialName + "."); - } - if (sRadiation > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return materialName; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return colour; - - } - - protected final int sRadiation; - @Override - public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { - Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); - } - - private void addBendingRecipe(){ - Utils.LOG_WARNING("Adding bender recipe for "+materialName+" Double Plates"); - String tempIngot = unlocalName.replace("itemPlateDouble", "ingot"); - String tempPlate = unlocalName.replace("itemPlateDouble", "plate"); - ItemStack inputIngot = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 2); - ItemStack inputPlate = UtilsItems.getItemStackOfAmountFromOreDict(tempPlate, 2); - if (null != inputIngot){ - GT_Values.RA.addBenderRecipe(inputIngot, - UtilsItems.getSimpleStack(this), - 4*20, - 96); - } - if (null != inputPlate){ - GT_Values.RA.addBenderRecipe(inputPlate, - UtilsItems.getSimpleStack(this), - 4*20, - 96); - } - } - - private void addCraftingRecipe(){ - Utils.LOG_WARNING("Adding crafting recipes for "+materialName+" Double Plates"); - String tempPlate = unlocalName.replace("itemPlateDouble", "plate"); - ItemStack inputPlate = UtilsItems.getItemStackOfAmountFromOreDict(tempPlate, 1); - if (null != inputPlate){ - - GT_ModHandler.addCraftingRecipe( - GT_Utility.copyAmount(1L, new Object[]{UtilsItems.getSimpleStack(this)}), - gregtech.api.util.GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | gregtech.api.util.GT_ModHandler.RecipeBits.BUFFERED, - new Object[]{"I", "B", "h", - Character.valueOf('I'), - inputPlate, - Character.valueOf('B'), - inputPlate}); - - GT_ModHandler.addShapelessCraftingRecipe( - GT_Utility.copyAmount(1L, new Object[]{UtilsItems.getSimpleStack(this)}), - new Object[]{gregtech.api.enums.ToolDictNames.craftingToolForgeHammer, - inputPlate, - inputPlate}); - } - } - } diff --git a/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java b/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java index d03b2b4e2f..fd09276dc3 100644 --- a/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java +++ b/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java @@ -2,69 +2,20 @@ package gtPlusPlus.core.item.base.rings; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.recipe.UtilsRecipe; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import cpw.mods.fml.common.registry.GameRegistry; -public class BaseItemRing extends Item{ - - final Material ringMaterial; - final String materialName; - final String unlocalName; +public class BaseItemRing extends BaseItemComponent{ public BaseItemRing(Material material) { - this.ringMaterial = material; - this.unlocalName = "itemRing"+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalName); - this.setMaxStackSize(64); - this.setTextureName(CORE.MODID + ":" + "itemRing"); - GameRegistry.registerItem(this, unlocalName); - GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); + super(material, BaseItemComponent.ComponentTypes.RING); addExtruderRecipe(); } - @Override - public String getItemStackDisplayName(ItemStack p_77653_1_) { - - return (materialName+ " Ring"); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (materialName != null && materialName != "" && !materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"A " + materialName + " Ring."); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return materialName; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (ringMaterial.getRgbAsHex() == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return ringMaterial.getRgbAsHex(); - - } - private void addExtruderRecipe(){ Utils.LOG_WARNING("Adding recipe for "+materialName+" Rings"); @@ -73,10 +24,10 @@ public class BaseItemRing extends Item{ ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); if (null != tempOutputStack){ GT_Values.RA.addExtruderRecipe(tempOutputStack, - ItemList.Shape_Extruder_Ring.get(1), + ItemList.Shape_Extruder_Ring.get(0), UtilsItems.getSimpleStack(this, 4), - (int) Math.max(ringMaterial.getMass() * 2L * 1, 1), - 6 * ringMaterial.vVoltageMultiplier); + (int) Math.max(componentMaterial.getMass() * 2L * 1, 1), + 6 * componentMaterial.vVoltageMultiplier); } //Shaped Recipe diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java index 0e4802ad0c..6f7cf4b6bc 100644 --- a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java @@ -2,43 +2,18 @@ package gtPlusPlus.core.item.base.rods; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.recipe.UtilsRecipe; - -import java.util.List; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import cpw.mods.fml.common.registry.GameRegistry; - -public class BaseItemRod extends Item{ - final Material rodMaterial; - final String materialName; - final String unlocalName; +public class BaseItemRod extends BaseItemComponent{ - public BaseItemRod(Material material, int sRadioactivity) { - this.rodMaterial = material; - this.unlocalName = "itemRod"+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalName); - this.setTextureName(CORE.MODID + ":" + "itemRod"); - this.setMaxStackSize(64); - this.sRadiation = sRadioactivity; - GameRegistry.registerItem(this, unlocalName); - GT_OreDictUnificator.registerOre(unlocalName.replace("itemRod", "stick"), UtilsItems.getSimpleStack(this)); + public BaseItemRod(Material material) { + super(material, BaseItemComponent.ComponentTypes.ROD); if (!material.equals(ELEMENT.URANIUM233)){ addExtruderRecipe(); @@ -46,70 +21,32 @@ public class BaseItemRod extends Item{ } - @Override - public String getItemStackDisplayName(ItemStack p_77653_1_) { - - return (materialName+ " Rod"); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (materialName != null && materialName != "" && !materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"A 40cm Rod of " + materialName + "."); - } - if (sRadiation > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return materialName; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (rodMaterial.getRgbAsHex() == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return rodMaterial.getRgbAsHex(); - - } - - protected final int sRadiation; - @Override - public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { - Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); - } private void addExtruderRecipe(){ Utils.LOG_WARNING("Adding recipe for "+materialName+" Rods"); - String tempStick = unlocalName.replace("itemRod", "stick"); - String tempStickLong = unlocalName.replace("itemRod", "stickLong"); - String tempBolt = unlocalName.replace("itemRod", "bolt"); - ItemStack stackStick = UtilsItems.getItemStackOfAmountFromOreDict(tempStick, 1); - ItemStack stackStick2 = UtilsItems.getItemStackOfAmountFromOreDict(tempStick, 2); - ItemStack stackBolt = UtilsItems.getItemStackOfAmountFromOreDict(tempBolt, 4); - ItemStack stackStickLong = UtilsItems.getItemStackOfAmountFromOreDict(tempStickLong, 1); - ItemStack stackIngot = rodMaterial.getIngot(1); + ItemStack stackStick = componentMaterial.getRod(1); + ItemStack stackStick2 = componentMaterial.getRod(2); + ItemStack stackBolt = componentMaterial.getBolt(4); + ItemStack stackStickLong = componentMaterial.getLongRod(1); + ItemStack stackIngot = componentMaterial.getIngot(1); GT_Values.RA.addExtruderRecipe( stackIngot, - ItemList.Shape_Extruder_Rod.get(1), + ItemList.Shape_Extruder_Rod.get(0), stackStick2, - (int) Math.max(rodMaterial.getMass() * 2L * 1, 1), - 6 * rodMaterial.vVoltageMultiplier); + (int) Math.max(componentMaterial.getMass() * 2L * 1, 1), + 6 * componentMaterial.vVoltageMultiplier); GT_Values.RA.addCutterRecipe( stackStick, stackBolt, null, - (int) Math.max(rodMaterial.getMass() * 2L, 1L), + (int) Math.max(componentMaterial.getMass() * 2L, 1L), 4); - if (sRadiation == 0){ + if (componentMaterial.isRadioactive){ UtilsRecipe.recipeBuilder( stackStick, stackStick, stackStick, stackStick, "craftingToolWrench", stackStick, @@ -118,7 +55,7 @@ public class BaseItemRod extends Item{ } //Shaped Recipe - Bolts - stackBolt = UtilsItems.getItemStackOfAmountFromOreDict(tempBolt, 2); + stackBolt = componentMaterial.getBolt(2); if (null != stackBolt){ UtilsRecipe.recipeBuilder( "craftingToolSaw", null, null, diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java index 6d87fd5872..714f8dc145 100644 --- a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java @@ -1,81 +1,25 @@ package gtPlusPlus.core.item.base.rods; import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.recipe.UtilsRecipe; - -import java.util.List; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import cpw.mods.fml.common.registry.GameRegistry; - -public class BaseItemRodLong extends Item{ - final Material rodLongMaterial; - final String materialName; - final String unlocalName; +public class BaseItemRodLong extends BaseItemComponent{ - public BaseItemRodLong(Material material, int sRadioactivity) { - this.rodLongMaterial = material; - this.unlocalName = "itemRodLong"+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(material.getUnlocalizedName()); - this.setTextureName(CORE.MODID + ":" + "itemRodLong"); - this.setMaxStackSize(64); - this.sRadiation = sRadioactivity; - GameRegistry.registerItem(this, unlocalName); - GT_OreDictUnificator.registerOre(unlocalName.replace("itemRod", "stick"), UtilsItems.getSimpleStack(this)); + public BaseItemRodLong(Material material) { + super(material, BaseItemComponent.ComponentTypes.RODLONG); addExtruderRecipe(); } - + @Override public String getItemStackDisplayName(ItemStack p_77653_1_) { - return ("Long "+materialName+ " Rod"); } - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (materialName != null && materialName != "" && !materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"A 80cm Rod of " + materialName + "."); - } - if (sRadiation > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return materialName; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (rodLongMaterial.getRgbAsHex() == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return rodLongMaterial.getRgbAsHex(); - - } - - protected final int sRadiation; - @Override - public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { - Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); - } - private void addExtruderRecipe(){ Utils.LOG_WARNING("Adding recipe for Long "+materialName+" Rods"); @@ -96,14 +40,14 @@ public class BaseItemRodLong extends Item{ GT_Values.RA.addForgeHammerRecipe( temp, stackLong, - (int) Math.max(rodLongMaterial.getMass(), 1L), + (int) Math.max(componentMaterial.getMass(), 1L), 16); GT_Values.RA.addCutterRecipe( stackLong, temp, null, - (int) Math.max(rodLongMaterial.getMass(), 1L), + (int) Math.max(componentMaterial.getMass(), 1L), 4); //Shaped Recipe - Long Rod to two smalls diff --git a/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java b/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java index d8ecea32bd..dd4804125a 100644 --- a/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java +++ b/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java @@ -1,88 +1,24 @@ package gtPlusPlus.core.item.base.rotors; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.recipe.UtilsRecipe; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import cpw.mods.fml.common.registry.GameRegistry; -public class BaseItemRotor extends Item{ +public class BaseItemRotor extends BaseItemComponent{ - protected int colour; - protected String materialName; - protected String unlocalName; - - public BaseItemRotor(String unlocalizedName, String materialName, int colour) { - setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalizedName); - this.unlocalName = unlocalizedName; - this.setMaxStackSize(64); - this.setTextureName(CORE.MODID + ":" + "itemRotor"); - this.colour = colour; - this.materialName = materialName; - GameRegistry.registerItem(this, unlocalizedName); - GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); + public BaseItemRotor(Material material) { + super(material, BaseItemComponent.ComponentTypes.ROTOR); generateRecipe(); } - @Override - public String getItemStackDisplayName(ItemStack p_77653_1_) { - - return (materialName+ " Rotor"); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (materialName != null && materialName != "" && !materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"A spindley Rotor made out of " + materialName + ". "); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return materialName; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return colour; - - } - - public static boolean getValidItemStack(ItemStack validStack){ - if (validStack != null){ - return true; - } - return false; - } - public void generateRecipe(){ - Utils.LOG_WARNING("Adding recipe for "+materialName+" Rotors"); - String tempIngot = unlocalName.replace("itemRotor", "plate"); - ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); - Utils.LOG_WARNING("Found for recipe:"+tempIngot+ "isValidStack()="+getValidItemStack(tempOutputStack)); - String screw = unlocalName.replace("itemRotor", "screw"); - ItemStack screwStack = UtilsItems.getItemStackOfAmountFromOreDict(screw, 1); - Utils.LOG_WARNING("Found for recipe:"+screw+ "isValidStack()="+getValidItemStack(screwStack)); - String ring = unlocalName.replace("itemRotor", "ring"); - ItemStack ringStack = UtilsItems.getItemStackOfAmountFromOreDict(ring, 1); - Utils.LOG_WARNING("Found for recipe:"+ring+ "isValidStack()="+getValidItemStack(ringStack)); - + ItemStack tempOutputStack = this.componentMaterial.getPlate(1); + ItemStack screwStack = this.componentMaterial.getScrew(1); + ItemStack ringStack = this.componentMaterial.getRing(1); UtilsRecipe.addShapedGregtechRecipe( tempOutputStack, "craftingToolHardHammer", tempOutputStack, screwStack, ringStack, "craftingToolFile", diff --git a/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java index 8d727770ce..84ac759ba8 100644 --- a/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java +++ b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java @@ -1,69 +1,20 @@ package gtPlusPlus.core.item.base.screws; import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.recipe.UtilsRecipe; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import cpw.mods.fml.common.registry.GameRegistry; -public class BaseItemScrew extends Item{ - - final Material screwMaterial; - final String materialName; - final String unlocalName; +public class BaseItemScrew extends BaseItemComponent{ public BaseItemScrew(Material material) { - this.screwMaterial = material; - this.unlocalName = "itemScrew"+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalName); - this.setMaxStackSize(64); - this.setTextureName(CORE.MODID + ":" + "itemScrew"); - GameRegistry.registerItem(this, unlocalName); - GT_OreDictUnificator.registerOre(unlocalName.replace("itemS", "s"), UtilsItems.getSimpleStack(this)); + super(material, BaseItemComponent.ComponentTypes.SCREW); addLatheRecipe(); } - @Override - public String getItemStackDisplayName(ItemStack p_77653_1_) { - - return (materialName+ " Screw"); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (materialName != null && materialName != "" && !materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"A 8mm Screw, fabricated out of some " + materialName + "."); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return materialName; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (screwMaterial.getRgbAsHex() == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return screwMaterial.getRgbAsHex(); - - } - private void addLatheRecipe(){ Utils.LOG_WARNING("Adding recipe for "+materialName+" Screws"); ItemStack boltStack = UtilsItems.getItemStackOfAmountFromOreDict(unlocalName.replace("itemScrew", "bolt"), 1); @@ -72,7 +23,7 @@ public class BaseItemScrew extends Item{ boltStack, UtilsItems.getSimpleStack(this), null, - (int) Math.max(screwMaterial.getMass() / 8L, 1L), + (int) Math.max(componentMaterial.getMass() / 8L, 1L), 4); diff --git a/src/Java/gtPlusPlus/core/material/ELEMENT.java b/src/Java/gtPlusPlus/core/material/ELEMENT.java index 307105eaf0..9c05e53165 100644 --- a/src/Java/gtPlusPlus/core/material/ELEMENT.java +++ b/src/Java/gtPlusPlus/core/material/ELEMENT.java @@ -46,7 +46,7 @@ public final class ELEMENT { public static final Material RUBIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Rubidium); public static final Material STRONTIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Strontium); public static final Material YTTRIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Yttrium); - public static final Material ZIRCONIUM = new Material("Zirconium", new short[]{255, 250, 205}, 1855, 4377, 40, 51, false, null);//Not a GT Inherited Material + public static final Material ZIRCONIUM = new Material("Zirconium", new short[]{255, 250, 205}, 1855, 4377, 40, 51, false, null, "Zr", 0);//Not a GT Inherited Material public static final Material NIOBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Niobium); public static final Material MOLYBDENUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Molybdenum); //public static final Material TECHNETIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Technetium); @@ -79,7 +79,7 @@ public final class ELEMENT { public static final Material THORIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thorium); public static final Material URANIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium); public static final Material PLUTONIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Plutonium); - public static final Material URANIUM233 = new Material("Uranium-233", new short[]{73, 220, 83, 0}, 1132, 4131, 92, 141, false, null);//Not a GT Inherited Material + public static final Material URANIUM233 = new Material("Uranium-233", new short[]{73, 220, 83, 0}, 1132, 4131, 92, 141, false, null, MaterialUtils.superscript("233U"), 0);//Not a GT Inherited Material } diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 3e5c3a4d67..d6f5d77f20 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -9,12 +9,16 @@ public class Material { final String unlocalizedName; final String localizedName; + + protected Object dataVar; private MaterialStack[] materialInput = new MaterialStack[4]; final short[] RGBA; final boolean usesBlastFurnace; + public final boolean isRadioactive; + public final byte vRadioationLevel; final int meltingPointK; final int boilingPointK; @@ -25,8 +29,17 @@ public class Material { final long vMass; public final int vTier; public final int vVoltageMultiplier; + public final String vChemicalFormula; + + public Material(String materialName, short[] rgba, int meltingPoint, int boilingPoint, long protons, long neutrons, boolean blastFurnace, MaterialStack[] inputs){ + this(materialName, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, inputs, "", 0); + } + + public Material(String materialName, short[] rgba, int meltingPoint, int boilingPoint, long protons, long neutrons, boolean blastFurnace, MaterialStack[] inputs, int radiationLevel){ + this(materialName, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, inputs, "", radiationLevel); + } - public Material(String materialName, short[] rgba, int meltingPoint, int boilingPoint, long protons, long neutrons, boolean blastFurnace, MaterialStack[] inputs){ + public Material(String materialName, short[] rgba, int meltingPoint, int boilingPoint, long protons, long neutrons, boolean blastFurnace, MaterialStack[] inputs, String chemicalFormula, int radiationLevel){ this.unlocalizedName = Utils.sanitizeString(materialName); this.localizedName = materialName; @@ -41,6 +54,21 @@ public class Material { this.vProtons = protons; this.vNeutrons = neutrons; this.vMass = getMass(); + if (chemicalFormula.equals("")){ + this.vChemicalFormula = getChemicalFormula(inputs); + } + else{ + this.vChemicalFormula = chemicalFormula; + } + + if (radiationLevel != 0){ + this.isRadioactive = true; + this.vRadioationLevel = (byte) radiationLevel; + } + else { + this.isRadioactive = false; + this.vRadioationLevel = (byte) radiationLevel; + } if (getMeltingPoint_K() >= 0 && getMeltingPoint_K() <= 750){ this.vTier = 1; @@ -91,6 +119,9 @@ public class Material { } } } + + dataVar = MathUtils.generateSingularRandomHexValue(); + Utils.LOG_INFO("Creating a Material instance for "+materialName); Utils.LOG_INFO("Protons: "+vProtons); Utils.LOG_INFO("Neutrons: "+vNeutrons); @@ -110,8 +141,13 @@ public class Material { public short[] getRGBA(){ return RGBA; } - + public int getRgbAsHex(){ + + int returnValue = Utils.rgbtoHexValue(RGBA[0], RGBA[1], RGBA[2]); + if (returnValue == 0){ + return (int) dataVar; + } return Utils.rgbtoHexValue(RGBA[0], RGBA[1], RGBA[2]); } @@ -148,15 +184,15 @@ public class Material { } public ItemStack getDust(int stacksize){ - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+unlocalizedName, stacksize); + return UtilsItems.getItemStackOfAmountFromOreDict("dust"+unlocalizedName, stacksize); } public ItemStack getSmallDust(int stacksize){ - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustSmall"+unlocalizedName, stacksize); + return UtilsItems.getItemStackOfAmountFromOreDict("dustSmall"+unlocalizedName, stacksize); } public ItemStack getTinyDust(int stacksize){ - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustTiny"+unlocalizedName, stacksize); + return UtilsItems.getItemStackOfAmountFromOreDict("dustTiny"+unlocalizedName, stacksize); } public ItemStack[] getValidInputStacks(){ @@ -164,23 +200,43 @@ public class Material { } public ItemStack getIngot(int stacksize){ - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("ingot"+unlocalizedName, stacksize); + return UtilsItems.getItemStackOfAmountFromOreDict("ingot"+unlocalizedName, stacksize); } public ItemStack getPlate(int stacksize){ - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("plate"+unlocalizedName, stacksize); + return UtilsItems.getItemStackOfAmountFromOreDict("plate"+unlocalizedName, stacksize); } public ItemStack getPlateDouble(int stacksize){ - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("plateDouble"+unlocalizedName, stacksize); + return UtilsItems.getItemStackOfAmountFromOreDict("plateDouble"+unlocalizedName, stacksize); } - + public ItemStack getGear(int stacksize){ - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("gear"+unlocalizedName, stacksize); + return UtilsItems.getItemStackOfAmountFromOreDict("gear"+unlocalizedName, stacksize); } - + public ItemStack getRod(int stacksize){ - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("stick"+unlocalizedName, stacksize); + return UtilsItems.getItemStackOfAmountFromOreDict("stick"+unlocalizedName, stacksize); + } + + public ItemStack getLongRod(int stacksize){ + return UtilsItems.getItemStackOfAmountFromOreDict("stickLong"+unlocalizedName, stacksize); + } + + public ItemStack getBolt(int stacksize){ + return UtilsItems.getItemStackOfAmountFromOreDict("bolt"+unlocalizedName, stacksize); + } + + public ItemStack getScrew(int stacksize){ + return UtilsItems.getItemStackOfAmountFromOreDict("screw"+unlocalizedName, stacksize); + } + + public ItemStack getRing(int stacksize){ + return UtilsItems.getItemStackOfAmountFromOreDict("ring"+unlocalizedName, stacksize); + } + + public ItemStack getRotor(int stacksize){ + return UtilsItems.getItemStackOfAmountFromOreDict("rotor"+unlocalizedName, stacksize); } public ItemStack[] getMaterialComposites(){ @@ -221,4 +277,82 @@ public class Material { return new int[]{}; } + + + +private int getInputMaterialCount(MaterialStack[] materialInput){ + int i = 0; + for (int r=0;r<4;r++){ + try { + if (!materialInput[r].equals(null)){ + i++; + } + } catch(Throwable x){ + return i; + } + } + return i; +} + + + public String getChemicalFormula(MaterialStack[] materialInput){ + if (materialInput != null && materialInput.length >= 1){ + int f = getInputMaterialCount(materialInput); + String[] formulaComponents = new String[f]; + for (int i=0;i<f;i++){ + try { + if (materialInput[i] != null){ + formulaComponents[i] = materialInput[i].stackMaterial.vChemicalFormula; + Utils.LOG_INFO("LOOK AT ME IN THE LOG - " + formulaComponents[i]); + } + else{ + Utils.LOG_INFO("LOOK AT ME IN THE LOG - materialInput[i] was null"); + } + } catch (Throwable e){ + Utils.LOG_INFO("LOOK AT ME IN THE LOG - got an error"); + return "??"; + } + } + + String properName = ""; + for (int r = 0; r < f; r++){ + properName = properName + formulaComponents[r]; + Utils.LOG_INFO("LOOK AT ME IN THE LOG - "+properName); + } + if (!properName.equals("")) + return properName; + + } + return "??"; + + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } diff --git a/src/Java/gtPlusPlus/core/material/MaterialStack.java b/src/Java/gtPlusPlus/core/material/MaterialStack.java index f8b9b35bd8..3682b73cfe 100644 --- a/src/Java/gtPlusPlus/core/material/MaterialStack.java +++ b/src/Java/gtPlusPlus/core/material/MaterialStack.java @@ -5,12 +5,12 @@ import net.minecraft.item.ItemStack; public class MaterialStack { - final Material materialInput; + final Material stackMaterial; final double percentageToUse; public MaterialStack(Material inputs, double percentage){ - this.materialInput = inputs; + this.stackMaterial = inputs; this.percentageToUse = percentage; @@ -43,16 +43,16 @@ public class MaterialStack { } switch (caseStatus) { case 1: { - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustTiny"+materialInput.unlocalizedName, amount); + return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustTiny"+stackMaterial.unlocalizedName, amount); } case 2: { - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustSmall"+materialInput.unlocalizedName, amount); + return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustSmall"+stackMaterial.unlocalizedName, amount); } case 3: { - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+materialInput.unlocalizedName, amount); + return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+stackMaterial.unlocalizedName, amount); } case 4: { - return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+materialInput.unlocalizedName, amount); + return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+stackMaterial.unlocalizedName, amount); } default: return null; @@ -61,7 +61,7 @@ public class MaterialStack { } public ItemStack[] getValidItemStacks(){ - return UtilsItems.validItemsForOreDict(materialInput.unlocalizedName); + return UtilsItems.validItemsForOreDict(stackMaterial.unlocalizedName); } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 9debd34283..298e012143 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -314,8 +314,8 @@ public class RECIPES_GREGTECH { null, //Fluid Input null, //Fluid Output UtilsItems.getItemStackOfAmountFromOreDict("dust2LiOHCaCO3", 10), //Output Stack - 600*20, - 128); + 600*20 + ); GT_Values.RA.addChemicalRecipe( UtilsItems.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 5), //Input Stack 1 @@ -323,8 +323,8 @@ public class RECIPES_GREGTECH { FluidUtils.getFluidStack("hydrofluoricacid", 2500), //Fluid Input FluidUtils.getFluidStack("water", 2500), //Fluid Output UtilsItems.getItemStackOfAmountFromOreDict("dustLithiumFluoride", 5), //Output Stack - 600*20, - 128); + 600*20 + ); } private static void blastFurnaceRecipes(){ diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index bee5de98ea..cdfa556de9 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -426,7 +426,10 @@ public class Utils { } } - public static int rgbtoHexValue(int r, int g, int b){ + public static int rgbtoHexValue(int r, int g, int b){ + if (r > 255 || g > 255 || b > 255 || r < 0 || g < 0 || b < 0){ + return 0; + } Color c = new Color(r,g,b); String temp = Integer.toHexString( c.getRGB() & 0xFFFFFF ).toUpperCase(); diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java index 62162e596d..fbda7554df 100644 --- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java +++ b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java @@ -1,6 +1,7 @@ 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; @@ -10,6 +11,8 @@ 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.dusts.decimal.BaseItemCentidust; +import gtPlusPlus.core.item.base.dusts.decimal.BaseItemDecidust; import gtPlusPlus.core.item.base.gears.BaseItemGear; import gtPlusPlus.core.item.base.ingots.BaseItemIngot; import gtPlusPlus.core.item.base.ingots.BaseItemIngotHot; @@ -244,7 +247,7 @@ public class UtilsItems { return null; } - + public static ItemStack getItemStackInPlayersHand(){ Minecraft mc = Minecraft.getMinecraft(); ItemStack heldItem = null; @@ -290,7 +293,7 @@ public class UtilsItems { Utils.LOG_INFO(oredictName+" was not valid."); return null; } - + public static ItemStack getItemStackOfAmountFromOreDictNoBrokenExcluding(String excludeModName, String oredictName, int amount){ ItemStack returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); @@ -347,9 +350,9 @@ public class UtilsItems { 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); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemRod(matInfo); + temp = new BaseItemRodLong(matInfo); } else { @@ -366,14 +369,14 @@ public class UtilsItems { 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 BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); temp = new BaseItemBolt(matInfo); - temp = new BaseItemRod(matInfo, sRadiation); - temp = new BaseItemRodLong(matInfo, sRadiation); + temp = new BaseItemRod(matInfo); + temp = new BaseItemRodLong(matInfo); temp = new BaseItemRing(matInfo); temp = new BaseItemScrew(matInfo); - temp = new BaseItemRotor("itemRotor"+unlocalizedName, materialName, Colour); + temp = new BaseItemRotor(matInfo); temp = new BaseItemGear(matInfo); } @@ -402,22 +405,22 @@ public class UtilsItems { 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; } @@ -437,22 +440,22 @@ public class UtilsItems { public static MultiSpadeBase generateMultiShovel(boolean GT_Durability, Materials material){ ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); - Utils.LOG_INFO("Generating a Multi-Shovel out of "+material.name()); + Utils.LOG_WARNING("Generating a Multi-Shovel 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; } @@ -470,6 +473,40 @@ public class UtilsItems { } + 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")){ @@ -504,7 +541,7 @@ public class UtilsItems { public static String getArrayStackNames(ItemStack[] aStack){ String itemNames = "Item Array: "; for (ItemStack alph : aStack){ - + if (alph != null){ String temp = itemNames; itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; diff --git a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java index 0eae02d827..61171e3688 100644 --- a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java @@ -1,6 +1,7 @@ package gtPlusPlus.core.util.materials; import gregtech.api.enums.Dyes; +import gregtech.api.enums.Element; import gregtech.api.enums.Materials; import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gregtech.api.enums.TextureSet; @@ -51,8 +52,83 @@ public class MaterialUtils { int boiling = material.mBlastFurnaceTemp; long protons = material.getProtons(); long neutrons = material.getNeutrons(); - boolean blastFurnace = material.mBlastFurnaceRequired; - return new Material(name, rgba, melting, boiling, protons, neutrons, blastFurnace, null); + boolean blastFurnace = material.mBlastFurnaceRequired; + String chemicalFormula = material.mChemicalFormula; + Element element = material.mElement; + int radioactivity = 0; + if (material.isRadioactive()){ + radioactivity = 1; + } + if (hasValidRGBA(rgba)){ + return new Material(name, rgba, melting, boiling, protons, neutrons, blastFurnace, null, chemicalFormula, radioactivity); + } + return null; + + } + + public static Material generateQuickMaterial(String materialName, short[] colour, int sRadioactivity) { + Material temp = new Material( + materialName, + colour, + 1000, //melting + 3000, //boiling + 50, //Protons + 50, //Neutrons + false, + null, + sRadioactivity); + return temp; + } + + public static boolean hasValidRGBA(short[] rgba){ + boolean test1 = false; + boolean test2 = false; + boolean test3 = false; + for (int r=0;r<rgba.length;r++){ + if (rgba[r] == 0){ + if (r == 0){ + test1 = true; + } + else if (r == 1){ + test2 = true; + } + else if (r == 2){ + test3 = true; + } + } + } + if ((test1 && test2) || (test1 && test3) || (test3 && test2)){ + return false; + } + return true; + } + + public static String superscript(String str) { + str = str.replaceAll("0", "⁰"); + str = str.replaceAll("1", "¹"); + str = str.replaceAll("2", "²"); + str = str.replaceAll("3", "³"); + str = str.replaceAll("4", "⁴"); + str = str.replaceAll("5", "⁵"); + str = str.replaceAll("6", "⁶"); + str = str.replaceAll("7", "⁷"); + str = str.replaceAll("8", "⁸"); + str = str.replaceAll("9", "⁹"); + return str; + } + + public static String subscript(String str) { + str = str.replaceAll("0", "₀"); + str = str.replaceAll("1", "₁"); + str = str.replaceAll("2", "₂"); + str = str.replaceAll("3", "₃"); + str = str.replaceAll("4", "₄"); + str = str.replaceAll("5", "₅"); + str = str.replaceAll("6", "₆"); + str = str.replaceAll("7", "₇"); + str = str.replaceAll("8", "₈"); + str = str.replaceAll("9", "₉"); + return str; } |