Posted November 27, 20186 yr package com.goingcrowd9.blazemod.items; import javax.annotation.Nullable; import com.goingcrowd9.blazemod.init.ModItems; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityEnderPearl; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.ItemEnderPearl; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemMagicPearl extends ItemEnderPearl { public ItemMagicPearl(String name){ this.setUnlocalizedName(name); this.setRegistryName(name); this.maxStackSize = 1; this.setMaxDamage(238); this.setCreativeTab(CreativeTabs.MISC); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn){ ItemStack itemstack = playerIn.getHeldItem(handIn); worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); //playerIn.getCooldownTracker().setCooldown(this, 20); if (!worldIn.isRemote){ EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, playerIn); entityenderpearl.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); worldIn.spawnEntity(entityenderpearl); } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); } @Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { System.out.println("hello, I'm here !!!!!!!!!!!!!!!!!!!!!!!"); System.out.println("Is this Item damageable ?: " + this.isDamageable() ); EntityPlayer entityplayer = (EntityPlayer)entityLiving; stack.damageItem(1, entityplayer); } public int getMaxItemUseDuration(ItemStack stack) { return 7200; } } I'm trying to make an ender pearl-like Item that gets damaged after you throw it, but it doesn't work... The Item itself is working, but it seems it doesn't even reach onPlayerStoppedUsing since nothing gets printed on the console (println) Obviously I'm doing something wrong, but I don't know what.. Any help appreciated
November 28, 20186 yr Author I tought onPlayerStoppedUsing was just for every Item when you release the key to use it. The package name was just something I used because of a tutorial. At least that works now. Now I just got to figure out how to make a model for the EntityMagicPearl, wich is now used instead of EntityEnderPearl (It works fine, it just doesn't use any model) But at least thanks for pointing out the Item doesn't "get used" like I tought
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.