Posted December 23, 20177 yr Quote package tortuga.primeiro.items; import net.minecraft.entity.effect.EntityLightningBolt; 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.RayTraceResult; import net.minecraft.world.World; import tortuga.primeiro.PrimeiroTab; import tortuga.primeiro.init.ModItems; public class ItemLightning extends ModItems { public ItemLightning(String name, PrimeiroTab tab, int size) { super(name, tab, size); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if(!worldIn.isRemote){ RayTraceResult pos = playerIn.rayTrace(100, 20); double x = pos.getBlockPos().getX(); double y = pos.getBlockPos().getY(); double z = pos.getBlockPos().getZ(); worldIn.addWeatherEffect(new EntityLightningBolt(worldIn, x, y, z, true)); } return new ActionResult(EnumActionResult.SUCCESS, new ItemStack()); { return new ActionResult(EnumActionResult.FAIL, new ItemStack()); } } } I Couldn't solve this error, can anyone help me pls?
December 23, 20177 yr Look at the source for ItemStack, there is no constructor for it that takes no arguments. You must pass at least a block or item You should return playerIn.getHeldItem(handIn) Edited December 23, 20177 yr by Aarilight
December 23, 20177 yr onItemRightClick gives you a Hand, which probably holds a stack. I think you can operate upon the stack (e.g. decrement its count) and then return it. If count reaches zero, then you may return the empty stack. The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
December 23, 20177 yr 2 hours ago, jeffryfisher said: onItemRightClick gives you a Hand, which probably holds a stack. I think you can operate upon the stack (e.g. decrement its count) and then return it. If count reaches zero, then you may return the empty stack. An ItemStack with zero count is automatically empty; you don't need to return ItemStack.EMPTY. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.