diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
commit | 221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch) | |
tree | d6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/core/item | |
parent | 5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff) | |
download | GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2 GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip |
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/core/item')
42 files changed, 5071 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java new file mode 100644 index 0000000000..3ceaf84228 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -0,0 +1,488 @@ +package gtPlusPlus.core.item; +import static gtPlusPlus.core.creative.AddToCreativeTab.tabMachines; +import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; +import static gtPlusPlus.core.lib.CORE.LOAD_ALL_CONTENT; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.BaseItemBackpack; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.item.base.bolts.BaseItemBolt; +import gtPlusPlus.core.item.base.foods.BaseItemFood; +import gtPlusPlus.core.item.base.foods.BaseItemHotFood; +import gtPlusPlus.core.item.base.gears.BaseItemGear; +import gtPlusPlus.core.item.base.ingots.BaseItemIngot; +import gtPlusPlus.core.item.base.ingots.BaseItemIngotHot; +import gtPlusPlus.core.item.base.plates.BaseItemPlate; +import gtPlusPlus.core.item.base.rings.BaseItemRing; +import gtPlusPlus.core.item.base.rods.BaseItemRod; +import gtPlusPlus.core.item.base.rotors.BaseItemRotor; +import gtPlusPlus.core.item.base.screws.BaseItemScrew; +import gtPlusPlus.core.item.effects.RarityUncommon; +import gtPlusPlus.core.item.general.BufferCore; +import gtPlusPlus.core.item.general.ItemCloakingDevice; +import gtPlusPlus.core.item.general.ItemHealingDevice; +import gtPlusPlus.core.item.general.RF2EU_Battery; +import gtPlusPlus.core.item.general.fuelrods.FuelRod_Base; +import gtPlusPlus.core.item.init.ItemsFoods; +import gtPlusPlus.core.item.tool.misc.SandstoneHammer; +import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.item.tool.staballoy.StaballoyAxe; +import gtPlusPlus.core.item.tool.staballoy.StaballoyPickaxe; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.lib.MaterialInfo; +import gtPlusPlus.core.lib.CORE.configSwitches; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.debug.DEBUG_INIT; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.item.Item; +import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemFood; +import net.minecraftforge.common.util.EnumHelper; +import cpw.mods.fml.common.registry.GameRegistry; +public final class ModItems { + + public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18); + + public static Item AAA_Broken; + + public static Item itemDebugShapeSpawner; + + public static Item itemBaseSpawnEgg; + + + //Tantaloy60(789, TextureSet.SET_DULL, 8.0F, 5120, 3, 1 | 2 | 16 | 32 | 64 | 128, 213, 231, 237, 0, "Tantaloy 60", 0, 0, 3035, 2200, true, false, 1, 2, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Tungsten, 1), new MaterialStack(Tantalum, 9)), Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 8), new TC_AspectStack(TC_Aspects.STRONTIO, 3))), + //Tantaloy61(790, TextureSet.SET_DULL, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 193, 211, 217, 0, "Tantaloy 61", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Tungsten, 1), new MaterialStack(Tantalum, 9), new MaterialStack(Titanium, 1)), Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 8), new TC_AspectStack(TC_Aspects.STRONTIO, 3))), + + + //EnderIO + public static Item itemPlateSoularium; + public static Item itemPlateRedstoneAlloy; + public static Item itemPlateElectricalSteel; + public static Item itemPlatePulsatingIron; + public static Item itemPlateEnergeticAlloy; + public static Item itemPlateVibrantAlloy; + public static Item itemPlateConductiveIron; + public static Item itemPlateDarkSteel; + //Big Reactors + public static Item itemPlateBlutonium; + public static Item itemPlateCyanite; + public static Item itemPlateLudicrite; + //Thaumcraft + public static Item itemPlateVoidMetal; + //ExtraUtils + public static Item itemPlateBedrockium; + //Pneumaticraft + public static Item itemPlateCompressedIron; + //SimplyJetpacks + public static Item itemPlateEnrichedSoularium; + //rfTools + public static Item itemPlateDimensionShard; + //Blood Steel Items + public static Item itemIngotBloodSteel; + public static Item itemPlateBloodSteel; + //Staballoy + public static Item itemStaballoyPickaxe; + public static Item itemStaballoyAxe; + public static Item itemPlateStaballoy; + public static Item itemIngotStaballoy; + public static Item itemDustStaballoy; + public static Item itemDustTinyStaballoy; + public static Item itemDustSmallStaballoy; + public static Item itemDustBloodSteel; + public static Item itemDustTinyBloodSteel; + public static Item itemDustSmallBloodSteel; + //Tools + public static Item itemSandstoneHammer; + //Machine Related + public static Item itemBufferCore0; + //Material related + public static Item itemStickyRubber; + public static Item itemIngotBatteryAlloy; + public static Item itemPlateBatteryAlloy; + public static Item itemHeliumBlob; + public static Item itemPLACEHOLDER_Circuit; + + public static Item FuelRod_Empty; + public static Item FuelRod_Thorium; + public static Item FuelRod_Uranium; + public static Item FuelRod_Plutonium; + + public static Item itemBedLocator_Base; + public static Item itemBaseItemWithCharge; + + public static Item itemHotIngotStaballoy; + + public static Item itemIngotRaisinBread; + public static Item itemHotIngotRaisinBread; + + public static BaseItemIngot itemIngotTantalloy60; + public static BaseItemIngotHot itemHotIngotTantalloy60; + public static BaseItemPlate itemPlateTantalloy60; + public static BaseItemIngot itemIngotTantalloy61; + public static BaseItemIngotHot itemHotIngotTantalloy61; + public static BaseItemPlate itemPlateTantalloy61; + + public static ItemFood itemFoodRaisinToast; + public static BaseItemHotFood itemHotFoodRaisinToast; + public static BaseItemFood itemFoodCurriedSausages; + public static BaseItemHotFood itemHotFoodCurriedSausages; + + public static Item itemDustTantalloy60; + public static Item itemDustSmallTantalloy60; + public static Item itemDustTinyTantalloy60; + + public static Item itemDustTantalloy61; + public static Item itemDustSmallTantalloy61; + public static Item itemDustTinyTantalloy61; + + public static BaseItemGear itemGearStaballoy; + public static BaseItemGear itemGearBloodSteel; + public static BaseItemGear itemGearTantalloy60; + public static BaseItemGear itemGearTantalloy61; + + public static BaseItemRotor itemRotorStaballoy; + public static BaseItemRotor itemRotorBloodSteel; + public static BaseItemRotor itemRotorTantalloy60; + public static BaseItemRotor itemRotorTantalloy61; + + public static BaseItemRod itemRodStaballoy; + public static BaseItemRod itemRodBloodSteel; + public static BaseItemRod itemRodTantalloy60; + public static BaseItemRod itemRodTantalloy61; + + public static BaseItemScrew itemScrewStaballoy; + public static BaseItemScrew itemScrewBloodSteel; + public static BaseItemScrew itemScrewTantalloy60; + public static BaseItemScrew itemScrewTantalloy61; + + public static BaseItemRing itemRingStaballoy; + public static BaseItemRing itemRingBloodSteel; + public static BaseItemRing itemRingTantalloy60; + public static BaseItemRing itemRingTantalloy61; + + public static BaseItemBolt itemBoltStaballoy; + public static BaseItemBolt itemBoltBloodSteel; + public static BaseItemBolt itemBoltTantalloy60; + public static BaseItemBolt itemBoltTantalloy61; + + public static Item RfEuBattery; + public static Item itemPersonalCloakingDevice; + public static Item itemPersonalCloakingDeviceCharged; + public static Item itemPersonalHealingDevice; + + public static MultiPickaxeBase MP_Iron; + public static MultiPickaxeBase MP_Gold; + public static MultiPickaxeBase MP_Diamond; + public static MultiPickaxeBase MP_Wood; + public static MultiPickaxeBase MP_Stone; + public static MultiPickaxeBase MP_Quartz; + public static MultiPickaxeBase MP_Obsidian; + public static MultiPickaxeBase MP_Redstone; + + + public static BaseItemBackpack backpack_Red; + public static BaseItemBackpack backpack_Green; + public static BaseItemBackpack backpack_Blue; + public static BaseItemBackpack backpack_Yellow; + public static BaseItemBackpack backpack_Purple; + public static BaseItemBackpack backpack_Cyan; + + + public static BaseItemBackpack backpack_Maroon; + public static BaseItemBackpack backpack_Olive; + public static BaseItemBackpack backpack_DarkGreen; + public static BaseItemBackpack backpack_DarkPurple; + public static BaseItemBackpack backpack_Teal; + public static BaseItemBackpack backpack_Navy; + + + public static BaseItemBackpack backpack_Silver; + public static BaseItemBackpack backpack_Gray; + public static BaseItemBackpack backpack_Black; + public static BaseItemBackpack backpack_White; + + + //@SuppressWarnings("unused") + public static final void init(){ + + AAA_Broken = new BaseItemIngot("AAA_Broken", "Errors - Tell Alkalus", Utils.rgbtoHexValue(128, 128, 128), 0); + + //Debug Loading + if (CORE.DEBUG){ + DEBUG_INIT.registerItems(); + } + + + //Make some backpacks + //Primary colours + backpack_Red = new BaseItemBackpack("backpackRed", Utils.rgbtoHexValue(200, 0, 0)); + backpack_Green = new BaseItemBackpack("backpackGreen", Utils.rgbtoHexValue(0, 200, 0)); + backpack_Blue = new BaseItemBackpack("backpackBlue", Utils.rgbtoHexValue(0, 0, 200)); + //Secondary Colours + backpack_Yellow = new BaseItemBackpack("backpackYellow", Utils.rgbtoHexValue(200, 200, 0)); + backpack_Purple = new BaseItemBackpack("backpackPurple", Utils.rgbtoHexValue(200, 0, 200)); + backpack_Cyan = new BaseItemBackpack("backpackCyan", Utils.rgbtoHexValue(0, 200, 200)); + //Tertiary Colours + backpack_Maroon = new BaseItemBackpack("backpackMaroon", Utils.rgbtoHexValue(128, 0, 0)); + backpack_Olive = new BaseItemBackpack("backpackOlive", Utils.rgbtoHexValue(128, 128, 0)); + backpack_DarkGreen = new BaseItemBackpack("backpackDarkGreen", Utils.rgbtoHexValue(0, 128, 0)); + backpack_DarkPurple = new BaseItemBackpack("backpackDarkPurple", Utils.rgbtoHexValue(128, 0, 128)); + backpack_Teal = new BaseItemBackpack("backpackTeal", Utils.rgbtoHexValue(0, 128, 128)); + backpack_Navy = new BaseItemBackpack("backpackNavy", Utils.rgbtoHexValue(0, 0, 128)); + //Shades + backpack_Silver = new BaseItemBackpack("backpackSilver", Utils.rgbtoHexValue(192, 192, 192)); + backpack_Gray = new BaseItemBackpack("backpackGray", Utils.rgbtoHexValue(128, 128, 128)); + backpack_Black = new BaseItemBackpack("backpackBlack", Utils.rgbtoHexValue(20, 20, 20)); + backpack_White = new BaseItemBackpack("backpackWhite", Utils.rgbtoHexValue(240, 240, 240)); + + + /*ItemsIngots.load(); + ItemsPlates.load(); + ItemsDusts.load(); + ItemsRods.load(); + ItemsGears.load(); + ItemsRotors.load(); + ItemsRings.load(); + ItemsBolts.load(); + ItemsScrews.load();*/ + + + //Start meta Item Generation + ItemsFoods.load(); + + UtilsItems.generateItemsFromMaterial("EnergyCrystal", "Energy Crystal", 8, MaterialInfo.ENERGYCRYSTAL, Utils.rgbtoHexValue(228, 225, 0), true); + UtilsItems.generateItemsFromMaterial("BloodSteel", "Blood Steel", 3, MaterialInfo.BLOODSTEEL, Utils.rgbtoHexValue(142, 28, 0), false); + UtilsItems.generateItemsFromMaterial("Staballoy", "Staballoy", 6, MaterialInfo.STABALLOY, Utils.rgbtoHexValue(68, 75, 66), true); + UtilsItems.generateItemsFromMaterial("Tantalloy60", "Tantalloy-60", 5, MaterialInfo.TANTALLOY60, Utils.rgbtoHexValue(68, 75, 166), true); + UtilsItems.generateItemsFromMaterial("Tantalloy61", "Tantalloy-61", 6, MaterialInfo.TANTALLOY61, Utils.rgbtoHexValue(122, 135, 196), true); + UtilsItems.generateItemsFromMaterial("Bedrockium", "Bedrockium", 9, MaterialInfo.BEDROCKIUM, Utils.rgbtoHexValue(32, 32, 32), false); + UtilsItems.generateItemsFromMaterial("Quantum", "Quantum", 10, MaterialInfo.QUANTUM, Utils.rgbtoHexValue(128, 128, 128), true); + + + UtilsItems.generateItemsFromMaterial("Inconel625", "Inconel-625", 4, MaterialInfo.INCONEL625, Utils.rgbtoHexValue(128, 200, 128), true); //Inconel 625: Acid resistant, good weldability. The LCF version is typically used in bellows. + UtilsItems.generateItemsFromMaterial("Inconel690", "Inconel-690", 6, MaterialInfo.INCONEL690, Utils.rgbtoHexValue(118, 220, 138), true); //Inconel 690: Low cobalt content for nuclear applications, and low resistivity. + UtilsItems.generateItemsFromMaterial("Inconel792", "Inconel-792", 5, MaterialInfo.INCONEL792, Utils.rgbtoHexValue(108, 240, 118), true); //Inconel 792: Increased aluminium content for improved high temperature corrosion properties, used especially in gas turbines. + + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + UtilsItems.generateItemsFromMaterial("TungstenCarbide", "Tungsten Carbide", 5, MaterialInfo.TUNGSTENCARBIDE, Utils.rgbtoHexValue(44, 44, 44), true); + } + UtilsItems.generateItemsFromMaterial("SiliconCarbide", "Silicon Carbide", 4, MaterialInfo.SILICONCARBIDE, Utils.rgbtoHexValue(32, 32, 32), false); + UtilsItems.generateItemsFromMaterial("Zeron100", "Zeron-100", 8, MaterialInfo.ZERON100, Utils.rgbtoHexValue(180, 180, 20), true); + UtilsItems.generateItemsFromMaterial("MaragingSteel250", "Maraging Steel 250", 4, MaterialInfo.MARAGING250, Utils.rgbtoHexValue(140, 140, 140), true); + UtilsItems.generateItemsFromMaterial("MaragingSteel300", "Maraging Steel 300", 5, MaterialInfo.MARAGING300, Utils.rgbtoHexValue(150, 150, 150), true); + UtilsItems.generateItemsFromMaterial("MaragingSteel350", "Maraging Steel 350", 6, MaterialInfo.MARAGING350, Utils.rgbtoHexValue(160, 160, 160), true); + UtilsItems.generateItemsFromMaterial("Stellite", "Stellite", 7, MaterialInfo.STELLITE, Utils.rgbtoHexValue(129, 75, 120), true); + UtilsItems.generateItemsFromMaterial("Talonite", "Talonite", 8, MaterialInfo.TALONITE, Utils.rgbtoHexValue(228, 75, 120), false); + + UtilsItems.generateItemsFromMaterial("Tumbaga", "Tumbaga", 2, MaterialInfo.TUMBAGA, Utils.rgbtoHexValue(255,178,15), false); //Tumbaga was the name given by Spaniards to a non-specific alloy of gold and copper + UtilsItems.generateItemsFromMaterial("Potin", "Potin", 4, MaterialInfo.POTIN, Utils.rgbtoHexValue(201,151,129), false); //Potin is traditionally an alloy of bronze, tin and lead, with varying quantities of each possible + + + UtilsItems.generateItemsFromMaterial("HastelloyW", "Hastelloy-W", 6, MaterialInfo.HASTELLOY_W, Utils.rgbtoHexValue(218, 165, 32), false); + UtilsItems.generateItemsFromMaterial("HastelloyX", "Hastelloy-X", 6, MaterialInfo.HASTELLOY_X, Utils.rgbtoHexValue(255, 193, 37), false); + UtilsItems.generateItemsFromMaterial("HastelloyC276", "Hastelloy-C276", 7, MaterialInfo.HASTELLOY_C276, Utils.rgbtoHexValue(238, 180, 34), true); + UtilsItems.generateItemsFromMaterial("HastelloyN", "Hastelloy-N", 8, MaterialInfo.HASTELLOY_N, Utils.rgbtoHexValue(155, 223, 237), true); + + UtilsItems.generateItemsFromMaterial("Incoloy020", "Incoloy-020", 7, MaterialInfo.INCOLOY020, Utils.rgbtoHexValue(81, 81, 81), false); + UtilsItems.generateItemsFromMaterial("IncoloyDS", "Incoloy-DS", 7, MaterialInfo.INCOLOYDS, Utils.rgbtoHexValue(91, 91, 91), false); + UtilsItems.generateItemsFromMaterial("IncoloyMA956", "Incoloy-MA956", 8, MaterialInfo.INCOLOYMA956, Utils.rgbtoHexValue(101, 101, 101), true); + + + UtilsItems.generateItemsFromMaterial("Zirconium", "Zirconium", 6, MaterialInfo.ZIRCONIUM, Utils.rgbtoHexValue(255, 250, 205), false); + UtilsItems.generateItemsFromMaterial("ZirconiumCarbide", "Zirconium Carbide", 7, MaterialInfo.ZIRCONIUMCARBIDE, Utils.rgbtoHexValue(222, 202, 180), true); + UtilsItems.generateItemsFromMaterial("TantalumCarbide", "Tantalum Carbide", 7, MaterialInfo.TANTALUMCARBIDE, Utils.rgbtoHexValue(139, 136, 120), true); + UtilsItems.generateItemsFromMaterial("NiobiumCarbide", "Niobium Carbide", 6, MaterialInfo.NIOMBIUMCARBIDE, Utils.rgbtoHexValue(205, 197, 191), true); + + + //Uranium-233if + UtilsItems.generateItemsFromMaterial("Uranium233", "Uranium 233", 4, MaterialInfo.INCONEL792, Utils.rgbtoHexValue(73, 220, 83), false); //Uranium-233 is a fissile isotope of uranium that is bred from thorium-232 as part of the thorium fuel cycle. + + MP_Wood = new MultiPickaxeBase("Wooden Multipick", ToolMaterial.WOOD, ToolMaterial.WOOD.getMaxUses(), Utils.rgbtoHexValue(139,90,43)); + MP_Stone = new MultiPickaxeBase("Cobblestone Multipick", ToolMaterial.STONE, ToolMaterial.STONE.getMaxUses(), Utils.rgbtoHexValue(161,161,161)); + MP_Iron = new MultiPickaxeBase("Iron Multipick", ToolMaterial.IRON, ToolMaterial.IRON.getMaxUses(), Utils.rgbtoHexValue(110,123,139)); + MP_Gold = new MultiPickaxeBase("Gold Multipick", ToolMaterial.GOLD, ToolMaterial.GOLD.getMaxUses(), Utils.rgbtoHexValue(238,221,130)); + MP_Diamond = new MultiPickaxeBase("Diamond Multipick", ToolMaterial.EMERALD, ToolMaterial.EMERALD.getMaxUses(), Utils.rgbtoHexValue(191,239,255)); + + MP_Redstone = UtilsItems.generateMultiPick(Materials.Redstone); + MP_Obsidian = UtilsItems.generateMultiPick(Materials.Obsidian); + MP_Obsidian = UtilsItems.generateMultiPick(Materials.Abyssal); + MP_Obsidian = UtilsItems.generateMultiPick(Materials.NetherStar); + MP_Obsidian = UtilsItems.generateMultiPick(Materials.Neutronium); + + //EnderIO Resources + if (LoadedMods.EnderIO || LOAD_ALL_CONTENT){ + Utils.LOG_INFO("EnderIO Found - Loading Resources."); + //Item Init + itemPlateSoularium = new Item().setUnlocalizedName("itemPlateSoularium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateSoularium"); + itemPlateRedstoneAlloy = new Item().setUnlocalizedName("itemPlateRedstoneAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateRedstoneAlloy"); + itemPlateElectricalSteel = new Item().setUnlocalizedName("itemPlateElectricalSteel").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateElectricalSteel"); + itemPlatePulsatingIron = new Item().setUnlocalizedName("itemPlatePulsatingIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlatePulsatingIron"); + itemPlateEnergeticAlloy = new Item().setUnlocalizedName("itemPlateEnergeticAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateEnergeticAlloy"); + itemPlateVibrantAlloy = new Item().setUnlocalizedName("itemPlateVibrantAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateVibrantAlloy"); + itemPlateConductiveIron = new Item().setUnlocalizedName("itemPlateConductiveIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateConductiveIron"); + itemPlateDarkSteel = new Item().setUnlocalizedName("itemPlateDarkSteel").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateDarkSteel"); + //Registry + GameRegistry.registerItem(itemPlateSoularium, "itemPlateSoularium"); + GameRegistry.registerItem(itemPlateRedstoneAlloy, "itemPlateRedstoneAlloy"); + GameRegistry.registerItem(itemPlateElectricalSteel, "itemPlateElectricalSteel"); + GameRegistry.registerItem(itemPlatePulsatingIron, "itemPlatePulsatingIron"); + GameRegistry.registerItem(itemPlateEnergeticAlloy, "itemPlateEnergeticAlloy"); + GameRegistry.registerItem(itemPlateVibrantAlloy, "itemPlateVibrantAlloy"); + GameRegistry.registerItem(itemPlateConductiveIron, "itemPlateConductiveIron"); + GameRegistry.registerItem(itemPlateDarkSteel, "itemPlateDarkSteel"); + } + else { + Utils.LOG_WARNING("EnderIO not Found - Skipping Resources."); + } + //Big Reactors + if (LoadedMods.Big_Reactors|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("BigReactors Found - Loading Resources."); + //Item Init + itemPlateBlutonium = new Item().setUnlocalizedName("itemPlateBlutonium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateBlutonium"); + itemPlateCyanite = new Item().setUnlocalizedName("itemPlateCyanite").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateCyanite"); + itemPlateLudicrite = new Item().setUnlocalizedName("itemPlateLudicrite").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateLudicrite"); + //Registry + GameRegistry.registerItem(itemPlateBlutonium, "itemPlateBlutonium"); + GameRegistry.registerItem(itemPlateCyanite, "itemPlateCyanite"); + GameRegistry.registerItem(itemPlateLudicrite, "itemPlateLudicrite"); + } + else { + Utils.LOG_WARNING("BigReactors not Found - Skipping Resources."); + } + //Thaumcraft + if (LoadedMods.Thaumcraft|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("Thaumcraft Found - Loading Resources."); + //Item Init + try { + itemPlateVoidMetal = new Item().setUnlocalizedName("itemPlateVoidMetal").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateVoidMetal"); + } catch (NullPointerException e){ + e.getClass(); + } + //Registry + GameRegistry.registerItem(itemPlateVoidMetal, "itemPlateVoidMetal"); + } + else { + Utils.LOG_WARNING("Thaumcraft not Found - Skipping Resources."); + } + //ExtraUtils + if (LoadedMods.Extra_Utils|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("ExtraUtilities Found - Loading Resources."); + //Item Init + try { + //itemPlateBedrockium = new Item().setUnlocalizedName("itemPlateBedrockium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateBedrockium"); + } catch (NullPointerException e){ + e.getClass(); + } + //Registry + //GameRegistry.registerItem(itemPlateBedrockium, "itemPlateBedrockium"); + } + else { + Utils.LOG_WARNING("ExtraUtilities not Found - Skipping Resources."); + } + //Pneumaticraft + if (LoadedMods.PneumaticCraft|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("PneumaticCraft Found - Loading Resources."); + //Item Init + itemPlateCompressedIron = new Item().setUnlocalizedName("itemPlateCompressedIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateCompressedIron"); + //Registry + GameRegistry.registerItem(itemPlateCompressedIron, "itemPlateCompressedIron"); + } + else { + Utils.LOG_WARNING("PneumaticCraft not Found - Skipping Resources."); + } + //Simply Jetpacks + if (LoadedMods.Simply_Jetpacks|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("SimplyJetpacks Found - Loading Resources."); + //Item Init + itemPlateEnrichedSoularium = new RarityUncommon().setUnlocalizedName("itemPlateEnrichedSoularium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateSoularium"); + //Registry + GameRegistry.registerItem(itemPlateEnrichedSoularium, "itemPlateEnrichedSoularium"); + } + else { + Utils.LOG_WARNING("SimplyJetpacks not Found - Skipping Resources."); + } + //rfTools + if (LoadedMods.RFTools|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("rfTools Found - Loading Resources."); + //Item Init + itemPlateDimensionShard = new Item().setUnlocalizedName("itemPlateDimensionShard").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateDimensionShard"); + //Registry + GameRegistry.registerItem(itemPlateDimensionShard, "itemPlateDimensionShard"); + } + else { + Utils.LOG_WARNING("rfTools not Found - Skipping Resources."); + } + //IC2 Exp + if (LoadedMods.IndustrialCraft2|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("IndustrialCraft2 Found - Loading Resources."); + //Item Init + FuelRod_Empty = new FuelRod_Base("itemFuelRod_Empty", "Empty", 0, 1000); + FuelRod_Thorium = new FuelRod_Base("itemFuelRod_Thorium", "Thorium", 1000, 1000); + FuelRod_Uranium = new FuelRod_Base("itemFuelRod_Uranium", "Uranium", 2500, 2500); + FuelRod_Plutonium = new FuelRod_Base("itemFuelRod_Plutonium", "Plutonium", 5000, 5000); + RfEuBattery = new RF2EU_Battery(); + itemPersonalCloakingDevice = new ItemCloakingDevice(0); + //itemPersonalCloakingDeviceCharged = new ItemCloakingDevice(0).set; + itemPersonalHealingDevice = new ItemHealingDevice(); + //Registry + //GameRegistry.registerItem(FuelRod_Empty, "itemFuelRod_Empty"); + //GameRegistry.registerItem(FuelRod_Thorium, "itemFuelRod_Thorium"); + //GameRegistry.registerItem(FuelRod_Uranium, "itemFuelRod_Uranium"); + //GameRegistry.registerItem(FuelRod_Plutonium, "itemFuelRod_Plutonium"); + } + else { + Utils.LOG_WARNING("IndustrialCraft2 not Found - Skipping Resources."); + } + + + //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); + } + + + //UtilsItems.generateSpawnEgg("ic2", "boatcarbon", Utils.generateSingularRandomHexValue(), Utils.generateSingularRandomHexValue()); + + + + /* + * Misc Items + */ + + //Staballoy Equipment + itemStaballoyPickaxe = new StaballoyPickaxe("itemStaballoyPickaxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(itemStaballoyPickaxe, itemStaballoyPickaxe.getUnlocalizedName()); + itemStaballoyAxe = new StaballoyAxe("itemStaballoyAxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(itemStaballoyAxe, itemStaballoyAxe.getUnlocalizedName()); + + //Sandstone Hammer + itemSandstoneHammer = new SandstoneHammer("itemSandstoneHammer").setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(itemSandstoneHammer, itemSandstoneHammer.getUnlocalizedName()); + + //Buffer Cores! + Item itemBufferCore; + for(int i=1; i<=10; i++){ + //Utils.LOG_INFO(""+i); + itemBufferCore = new BufferCore("itemBufferCore", i).setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerItem(itemBufferCore, itemBufferCore.getUnlocalizedName()+i); + //System.out.println("Buffer Core registration count is: "+i); + } + + itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMachines).setTextureName(CORE.MODID + ":itemStickyRubber"); + GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); + GT_OreDictUnificator.registerOre("ingotRubber", UtilsItems.getItemStack(CORE.MODID+":itemStickyRubber", 1)); + + itemHeliumBlob = new CoreItem("itemHeliumBlob", tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob"); + //GameRegistry.registerItem(itemHeliumBlob, "itemHeliumBlob"); + + itemPLACEHOLDER_Circuit = new Item().setUnlocalizedName("itemPLACEHOLDER_Circuit").setTextureName(CORE.MODID + ":itemPLACEHOLDER_Circuit"); + GameRegistry.registerItem(itemPLACEHOLDER_Circuit, "itemPLACEHOLDER_Circuit"); + + //ItemBlockGtFrameBox = new ItemBlockGtFrameBox(ModBlocks.blockGtFrameSet1); + //GameRegistry.registerItem(ItemBlockGtFrameBox, "itemGtFrameBoxSet1"); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemBackpack.java b/src/Java/gtPlusPlus/core/item/base/BaseItemBackpack.java new file mode 100644 index 0000000000..316f922639 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemBackpack.java @@ -0,0 +1,89 @@ +package gtPlusPlus.core.item.base; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BaseItemBackpack extends Item{ + + protected final int colourValue; + protected final String unlocalName; + + + public BaseItemBackpack(String unlocalizedName, int colour){ + this.unlocalName = unlocalizedName; + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + "itemBackpack"); + this.colourValue = colour; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre("storageBackpack", UtilsItems.getSimpleStack(this)); + setMaxStackSize(1); + setCreativeTab(AddToCreativeTab.tabOther); + } + + // Without this method, your inventory will NOT work!!! + @Override + public int getMaxItemUseDuration(ItemStack stack) { + return 1; // return any value greater than zero + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) + { + if (!world.isRemote) + { + // If player not sneaking, open the inventory gui + if (!player.isSneaking()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI3, world, 0, 0, 0); + } + + // Otherwise, stealthily place some diamonds in there for a nice surprise next time you open it up :) + else { + // Utils.LOG_INFO("Player is Sneaking, giving them sneaky diamonds."); + // new BaseInventoryBackpack(player.getHeldItem()).setInventorySlotContents(0, new ItemStack(Items.diamond,4)); + } + } + + return itemstack; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colourValue == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colourValue; + + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + //Name Formatting. + String temp = unlocalName.replace("backpack", ""); + //Lets find the colour. + if (temp.toLowerCase().contains("dark")){ + temp = unlocalName.substring(12, unlocalName.length()); + temp = "Dark "+ temp; + } + return (temp+" Backpack"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemBackpack"); + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java b/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java new file mode 100644 index 0000000000..a6cc29497e --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java @@ -0,0 +1,30 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +public class BaseItemGeneric extends Item +{ + public BaseItemGeneric(String unlocalizedName, CreativeTabs c, int stackSize, int maxDmg) + { + setUnlocalizedName(CORE.MODID + "_" + unlocalizedName); + setTextureName(CORE.MODID + ":" + unlocalizedName); + setCreativeTab(c); + setMaxStackSize(stackSize); + setMaxDamage(maxDmg); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+""); + super.addInformation(stack, aPlayer, list, bool); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemWithCharge.java b/src/Java/gtPlusPlus/core/item/base/BaseItemWithCharge.java new file mode 100644 index 0000000000..c793776e37 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemWithCharge.java @@ -0,0 +1,75 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +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.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BaseItemWithCharge extends Item{ + + public int int_Charge = 0; + public int int_Max_Charge = 0; + + public BaseItemWithCharge(String unlocalizedName, int constructor_Charge, int constructor_Max_Charge) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.int_Charge = constructor_Charge; + this.int_Max_Charge = constructor_Max_Charge; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + int NBT_Charge = int_Charge; + int NBT_Max_Charge = int_Max_Charge; + if (stack.stackTagCompound != null) { + NBT_Charge = stack.stackTagCompound.getInteger("charge_Current"); + NBT_Max_Charge = stack.stackTagCompound.getInteger("charge_Max"); + String tempX = String.valueOf(NBT_Charge); + String tempY = String.valueOf(NBT_Max_Charge); + String formattedX = EnumChatFormatting.RED+tempX+EnumChatFormatting.GRAY; + String formattedY = EnumChatFormatting.DARK_RED+tempY+EnumChatFormatting.GRAY; + list.add(EnumChatFormatting.GRAY+"Charge:"+formattedX+"/"+formattedY+"."); + super.addInformation(stack, aPlayer, list, bool); + } + } + + //Ticking and NBT Handling + /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and + * update it's contents. + * + * public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = 5000; + * + */ + @Override + public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { + + } + + @Override + public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) { + itemStack.stackTagCompound = new NBTTagCompound(); + return super.onItemRightClick(itemStack, world, par3Entity); + } + + + +} diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java b/src/Java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java new file mode 100644 index 0000000000..ec052ef1f9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java @@ -0,0 +1,29 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.lib.CORE; + +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; + +public class BaseItemWithDamageValue extends Item{ + public BaseItemWithDamageValue(String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(100); + } + @Override + public void setDamage(ItemStack stack, int damage) { + super.setDamage(stack, damage); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+""); + super.addInformation(stack, aPlayer, list, bool); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/BasicSpawnEgg.java b/src/Java/gtPlusPlus/core/item/base/BasicSpawnEgg.java new file mode 100644 index 0000000000..9407689cfc --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BasicSpawnEgg.java @@ -0,0 +1,259 @@ +package gtPlusPlus.core.item.base; + + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + + + +public class BasicSpawnEgg extends ItemMonsterPlacer +{ + @SideOnly(Side.CLIENT) + private IIcon theIcon; + protected int colorBase = 0x000000; + protected int colorSpots = 0xFFFFFF; + protected String entityMODID = ""; + protected String entityToSpawnName = ""; + protected String entityToSpawnNameFull = ""; + protected EntityLiving entityToSpawn = null; + + public BasicSpawnEgg(){ + super(); + } + + public BasicSpawnEgg(String MODID, String parEntityToSpawnName, int parPrimaryColor, int parSecondaryColor){ + setHasSubtypes(false); + maxStackSize = 64; + setCreativeTab(AddToCreativeTab.tabOther); + setEntityToSpawnName(parEntityToSpawnName); + colorBase = parPrimaryColor; + colorSpots = parSecondaryColor; + entityMODID = MODID; + + // DEBUG + Utils.LOG_WARNING("Spawn egg constructor for "+entityToSpawnName); + } + + /** + * Callback for item usage. If the item does something special on right clicking, + + * he will have one of those. Return + * True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10){ + if (par3World.isRemote) + { + return true; + } + Block block = par3World.getBlock(par4, par5, par6); + par4 += Facing.offsetsXForSide[par7]; + par5 += Facing.offsetsYForSide[par7]; + par6 += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if (par7 == 1 && block.getRenderType() == 11) + { + d0 = 0.5D; + } + + Entity entity = spawnEntity(par3World, par4 + 0.5D, par5 + d0, par6 + 0.5D); + + if (entity != null) + { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) + { + ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par2EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + + return true; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. + + *Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){ + if (par2World.isRemote) + { + return par1ItemStack; + } + MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) + { + return par1ItemStack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition + + .MovingObjectType.BLOCK) + + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) + { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k) instanceof BlockLiquid) + { + Entity entity = spawnEntity(par2World, i, j, k); + + if (entity != null) + { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) + { + ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + } + } + + return par1ItemStack; + } + + /** + * Spawns the creature specified by the egg's type in the location specified by + + * the last three parameters. + * Parameters: world, entityID, x, y, z. + */ + public Entity spawnEntity(World parWorld, double parX, double parY, double parZ){ + + if (!parWorld.isRemote) // never spawn entity on client side + { + entityToSpawnNameFull = entityMODID+"."+entityToSpawnName; + if (EntityList.stringToClassMapping.containsKey(entityToSpawnNameFull)) + { + entityToSpawn = (EntityLiving) EntityList + + .createEntityByName(entityToSpawnNameFull, parWorld); + entityToSpawn.setLocationAndAngles(parX, parY, parZ, + + MathHelper.wrapAngleTo180_float(parWorld.rand.nextFloat() + + * 360.0F), 0.0F); + parWorld.spawnEntityInWorld(entityToSpawn); + entityToSpawn.onSpawnWithEgg((IEntityLivingData)null); + entityToSpawn.playLivingSound(); + } + else + { + //DEBUG + Utils.LOG_WARNING("Entity not found "+entityToSpawnName); + } + } + + return entityToSpawn; + } + + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item parItem, CreativeTabs parTab, List parList){ + parList.add(new ItemStack(parItem, 1, 0)); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int parColorType){ + return (parColorType == 0) ? colorBase : colorSpots; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses(){ + return true; + } + + @Override + // Doing this override means that there is no localization for language + // unless you specifically check for localization here and convert + public String getItemStackDisplayName(ItemStack par1ItemStack){ + return "Spawn "+entityToSpawnName; + } + + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister){ + super.registerIcons(par1IconRegister); + theIcon = par1IconRegister.registerIcon(getIconString() + "_overlay"); + } + + /** + * Gets an icon index based on an item's damage value and the given render pass + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int parDamageVal, int parRenderPass){ + return parRenderPass > 0 ? theIcon : super.getIconFromDamageForRenderPass(parDamageVal, parRenderPass); + } + + public void setColors(int parColorBase, int parColorSpots){ + colorBase = parColorBase; + colorSpots = parColorSpots; + } + + public int getColorBase(){ + return colorBase; + } + + public int getColorSpots(){ + return colorSpots; + } + + public void setEntityToSpawnName(String parEntityToSpawnName){ + entityToSpawnName = parEntityToSpawnName; + entityToSpawnNameFull = entityMODID+"."+entityToSpawnName; + } + +} + diff --git a/src/Java/gtPlusPlus/core/item/base/CoreItem.java b/src/Java/gtPlusPlus/core/item/base/CoreItem.java new file mode 100644 index 0000000000..b77b2d336e --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/CoreItem.java @@ -0,0 +1,118 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CoreItem extends Item +{ + + private final EnumRarity rarity; + private final EnumChatFormatting descColour; + private final String itemDescription; + private final boolean hasEffect; + + //0 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab) + { + this(unlocalizedName, creativeTab, 64, 0); //Calls 3 + } + //1 + /* + * Name, Tab, Stack - 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize) + { + this(unlocalizedName, creativeTab, stackSize, 0); //Calls 3 + } + //2 + /* + * Name, Tab, Stack, Description - 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, String description) + { + this(unlocalizedName, creativeTab, stackSize, 0, description); //Calls 4 + } + //3 + /* + * Name, Tab, Stack, Dmg - Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, ""); //Calls 4 + } + //4 //Not Rare + basic tooltip + /* + * Name, Tab, Stack, Dmg, Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, EnumRarity.common, EnumChatFormatting.GRAY, false); //Calls 4.5 + } + //4.5 + /* + * Name, Tab, Stack, Dmg, Description, Text Colour - Common + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description, EnumChatFormatting colour) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, EnumRarity.common, colour, false); //Calls 5 + } + + //4.75 + /* + * Name, Tab, Stack, Dmg, Description, Rarity - Gray text + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description, EnumRarity rarity) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, rarity, EnumChatFormatting.GRAY, false); //Calls 5 + } + + //5 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description, EnumRarity regRarity, EnumChatFormatting colour, boolean Effect) + { + setUnlocalizedName(unlocalizedName); + setTextureName(CORE.MODID + ":" + unlocalizedName); + setCreativeTab(creativeTab); + setMaxStackSize(stackSize); + setMaxDamage(maxDmg); + this.rarity = regRarity; + this.itemDescription = description; + this.descColour = colour; + this.hasEffect = Effect; + GameRegistry.registerItem(this, unlocalizedName); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(descColour+itemDescription); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return rarity; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return hasEffect; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java b/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java new file mode 100644 index 0000000000..0f56730177 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java @@ -0,0 +1,82 @@ +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.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{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemBolt(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemBolt"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemB", "b"), UtilsItems.getSimpleStack(this)); + 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 (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + 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), + UtilsItems.getSimpleStack(this, 8), + 30*mTier*20, + 24*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java new file mode 100644 index 0000000000..6d12624487 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -0,0 +1,352 @@ +package gtPlusPlus.core.item.base.dusts; + +import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.MaterialInfo; +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 BaseItemDust extends Item{ + + protected int colour; + protected String materialName; + protected String pileType; + protected boolean useBlastFurnace; + String name = ""; + private int mTier; + private MaterialInfo dustInfo; + + public BaseItemDust(String unlocalizedName, String materialName, MaterialInfo matInfo, int colour, String pileSize, boolean blastFurnaceRequired, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(64); + if (pileSize == "dust" || pileSize == "Dust"){ + this.setTextureName(CORE.MODID + ":" + "dust");} + else{ + this.setTextureName(CORE.MODID + ":" + "dust"+pileSize);} + this.setCreativeTab(tabMisc); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.useBlastFurnace = blastFurnaceRequired; + this.dustInfo = matInfo; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + + String temp = ""; + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = getUnlocalizedName(); + } + if (temp.contains("DustTiny")){ + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else if (temp.contains("DustSmall")){ + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + if (temp != null && temp != ""){ + GT_OreDictUnificator.registerOre(temp, UtilsItems.getSimpleStack(this)); + } + addMixerRecipe(); + addFurnaceRecipe(); + addMacerationRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack iStack) { + + if (getUnlocalizedName().contains("DustTiny")){ + name = "Tiny Pile of "+materialName + " Dust"; + } + else if (getUnlocalizedName().contains("DustSmall")){ + name = "Small Pile of "+materialName + " Dust"; + } + else { + name = materialName + " Dust"; + } + return name; + } + + 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); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + //if (pileType != null && materialName != null && pileType != "" && materialName != "" && !pileType.equals("") && !materialName.equals("")){ + if (getUnlocalizedName().contains("DustTiny")){ + list.add(EnumChatFormatting.GRAY+"A tiny pile of " + materialName + " dust."); + } + else if (getUnlocalizedName().contains("DustSmall")){ + list.add(EnumChatFormatting.GRAY+"A small pile of " + materialName + " dust."); + } + else { + list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); + } + 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; + + } + + + + private void addMixerRecipe(){ + ItemStack tempStack = UtilsItems.getSimpleStack(this); + ItemStack tempOutput = null; + ItemStack[] inputStacks = dustInfo.getInputs(); + ItemStack[] outputStacks = dustInfo.getOutputs(); + String temp = ""; + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = getUnlocalizedName(); + } + if (temp.contains("DustTiny")){ + temp = temp.replace("itemDustTiny", "dust"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else if (temp.contains("DustSmall")){ + temp = temp.replace("itemDustSmall", "dust"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + if (temp != null && temp != ""){ + + if (getUnlocalizedName().contains("DustTiny") || getUnlocalizedName().contains("DustSmall")){ + tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + } + else { + if (outputStacks[0] != null){ + Utils.LOG_WARNING("Getting output dusts for mixer recipe. Checking ENUM, got: "+outputStacks[0].toString()); + tempOutput = outputStacks[0]; + } + else { + Utils.LOG_WARNING("Getting output dusts for mixer recipe. Enum check failed, failback item is: "+temp); + tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + } + } + + } + + if (tempOutput != null){ + if (getUnlocalizedName().contains("DustTiny")){ + Utils.LOG_WARNING("Generating a 9 Tiny dust to 1 Dust recipe for "+materialName); + UtilsRecipe.addShapelessGregtechRecipe(tempOutput, + tempStack, tempStack, tempStack, + tempStack, tempStack, tempStack, + tempStack, tempStack, tempStack); + } + else if (getUnlocalizedName().contains("DustSmall")){ + Utils.LOG_WARNING("Generating a 4 Small dust to 1 Dust recipe for "+materialName); + UtilsRecipe.addShapelessGregtechRecipe(tempOutput, + tempStack, tempStack, null, + tempStack, tempStack, null, + null, null, null); + } + else { + Utils.LOG_WARNING("Generating a Dust recipe for "+materialName+" in the mixer."); + + + int i = 0; + if (inputStacks.length >= 2){ + for (ItemStack is : inputStacks){ + if (is != null){ + Utils.LOG_WARNING("Found "+is.getDisplayName()+" as an input for mixer recipe."); + if (is.getDisplayName().toLowerCase().contains("tell alkalus")){ + ItemStack tempStackForAName = inputStacks[i]; + String[] inputList = dustInfo.getInputItemsAsList(); + int[] inputSizes = dustInfo.getInputStackSizesAsList(); + inputStacks[i] = UtilsItems.getItemStackOfAmountFromOreDict(inputList[i], inputSizes[i]); + Utils.LOG_WARNING("Swapping input slot "+i+" which contains "+tempStackForAName.getDisplayName()+" with "+inputStacks[i].getDisplayName()+"."); + } + + } + + else { + Utils.LOG_WARNING("Input "+i+" was null."); + } + + i++; + } + } + + GT_Values.RA.addMixerRecipe( + inputStacks[0], inputStacks[1], + inputStacks[2], inputStacks[3], + null, null, + tempOutput, + 8*mTier*20, 8*mTier*2); + + /*GT_Values.RA.addMixerRecipe( + GT_Utility.copyAmount(inputStacks[0].stackSize, new Object[]{inputStacks[0]}), GT_Utility.copyAmount(inputStacks[1].stackSize, new Object[]{inputStacks[1]}), + GT_Utility.copyAmount(inputStacks[2].stackSize, new Object[]{inputStacks[2]}), GT_Utility.copyAmount(inputStacks[3].stackSize, new Object[]{inputStacks[3]}), + null, null, + tempOutput, + 8*mTier*20, 8*mTier*2);*/ + + } + } + + } + + private void addMacerationRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Dusts"); + + String tempIngot = getUnlocalizedName().replace("item.itemDust", "ingot"); + String tempDust = getUnlocalizedName().replace("item.itemDust", "dust"); + ItemStack tempInputStack; + ItemStack tempOutputStack; + + if (getUnlocalizedName().contains("DustSmall") || getUnlocalizedName().contains("DustTiny")){ + return; + } + + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + tempIngot = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+tempIngot); + } + else { + tempIngot = getUnlocalizedName(); + } + + tempIngot = tempIngot.replace("itemDust", "ingot"); + Utils.LOG_WARNING("Generating OreDict Name: "+tempIngot); + ItemStack[] outputStacks = dustInfo.getOutputs(); + if (tempIngot != null && tempIngot != ""){ + tempInputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempDust, 1); + ItemStack tempStackOutput2; + int chance = mTier*10/MathUtils.randInt(10, 20); + if (outputStacks[1] != null && !outputStacks[1].getUnlocalizedName().toLowerCase().contains("aaa_broken")){ + tempStackOutput2 = outputStacks[1]; + tempOutputStack = outputStacks[0]; + } + else { + tempStackOutput2 = null; + } + if (null != tempOutputStack && null != tempInputStack){ + GT_ModHandler.addPulverisationRecipe(tempInputStack, tempOutputStack.splitStack(1), tempStackOutput2, chance); + } + } + } + + private void addFurnaceRecipe(){ + + String temp = ""; + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + } + else { + temp = getUnlocalizedName(); + } + if (temp.contains("DustTiny") || temp.contains("DustSmall")){ + return; + } + temp = temp.replace("itemDust", "ingot"); + if (temp != null && temp != ""){ + + if (this.useBlastFurnace){ + Utils.LOG_WARNING("Adding recipe for Hot "+materialName+" Ingots in a Blast furnace."); + String tempIngot = temp.replace("ingot", "ingotHot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + Utils.LOG_WARNING("This will produce "+tempOutputStack.getDisplayName() + " Debug: "+tempIngot); + if (null != tempOutputStack){ + addBlastFurnaceRecipe(UtilsItems.getSimpleStack(this), null, tempOutputStack, null, 350*mTier); + } + return; + } + Utils.LOG_WARNING("Adding recipe for "+materialName+" Ingots in a furnace."); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + Utils.LOG_WARNING("This will produce an ingot of "+tempOutputStack.getDisplayName() + " Debug: "+temp); + if (null != tempOutputStack){ + if (mTier < 5){ + CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(UtilsItems.getSimpleStack(this), tempOutputStack); + } + else if (mTier >= 5){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Ingots in a Blast furnace."); + Utils.LOG_WARNING("This will produce "+tempOutputStack.getDisplayName()); + if (null != tempOutputStack){ + addBlastFurnaceRecipe(UtilsItems.getSimpleStack(this), null, tempOutputStack, null, 350*mTier); + } + return; + } + } + + } + } + + private void addBlastFurnaceRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tempRequired){ + //Special Cases + /*if (input1.getUnlocalizedName().toLowerCase().contains("tantalloy61")){ + Utils.LOG_INFO("Adding Special handler for Staballoy-61 in the Blast Furnace"); + input2 = UtilsItems.getItemStackOfAmountFromOreDict("dustTantalloy60", 2); + if (input2 == null){ + Utils.LOG_INFO("invalid itemstack."); + } + else { + Utils.LOG_INFO("Found "+input2.getDisplayName()); + } + }*/ + GT_Values.RA.addBlastRecipe( + input1, + input2, + GT_Values.NF, GT_Values.NF, + output1, + output2, + 250*mTier*20, + mTier*64, + tempRequired); + + + + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java new file mode 100644 index 0000000000..a49dc58188 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java @@ -0,0 +1,42 @@ +package gtPlusPlus.core.item.base.dusts; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; + +public abstract class BaseItemDustAbstract extends Item{ + + protected int colour = 0; + protected String materialName; + protected String pileType; + + public BaseItemDustAbstract(String unlocalizedName, String materialName, int colour, String pileSize) { + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(64); + if (pileSize == "dust" || pileSize == "Dust"){ + this.setTextureName(CORE.MODID + ":" + "dust"); + } + else{ + this.setTextureName(CORE.MODID + ":" + "dust"+pileSize); + } + this.setMaxStackSize(64); + this.colour = colour; + this.materialName = materialName; + setUnlocalizedName(unlocalizedName); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public abstract void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool); + + public abstract String getMaterialName(); + + @Override + public abstract int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF); + +} diff --git a/src/Java/gtPlusPlus/core/item/base/foods/BaseItemFood.java b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemFood.java new file mode 100644 index 0000000000..7b0663d9cf --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemFood.java @@ -0,0 +1,47 @@ +package gtPlusPlus.core.item.base.foods; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemFood extends ItemFood { + + private PotionEffect[] effects; + protected String localName; + + public BaseItemFood(String unlocalizedName, String localizedName, int healAmount, float saturationModifier, boolean wolvesFavorite, PotionEffect... effects) { + super(healAmount, saturationModifier, wolvesFavorite); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName.replace("Hot", "")); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.effects = effects; + this.localName = localizedName; + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) { + super.onFoodEaten(stack, world, player); + + for (int i = 0; i < effects.length; i ++) { + if (!world.isRemote && effects[i] != null && effects[i].getPotionID() > 0) + player.addPotionEffect(new PotionEffect(this.effects[i].getPotionID(), + this.effects[i].getDuration(), this.effects[i].getAmplifier(), + this.effects[i].getIsAmbient() + ) + ); + } + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("A Serving of "+localName); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java new file mode 100644 index 0000000000..aaad22be9c --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java @@ -0,0 +1,78 @@ +package gtPlusPlus.core.item.base.foods; + +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 net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BaseItemHotFood extends BaseItemFood{ + + protected String materialName; + protected String unlocalName; + protected int cooldownTime; + protected Item output; + + public BaseItemHotFood(String unlocalizedName, int healAmount, float healSaturation, String foodName, int timeToCoolInSeconds, Item cooledFood) { + super(unlocalizedName, "Hot "+foodName, healAmount, healSaturation, false); + this.unlocalName = unlocalizedName; + this.cooldownTime = timeToCoolInSeconds * 20; + this.materialName = foodName; + this.output = cooledFood; + this.setMaxStackSize(1); + } + + @Override + public ItemStack onEaten(ItemStack iStack, World world, EntityPlayer player) { + return super.onEaten(iStack, world, player); + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + //Utils.LOG_INFO("Item Damage: "+iStack.getItemDamage()+" Max Damage: "+iStack.getMaxDamage()); + if (!world.isRemote){ + if(iStack.getItemDamage() == cooldownTime) { + if (entityHolding instanceof EntityPlayer){ + Utils.LOG_INFO("Foods Done."); + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory(UtilsItems.getSimpleStack(output)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + }else if(iStack.getItemDamage() < cooldownTime){ + iStack.setItemDamage(iStack.getItemDamage() + 1); + } + if(MathUtils.divideXintoY(iStack.getItemDamage(), 150)){ + entityHolding.attackEntityFrom(DamageSource.onFire, 1); + } + + + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.RED+"Very hot!"+EnumChatFormatting.GRAY+" Avoid direct handling.."); + list.add(EnumChatFormatting.GRAY+"This food has "+((cooldownTime-(int) stack.getItemDamage())/20)+" seconds left, until it is cool."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(230, 96, 96); + + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java b/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java new file mode 100644 index 0000000000..ba41625b25 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java @@ -0,0 +1,82 @@ +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.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{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemGear(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemGear"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemG", "g"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " 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 (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Gears"); + String tempIngot = unlocalName.replace("itemGear", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 8); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Gear.get(1), + UtilsItems.getSimpleStack(this), + 40*mTier*20, + 24*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java new file mode 100644 index 0000000000..e193636043 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java @@ -0,0 +1,118 @@ +package gtPlusPlus.core.item.base.ingots; + +import gregtech.api.util.GT_ModHandler; +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 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 BaseItemIngot extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + + public BaseItemIngot(String unlocalizedName, String materialName, int colour, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemIngot"); + this.setMaxStackSize(64); + this.colour = colour; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + String temp = ""; + if (unlocalName.contains("itemIngot")){ + temp = unlocalName.replace("itemI", "i"); + } + else if (unlocalName.contains("itemHotIngot")){ + temp = unlocalName.replace("itemHotIngot", "ingotHot"); + } + if (temp != null && temp != ""){ + GT_OreDictUnificator.registerOre(temp, UtilsItems.getSimpleStack(this)); + } + generateCompressorRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Ingot"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("") && !unlocalName.contains("HotIngot")){ + list.add(EnumChatFormatting.GRAY+"A solid ingot of " + materialName + "."); + } + else 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 (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; + + } + + private void generateCompressorRecipe(){ + if (unlocalName.contains("itemIngot")){ + ItemStack tempStack = UtilsItems.getSimpleStack(this, 9); + ItemStack tempOutput = null; + String temp = getUnlocalizedName().replace("item.itemIngot", "block"); + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + temp = temp.replace("itemIngot", "block"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + if (temp != null && temp != ""){ + tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + if (tempOutput != null){ + GT_ModHandler.addCompressionRecipe(tempStack, tempOutput); + } + + } + } + else if (unlocalName.contains("itemHotIngot")){ + return; + } + + + } + + + 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); + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java new file mode 100644 index 0000000000..6fa358f36f --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java @@ -0,0 +1,73 @@ +package gtPlusPlus.core.item.base.ingots; + +import gregtech.api.enums.GT_Values; +import gtPlusPlus.core.lib.CORE; +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.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BaseItemIngotHot extends BaseItemIngot{ + + private ItemStack outputIngot; + private int tickCounter = 0; + private int tickCounterMax = 200; + private int mTier; + + public BaseItemIngotHot(String unlocalizedName, String materialName, ItemStack coldIngot, int tier) { + super(unlocalizedName, materialName, Utils.rgbtoHexValue(225, 225, 225), 0); + this.setTextureName(CORE.MODID + ":" + "itemIngotHot"); + this.outputIngot = coldIngot; + this.mTier = tier; + generateRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("Hot "+materialName+ " Ingot"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A "+EnumChatFormatting.RED+"burning hot"+EnumChatFormatting.GRAY+" ingot of " + materialName + "."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(225, 225, 225); + } + + private void generateRecipe(){ + Utils.LOG_WARNING("Adding Vacuum Freezer recipe for a Hot Ingot of "+materialName+"."); + GT_Values.RA.addVacuumFreezerRecipe(UtilsItems.getSimpleStack(this), outputIngot.copy(), 60*mTier); + + + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + if (!world.isRemote){ + if(tickCounter < tickCounterMax){ + tickCounter++; + } + else if(tickCounter == tickCounterMax){ + entityHolding.attackEntityFrom(DamageSource.onFire, 1); + tickCounter = 0; + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } + } + + +} diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java new file mode 100644 index 0000000000..488f9a6f60 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class ItemBlockBase extends ItemBlock { + + public ItemBlockBase(Block block) { + super(block); + this.setCreativeTab(AddToCreativeTab.tabBlock); + } + + @Override + public int getColorFromItemStack(ItemStack p_82790_1_, int p_82790_2_) { + + return super.getColorFromItemStack(p_82790_1_, p_82790_2_); + } + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java new file mode 100644 index 0000000000..04d01c2c97 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java @@ -0,0 +1,51 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ItemBlockGtBlock extends ItemBlock{ + + protected final int blockColour; + protected final int sRadiation; + + public ItemBlockGtBlock(Block block) { + super(block); + this.blockColour = block.getBlockColor(); + if (block.getLocalizedName().toLowerCase().contains("uranium") || block.getLocalizedName().toLowerCase().contains("plutonium") || block.getLocalizedName().toLowerCase().contains("thorium")){ + sRadiation = 2; + } + else { + sRadiation = 0; + } + GT_OreDictUnificator.registerOre("block"+block.getUnlocalizedName().replace("tile.block", "").replace("tile.", "").replace("of", "").replace("Of", "").replace("Block", "").replace("-", "").replace("_", "").replace(" ", ""), UtilsItems.getSimpleStack(this)); + } + + public int getRenderColor(int aMeta) { + return blockColour; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java new file mode 100644 index 0000000000..c8d791b905 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +public class ItemBlockGtFrameBox extends ItemBlock{ + + protected int blockColour; + + public ItemBlockGtFrameBox(Block block) { + super(block); + this.blockColour = block.getBlockColor(); + GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", ""), UtilsItems.getSimpleStack(this)); + } + + public int getRenderColor(int aMeta) { + return blockColour; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java new file mode 100644 index 0000000000..9d21198033 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java @@ -0,0 +1,92 @@ +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 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 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 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 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/rings/BaseItemRing.java b/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java new file mode 100644 index 0000000000..d5c513c37d --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java @@ -0,0 +1,82 @@ +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.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 BaseItemRing extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemRing(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemRing"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); + 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 (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Rings"); + String tempIngot = unlocalName.replace("itemRing", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Ring.get(1), + UtilsItems.getSimpleStack(this, 4), + 12*mTier*20, + 24*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java new file mode 100644 index 0000000000..befe7552ec --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java @@ -0,0 +1,100 @@ +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.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{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemRod(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setTextureName(CORE.MODID + ":" + "itemRod"); + this.setMaxStackSize(64); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemRod", "stick"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @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 (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 addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Rods"); + String tempIngot = unlocalName.replace("itemRod", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Rod.get(1), + UtilsItems.getSimpleStack(this, 2), + 12*mTier*20, 24*mTier); + } + ItemStack rods = UtilsItems.getSimpleStack(this, 1); + UtilsRecipe.addShapedGregtechRecipe( + rods, rods, rods, + rods, "craftingToolWrench", rods, + rods, rods, rods, + UtilsItems.getItemStackOfAmountFromOreDict(unlocalName.replace("itemRod", "frameGt"), 2)); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java new file mode 100644 index 0000000000..4e157d22b1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java @@ -0,0 +1,99 @@ +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.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{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemRodLong(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setTextureName(CORE.MODID + ":" + "itemRodLong"); + this.setMaxStackSize(64); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemRod", "stick"), UtilsItems.getSimpleStack(this)); + 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 (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 addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for Long "+materialName+" Rods"); + String tempIngot = unlocalName.replace("itemRodLong", "stick"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 2); + if (null != tempOutputStack){ + GT_Values.RA.addForgeHammerRecipe(tempOutputStack, + UtilsItems.getSimpleStack(this, 1), + 12*mTier*20, 24*mTier); + } + ItemStack rods = UtilsItems.getSimpleStack(this, 1); + ItemStack tempOutputStack2 = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + UtilsRecipe.addShapedGregtechRecipe( + tempOutputStack2, "craftingToolHardHammer", tempOutputStack2, + null, null, null, + null, null, null, + rods); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java b/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java new file mode 100644 index 0000000000..d8ecea32bd --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java @@ -0,0 +1,93 @@ +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.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{ + + 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)); + 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)); + + UtilsRecipe.addShapedGregtechRecipe( + tempOutputStack, "craftingToolHardHammer", tempOutputStack, + screwStack, ringStack, "craftingToolFile", + tempOutputStack, "craftingToolScrewdriver", tempOutputStack, + UtilsItems.getSimpleStack(this)); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java new file mode 100644 index 0000000000..953c3a99a3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java @@ -0,0 +1,85 @@ +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.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{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemScrew(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemScrew"); + this.setMaxStackSize(64); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemS", "s"), UtilsItems.getSimpleStack(this)); + 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 (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addLatheRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Screws"); + ItemStack boltStack = UtilsItems.getItemStackOfAmountFromOreDict(unlocalName.replace("itemScrew", "bolt"), 1); + if (null != boltStack){ + GT_Values.RA.addLatheRecipe(boltStack, + UtilsItems.getSimpleStack(this), null, + 60*mTier, 16*mTier); + UtilsRecipe.addShapedGregtechRecipe( + "craftingToolFile", boltStack, null, + boltStack, null, null, + null, null, null, + UtilsItems.getSimpleStack(this)); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/effects/RarityEffect.java b/src/Java/gtPlusPlus/core/item/effects/RarityEffect.java new file mode 100644 index 0000000000..cd5149b622 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/effects/RarityEffect.java @@ -0,0 +1,41 @@ +package gtPlusPlus.core.item.effects; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/* + * +This determines the name colour. EnumRarity can be: +EnumRarity.common - the standard white colour. +EnumRarity.uncommon - a yellow colour. +EnumRarity.rare - a light blue colour. This is used for enchanted items. +EnumRarity.epic - the purple colour used on the Golden Apple. +@SideOnly is an FML annotation. It marks the method below it for existing only on one side. Possible values are: +Side.CLIENT is probably the most common one. This marks the method as existing only on the client side. +Side.SERVER marks the method as existing only on the server side. + * + */ + +public class RarityEffect extends Item { + + public RarityEffect(int par1){ + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.common; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/effects/RarityEpic.java b/src/Java/gtPlusPlus/core/item/effects/RarityEpic.java new file mode 100644 index 0000000000..35c5527d16 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/effects/RarityEpic.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.item.effects; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RarityEpic extends Item { + + public RarityEpic(int par1){ + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.epic; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/effects/RarityRare.java b/src/Java/gtPlusPlus/core/item/effects/RarityRare.java new file mode 100644 index 0000000000..c64accb7aa --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/effects/RarityRare.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.item.effects; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RarityRare extends Item { + + public RarityRare(int par1){ + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/effects/RarityUncommon.java b/src/Java/gtPlusPlus/core/item/effects/RarityUncommon.java new file mode 100644 index 0000000000..398217a24a --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/effects/RarityUncommon.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.item.effects; + +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RarityUncommon extends Item { + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java b/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java new file mode 100644 index 0000000000..5a05ac7655 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java @@ -0,0 +1,107 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +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.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BedLocator_Base extends Item{ + + public int bed_X = 0; + public int bed_Y = 0; + public int bed_Z = 0; + + public BedLocator_Base(String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + + + int NBT_X = bed_X; + int NBT_Y = bed_Y; + int NBT_Z = bed_Z; + + + if (stack.stackTagCompound != null) { + NBT_X = stack.stackTagCompound.getInteger("pos_x"); + NBT_Y = stack.stackTagCompound.getInteger("pos_y"); + NBT_Z = stack.stackTagCompound.getInteger("pos_z"); + + String tempX = String.valueOf(NBT_X); + String tempY = String.valueOf(NBT_Y); + String tempZ = String.valueOf(NBT_Z); + String formattedX = EnumChatFormatting.DARK_RED+tempX+EnumChatFormatting.GRAY; + String formattedY = EnumChatFormatting.RED+tempY+EnumChatFormatting.GRAY; + String formattedZ = EnumChatFormatting.RED+tempZ+EnumChatFormatting.GRAY; + + list.add(EnumChatFormatting.GRAY+"X: "+formattedX+"."); + list.add(EnumChatFormatting.GRAY+"Y: "+formattedY+"."); + list.add(EnumChatFormatting.GRAY+"Z: "+formattedZ+"."); + super.addInformation(stack, aPlayer, list, bool); + } + } + + //Ticking and NBT Handling + /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and + * update it's contents. + * + * public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = 5000; + * + */ + @Override + public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { + itemStack.stackTagCompound = new NBTTagCompound(); + this.bed_X = 0; + this.bed_Y = 0; + this.bed_Z = 0; + itemStack.stackTagCompound.setInteger("pos_x", bed_X); + itemStack.stackTagCompound.setInteger("pos_y", bed_Y); + itemStack.stackTagCompound.setInteger("pos_z", bed_Z); + } + + @Override + public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + + + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) { + itemStack.stackTagCompound = new NBTTagCompound(); + if (par3Entity.getBedLocation() != null){ + this.bed_X = par3Entity.getBedLocation().posX; + this.bed_Y = par3Entity.getBedLocation().posY; + this.bed_Z = par3Entity.getBedLocation().posZ; + } + else { + this.bed_X = 0; + this.bed_Y = 0; + this.bed_Z = 0; + } + itemStack.stackTagCompound.setInteger("pos_x", bed_X); + itemStack.stackTagCompound.setInteger("pos_y", bed_Y); + itemStack.stackTagCompound.setInteger("pos_z", bed_Z); + return super.onItemRightClick(itemStack, world, par3Entity); + } + + + +} diff --git a/src/Java/gtPlusPlus/core/item/general/BufferCore.java b/src/Java/gtPlusPlus/core/item/general/BufferCore.java new file mode 100644 index 0000000000..6343ede855 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/BufferCore.java @@ -0,0 +1,93 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.item.base.BaseItemWithDamageValue; +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BufferCore extends BaseItemWithDamageValue{ + + public int coreTier = 0; + + public BufferCore(String unlocalizedName, int i) { + super(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(2); + this.coreTier = i; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return super.getItemStackDisplayName(stack)+" ["+CORE.VOLTAGES[this.coreTier-1]+"]."; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY+"A key crafting component for making energy buffers."); + super.addInformation(stack, aPlayer, list, bool); + } + + public final int getCoreTier() { + return coreTier; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + //Figure Out Damage + String s = String.format("%X", HEX_OxFFFFFF); + //Utils.LOG_INFO(s); + //String rgb = Utils.hex2Rgb(s); + //Utils.LOG_INFO(rgb); + if (coreTier == 1){ + HEX_OxFFFFFF = 0x4d4d4d; + } + else if (coreTier == 2){ + HEX_OxFFFFFF = 0x666666; + } + else if (coreTier == 3){ + HEX_OxFFFFFF = 0x8c8c8c; + } + else if (coreTier == 4){ + HEX_OxFFFFFF = 0xa6a6a6; + } + else if (coreTier == 5){ + HEX_OxFFFFFF = 0xcccccc; + } + else if (coreTier == 6){ + HEX_OxFFFFFF = 0xe6e6e6; + } + else if (coreTier == 7){ + HEX_OxFFFFFF = 0xffffcc; + } + else if (coreTier == 8){ + HEX_OxFFFFFF = 0xace600; + } + else if (coreTier == 9){ + HEX_OxFFFFFF = 0xffff00; + } + else if (coreTier == 10){ + HEX_OxFFFFFF = 0xff0000; + } + else { + HEX_OxFFFFFF = 0xffffff; + } + + + return HEX_OxFFFFFF; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java new file mode 100644 index 0000000000..22b6ed27f1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java @@ -0,0 +1,256 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import baubles.api.BaubleType; +import baubles.api.IBauble; +import cpw.mods.fml.common.registry.GameRegistry; + +public class ItemCloakingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble{ + + private final String unlocalizedName = "personalCloakingDevice"; + private final ItemStack thisStack; + private final static int maxValueEU = 10000*20*500; + protected double chargeEU = 0; + + public ItemCloakingDevice(double charge){ + this.chargeEU = charge; + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "personalCloakingDevice"); + this.thisStack = UtilsItems.getSimpleStack(this); + this.charge(thisStack, charge, 3, true, false); + if (charge == 10000*20*500){ + this.setDamage(thisStack, 13); + } + GameRegistry.registerItem(this, unlocalizedName+"-"+charge); + } + + @Override + public void onUpdate(ItemStack itemStack, World worldObj, Entity player, int p_77663_4_, boolean p_77663_5_) { + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer){ + for (ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof IElectricItem) { + IElectricItem electricItem = (IElectricItem) is.getItem(); + chargeEU = ElectricItem.manager.getCharge(is); + } + + } + } + } + + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(ItemStack itemStack) { + return 5; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return 8196; + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (EnumChatFormatting.BLUE+"Personal Cloaking Device"+EnumChatFormatting.GRAY); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + //return 1.0D - getEnergyStored(stack) / this.capacity; + return 1.0D - (double)getCharge(stack) / (double)getMaxCharge(stack); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return true; + } + + public int secondsLeft(ItemStack stack){ + double r = 0; + r = getCharge(stack)/(10000*20); + return (int) MathUtils.decimalRounding(r); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(""); + list.add(EnumChatFormatting.GREEN+"Worn as a Belt within Baubles."+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN+"Drains 10,000EU/t to provide invisibility."+EnumChatFormatting.GRAY); + list.add(""); + list.add(EnumChatFormatting.GOLD+"IC2/EU Information"+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY+"Tier: ["+EnumChatFormatting.YELLOW+getTier(thisStack)+EnumChatFormatting.GRAY+"] Input Limit: ["+EnumChatFormatting.YELLOW+getTransferLimit(thisStack)+EnumChatFormatting.GRAY +"EU/t]"); + list.add(EnumChatFormatting.GRAY+"Current Power: ["+EnumChatFormatting.YELLOW+(long) getCharge(stack)+EnumChatFormatting.GRAY+"EU] ["+EnumChatFormatting.YELLOW+MathUtils.findPercentage(getCharge(stack), getMaxCharge(stack))+EnumChatFormatting.GRAY +"%]"); + list.add(EnumChatFormatting.GRAY+"Time Remaining: ["+EnumChatFormatting.YELLOW+secondsLeft(stack)+ EnumChatFormatting.GRAY +" seconds]"); + super.addInformation(stack, aPlayer, list, bool); + } + + /*@Override + public ItemStack getContainerItem(ItemStack itemStack) + { + ItemStack newItem = itemStack.copy(); + newItem.stackSize = 1; + extractEnergy(newItem, 150000, false); + return newItem; + }*/ + + /*@Override + public boolean hasContainerItem(ItemStack stack) + { + return true; + }*/ + + /*@Override + public int getBurnTime(ItemStack fuel) { + if ((fuel == null) || (fuel.getItem() != this)) { + return 0; + } + return extractEnergy(fuel, 150000, true) / 50 / 100; + }*/ + + @Override + public double charge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean simulate) { + + if (!simulate) + { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + + } + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public double discharge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean externally, boolean simulate) { + if (!simulate) + { + ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(ItemStack stack, double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(ItemStack stack, double amount, EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(ItemStack arg0, EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.BELT; + } + + @Override //TODO + public void onEquipped(ItemStack arg0, EntityLivingBase arg1) { + + } + + @Override //TODO + public void onUnequipped(ItemStack arg0, EntityLivingBase arg1) { + + } + + @Override //TODO + public void onWornTick(ItemStack arg0, EntityLivingBase arg1) { + //Utils.LOG_INFO("Trying to Tick Belt. 1"); + if (!arg1.worldObj.isRemote){ + if (getCharge(arg0) >= 10000){ + arg1.addPotionEffect(new PotionEffect(Potion.invisibility.id, 10, 2)); + discharge(arg0, 10000, 5, true, true, false); + } + else { + if (arg1.isPotionActive((Potion.invisibility))){ + arg1.removePotionEffect(Potion.invisibility.id); + } + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java new file mode 100644 index 0000000000..728d498e2b --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java @@ -0,0 +1,228 @@ +package gtPlusPlus.core.item.general; + +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 ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +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 baubles.api.BaubleType; +import baubles.api.IBauble; +import cpw.mods.fml.common.registry.GameRegistry; + +public class ItemHealingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble{ + + private final String unlocalizedName = "personalHealingDevice"; + private final ItemStack thisStack; + private final static int maxValueEU = 1000000000; + protected double chargeEU = 0; + + public ItemHealingDevice(){ + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "personalCloakingDevice"); + this.thisStack = UtilsItems.getSimpleStack(this); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void onUpdate(ItemStack itemStack, World worldObj, Entity player, int p_77663_4_, boolean p_77663_5_) { + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer){ + for (ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof IElectricItem) { + IElectricItem electricItem = (IElectricItem) is.getItem(); + chargeEU = ElectricItem.manager.getCharge(is); + } + + } + } + } + + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(ItemStack itemStack) { + return 5; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return 32784; + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (EnumChatFormatting.BLUE+"Personal Healing NanoBooster"+EnumChatFormatting.RESET); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + //return 1.0D - getEnergyStored(stack) / this.capacity; + return 1.0D - (double)getCharge(stack) / (double)getMaxCharge(stack); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return true; + } + + public double secondsLeft(ItemStack stack){ + + double r = 0; + r = getCharge(stack)/(1638400/4); + return (int) r; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(""); + list.add(EnumChatFormatting.GREEN+"Worn as a Necklace within Baubles."+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN+"Drains 1638400eu to restore hunger."+EnumChatFormatting.GRAY); + list.add(""); + list.add(EnumChatFormatting.GOLD+"IC2/EU Information"+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY+"Tier: ["+EnumChatFormatting.YELLOW+getTier(thisStack)+EnumChatFormatting.GRAY+"] Transfer Limit: ["+EnumChatFormatting.YELLOW+getTransferLimit(thisStack)+EnumChatFormatting.GRAY +"Eu/t]"); + list.add(EnumChatFormatting.GRAY+"Current Power: ["+EnumChatFormatting.YELLOW+(long) getCharge(stack)+EnumChatFormatting.GRAY+"Eu] ["+EnumChatFormatting.YELLOW+MathUtils.findPercentage(getCharge(stack), getMaxCharge(stack))+EnumChatFormatting.GRAY +"%]"); + list.add(EnumChatFormatting.GRAY+"Uses Remaining: ["+EnumChatFormatting.YELLOW+secondsLeft(stack)+ EnumChatFormatting.GRAY +"]"); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public double charge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean simulate) { + + if (!simulate) + { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + + } + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public double discharge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean externally, boolean simulate) { + if (!simulate) + { + ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(ItemStack stack, double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(ItemStack stack, double amount, EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(ItemStack arg0, EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override //TODO + public void onEquipped(ItemStack arg0, EntityLivingBase arg1) { + + } + + @Override //TODO + public void onUnequipped(ItemStack arg0, EntityLivingBase arg1) { + + } + + @Override //TODO + public void onWornTick(ItemStack arg0, EntityLivingBase arg1) { + if (!arg1.worldObj.isRemote){ + if (getCharge(arg0) >= 1638400/4){ + if (arg1.getHealth() < arg1.getMaxHealth()){ + float rx = arg1.getMaxHealth()-arg1.getHealth(); + Utils.LOG_INFO("rx:"+rx); + arg1.heal(rx*2); + discharge(arg0, (1638400/4)*rx, 6, true, true, false); + Utils.messagePlayer((EntityPlayer) arg1, "Your NanoBooster Whirs! Leaving you feeling stronger. It Healed "+rx+" hp."); + Utils.messagePlayer((EntityPlayer) arg1, "You check it's remaining uses, it has "+secondsLeft(arg0)+"."); + } + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java b/src/Java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java new file mode 100644 index 0000000000..f452b83a73 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java @@ -0,0 +1,210 @@ +package gtPlusPlus.core.item.general; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import cpw.mods.fml.common.eventhandler.Event; + +public class NuclearFuelRodBase extends Item +{ + /** field for checking if the bucket has been filled. */ + private Block isFull; + public NuclearFuelRodBase(Block p_i45331_1_) + { + this.maxStackSize = 1; + this.isFull = p_i45331_1_; + this.setCreativeTab(CreativeTabs.tabMisc); + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) + { + boolean flag = this.isFull == Blocks.air; + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(p_77659_2_, p_77659_3_, flag); + + if (movingobjectposition == null) + { + return p_77659_1_; + } + FillBucketEvent event = new FillBucketEvent(p_77659_3_, p_77659_1_, p_77659_2_, movingobjectposition); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return p_77659_1_; + } + + if (event.getResult() == Event.Result.ALLOW) + { + if (p_77659_3_.capabilities.isCreativeMode) + { + return p_77659_1_; + } + + if (--p_77659_1_.stackSize <= 0) + { + return event.result; + } + + if (!p_77659_3_.inventory.addItemStackToInventory(event.result)) + { + p_77659_3_.dropPlayerItemWithRandomChoice(event.result, false); + } + + return p_77659_1_; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!p_77659_2_.canMineBlock(p_77659_3_, i, j, k)) + { + return p_77659_1_; + } + + if (flag) + { + if (!p_77659_3_.canPlayerEdit(i, j, k, movingobjectposition.sideHit, p_77659_1_)) + { + return p_77659_1_; + } + + Material material = p_77659_2_.getBlock(i, j, k).getMaterial(); + int l = p_77659_2_.getBlockMetadata(i, j, k); + + if (material == Material.water && l == 0) + { + p_77659_2_.setBlockToAir(i, j, k); + return this.func_150910_a(p_77659_1_, p_77659_3_, Items.water_bucket); + } + + if (material == Material.lava && l == 0) + { + p_77659_2_.setBlockToAir(i, j, k); + return this.func_150910_a(p_77659_1_, p_77659_3_, Items.lava_bucket); + } + } + else + { + if (this.isFull == Blocks.air) + { + return new ItemStack(Items.bucket); + } + + if (movingobjectposition.sideHit == 0) + { + --j; + } + + if (movingobjectposition.sideHit == 1) + { + ++j; + } + + if (movingobjectposition.sideHit == 2) + { + --k; + } + + if (movingobjectposition.sideHit == 3) + { + ++k; + } + + if (movingobjectposition.sideHit == 4) + { + --i; + } + + if (movingobjectposition.sideHit == 5) + { + ++i; + } + + if (!p_77659_3_.canPlayerEdit(i, j, k, movingobjectposition.sideHit, p_77659_1_)) + { + return p_77659_1_; + } + + if (this.tryPlaceContainedLiquid(p_77659_2_, i, j, k) && !p_77659_3_.capabilities.isCreativeMode) + { + return new ItemStack(Items.bucket); + } + } + } + + return p_77659_1_; + } + + @SuppressWarnings("static-method") + private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) + { + if (p_150910_2_.capabilities.isCreativeMode) + { + return p_150910_1_; + } + else if (--p_150910_1_.stackSize <= 0) + { + return new ItemStack(p_150910_3_); + } + else + { + if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) + { + p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); + } + + return p_150910_1_; + } + } + + /** + * Attempts to place the liquid contained inside the bucket. + */ + public boolean tryPlaceContainedLiquid(World p_77875_1_, int p_77875_2_, int p_77875_3_, int p_77875_4_) + { + if (this.isFull == Blocks.air) + { + return false; + } + Material material = p_77875_1_.getBlock(p_77875_2_, p_77875_3_, p_77875_4_).getMaterial(); + boolean flag = !material.isSolid(); + + if (!p_77875_1_.isAirBlock(p_77875_2_, p_77875_3_, p_77875_4_) && !flag) + { + return false; + } + if (p_77875_1_.provider.isHellWorld && this.isFull == Blocks.flowing_water) + { + p_77875_1_.playSoundEffect((double)((float)p_77875_2_ + 0.5F), (double)((float)p_77875_3_ + 0.5F), (double)((float)p_77875_4_ + 0.5F), "random.fizz", 0.5F, 2.6F + (p_77875_1_.rand.nextFloat() - p_77875_1_.rand.nextFloat()) * 0.8F); + + for (int l = 0; l < 8; ++l) + { + p_77875_1_.spawnParticle("largesmoke", (double)p_77875_2_ + Math.random(), (double)p_77875_3_ + Math.random(), (double)p_77875_4_ + Math.random(), 0.0D, 0.0D, 0.0D); + } + } + else + { + if (!p_77875_1_.isRemote && flag && !material.isLiquid()) + { + p_77875_1_.func_147480_a(p_77875_2_, p_77875_3_, p_77875_4_, true); + } + + p_77875_1_.setBlock(p_77875_2_, p_77875_3_, p_77875_4_, this.isFull, 0, 3); + } + + return true; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/general/RF2EU_Battery.java b/src/Java/gtPlusPlus/core/item/general/RF2EU_Battery.java new file mode 100644 index 0000000000..f1141e1ef4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/RF2EU_Battery.java @@ -0,0 +1,314 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import cofh.api.energy.ItemEnergyContainer; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, IElectricItemManager, IFuelHandler{ + + public static int rfPerEU = 4; + private final String unlocalizedName = "rfEUBattery"; + private final ItemStack thisStack; + private final static int maxValueEU = 100000000; + private final static int maxValueRF = maxValueEU * rfPerEU; + protected double chargeEU = 0; + + public RF2EU_Battery(){ + super(maxValueRF, maxValueRF, maxValueRF); + GameRegistry.registerFuelHandler(this); + //this.setMaxDamage(Integer.MAX_VALUE); + //this.setDamage(UtilsItems.getSimpleStack(this), 0); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "itemIngot"); + this.thisStack = UtilsItems.getSimpleStack(this); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void onUpdate(ItemStack itemStack, World worldObj, Entity player, int p_77663_4_, boolean p_77663_5_) { + getEnergyStored(itemStack); + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer){ + for (ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof IElectricItem) { + IElectricItem electricItem = (IElectricItem) is.getItem(); + chargeEU = ElectricItem.manager.getCharge(is); + } + + } + } + } + + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(ItemStack itemStack) { + return 3; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return 8196; + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("Universally Chargeable Battery"); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + //return 1.0D - getEnergyStored(stack) / this.capacity; + return MathUtils.findPercentage(getEnergyStored(stack), getMaxEnergyStored(stack)); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + int i = 30; + + float f13 = (float)(Minecraft.getSystemTime() % 6000L) / 3000.0F * 3.141592F * 2.0F; + + float t = 0.9F + 0.1F * MathHelper.cos(f13); + + double v = 1.0D - getDurabilityForDisplay(par1ItemStack); + + int r = i + (int)(v * (255 - i) * t); + if (r > 255) { + r = 255; + } + int g = i + (int)(v * (64 - i) * t); + + return r << 16 | g << 8 | i; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return false; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.YELLOW+"IC2/EU Information"+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY+"Tier: ["+EnumChatFormatting.YELLOW+getTier(thisStack)+EnumChatFormatting.GRAY+"] Current Power: ["+EnumChatFormatting.YELLOW+(long) getCharge(stack)+EnumChatFormatting.GRAY+"/EU]"); + list.add(EnumChatFormatting.GRAY+"Transfer Limit: ["+EnumChatFormatting.YELLOW+getTransferLimit(thisStack)+ EnumChatFormatting.GRAY +"Eu/t]" +"Burn Time: ["+EnumChatFormatting.YELLOW+getBurnTime(stack)/20+EnumChatFormatting.GRAY+"s]"); + list.add(""); + list.add(EnumChatFormatting.RED+"RF Information"); + list.add(EnumChatFormatting.GRAY+"Extraction Rate: [" +EnumChatFormatting.RED+ this.maxExtract + EnumChatFormatting.GRAY + "Rf/t]" + " Insert Rate: [" +EnumChatFormatting.RED+ this.maxReceive+EnumChatFormatting.GRAY+"Rf/t]"); + list.add(EnumChatFormatting.GRAY+"Current Charge: ["+EnumChatFormatting.RED+getEnergyStored(stack) + EnumChatFormatting.GRAY + "Rf / " + getMaxEnergyStored(stack)+"Rf] "+EnumChatFormatting.RED+MathUtils.findPercentage(getEnergyStored(stack), getMaxEnergyStored(stack))+EnumChatFormatting.GRAY+"%"); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) + { + ItemStack newItem = itemStack.copy(); + newItem.stackSize = 1; + extractEnergy(newItem, 150000, false); + return newItem; + } + + @Override + public boolean hasContainerItem(ItemStack stack) + { + return true; + } + + @Override + public int getBurnTime(ItemStack fuel) { + if ((fuel == null) || (fuel.getItem() != this)) { + return 0; + } + return extractEnergy(fuel, 150000, true) / 50 / 100; + } + + @Override + public double charge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean simulate) { + if (stack.stackTagCompound == null) { + stack.stackTagCompound = new NBTTagCompound(); + } + int energy = stack.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) + { + energy += energyReceived; + stack.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); + ElectricItem.manager.charge(stack, energy/rfPerEU, 3, true, false); + + } + return ElectricItem.manager.charge(stack, amount, tier, ignoreTransferLimit, simulate); + } + + @Override + public double discharge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean externally, boolean simulate) { + if ((stack.stackTagCompound == null) || (!stack.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } + return 0; + } + int energy = stack.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) + { + energy -= energyExtracted; + stack.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); + ElectricItem.manager.charge(stack, energy/rfPerEU, 3, true, false); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(ItemStack stack, double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(ItemStack stack, double amount, EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) + { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy/rfPerEU, 3, true, false); + + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) + { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy/rfPerEU, 3, true, false); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy/rfPerEU, 3, true, false); + return energy; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java b/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java new file mode 100644 index 0000000000..36e6c66df8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java @@ -0,0 +1,223 @@ +package gtPlusPlus.core.item.general.fuelrods; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +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.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class FuelRod_Base extends Item{ + + public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = getMaxHeat(); + public FuelRod_Base(String unlocalizedName, String type, int fuelLeft, int maxFuel) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(maxFuel); + this.maximumFuel = maxFuel; + this.fuelRemaining = fuelLeft; + this.fuelType = type; + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + private float getMaxHeat(){ + float tempvar; + if (fuelType == "Thorium"){ + tempvar = 2500; + } + + else if (fuelType == "Uranium"){ + tempvar = 5000; + } + + else if (fuelType == "Plutonium"){ + tempvar = 10000; + } + + else { + tempvar = 5000; + } + return tempvar; + + } + + private void updateVars(ItemStack stack){ + if (stack.stackTagCompound != null) { + heat = stack.stackTagCompound.getFloat("heat"); + fuelRemaining = stack.stackTagCompound.getInteger("fuelRemaining"); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + + Float NBT_Heat = heat; + Float NBT_MaxHeat = maxHeat; + int NBT_Fuel = fuelRemaining; + String NBT_Type= fuelType; + + if (stack.stackTagCompound != null) { + NBT_Heat = stack.stackTagCompound.getFloat("heat"); + NBT_MaxHeat = stack.stackTagCompound.getFloat("maxHeat"); + NBT_Fuel = stack.stackTagCompound.getInteger("fuelRemaining"); + NBT_Type = stack.stackTagCompound.getString("fuelType"); + } + + String tempHeat = String.valueOf(NBT_Heat); + String tempMaxHeat = String.valueOf(NBT_MaxHeat); + String tempFuel = String.valueOf(NBT_Fuel); + String formattedType = EnumChatFormatting.DARK_RED+NBT_Type+EnumChatFormatting.GRAY; + String formattedHeat = EnumChatFormatting.RED+tempHeat+EnumChatFormatting.GRAY; + String formattedMaxHeat = EnumChatFormatting.RED+tempMaxHeat+EnumChatFormatting.GRAY; + String formattedFuelLeft = tempFuel+EnumChatFormatting.GRAY; + + int tempMax = maximumFuel; + float tempCurrentHeat = heat; + int tempFuelLeft = fuelRemaining; + + //Fuel Usage Formatting + if (tempFuelLeft <= maximumFuel/3){ + formattedFuelLeft = EnumChatFormatting.RED+tempFuel+EnumChatFormatting.GRAY; + } + else if (tempFuelLeft >= maximumFuel/3 && tempFuelLeft <= (maximumFuel/3)*2){ + formattedFuelLeft = EnumChatFormatting.YELLOW+tempFuel+EnumChatFormatting.GRAY; + } + else if (tempFuelLeft >= (maximumFuel/3)*2 && tempFuelLeft <= maximumFuel){ + formattedFuelLeft = EnumChatFormatting.GREEN+tempFuel+EnumChatFormatting.GRAY; + } + else { + formattedFuelLeft = EnumChatFormatting.GRAY+tempFuel+EnumChatFormatting.GRAY; + } + + //Heat Formatting + if (tempCurrentHeat <= 200 && tempCurrentHeat >= 0){ + formattedHeat = EnumChatFormatting.GRAY+tempHeat+EnumChatFormatting.GRAY; + } + else if (tempCurrentHeat <= maxHeat/3 && tempCurrentHeat > 200){ + formattedHeat = EnumChatFormatting.YELLOW+tempHeat+EnumChatFormatting.GRAY; + } + else if (tempCurrentHeat >= maxHeat/3 && tempMax < (maxHeat/3)*2 && tempCurrentHeat != 0){ + formattedHeat = EnumChatFormatting.GOLD+tempHeat+EnumChatFormatting.GRAY; + } + else if (tempCurrentHeat >= ((maxHeat/3)*2) && tempMax <= maxHeat && tempCurrentHeat != 0){ + formattedHeat = EnumChatFormatting.RED+tempHeat+EnumChatFormatting.GRAY; + } + else { + formattedHeat = EnumChatFormatting.BLUE+tempHeat+EnumChatFormatting.GRAY; + } + list.add(EnumChatFormatting.GRAY+"A "+formattedType+" Fuel Rod."); + list.add(EnumChatFormatting.GRAY+"Running at "+formattedHeat+"/"+formattedMaxHeat+" Kelvin."); + list.add(EnumChatFormatting.GRAY+"Fuel Remaining: "+formattedFuelLeft+"L."); + super.addInformation(stack, aPlayer, list, bool); + } + + public String getType(ItemStack stack){ + if (stack.stackTagCompound != null){ + return stack.stackTagCompound.getString("fuelType"); + } + return fuelType; + } + + public int getFuelRemaining(ItemStack stack){ + if (stack.stackTagCompound != null){ + return stack.stackTagCompound.getInteger("fuelRemaining"); + } + return 0; + } + + public int getMaxFuel(){ + return maximumFuel; + } + + public int getFuel(ItemStack stack){ + if (stack != null){ + int i = stack.getItemDamage(); + int r = maximumFuel - i; + return r; + } + return getFuelRemaining(stack); + } + + public boolean setFuelRemainingExplicitly(int i){ + int tempFuel = fuelRemaining; + fuelRemaining = i; + if (i != tempFuel){ + return true; + } + return false; + } + + public boolean addFuel(int i){ + int tempFuel = fuelRemaining; + fuelRemaining = tempFuel+i; + if (fuelRemaining != tempFuel){ + return true; + } + return false; + } + + public float getHeat(ItemStack value){ + if (value.stackTagCompound != null){ + return value.stackTagCompound.getFloat("heat"); + } + return 0f; + } + + public boolean addHeat(float i){ + float tempFuel = heat; + heat = tempFuel+i; + if (heat != tempFuel){ + return true; + } + return false; + } + + + //Ticking and NBT Handling + /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and + * update it's contents. + * + * public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = 5000; + * + */ + @Override + public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { + itemStack.stackTagCompound = new NBTTagCompound(); + itemStack.stackTagCompound.setInteger("fuelRemaining", getFuelRemaining(itemStack)); + itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel); + itemStack.stackTagCompound.setFloat("heat", getHeat(itemStack)); + itemStack.stackTagCompound.setFloat("maxHeat", getMaxHeat()); + itemStack.stackTagCompound.setString("fuelType", getType(itemStack)); + updateVars(itemStack); + } + + @Override + public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + itemStack.stackTagCompound = new NBTTagCompound(); + itemStack.stackTagCompound.setInteger("fuelRemaining", getFuelRemaining(itemStack)); + itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel); + itemStack.stackTagCompound.setFloat("heat", getHeat(itemStack)); + itemStack.stackTagCompound.setFloat("maxHeat", getMaxHeat()); + itemStack.stackTagCompound.setString("fuelType", getType(itemStack)); + updateVars(itemStack); + } + + + +} diff --git a/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java b/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java new file mode 100644 index 0000000000..9b852cb1ea --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java @@ -0,0 +1,13 @@ +package gtPlusPlus.core.item.general.fuelrods; + +public class FuelRod_Thorium extends FuelRod_Base{ + + public FuelRod_Thorium(String unlocalizedName, String type, int fuelLeft, int maxFuel) { + super(unlocalizedName, type, fuelLeft, maxFuel); + this.setMaxDamage(maxFuel); + this.maximumFuel = maxFuel; + this.fuelRemaining = fuelLeft; + this.fuelType = type; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java new file mode 100644 index 0000000000..8f1a2083ac --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java @@ -0,0 +1,43 @@ +package gtPlusPlus.core.item.init; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.base.foods.BaseItemFood; +import gtPlusPlus.core.item.base.foods.BaseItemHotFood; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; + +public class ItemsFoods { + + public static void load(){ + run(); + } + + private static void run(){ + + //Raisin Bread + ModItems.itemIngotRaisinBread = new BaseItemFood("itemIngotRaisinBread", "Raisin Bread", 3, 1.5f, false, new PotionEffect(Potion.weakness.id, 40, 1)).setAlwaysEdible(); + GT_OreDictUnificator.registerOre("foodRaisinBread", UtilsItems.getItemStack(CORE.MODID+":itemIngotRaisinBread", 1)); + //Hot Raisin Bread + ModItems.itemHotIngotRaisinBread = new BaseItemHotFood("itemHotIngotRaisinBread", 1, 0.5f, "Raisin Bread", 120, ModItems.itemIngotRaisinBread); + GT_OreDictUnificator.registerOre("foodHotRaisinBread", UtilsItems.getItemStack(CORE.MODID+":itemHotIngotRaisinBread", 1)); + + //Raisin Bread + ModItems.itemFoodRaisinToast = new BaseItemFood("itemFoodRaisinToast", "Raisin Toast", 1, 0.5f, false).setAlwaysEdible(); + GT_OreDictUnificator.registerOre("foodRaisinToast", UtilsItems.getItemStack(CORE.MODID+":itemFoodRaisinToast", 1)); + //Hot Raisin Bread + ModItems.itemHotFoodRaisinToast = new BaseItemHotFood("itemHotFoodRaisinToast", 1, 0.5f, "Raisin Toast", 20, ModItems.itemFoodRaisinToast); + GT_OreDictUnificator.registerOre("foodHotRaisinToast", UtilsItems.getItemStack(CORE.MODID+":itemHotFoodRaisinToast", 1)); + + //Raisin Bread + ModItems.itemFoodCurriedSausages = new BaseItemFood("itemFoodCurriedSausages", "Curried Sausages", 5, 2f, false); + GT_OreDictUnificator.registerOre("foodCurriedSausages", UtilsItems.getItemStack(CORE.MODID+":itemFoodCurriedSausages", 1)); + //Hot Raisin Bread + ModItems.itemHotFoodCurriedSausages = new BaseItemHotFood("itemHotFoodCurriedSausages", 1, 0.5f, "Curried Sausages", 240, ModItems.itemFoodCurriedSausages); + GT_OreDictUnificator.registerOre("foodHotCurriedSausages", UtilsItems.getItemStack(CORE.MODID+":itemHotFoodCurriedSausages", 1)); + + } + +} diff --git a/src/Java/gtPlusPlus/core/item/materials/MaterialHandler.java b/src/Java/gtPlusPlus/core/item/materials/MaterialHandler.java new file mode 100644 index 0000000000..0f89f2a0ff --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/materials/MaterialHandler.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.item.materials; + +public class MaterialHandler { + + @SuppressWarnings("unused") + private String Staballoy; + + + +} diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java new file mode 100644 index 0000000000..108ac4b83d --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java @@ -0,0 +1,79 @@ +package gtPlusPlus.core.item.tool.misc; + +import gtPlusPlus.core.item.base.BaseItemWithDamageValue; +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SandstoneHammer extends BaseItemWithDamageValue{ + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getColorFromItemStack(net.minecraft.item.ItemStack, int) + */ + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + //Figure Out Damage + + + return super.getColorFromItemStack(stack, HEX_OxFFFFFF); + } + + public SandstoneHammer(String unlocalizedName) { + super(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(2500); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY+"Allows you to craft sand from cobble, or sandstone from sand."); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) + { + return false; + } + + @Override + public boolean getShareTag() + { + return true; + } + + @Override + public boolean hasContainerItem(ItemStack itemStack) + { + return true; + } + @Override + public ItemStack getContainerItem(ItemStack itemStack) + { + itemStack.setItemDamage(itemStack.getItemDamage() + 8); + + return itemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return false; + } + + +} diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java new file mode 100644 index 0000000000..ea59ed2b7e --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -0,0 +1,179 @@ +package gtPlusPlus.core.item.tool.staballoy; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.player.UtilsMining; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MultiPickaxeBase extends StaballoyPickaxe{ + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0){ + return super.getDurabilityForDisplay(stack);} + return 0; + } + + protected Boolean FACING_HORIZONTAL = true; + protected String FACING = "north"; + protected EntityPlayer localPlayer; + protected String lookingDirection; + protected World localWorld; + protected ItemStack thisPickaxe = null; + protected final int colour; + protected final String materialName; + + public MultiPickaxeBase(String unlocalizedName, ToolMaterial material, int materialDurability, int colour) { + super(Utils.sanitizeString(unlocalizedName), material); + this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); + this.setTextureName(CORE.MODID + ":" + "itemPickaxe"); + this.FACING_HORIZONTAL=true; + this.setMaxStackSize(1); + this.setMaxDamage(materialDurability); + this.colour = colour; + this.materialName = material.name(); + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + this.setCreativeTab(AddToCreativeTab.tabTools); + } + + /* + * + * + * + * Methods + * + * + * + */ + + public final String getMaterialName() { + return materialName; + } + + @Override + public String getItemStackDisplayName(ItemStack iStack) { + + String name; + if (getUnlocalizedName().toLowerCase().contains("wood")){ + name = "Wooden"; + } + else if (getUnlocalizedName().toLowerCase().contains("cobblestone")){ + name = "Cobblestone"; + } + else if (getUnlocalizedName().toLowerCase().contains("iron")){ + name = "Iron"; + } + else if (getUnlocalizedName().toLowerCase().contains("gold")){ + name = "Gold"; + } + else if (getUnlocalizedName().toLowerCase().contains("diamond")){ + name = "Diamond"; + } + else { + name = materialName; + } + return name+" Multipickaxe"; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + @SuppressWarnings("static-method") + private float calculateDurabilityLoss(World world, int X, int Y, int Z){ + float bDurabilityLoss = 0; + Boolean correctTool = false; + float bHardness = 0; + if (!world.isRemote){ + try { + Block removalist = world.getBlock(X, Y, Z); + //Utils.LOG_WARNING(removalist.toString()); + + bHardness = removalist.getBlockHardness(world, X, Y, Z); + Utils.LOG_WARNING("Hardness: "+bHardness); + + bDurabilityLoss = (bDurabilityLoss + bHardness); + //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); + + correctTool = canPickaxeBlock(removalist, world); + Utils.LOG_WARNING(""+correctTool); + + if (!correctTool){ + return 0; + } + + } catch (NullPointerException e){ + + } + } + return bDurabilityLoss; + } + + @Override + public int doDurabilityDamage(int x){ + return x; + } + + //Should clear up blocks quicker if I chain it. + @Override + public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + try { + Block block = world.getBlock(X, Y, Z); + float dur = calculateDurabilityLoss(world, X, Y, Z); + Utils.LOG_WARNING(block.toString()); + String removalTool = ""; + removalTool = block.getHarvestTool(1); + + if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block)){ + if (canPickaxeBlock(block, world)){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + + if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ + + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + + } + + } + } + else { + Utils.LOG_WARNING("Incorrect Tool for mining this block."); + } + } + } catch (NullPointerException e){ + + } + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return false; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java new file mode 100644 index 0000000000..07c5800a1f --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java @@ -0,0 +1,279 @@ +package gtPlusPlus.core.item.tool.staballoy; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockCocoa; +import net.minecraft.block.BlockDirt; +import net.minecraft.block.BlockDoublePlant; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.BlockGrass; +import net.minecraft.block.BlockHugeMushroom; +import net.minecraft.block.BlockLeavesBase; +import net.minecraft.block.BlockLog; +import net.minecraft.block.BlockMushroom; +import net.minecraft.block.BlockSand; +import net.minecraft.block.BlockSnow; +import net.minecraft.block.BlockSnowBlock; +import net.minecraft.block.BlockTallGrass; +import net.minecraft.block.BlockVine; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class StaballoyAxe extends ItemAxe{ + public String mat; + + public StaballoyAxe(String unlocalizedName, ToolMaterial material) { + super(material); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + } + + // EXPLODE TREE + byte[] tre= new byte[32000]; + byte unchecked=0; + byte needcheck=1; + byte ignore =2; + byte harvest =3; + + private boolean setcheck(int x, int y, int z) { + if(x<0 || x>19 || z<0 || z>19 || y<0 || y>79) return false; + int o=x+z*20+y*400; + if (tre[o]==unchecked) tre[o]=needcheck; + return true; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+"Fells entire trees in a single swipe!.."); + list.add(EnumChatFormatting.GRAY+"Ask Alkalus for new trees to be supported."); + super.addInformation(stack, aPlayer, list, bool); + } + + public boolean canIgnore(Block bit){ + if (bit instanceof BlockAir)return true; + if (bit instanceof BlockGrass)return true; + if (bit instanceof BlockSand)return true; + if (bit instanceof BlockDirt)return true; + if (bit instanceof BlockCocoa)return true; + if (bit instanceof BlockVine)return true; + if (bit instanceof BlockMushroom)return true; + if (bit instanceof BlockSnow)return true; + if (bit instanceof BlockSnowBlock)return true; + if (bit instanceof BlockFlower)return true; + if (bit instanceof BlockTallGrass)return true; + if (bit instanceof BlockDoublePlant)return true; + + //LoonTools.log("Found uncuttable "+bit.getClass().getSimpleName()); + return false; + } + + private int check(World par1World, int x, int y, int z, int xo, int yo,int zo) { + int f=0; + int o=x+z*20+y*400; + if (tre[o]==needcheck){ + tre[o]=ignore; + Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase)||(bit instanceof BlockHugeMushroom) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ + f=1; + tre[o]=harvest; + //if (bit instanceof BlockLog){ + // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); + //} + for(int xb=-1;xb<2;xb++) + for(int yb=-1;yb<2;yb++) + for(int zb=-1;zb<2;zb++) + if (!setcheck(x+xb,y+yb,z+zb))return 3; + }else{ + if (!canIgnore(bit)) return 2; + } + } + return f; + } + + public int checkTree(World par1World,int xo,int yo,int zo){ + boolean f; + for (f=true;f==true;){ + f=false; + for (int y=0;y<80;y++) + for(int z=0;z<20;z++) + for(int x=0;x<20;x++){ + int r=check(par1World,x,y,z,xo,yo,zo); + if (r==3) return 3; + if (r==2) return 2; + if (r==1) f=true; + } + + for (int y=79;y>=0;y--) + for(int z=19;z>=0;z--) + for(int x=19;x>=0;x--){ + int r=check(par1World,x,y,z,xo,yo,zo); + if (r==2) return 3; + if (r==2) return 2; + if (r==1) f=true; + } + } + return 1; + } + + private int check2(World par1World, int x, int y, int z, int xo, int yo,int zo) { + int f=0; + int o=x+z*20+y*400; + if (tre[o]==needcheck){ + tre[o]=ignore; + Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + if (bit instanceof BlockLog){ + f=1; + tre[o]=harvest; + //if (bit instanceof BlockLog){ + // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); + //} + for(int xb=-1;xb<2;xb++) + for(int yb=-1;yb<2;yb++) + for(int zb=-1;zb<2;zb++) + if (!setcheck(x+xb,y+yb,z+zb))return 3; + }else if (bit instanceof BlockLeavesBase){ + }else{ + if (!canIgnore(bit)) return 2; + } + } + return f; + } + + public int checkTree2(World par1World,int xo,int yo,int zo){ + boolean f; + for (f=true;f==true;){ + f=false; + for (int y=0;y<80;y++) + for(int z=0;z<20;z++) + for(int x=0;x<20;x++){ + int r=check2(par1World,x,y,z,xo,yo,zo); + if (r==3) return 3; + if (r==2) return 2; + if (r==1) f=true; + } + + for (int y=79;y>=0;y--) + for(int z=19;z>=0;z--) + for(int x=19;x>=0;x--){ + int r=check2(par1World,x,y,z,xo,yo,zo); + if (r==2) return 3; + if (r==2) return 2; + if (r==1) f=true; + } + } + return 1; + } + + public void exploadTree(World par1World,int xo,int yo,int zo, EntityPlayer plr){ + for (int y=0;y<80;y++) + for(int z=0;z<20;z++) + for(int x=0;x<20;x++){ + int o=x+z*20+y*400; + if (tre[o]==harvest){ + Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); + + if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ + bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met); + par1World.setBlockToAir(x+xo, y+yo, z+zo); + } + } + } + } + + private void breakMushroom(World wld, Block bit, EntityPlayer plr, boolean silk, int x, int y, int z, int met) { + if (silk){ + ItemStack stk = null; //TODO + /*if (bit==Blocks.brown_mushroom_block) stk = new ItemStack(LoonToolItems.brown_mushroom_block,1,met); + else if (bit==Blocks.red_mushroom_block) stk = new ItemStack(LoonToolItems.red_mushroom_block,1,met); + else stk = new ItemStack(bit,1,met);*/ + EntityItem entityitem = new EntityItem(wld, x+0.5, y+0.5, z+0.5, stk); + entityitem.delayBeforeCanPickup = 10; + wld.spawnEntityInWorld(entityitem); + }else{ + bit.harvestBlock(wld, plr, x, y, z, met); + } + wld.setBlockToAir(x, y, z); + } + + public void exploadMushroom(World par1World,int xo,int yo,int zo, EntityPlayer plr, boolean silk){ + for (int y=0;y<80;y++) + for(int z=0;z<20;z++) + for(int x=0;x<20;x++){ + int o=x+z*20+y*400; + if (tre[o]==harvest){ + Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); + if (bit instanceof BlockHugeMushroom){ + breakMushroom(par1World, bit, plr, silk, x+xo, y+yo, z+zo,met); + }else{ + bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met); + par1World.setBlockToAir(x+xo, y+yo, z+zo); + } + } + } + } + + + @Override + public boolean onBlockDestroyed(ItemStack itm, World wld,Block blk, int x, int y,int z, EntityLivingBase plr) { + if (!wld.isRemote){ + Block bit = wld.getBlock(x, y, z); + boolean silk=EnchantmentHelper.getSilkTouchModifier(plr); + if ((bit instanceof BlockHugeMushroom)){ + for (int n=0;n<32000;n++) tre[n]=unchecked; + int met = wld.getBlockMetadata(x, y, z); + breakMushroom(wld, bit, (EntityPlayer) plr, silk, x, y, z,met); + wld.setBlockToAir(x,y,z); + tre[2210]=needcheck; + if (checkTree(wld,x-10,y-4,z-10)==1){ + exploadMushroom(wld,x-10,y-4,z-10,(EntityPlayer) plr,silk); + } + } + + if (bit instanceof BlockLog || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ + //LoonTools.log("cutting tree @ "+x+" "+y+" "+z+" "); + for (int n=0;n<32000;n++) tre[n]=unchecked; + int met = wld.getBlockMetadata(x, y, z); + bit.harvestBlock(wld, (EntityPlayer) plr, x, y, z,met); + wld.setBlockToAir(x,y,z); + tre[2210]=needcheck; + if (checkTree(wld,x-10,y-4,z-10)==1){ + exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); + }else{ + for (int n=0;n<32000;n++) tre[n]=unchecked; + tre[2210]=needcheck; + if (checkTree2(wld,x-10,y-4,z-10)==1){ + exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); + } + } + } + } + return super.onBlockDestroyed(itm, wld, blk, x, y, z, plr); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java new file mode 100644 index 0000000000..a21ee7e6ad --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java @@ -0,0 +1,310 @@ +package gtPlusPlus.core.item.tool.staballoy; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.UtilsMining; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class StaballoyPickaxe extends ItemPickaxe{ + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0){ + return super.getDurabilityForDisplay(stack);} + return 0; + } + + protected Boolean FACING_HORIZONTAL = true; + protected String FACING = "north"; + protected EntityPlayer localPlayer; + protected String lookingDirection; + protected World localWorld; + public ItemStack thisPickaxe = null; + + /* + * + * + * + * Methods + * + * + * + */ + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer aPlayer) { + localPlayer = aPlayer; + localWorld = world; + thisPickaxe = stack; + return super.onItemRightClick(stack, world, aPlayer); + } + + + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int X, int Y, int Z, EntityLivingBase entity) { + //super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); + localWorld = world; + thisPickaxe = stack; + //checkFacing(world); + if (!world.isRemote){ + GetDestroyOrientation(lookingDirection, world, X, Y, Z, stack); + } + + return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); + } + + @SuppressWarnings("static-method") + private float calculateDurabilityLoss(World world, int X, int Y, int Z){ + float bDurabilityLoss = 0; + Boolean correctTool = false; + float bHardness = 0; + if (!world.isRemote){ + try { + Block removalist = world.getBlock(X, Y, Z); + //Utils.LOG_WARNING(removalist.toString()); + + bHardness = removalist.getBlockHardness(world, X, Y, Z); + Utils.LOG_WARNING("Hardness: "+bHardness); + + bDurabilityLoss = (bDurabilityLoss + bHardness); + //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); + + correctTool = canPickaxeBlock(removalist, world); + Utils.LOG_WARNING(""+correctTool); + + if (!correctTool){ + return 0; + } + + } catch (NullPointerException e){ + + } + } + return bDurabilityLoss; + } + + public Boolean canPickaxeBlock(Block currentBlock, World currentWorld){ + String correctTool = ""; + if (!currentWorld.isRemote){ + try { + correctTool = currentBlock.getHarvestTool(0); + //Utils.LOG_WARNING(correctTool); + if (UtilsMining.getBlockType(currentBlock) || correctTool.equals("pickaxe")){ + return true;} + } catch (NullPointerException e){ + return false;} + } + return false; + } + + private void GetDestroyOrientation(String FACING, World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + float DURABILITY_LOSS = 0; + if (!world.isRemote){ + + if (FACING.equals("below") || FACING.equals("above")){ + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + float dur = calculateDurabilityLoss(world, X + i, Y, Z + j); + DURABILITY_LOSS = (DURABILITY_LOSS + calculateDurabilityLoss(world, X + i, Y, Z + j)); + Utils.LOG_WARNING("Added Loss: "+dur); + removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem); + } + } + } + + else if (FACING.equals("facingEast") || FACING.equals("facingWest")){ + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + float dur = calculateDurabilityLoss(world, X, Y + i, Z + j); + DURABILITY_LOSS = (DURABILITY_LOSS + calculateDurabilityLoss(world, X, Y + i, Z + j)); + Utils.LOG_WARNING("Added Loss: "+dur); + removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem); + } + } + } + + else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){ + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + float dur = calculateDurabilityLoss(world, X + j, Y + i, Z); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); + Utils.LOG_WARNING("Added Loss: "+dur); + removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem); + } + } + } + + //int heldItemDurability = heldItem.getDamage(1); + Utils.LOG_WARNING("Total Loss: "+(int)DURABILITY_LOSS); + //heldItem.setDamage(heldStack, DURABILITY_LOSS); + //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + //Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); + if (heldItem.getItemDamage() < (heldItem.getMaxDamage()-DURABILITY_LOSS)){ + heldItem.damageItem((int) DURABILITY_LOSS, localPlayer); + } + //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + DURABILITY_LOSS = 0; + + } + } + + public int doDurabilityDamage(int x){ + return x; + } + + //Should clear up blocks quicker if I chain it. + public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + try { + Block block = world.getBlock(X, Y, Z); + float dur = calculateDurabilityLoss(world, X, Y, Z); + Utils.LOG_WARNING(block.toString()); + String removalTool = ""; + removalTool = block.getHarvestTool(1); + + if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block)){ + if (canPickaxeBlock(block, world)){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + + if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ + + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + + } + + } + } + else { + Utils.LOG_WARNING("Incorrect Tool for mining this block."); + } + } + } catch (NullPointerException e){ + + } + } + + public boolean checkFacing(World world){ + localWorld = world; + if (localPlayer != null){ + int direction = MathHelper.floor_double((double)((localPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3; + //Utils.LOG_WARNING("Player - F: "+direction); + //Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord); + + /*if (localPlayer.getLookVec().yCoord > 0){ + localPlayer.getLookVec().yCoord; + }*/ + + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, (EntityPlayer) localPlayer, false); + if (movingobjectposition != null){ + int sideHit = movingobjectposition.sideHit; + String playerStandingPosition = ""; + if (movingobjectposition != null) { + //System.out.println("Side Hit: "+movingobjectposition.sideHit); + } + + if (sideHit == 0){ + playerStandingPosition = "above"; + FACING_HORIZONTAL = false; + } + else if (sideHit == 1){ + playerStandingPosition = "below"; + FACING_HORIZONTAL = false; + } + else if (sideHit == 2){ + playerStandingPosition = "facingSouth"; + FACING_HORIZONTAL = true; + } + else if (sideHit == 3){ + playerStandingPosition = "facingNorth"; + FACING_HORIZONTAL = true; + } + else if (sideHit == 4){ + playerStandingPosition = "facingEast"; + FACING_HORIZONTAL = true; + } + else if (sideHit == 5){ + playerStandingPosition = "facingWest"; + FACING_HORIZONTAL = true; + } + lookingDirection = playerStandingPosition; + + if (direction == 0){ + FACING = "south"; + } + else if (direction == 1){ + FACING = "west"; + } + else if (direction == 2){ + FACING = "north"; + } + else if (direction == 3){ + FACING = "east"; + } + } + + + return true; + } + return false; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + thisPickaxe = stack; + list.add(EnumChatFormatting.GOLD+"Mines a 3x3 area in the direction you are facing."); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + + + @Override + public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer aPlayer) { + thisPickaxe = itemstack; + localPlayer = aPlayer; + checkFacing(localPlayer.worldObj); + return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer); + } + public StaballoyPickaxe(String unlocalizedName, ToolMaterial material) { + super(material); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.FACING_HORIZONTAL=true; + this.setMaxStackSize(1); + this.setMaxDamage(3200); + } +} |