diff options
author | Alkalus <Draknyte1@hotmail.com> | 2020-05-29 21:23:28 +0100 |
---|---|---|
committer | Alkalus <Draknyte1@hotmail.com> | 2020-05-29 21:23:28 +0100 |
commit | 132faf38b856454007e97f4a8837133f496c64e3 (patch) | |
tree | 73b809f84a4b0cbec00459027f93aa51a28057a0 /src/Java/gtPlusPlus/core/item/general | |
parent | 85f9a37942da9156436c23beae947a402544bcc9 (diff) | |
download | GT5-Unofficial-132faf38b856454007e97f4a8837133f496c64e3.tar.gz GT5-Unofficial-132faf38b856454007e97f4a8837133f496c64e3.tar.bz2 GT5-Unofficial-132faf38b856454007e97f4a8837133f496c64e3.zip |
+ Added low tier basic turbines for Pollution Scrubbers.
+ Added capability for Scrubbers to be automated.
Diffstat (limited to 'src/Java/gtPlusPlus/core/item/general')
-rw-r--r-- | src/Java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java | 147 |
1 files changed, 147 insertions, 0 deletions
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 |