/** Copyright (C) <2017> <coolAlias> This file is part of coolAlias' Zelda Sword Skills Minecraft Mod; as such, you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package zeldaswordskills.item; import java.util.List; import java.util.Random; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.World; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.util.Constants; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemMaskZora extends ItemMask { public ItemMaskZora(ArmorMaterial material, int renderIndex) { super(material, renderIndex); } @Override public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { super.onArmorTick(world, player, stack); player.setAir(300); } @Override public WeightedRandomChestContent getChestGenBase(ChestGenHooks chest, Random rnd, WeightedRandomChestContent original) { ItemStack mask = new ItemStack(this); mask.addEnchantment(Enchantment.respiration, 3); original.theItemId = mask; return original; } @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack) { if (stack.isItemEnchanted()) { NBTTagList enchantments = stack.getTagCompound().getTagList("ench", Constants.NBT.TAG_COMPOUND); return (enchantments.tagCount() > 1 || ((NBTTagCompound) enchantments.getCompoundTagAt(0)).getShort("id") != Enchantment.respiration.effectId); } return false; } @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) { ItemStack mask = new ItemStack(item); mask.addEnchantment(Enchantment.respiration, 3); list.add(mask); } }