Jump to content

NathanMndz1

Members
  • Posts

    0
  • Joined

  • Last visited

NathanMndz1's Achievements

Newbie

Newbie (1/8)

0

Reputation

  1. Hello, i need some help/suggestions on implementing a method. I have created a class that allows the player to summon ender pearls via a staff. I want to make it so when the items durability reaches 0, instead of the item breaking, the class searches the players inventory for ender pearls if it finds some it then removes a certain amount and it replenishes the objects durability. Any suggestions? Below is the staff class. package com.aww_man.Teleportation.items; import com.aww_man.Teleportation.Main; import com.aww_man.Teleportation.init.ModItems; import com.aww_man.Teleportation.util.IHasModel; import com.mojang.realmsclient.dto.PlayerInfo; import net.minecraft.client.Minecraft; import net.minecraft.entity.item.EntityEnderPearl; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.client.event.sound.PlaySoundEvent; public class VoidStaff extends Item implements IHasModel{ public VoidStaff(String name) { setUnlocalizedName(name); setRegistryName(name); setCreativeTab(Main.modtabs); ModItems.ITEMS.add(this); setMaxDamage(100); setMaxStackSize(1); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack enderpearls = playerIn.getHeldItemOffhand(); ItemStack item = playerIn.getHeldItem(handIn); Vec3d Look = playerIn.getLookVec(); item.damageItem(5, playerIn); EntityEnderPearl enderpearl = new EntityEnderPearl(worldIn, playerIn); enderpearl.setPosition(playerIn.posX+Look.x*30d, playerIn.posY+Look.y*30d, playerIn.posZ+Look.z*30d); worldIn.spawnEntity(enderpearl); playerIn.getCooldownTracker().setCooldown(this, 60); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS,item); } @Override public void registerModels() { Main.proxy.registerItemRender(this,0,"inventory"); } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.