Tortuga Posted December 23, 2017 Posted December 23, 2017 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? Quote
Aarilight Posted December 23, 2017 Posted December 23, 2017 (edited) 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, 2017 by Aarilight Quote
jeffryfisher Posted December 23, 2017 Posted December 23, 2017 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. Quote 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.
Choonster Posted December 23, 2017 Posted December 23, 2017 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. Quote 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.
Recommended Posts
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.