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/core/item | |
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/core/item')
14 files changed, 358 insertions, 646 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); |