Jump to content

Recommended Posts

Posted

Hi!

I have a throwing entity that get the closest player where it landed. The problem is that i want it to ignore itself (this.getThrower), and itself

I guess it's more a Java problem than a Forge one but i don't understand how i can do it, so here's what i did (And it's not working because it's ticking itself (the throwing entity))

EntityPlayer thrower = (EntityPlayer) this.getThrower();
        	Predicate isThrower = Predicate.isEqual(thrower);

EntityPlayer nearplayer = world.getClosestPlayer(wherehit.getX(), wherehit.getY(), wherehit.getZ(), 25, (com.google.common.base.Predicate<Entity>) isThrower.negate());

 

Posted

Predicate is just a functional interface that takes a given argument and returns true or false. You can learn more about finctional interfaces and lambdas here

So in your case something like

e -> e != thrower && e != this

would work just fine.

 

Also don't bump, this is not a chat room. Your post is within the top 10 recent posts, there is no reason to bump it.

  • Thanks 1
Posted
2 minutes ago, V0idWa1k3r said:

Predicate is just a functional interface that takes a given argument and returns true or false. You can learn more about finctional interfaces and lambdas here

So in your case something like


e -> e != thrower && e != this

would work just fine.

 

Also don't bump, this is not a chat room. Your post is within the top 10 recent posts, there is no reason to bump it.

Thanks dude im gonna try that (And sorry for the useless bump)

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.