diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/item')
14 files changed, 733 insertions, 261 deletions
diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index fd2b98c7be..1e0b779bac 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -11,12 +11,8 @@ import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.BlockBaseModular; import gtPlusPlus.core.common.compat.COMPAT_Baubles; import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.BaseEuItem; -import gtPlusPlus.core.item.base.BaseItemBackpack; +import gtPlusPlus.core.item.base.*; import gtPlusPlus.core.item.base.BaseItemComponent.ComponentTypes; -import gtPlusPlus.core.item.base.BaseItemDamageable; -import gtPlusPlus.core.item.base.BaseItemTCShard; -import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.item.base.foil.BaseItemFoil; import gtPlusPlus.core.item.base.foods.BaseItemFood; import gtPlusPlus.core.item.base.foods.BaseItemHotFood; @@ -27,39 +23,18 @@ import gtPlusPlus.core.item.base.misc.BaseItemMisc; import gtPlusPlus.core.item.base.misc.BaseItemMisc.MiscTypes; import gtPlusPlus.core.item.base.plates.BaseItemPlate; import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; -import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; -import gtPlusPlus.core.item.bauble.HealthBoostBauble; -import gtPlusPlus.core.item.bauble.ModularBauble; -import gtPlusPlus.core.item.bauble.MonsterKillerBaseBauble; -import gtPlusPlus.core.item.chemistry.AgriculturalChem; -import gtPlusPlus.core.item.chemistry.CoalTar; -import gtPlusPlus.core.item.chemistry.GenericChem; -import gtPlusPlus.core.item.chemistry.IonParticles; -import gtPlusPlus.core.item.chemistry.MilledOreProcessing; -import gtPlusPlus.core.item.chemistry.NuclearChem; -import gtPlusPlus.core.item.chemistry.RocketFuels; -import gtPlusPlus.core.item.chemistry.StandardBaseParticles; +import gtPlusPlus.core.item.bauble.*; +import gtPlusPlus.core.item.chemistry.*; import gtPlusPlus.core.item.crafting.ItemDummyResearch; import gtPlusPlus.core.item.effects.RarityUncommon; import gtPlusPlus.core.item.food.BaseItemMetaFood; -import gtPlusPlus.core.item.general.BaseItemGrindle; -import gtPlusPlus.core.item.general.BufferCore; -import gtPlusPlus.core.item.general.ItemAirFilter; -import gtPlusPlus.core.item.general.ItemAreaClear; -import gtPlusPlus.core.item.general.ItemBasicFirestarter; -import gtPlusPlus.core.item.general.ItemBlueprint; -import gtPlusPlus.core.item.general.ItemControlCore; -import gtPlusPlus.core.item.general.ItemEmpty; -import gtPlusPlus.core.item.general.ItemGemShards; -import gtPlusPlus.core.item.general.ItemGenericToken; -import gtPlusPlus.core.item.general.ItemGiantEgg; -import gtPlusPlus.core.item.general.ItemHalfCompleteCasings; -import gtPlusPlus.core.item.general.ItemLavaFilter; +import gtPlusPlus.core.item.general.*; import gtPlusPlus.core.item.general.books.ItemBaseBook; import gtPlusPlus.core.item.general.capture.ItemEntityCatcher; import gtPlusPlus.core.item.general.chassis.ItemBoilerChassis; import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoil; import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoilWire; +import gtPlusPlus.core.item.general.spawn.ItemCustomSpawnEgg; import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemThrowableBomb; @@ -71,20 +46,12 @@ import gtPlusPlus.core.item.tool.misc.SandstoneHammer; import gtPlusPlus.core.item.tool.misc.box.AutoLunchBox; import gtPlusPlus.core.item.tool.misc.box.MagicToolBag; import gtPlusPlus.core.item.tool.misc.box.UniversalToolBox; -import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; -import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; -import gtPlusPlus.core.item.tool.staballoy.StaballoyAxe; -import gtPlusPlus.core.item.tool.staballoy.StaballoyPickaxe; +import gtPlusPlus.core.item.tool.staballoy.*; import gtPlusPlus.core.item.wearable.WearableLoader; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.material.ALLOY; -import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.MISC_MATERIALS; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.MaterialGenerator; -import gtPlusPlus.core.material.NONMATERIAL; +import gtPlusPlus.core.material.*; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.material.nuclear.NUCLIDE; import gtPlusPlus.core.recipe.common.CI; @@ -99,19 +66,18 @@ import gtPlusPlus.everglades.GTplusplus_Everglades; import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.xmod.cofh.HANDLER_COFH; import gtPlusPlus.xmod.eio.material.MaterialEIO; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; +import net.minecraft.item.*; import net.minecraft.item.Item.ToolMaterial; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; public final class ModItems { - public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18); public static Item ZZZ_Empty; @@ -120,7 +86,7 @@ public final class ModItems { public static Item itemAlkalusDisk; public static Item itemDebugShapeSpawner; - public static Item itemBaseSpawnEgg; + public static ItemCustomSpawnEgg itemCustomSpawnEgg; //EnderIO public static Item itemPlateSoularium; @@ -295,6 +261,7 @@ public final class ModItems { public static Item itemSugarCoke; public static Item itemCircuitLFTR; + public static Item itemBasicTurbine; public static Item itemDebugAreaClear; @@ -317,7 +284,7 @@ public final class ModItems { public static Item dustDecayedRadium226; public static Item dustRadium226; - public static Item itemBigEgg; + public static ItemGiantEgg itemBigEgg; public static GregtechPump toolGregtechPump; @@ -384,9 +351,10 @@ public final class ModItems { itemDebugScanner = new DebugScanner(); itemAlkalusDisk = new BaseItemDamageable("itemAlkalusDisk", AddToCreativeTab.tabMisc, 1, 0, "Unknown Use", EnumRarity.rare, EnumChatFormatting.AQUA, false, null); - itemBigEgg = new ItemGiantEgg("itemBigEgg", "Ginourmous Chicken Egg", tabMisc, 64, 0, "I had best try disassemble this.. for science!", "fuelLargeChickenEgg", 5000, 0).setTextureName(CORE.MODID + ":itemBigEgg"); + itemBigEgg = new ItemGiantEgg(); itemGenericToken = new ItemGenericToken(); itemDummyResearch = new ItemDummyResearch(); + itemCustomSpawnEgg = new ItemCustomSpawnEgg(); //Debug Loading if (CORE_Preloader.DEBUG_MODE){ @@ -662,6 +630,8 @@ public final class ModItems { MaterialGenerator.generate(ALLOY.CINOBITE); MaterialGenerator.generate(ALLOY.PIKYONIUM); MaterialGenerator.generate(ALLOY.ABYSSAL); + MaterialGenerator.generate(ALLOY.LAURENIUM); + MaterialGenerator.generate(ALLOY.BOTMIUM); MaterialGenerator.generate(ALLOY.TITANSTEEL); @@ -749,6 +719,9 @@ public final class ModItems { //LFTR Control Circuit itemCircuitLFTR = new CoreItem("itemCircuitLFTR", ""+EnumChatFormatting.GREEN+"Control Circuit", AddToCreativeTab.tabMisc, 1, 0, new String[] {"Keeps Multiblocks Stable"}, EnumRarity.epic, EnumChatFormatting.DARK_GREEN, false, null); + if (CORE.ConfigSwitches.enableMachine_Pollution) { + itemBasicTurbine = new ItemBasicScrubberTurbine(); + } //Zirconium //Cinter Pellet. @@ -973,8 +946,12 @@ public final class ModItems { itemIonParticleBase = new IonParticles(); itemStandarParticleBase = new StandardBaseParticles(); - - + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + Item a8kFlask = VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_8k", "Large Volumetric Flask", 8000); + Item a64kFlask = VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_32k", "Gigantic Volumetric Flask", 32000); + GregtechItemList.VOLUMETRIC_FLASK_8k.set(a8kFlask); + GregtechItemList.VOLUMETRIC_FLASK_32k.set(a64kFlask); + } itemBoilerChassis = new ItemBoilerChassis(); itemDehydratorCoilWire = new ItemDehydratorCoilWire(); diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java b/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java index 54710662d8..79a49f92b7 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java @@ -14,10 +14,11 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; - +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class BaseItemTickable extends CoreItem { @@ -57,7 +58,7 @@ public class BaseItemTickable extends CoreItem { } - boolean active = getIsActive(world, iStack); + boolean active = isTicking(world, iStack); if (active) { tickItemTag(world, iStack); } @@ -113,12 +114,15 @@ public class BaseItemTickable extends CoreItem { } } + protected int getMaxTicks(ItemStack aStack) { + return maxTicks; + } - private boolean createNBT(World world, ItemStack rStack){ + protected boolean createNBT(World world, ItemStack rStack){ final NBTTagCompound tagMain = new NBTTagCompound(); final NBTTagCompound tagNBT = new NBTTagCompound(); tagNBT.setLong("Tick", 0); - tagNBT.setLong("maxTick", this.maxTicks); + tagNBT.setLong("maxTick", getMaxTicks(rStack)); tagNBT.setBoolean("isActive", true); //Try set world time @@ -127,11 +131,12 @@ public class BaseItemTickable extends CoreItem { } tagMain.setTag("TickableItem", tagNBT); - rStack.setTagCompound(tagMain); + rStack.setTagCompound(tagMain); + Logger.INFO("Created Tickable NBT data."); return true; } - public final long getFilterDamage(World world, final ItemStack aStack) { + public final long getTicks(World world, final ItemStack aStack) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag("TickableItem"); @@ -145,7 +150,7 @@ public class BaseItemTickable extends CoreItem { return 0L; } - public final boolean setFilterDamage(World world, final ItemStack aStack, final long aDamage) { + public final boolean setTicks(World world, final ItemStack aStack, final long aDamage) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag("TickableItem"); @@ -160,7 +165,7 @@ public class BaseItemTickable extends CoreItem { return false; } - public final boolean getIsActive(World world, final ItemStack aStack) { + public final boolean isTicking(World world, final ItemStack aStack) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag("TickableItem"); @@ -174,7 +179,7 @@ public class BaseItemTickable extends CoreItem { return true; } - public final boolean setIsActive(World world, final ItemStack aStack, final boolean active) { + public final boolean setTicking(World world, final ItemStack aStack, final boolean active) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag("TickableItem"); @@ -251,26 +256,15 @@ public class BaseItemTickable extends CoreItem { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { if (aNBT.hasKey("TickableItem")) { - aNBT = aNBT.getCompoundTag("TickableItem"); - - /*if (!aNBT.hasKey("CreationDate") && world != null) { - aNBT.setLong("CreationDate", world.getTotalWorldTime()); - }*/ - + aNBT = aNBT.getCompoundTag("TickableItem"); //Done Ticking - if (maxTicks-getFilterDamage(world, aStack) <= 0) { - setIsActive(world, aStack, false); + if (getMaxTicks(aStack)-getTicks(world, aStack) <= 0) { + setTicking(world, aStack, false); return false; } - if (getIsActive(world, aStack)) { + if (isTicking(world, aStack)) { if (aNBT != null) { - - //if ((world.getTotalWorldTime()-)) - - // Just tick once - aNBT.setLong("Tick", getFilterDamage(world, aStack)+1); - - + aNBT.setLong("Tick", getTicks(world, aStack)+1); return true; } else { @@ -288,10 +282,11 @@ public class BaseItemTickable extends CoreItem { @Override public double getDurabilityForDisplay(ItemStack stack) { if (stack.getTagCompound() == null){ - createNBT(null, stack); + //createNBT(null, stack); + return 0; } - double currentDamage = getFilterDamage(null, stack); - double durabilitypercent = currentDamage / maxTicks; + double currentDamage = getTicks(null, stack); + double durabilitypercent = currentDamage / getMaxTicks(stack); return durabilitypercent; } @@ -302,23 +297,28 @@ public class BaseItemTickable extends CoreItem { if (this.descriptionString.length > 0) { list.add(EnumChatFormatting.GRAY+this.descriptionString[0]); } + long maxTicks = getMaxTicks(stack); + long ticks = 0; + if (stack.hasTagCompound()) { + ticks = getTicks(world, stack); + } EnumChatFormatting durability = EnumChatFormatting.GRAY; - if (maxTicks-getFilterDamage(world, stack) > (maxTicks*0.8)){ + if (maxTicks-ticks > (maxTicks*0.8)){ durability = EnumChatFormatting.GRAY; } - else if (maxTicks-getFilterDamage(world, stack) > (maxTicks*0.6)){ + else if (maxTicks-ticks > (maxTicks*0.6)){ durability = EnumChatFormatting.GREEN; } - else if (maxTicks-getFilterDamage(world, stack) > (maxTicks*0.4)){ + else if (maxTicks-ticks > (maxTicks*0.4)){ durability = EnumChatFormatting.YELLOW; } - else if (maxTicks-getFilterDamage(world, stack) > (maxTicks*0.2)){ + else if (maxTicks-ticks > (maxTicks*0.2)){ durability = EnumChatFormatting.GOLD; } - else if (maxTicks-getFilterDamage(world, stack) > 0){ + else if (maxTicks-ticks > 0){ durability = EnumChatFormatting.RED; } - list.add(durability+""+((maxTicks-getFilterDamage(world, stack))/20)+EnumChatFormatting.GRAY+" seconds until decay"); + list.add(durability+""+((maxTicks-ticks)/20)+EnumChatFormatting.GRAY+" seconds until decay"); if (this.descriptionString.length > 1) { for (int h=1;h<this.descriptionString.length;h++) { diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java index 251230932c..14344c1817 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java @@ -51,11 +51,12 @@ public class ItemBlockBasicTile extends ItemBlock { list.add("Use either Formaldehyde or Hydrogen cyanide"); list.add("Be weary of your neighbours"); } - else if (this.mID == 7) { - + else if (this.mID == 7) { // Egg Box + list.add("A box for holding big eggs"); } - else if (this.mID == 8){ - + else if (this.mID == 8){ // Volumetric Flask Setter + list.add("Easy Flask Configuration"); + list.add("Configure default input slot with a screwdriver"); } else if (this.mID == 9){ diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java index 2d0fd00dd9..7a4222ed0f 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java @@ -107,4 +107,9 @@ public class ItemBlockRoundRobinator extends ItemBlockWithMetadata public int getItemEnchantability(ItemStack stack) { return 0; } + + @Override + public boolean getHasSubtypes() { + return true; + } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java index 356fdac24e..883eb241da 100644 --- a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -178,9 +178,9 @@ public class BaseOreComponent extends Item{ @SideOnly(Side.CLIENT) public void registerIcons(final IIconRegister par1IconRegister){ if (this.componentType == ComponentTypes.MILLED) { - this.base = par1IconRegister.registerIcon(CORE.MODID + ":" + "processing/MilledOre/"+this.componentType.getComponent()); + this.base = par1IconRegister.registerIcon(CORE.MODID + ":" + "processing/MilledOre/milled"); if (this.componentType.hasOverlay()){ - this.overlay = par1IconRegister.registerIcon(CORE.MODID + ":" + "processing/MilledOre/"+this.componentType.getComponent()+"_Overlay"); + this.overlay = par1IconRegister.registerIcon(CORE.MODID + ":" + "processing/MilledOre/milled_OVERLAY"); } } else if (CORE.ConfigSwitches.useGregtechTextures){ diff --git a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java index 37428b18d6..badd318414 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java @@ -5,7 +5,6 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.minecraft.ItemPackage; -import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; @@ -289,6 +288,7 @@ public class CoalTar extends ItemPackage { FluidStack aGtAcid = FluidUtils.getFluidStack("phtalicacid", 500); if (aMyAcid != null && aGtAcid != null) { CORE.RA.addDistilleryRecipe(CI.getNumberedBioCircuit(8), aMyAcid, aGtAcid, null, 50, 16, false); + CORE.RA.addDistilleryRecipe(CI.getNumberedBioCircuit(9), aGtAcid, aMyAcid, null, 50, 16, false); } } @@ -354,7 +354,7 @@ public class CoalTar extends ItemPackage { Naphthalene = FluidUtils.generateFluidNonMolten("Naphthalene", "Naphthalene", 115, new short[]{210, 185, 135, 100}, null, null); // v - Oxidize with mercury and nitric acid //Create Phthalic Acid - Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phtalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); + Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); // v - Dehydrate at 180C+ //Create Phthalic Anhydride //ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); diff --git a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java index 80a51d80cc..f61a2096b7 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java @@ -406,7 +406,7 @@ public class GenericChem extends ItemPackage { }, 20 *60, 120, - 2); + 4); //Sodium ethyl xanthate - CH3CH2ONa + CS2 → CH3CH2OCS2Na CORE.RA.addChemicalPlantRecipe( @@ -425,7 +425,7 @@ public class GenericChem extends ItemPackage { }, 20 *60, 120, - 2); + 4); } @@ -869,7 +869,7 @@ public class GenericChem extends ItemPackage { }, 20 * 30, 500, - 3); + 4); } @@ -891,7 +891,7 @@ public class GenericChem extends ItemPackage { }, 20 * 15, 120, - 1); + 2); /*GT_Values.RA.addChemicalRecipe( ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 4), @@ -922,7 +922,7 @@ public class GenericChem extends ItemPackage { }, 20 * 40, 120, - 1); + 2); /*GT_Values.RA.addChemicalRecipe( ItemUtils.getItemStackOfAmountFromOreDict("platePalladium", 0), diff --git a/src/Java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java b/src/Java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java index 71bf2f3e6f..8c6e66fcb8 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java @@ -629,7 +629,7 @@ public class MilledOreProcessing extends ItemPackage { }, 20 * 60, 120, - 2); + 3); CORE.RA.addChemicalPlantRecipe( new ItemStack[] { @@ -653,7 +653,7 @@ public class MilledOreProcessing extends ItemPackage { }, 20 * 45, 120, - 3); + 4); } @@ -683,7 +683,7 @@ public class MilledOreProcessing extends ItemPackage { aChances, aTime * 20, aEU, - 1); + 3); } public static ItemStack[] cleanArray(ItemStack[] input) { diff --git a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java index 719e5145e9..86088fe8c6 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -100,7 +100,7 @@ public class RocketFuels extends ItemPackage { CORE.RA.addChemicalPlantRecipe( new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 16), + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 12), ItemUtils.getSimpleStack(GenericChem.mOrangeCatalyst, 0), }, new FluidStack[] { @@ -118,7 +118,7 @@ public class RocketFuels extends ItemPackage { new int[]{100, 100, 50, 50}, 20*30, MaterialUtils.getVoltageForTier(3), - 2); + 3); } @@ -276,7 +276,7 @@ public class RocketFuels extends ItemPackage { }, 20 * 60, 120, - 2); + 3); } @@ -388,7 +388,7 @@ public class RocketFuels extends ItemPackage { }, 20 * 30, 240, - 3); + 4); // Monomethylhydrazine_Plus_Nitric_Acid @@ -397,19 +397,19 @@ public class RocketFuels extends ItemPackage { CI.getNumberedCircuit(3), }, new FluidStack[] { - FluidUtils.getFluidStack(Monomethylhydrazine, 1000), + FluidUtils.getFluidStack(Monomethylhydrazine, 2000), FluidUtils.getFluidStack("nitricacid", 1000), }, new ItemStack[] { }, new FluidStack[] { - FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 3000), + FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 2000), }, 20 * 45, 480, - 3); + 5); // Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide @@ -425,12 +425,12 @@ public class RocketFuels extends ItemPackage { }, new FluidStack[] { - FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 4000), + FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 5000), }, 20 * 60, 480, - 3); + 6); } diff --git a/src/Java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java b/src/Java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java new file mode 100644 index 0000000000..bd8159eb01 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java @@ -0,0 +1,147 @@ +package gtPlusPlus.core.item.general; +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +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.IIcon; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +public class ItemBasicScrubberTurbine extends Item { + + public IIcon[] icons = new IIcon[1]; + + public ItemBasicScrubberTurbine() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemBasicTurbine"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "itemBasicTurbine"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[0]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i ++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if (tItem == null) { + return "Basic Turbine"; + } + return super.getItemStackDisplayName(tItem); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + int meta = stack.getItemDamage(); + if (meta == 0){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(200,200,200); + } + if (meta == 1){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(255,128,0); + } + return HEX_OxFFFFFF; + } + + private static boolean createNBT(ItemStack rStack){ + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagMain.setTag("BasicTurbine", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getFilterDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("BasicTurbine"); + if (aNBT != null) { + return aNBT.getLong("Damage"); + } + } + else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("BasicTurbine"); + if (aNBT != null) { + aNBT.setLong("Damage", aDamage); + return true; + } + } + return false; + } + + public int getMaxDurability(ItemStack aStack) { + if (aStack != null) { + int aMeta = aStack.getItemDamage(); + if (aMeta == 0) { + return 2500; + } + if (aMeta == 1) { + return 5000; + } + } + return 0; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null){ + createNBT(stack); + } + double currentDamage = getFilterDamage(stack); + double meta = getMaxDurability(stack); + double durabilitypercent = currentDamage / meta; + return durabilitypercent; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY+"An early tier Turbine for Atmospheric Reconditioning."); + int maxDamage = getMaxDurability(stack); + list.add(EnumChatFormatting.GRAY+""+(maxDamage-getFilterDamage(stack))+"/"+maxDamage+" uses left."); + super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java b/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java index d98b27d163..b3338bb681 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java @@ -4,188 +4,232 @@ import static gtPlusPlus.core.lib.CORE.RANDOM; import java.util.List; -import gregtech.api.enums.ItemList; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.entity.item.ItemEntityGiantEgg; -import gtPlusPlus.core.item.base.BaseItemBurnable; +import gtPlusPlus.core.item.base.BaseItemTickable; +import gtPlusPlus.core.item.general.spawn.ItemCustomSpawnEgg; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; -import net.minecraft.creativetab.CreativeTabs; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; -public class ItemGiantEgg extends BaseItemBurnable { +public class ItemGiantEgg extends BaseItemTickable { - public ItemGiantEgg(String unlocalizedName, String displayName, CreativeTabs creativeTab, int stackSize, int maxDmg, - String description, String oredictName, int burnTime, int meta) { - super(unlocalizedName, displayName, creativeTab, stackSize, maxDmg, description, oredictName, burnTime, meta); - this.setMaxStackSize(1); - } + private static ItemStack turnsIntoItem; + private static ItemStack mCorrectEgg; + private static ItemStack mCorrectStemCells; - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String localName = super.getItemStackDisplayName(aStack); - nbtWork(aStack); - int size = 1; - if (NBTUtils.hasKey(aStack, "size")){ - size = NBTUtils.getInteger(aStack, "size"); - return ""+size+" "+localName; - } - return "?? "+localName; + public void registerFuel(int burn){ + CORE.burnables.add(new Pair<Integer, ItemStack>(burn, ItemUtils.getSimpleStack(this, 1))); } - private static ItemStack mCorrectEgg; - private static ItemStack mCorrectStemCells; + public final void registerOrdictionary(String name){ + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(this), name); + } - @Override - public void onUpdate(ItemStack aStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + public ItemGiantEgg() { + this(Utils.rgbtoHexValue(255, 255, 255), Short.MAX_VALUE * Byte.MAX_VALUE, new String[] {"I had best try disassemble this.. for science!"}); + } - if (world.isRemote) { - super.onUpdate(aStack, world, entityHolding, p_77663_4_, p_77663_5_); - return; - } - try { - boolean player = (entityHolding != null && entityHolding instanceof EntityPlayer); + private ItemGiantEgg(int colour, int maxTicks, String[] desc1) { + super(true, false, "itemBigEgg", colour, maxTicks, desc1); + setTextureName(CORE.MODID + ":itemBigEgg"); + this.setMaxStackSize(1); + registerFuel(5000); + registerOrdictionary("fuelLargeChickenEgg"); + } + + public static void postInit(ItemGiantEgg aGiantEggItem) { + ItemGiantEgg.turnsIntoItem = getSpawnEggStack(); + //new DecayableRecipe(aGiantEggItem.maxTicks, getSimpleStack(aGiantEggItem), ItemUtils.getSimpleStack(ItemGiantEgg.turnsIntoItem, 1)); + } - if (player) { - NBTUtils.setBoolean(aStack, "playerHeld", true); - } - else { - NBTUtils.setBoolean(aStack, "playerHeld", false); - } - - nbtWork(aStack); - - int age = NBTUtils.hasKey(aStack, "mAge") ? NBTUtils.getInteger(aStack, "mAge") : 0; - if (player) { - NBTUtils.setInteger(aStack, "mAge", age+1); - - //Set the correct egg for future hatches - if (mCorrectEgg == null) { - if (NBTUtils.hasKey(aStack, "mAge") && NBTUtils.hasKey(aStack, "mEggAge")) { - if (NBTUtils.getInteger(aStack, "mAge") >= NBTUtils.getInteger(aStack, "mEggAge")) { - for (int g=0;g<128;g++) { - ItemStack mSpawn = ItemUtils.simpleMetaStack(Items.spawn_egg, g, 1); - if (mSpawn != null) { - String s = ("" + StatCollector.translateToLocal(mSpawn.getUnlocalizedName() + ".name")).trim(); - String s1 = EntityList.getStringFromID(mSpawn.getItemDamage()); - if (s1 != null){ - s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name"); - if (s1.equalsIgnoreCase("bigChickenFriendly")) { - mCorrectEgg = mSpawn; - break; - } - } - } - } + private static ItemStack getSpawnEggStack() { + //Set the correct egg for future hatches + if (mCorrectEgg == null) { + /*for (int g=0;g<Byte.MAX_VALUE;g++) { + ItemStack mSpawn = ItemUtils.simpleMetaStack(Items.spawn_egg, g, 1); + if (mSpawn != null) { + //String s = ("" + StatCollector.translateToLocal(mSpawn.getUnlocalizedName() + ".name")).trim(); + String s1 = EntityList.getStringFromID(mSpawn.getItemDamage()); + if (s1 != null){ + //s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name"); + if (s1.equalsIgnoreCase("bigChickenFriendly")) { + mCorrectEgg = mSpawn; + return mCorrectEgg; } } - } + } + }*/ + ItemStack aTempEgg = ItemCustomSpawnEgg.getSpawnEggForEntityname("bigChickenFriendly", 1); + if (aTempEgg != null) { + mCorrectEgg = aTempEgg; + } + } + return mCorrectEgg; + } - if (mCorrectEgg != null) { - if (NBTUtils.hasKey(aStack, "mAge") && NBTUtils.hasKey(aStack, "mEggAge")) { - if (NBTUtils.getInteger(aStack, "mAge") >= NBTUtils.getInteger(aStack, "mEggAge")) { - if (MathUtils.randInt(0, 1000) >= 990) { - if (NBTUtils.hasKey(aStack, "size")) { - if ((NBTUtils.getInteger(aStack, "size")+1) >= MathUtils.randInt(0, 9)) { - ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((mCorrectEgg)); - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); - } - else { - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); - } - } - } - } - } + private static ItemStack getStemCellStack() { + if (mCorrectStemCells == null) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 28) { + ItemStack xl = ItemUtils.getValueOfItemList("Circuit_Chip_Stemcell", 1, ItemUtils.getSimpleStack(Items.egg, 2)); + if (xl != null) { + mCorrectStemCells = xl.copy(); } } + else { + mCorrectStemCells = ItemUtils.getSimpleStack(Items.egg, 2); + } } - catch (Throwable t) { - t.printStackTrace(); - } + return mCorrectStemCells; + } - super.onUpdate(aStack, world, entityHolding, p_77663_4_, p_77663_5_); + protected int getMaxTicks(ItemStack aStack) { + if (aStack != null && aStack.hasTagCompound() && aStack.getTagCompound().hasKey("mEggAge")) { + return NBTUtils.getInteger(aStack, "mEggAge"); + } + return maxTicks; } @Override - public void onCreated(ItemStack p_77622_1_, World p_77622_2_, EntityPlayer p_77622_3_) { - super.onCreated(p_77622_1_, p_77622_2_, p_77622_3_); + public void registerIcons(final IIconRegister i) { + this.mIcon[0] = i.registerIcon(CORE.MODID + ":" + "itemBigEgg"); } - public void nbtWork(ItemStack aStack) { - if (NBTUtils.hasKey(aStack, "playerHeld")) { - boolean player = NBTUtils.getBoolean(aStack, "playerHeld"); - if (player && !NBTUtils.hasKey(aStack, "size")) { - NBTUtils.setInteger(aStack, "size", MathUtils.randInt(1, 8)); + + @Override + protected boolean createNBT(World world, ItemStack aStack){ + + if (aStack.getTagCompound() != null && aStack.getTagCompound().hasKey("size")) { + return false; + } + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(1)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(2)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(3)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(4)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(5)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(6)); + //Logger.INFO("Creating Egg NBT."); + boolean aSuper = super.createNBT(world, aStack); + int size = MathUtils.randInt(1, 8); + NBTUtils.setInteger(aStack, "size", size); + NBTUtils.setInteger(aStack, "mEggAge", ((MathUtils.randInt(8000, 16000)*size))); + ItemStack aStemCells = getStemCellStack(); + if (aStemCells != null) { + int mSize = NBTUtils.getInteger(aStack, "size"); + float mSizeMod = (MathUtils.randInt(-5, 5)/5); + mSize += mSizeMod; + mSize = Math.max(mSize, 1); + ItemStack eggYolks[] = new ItemStack[mSize]; + for (int u=0;u<mSize;u++) { + eggYolks[u] = ItemUtils.getSimpleStack(aStemCells, MathUtils.randInt(1, 4)); } - if (player && !NBTUtils.hasKey(aStack, "mEggAge") && NBTUtils.hasKey(aStack, "size")) { - NBTUtils.setInteger(aStack, "mEggAge", ((MathUtils.randInt(8000, 16000)*NBTUtils.getInteger(aStack, "size"))/2)); + int mexpected = 0; + for (ItemStack e : eggYolks) { + if (e != null) { + mexpected += e.stackSize; + } } + if (mexpected > 0) { + NBTUtils.setInteger(aStack, "mExpected", mexpected); + NBTUtils.writeItemsToGtCraftingComponents(aStack, new ItemStack[]{ ItemUtils.getSimpleStack(aStemCells, mexpected)}, true); + } + } + return aSuper; + + } - if (player && NBTUtils.getTagCompound(aStack, "GT.CraftingComponents") == null) { - if (mCorrectStemCells == null) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 28) { - - ItemList xl = ItemUtils.getValueOfItemList("Circuit_Chip_Stemcell", ItemList.Circuit_Elite); - if (xl != null && xl.hasBeenSet()) { - mCorrectStemCells = xl.get(1); - } - } - else { - mCorrectStemCells = ItemUtils.getSimpleStack(Items.egg, 2); - } - } - if (mCorrectStemCells != null) { - int mSize = NBTUtils.getInteger(aStack, "size"); - float mSizeMod = (MathUtils.randInt(-5, 5)/10); - mSize += mSizeMod; - mSize = Math.max(mSize, 1); - ItemStack eggYolks[] = new ItemStack[mSize]; - for (int u=0;u<mSize;u++) { - eggYolks[u] = ItemUtils.getSimpleStack(mCorrectStemCells, MathUtils.randInt(1, 4)); - } + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + if (iStack.getTagCompound() == null || !iStack.getTagCompound().hasKey("size")) { + this.createNBT(world, iStack); + Logger.INFO("Egg has no NBT, creating (onUpdate)"); + } + boolean a1, a2; + a1 = this.isTicking(world, iStack); + a2 = a1 ? tickItemTag(world, iStack) : false; - int mexpected = 0; - for (ItemStack e : eggYolks) { - if (e != null) { - mexpected += e.stackSize; + //Logger.INFO("Is Ticking? "+a1); + //Logger.INFO("Did Tick? "+a2); + if (!a1 && !a2) { + if (entityHolding instanceof EntityPlayer){ + if (MathUtils.randInt(0, 1000) >= 990) { + if (NBTUtils.hasKey(iStack, "size")) { + if ((NBTUtils.getInteger(iStack, "size")+1) >= MathUtils.randInt(0, 9)) { + ItemStack replacement = ItemUtils.getSimpleStack(getHatchResult(), 1); + if (replacement == null) { + + } + //Logger.INFO("Replacing "+iStack.getDisplayName()+" with "+replacement.getDisplayName()+"."); + final ItemStack tempTransform = replacement.copy(); + if (iStack.stackSize > 1){ + int u = iStack.stackSize; + tempTransform.stackSize = u; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l=0;l<u;l++){ + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } + else { + tempTransform.stackSize=1; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } } } - if (mexpected > 0) { - NBTUtils.setInteger(aStack, "mExpected", mexpected); - } - - NBTUtils.writeItemsToGtCraftingComponents(aStack, eggYolks, true); } } - if (player && NBTUtils.getTagCompound(aStack, "GT.CraftingComponents") != null) { + } + } - } - } + public ItemStack getHatchResult() { + return turnsIntoItem; } @Override + public String getItemStackDisplayName(ItemStack aStack) { + String localName = super.getItemStackDisplayName(aStack); + /*if (aStack.getTagCompound() == null){ + createNBT(null, aStack); + Logger.INFO("Egg has no NBT, creating (getDisplayName)"); + }*/ + int size = 1; + if (NBTUtils.hasKey(aStack, "size")){ + size = NBTUtils.getInteger(aStack, "size"); + return ""+size+" "+localName; + } + return "?? "+localName; + } + + + @Override public boolean hasCustomEntity(ItemStack stack) { return true; } @Override public Entity createEntity(World world, Entity location, ItemStack itemstack) { - if (location instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) location; - if (itemstack == null) { return null; } @@ -217,27 +261,40 @@ public class ItemGiantEgg extends BaseItemBurnable { @Override public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { int size = 0; - if (NBTUtils.hasKey(stack, "size")){ - size = NBTUtils.getInteger(stack, "size"); - } - int age = 0; - if (NBTUtils.hasKey(stack, "mAge")){ - age = NBTUtils.getInteger(stack, "mAge"); - } - int life = 0; - if (NBTUtils.hasKey(stack, "mEggAge")){ - life = NBTUtils.getInteger(stack, "mEggAge"); - } + long age = 0; + long life = 0; int expected = 0; - if (NBTUtils.hasKey(stack, "mExpected")){ - expected = NBTUtils.getInteger(stack, "mExpected"); + if (this.descriptionString.length > 0) { + list.add(EnumChatFormatting.GRAY+this.descriptionString[0]); } - list.add("Egg Size: "+size+" ounces"); - list.add("Expected Stem Cells: "+expected); - list.add("Age: "+(age/20)+"s"+" / "+(life/20)+"s"); + if (NBTUtils.hasKey(stack, "size")){ + size = NBTUtils.getInteger(stack, "size"); + if (size > 0 && NBTUtils.hasKey(stack, "TickableItem")){ + NBTTagCompound aNBT = stack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + age = aNBT.getLong("Tick"); + } + } + } + if (NBTUtils.hasKey(stack, "mEggAge")){ + life = NBTUtils.getInteger(stack, "mEggAge"); + } + if (NBTUtils.hasKey(stack, "mExpected")){ + expected = NBTUtils.getInteger(stack, "mExpected"); + } + } + String aSize = size > 0 ? ""+size : "??"; + String aExpected = expected > 0 ? ""+expected : "??"; + String aAge = age > 0 ? ""+(age/20) : "??"; + String aLife = life > 0 ? ""+(life/20) : "??"; + list.add("Egg Size: "+aSize+" ounces"); + list.add("Expected Stem Cells: "+aExpected); + list.add("Age: "+aAge+"s"+" / "+aLife+"s"); list.add("Larger eggs take longer to hatch,"); - list.add("but have a better chance of hatching."); - super.addInformation(stack, aPlayer, list, bool); + list.add("but have a better chance of hatching."); + } } diff --git a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java index 2f49ac1287..9ac09b92e4 100644 --- a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java +++ b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java @@ -26,6 +26,7 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -54,9 +55,6 @@ public class ItemBaseBook extends ItemWritableBook{ mBookMap.get(i).mPages);*/ NBTUtils.createIntegerTagCompound(bookstack, "stats", "mMeta", i); - - GT_OreDictUnificator.registerOre("bookWritten", bookstack); - GT_OreDictUnificator.registerOre("craftingBook", bookstack); list.add(bookstack); } } @@ -106,7 +104,9 @@ public class ItemBaseBook extends ItemWritableBook{ public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { //player.displayGUIBook(item); int i = item.getItemDamage(); - ItemStack bookstack = GT_Utility.getWrittenBook( + ItemStack bookstack = Utils.getWrittenBook( + null, + mBookMap.get(i).mMeta, mBookMap.get(i).mMapping, mBookMap.get(i).mTitle, mBookMap.get(i).mAuthor, diff --git a/src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java b/src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java new file mode 100644 index 0000000000..727b933fa7 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java @@ -0,0 +1,285 @@ +package gtPlusPlus.core.item.general.spawn; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +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.*; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.*; +import net.minecraft.util.*; +import net.minecraft.world.World; + +public class ItemCustomSpawnEgg extends ItemMonsterPlacer { + + private static final HashMap<Integer, IIcon> mIconMap = new HashMap<Integer, IIcon>(); + private static int mTotalMetaItems = 0; + + private static final HashMap<Integer, Integer> mMaxStackSizeMap = new HashMap<Integer, Integer>(); + private static final HashMap<Integer, EnumRarity> mRarityMap = new HashMap<Integer, EnumRarity>(); + private static final HashMap<Integer, ArrayList<String>> mOreDictNames = new HashMap<Integer, ArrayList<String>>(); + + private static final HashMap<Integer, Integer> mColourBaseMap = new HashMap<Integer, Integer>(); + private static final HashMap<Integer, Integer> mColourSpotsMap = new HashMap<Integer, Integer>(); + private static final HashMap<Integer, String> mEntityNameMap = new HashMap<Integer, String>(); + private static final HashMap<Integer, String> mEntityFullNameMap = new HashMap<Integer, String>(); + + private static final HashMap<String, Integer> mReverseEntityMap = new HashMap<String, Integer>(); + + protected EntityLiving entityToSpawn = null; + + public static ItemStack getSpawnEggForEntityname(String aEntityName, int aSize) { + return ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, mReverseEntityMap.get(aEntityName), aSize); + } + + public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, int aSecondaryColor) { + registerEntityForSpawnEgg(aMetaID, parEntityToSpawnName, aPrimaryColor, aSecondaryColor, EnumRarity.common, new ArrayList<String>()); + } + + public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, int aSecondaryColor, EnumRarity aRarity, final ArrayList<String> aOreDictNames) { + mTotalMetaItems++; + mMaxStackSizeMap.put(aMetaID, 64); + mRarityMap.put(aMetaID, aRarity); + mOreDictNames.put(aMetaID, aOreDictNames); + mColourBaseMap.put(aMetaID, aPrimaryColor); + mColourSpotsMap.put(aMetaID, aSecondaryColor); + mReverseEntityMap.put(parEntityToSpawnName, aMetaID); + setEntityToSpawnName(aMetaID, parEntityToSpawnName); + } + + public static void registerEggsToOreDict() { + for (int aMetaID = 0; aMetaID < mTotalMetaItems; aMetaID++) { + ArrayList<String> aOreDictNames = mOreDictNames.get(aMetaID); + if (aOreDictNames != null && !aOreDictNames.isEmpty()) { + ItemStack aFoodStack = ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, aMetaID, 1 + ); + for (String aOreName : aOreDictNames) { + ItemUtils.addItemToOreDictionary(aFoodStack, aOreName); + } + } + } + } + + public ItemCustomSpawnEgg() { + super(); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName("BasicMetaSpawnEgg"); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + } + + /** + * 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; + } + else { + 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(par1ItemStack, 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; + } + else { + MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) { + return par1ItemStack; + } + else { + 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(par1ItemStack, 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. + * @param par1ItemStack + */ + public Entity spawnEntity(ItemStack par1ItemStack, World parWorld, double parX, double parY, double parZ) { + + if (!parWorld.isRemote) // never spawn entity on client side + { + int aDamage = par1ItemStack.getItemDamage(); + String entityToSpawnNameFull = mEntityFullNameMap.get(aDamage); + String entityToSpawnName = mEntityNameMap.get(aDamage); + //entityToSpawnNameFull = WildAnimals.MODID + "." + 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 + System.out.println("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 aItem, CreativeTabs p_150895_2_, List aList) { + for (int aMeta : mReverseEntityMap.values()) { + aList.add(ItemUtils.simpleMetaStack(aItem, aMeta, 1)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int parColorType) { + int aID = par1ItemStack.getItemDamage(); + return (parColorType == 0) ? mColourBaseMap.get(aID) : mColourSpotsMap.get(aID); + } + + @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 " + mEntityNameMap.get(par1ItemStack.getItemDamage()); + } + + + @Override + public void registerIcons(final IIconRegister u) { + mIconMap.put(0, u.registerIcon(CORE.MODID + ":" + "spawn_egg")); + mIconMap.put(1, u.registerIcon(CORE.MODID + ":" + "spawn_egg_overlay")); + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int renderPass) { + return mIconMap.get(renderPass); + } + + @Override + public IIcon getIconFromDamage(int damage) { + return getIconFromDamageForRenderPass(0, 0); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return getIconFromDamageForRenderPass(0, renderPass); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass) { + return getIconFromDamageForRenderPass(0, renderPass); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + public static void setEntityToSpawnName(int aMetaID, String parEntityToSpawnName) { + mEntityNameMap.put(aMetaID, parEntityToSpawnName); + mEntityFullNameMap.put(aMetaID, CORE.MODID + "." + parEntityToSpawnName); + } +} diff --git a/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java index 9994c7d362..d42ac85012 100644 --- a/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java +++ b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java @@ -64,7 +64,7 @@ public class DustDecayable extends BaseItemTickable { } boolean a1, a2; - a1 = this.getIsActive(world, iStack); + a1 = this.isTicking(world, iStack); a2 = tickItemTag(world, iStack); if (!a1 && !a2) { |