Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

RandomPositionGenerator.findRandomTargetBlockAwayFrom method ...powerful, but ..

Featured Replies

Posted

Hi guys,

 

I would really like to use this method:

 

        _vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom((EntityCreature)this.closestEntity, 8, 4, Vec3.createVectorHelper(this.closestEntity.posX, this.closestEntity.posY, this.closestEntity.posZ));

 

In my code, this.closestentity is the player ... and minecraft hate this with the following error. I would really like to use that method, but how come it cannot be use with an entity. Am I missing something ... ?

 

java.lang.ClassCastException: net.minecraft.entity.player.EntityPlayerMP cannot be cast to net.minecraft.entity.EntityCreature

 

What I am trying to do is for a water mob to flee away from the player when they get too close. Someone knows another method I could use?

 

 

 

You can't use it with EntityPlayer - only with entities that inherit from EntityCreature, which players do not.

 

If you can't find another method that works for you, you could just look at the method and re-implement the logic but allow for any type of Entity, or perhaps EntityLivingBase.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.