Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.10.2] Eclipse error "The constructor ItemStack() is not visible"


Tortuga
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.