Jump to content

[Solved][1.7.10] Entity Cannot be Interacted With


Recommended Posts

Posted

EDIT: I've solved the problem now. If you have a similar problem, see my comment below.

 

I'm trying to add a custom entity to my mod, and it's supposed to perform an action when right clicked by the player while holding a specific item. However, for some reason the game doesn't think the entity exists as far as right clicking goes. I've tried using EntityInteractEvent, which works for vanilla entities but not mine, as well as Minecraft.getMinecraft().objectMouseOver.entityHit, which has similar results. I've also tried overriding interactFirst() in my entity's class, which does absolutely nothing.

 

The entity is an artillery cannon, and the item is a pair of binoculars which sets the target coordinates for the cannon. My two theories are that either (A) the entity's bounding box is in the wrong place or nonexistent, or (B) the entity is not registered properly so the game ignores it. Any ideas as to what could be causing this and how to fix it?

 

EntityArtillery.java:

 

  Reveal hidden contents

 

 

Relevant parts of main mod class:

 

  Reveal hidden contents

 

 

ItemBinoculars.java:

 

  Reveal hidden contents

 

 

Relevant method from event handler class:

 

  Reveal hidden contents

 

  • 2 weeks later...
Posted

In case anyone else finds this thread and has a similar problem, I've found the solution. There is a method in Entity called canBeCollidedWith(), which is set by default to return false. The name is somewhat misleading, however, as it actually determines whether or not the entity will respond to interactions such as right-clicking. Overriding it to return true (see below) causes the entity to work properly.

 

@Override
public boolean canBeCollidedWith(){
    return true;
}

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.