/** * This class was created by <Vazkii>. It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 25, 2015, 6:42:47 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; import javax.annotation.Nonnull; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.NonNullList; import net.minecraft.util.SoundCategory; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.client.core.handler.ModelHandler; import vazkii.botania.common.achievement.ICraftAchievement; import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.entity.EntityThornChakram; import vazkii.botania.common.lib.LibItemNames; public class ItemThornChakram extends ItemMod implements ICraftAchievement { public ItemThornChakram() { super(LibItemNames.THORN_CHAKRAM); setMaxStackSize(6); setHasSubtypes(true); } @SideOnly(Side.CLIENT) @Override public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> list) { for(int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); } @Nonnull @Override public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName() + stack.getItemDamage(); } @Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(!world.isRemote) { ItemStack copy = stack.copy(); copy.setCount(1); EntityThornChakram c = new EntityThornChakram(world, player, copy); c.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F); c.setFire(stack.getItemDamage() != 0); world.spawnEntity(c); world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); stack.shrink(1); } return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } @Override public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { return ModAchievements.terrasteelWeaponCraft; } @SideOnly(Side.CLIENT) @Override public void registerModels() { ModelHandler.registerItemAppendMeta(this, 2, LibItemNames.THORN_CHAKRAM); } }