Jump to content

Troubles with interact()


Cyan

Recommended Posts

Hello again,

 

So..... I'm back again unfortunately having to ask for more help converting over to Forge. This time however, it is with my interact!

 

I have noticed that I get either "ticking entity" errors or a NullPointerException error when anything calls the interact function. More specifically, when I right click on my entities. Most of the items in the interact function either tames the entities, or swaps them with a different entity(evolving). So..My logical guess is that something on the server side is not compatible with my code, but I do not have enough knowledge to really know what exactly that might be.

 

 

Here's my interact code:

 

 

public boolean interact(EntityPlayer entityplayer)
    {
    	
    	
    	
        ItemStack itemstack = entityplayer.inventory.getCurrentItem();

        if (readyToTame)
        {
            tame(entityplayer);
            return true;
        }

        if (itemstack == null && isTamed())
        {
            sitting = !sitting;
            motionY = 0;
            motionX = 0;
            motionZ = 0;
            return true;
        }

          if(itemstack!=null && itemstack.itemID == digimobs.xros.shiftedIndex)
        {
            itemstack = null;
            return false;
        }
        
        if (itemstack!=null && itemstack.itemID == digimobs.digirope.shiftedIndex)
        {
            itemstack = null;
            return false;
        }
        
        
        if (itemstack!=null && itemstack.itemID == digimobs.digivice.shiftedIndex)
        {	itemstack = null;
        	tame(entityplayer);
            return true;
        }
        

        if (isTamed() && itemstack.itemID == digimobs.data.shiftedIndex)
        {
        	switch(itemstack.getItemDamage()){
        	case 3:exp+=45;
        	case 2:exp+=35;
        	case 1:exp+=15;
        	case 0:exp+=10;
        	}
            entityplayer.inventory.consumeInventoryItem(itemstack.itemID);
            return true;
        }

        if (itemstack!=null && itemstack.getItem().shiftedIndex == digimobs.acorn.shiftedIndex
                ||itemstack!=null && itemstack.getItem().shiftedIndex == digimobs.acorn.shiftedIndex)
        {
            heal(;
            //if((int)hunger!=(int)getMaxHunger() && itemstack!=null && itemstack.getItem() instanceof ItemFood)hunger+=2;
            /*
             * worldObj.playSoundAtEntity( this, "sound.secret", 0.6F,
             * ((rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);
             */
            worldObj.spawnParticle("heart", posX, posY + height, posZ, 0,
                    0, 0);
            entityplayer.inventory.consumeInventoryItem(itemstack.itemID);
            return true;
        }

        if (isEvolveItem(itemstack) && isTamed())
        {
            evolve();
            //DigimonSaveHandler.saveDigimon(this);
            return true;
        }

        if (isTamed())
        {
            sitting = !sitting;
            motionY = 0;
            motionX = 0;
            motionZ = 0;
        }

        return super.interact(entityplayer);
        
    }

 

 

Thanks for any insight you may be able to provide! :)

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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