Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mraof.minestuck.item.weapon;
- import com.mraof.minestuck.item.TabMinestuck;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.SoundEvents;
- import net.minecraft.item.EnumAction;
- import net.minecraft.item.ItemFood;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.ActionResult;
- import net.minecraft.util.EnumActionResult;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.SoundCategory;
- import net.minecraft.world.World;
- public class ItemConsumableWeapon extends ItemWeapon {
- private final int healAmount;
- private final float saturationModifier;
- public ItemConsumableWeapon(int maxUses, double damageVsEntity, double weaponSpeed, int enchantability, String name, int amount, float saturation) {
- super(maxUses, damageVsEntity, weaponSpeed, enchantability, name);
- this.setCreativeTab(TabMinestuck.instance);
- this.healAmount = amount;
- this.saturationModifier = saturation;
- }
- @Override
- public int getMaxItemUseDuration(ItemStack stack)
- {
- return 32;
- }
- @Override
- public EnumAction getItemUseAction(ItemStack stack)
- {
- return EnumAction.EAT;
- }
- @Override
- public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
- {
- stack.damageItem(50, entityLiving);
- if(entityLiving instanceof EntityPlayer)
- {
- EntityPlayer entityplayer = (EntityPlayer)entityLiving;
- entityplayer.getFoodStats().addStats(healAmount, saturationModifier);
- worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
- }
- return stack;
- }
- public void addStats(ItemFood foodItem, ItemStack stack)
- {
- this.addStats(foodItem.getHealAmount(stack), foodItem.getSaturationModifier(stack));
- }
- @Override
- public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
- {
- playerIn.setActiveHand(handIn);
- return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement