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.

Featured Replies

Posted

I continue to have fun modding in minecraft.

 

If I have two Vec3 instances, and I want to find the midpoint between them, then I find myself doing a lot of manual math.

 

In theory, it should be

 

vec2 - vec1 = vecDiff

midVec = vec1 + ( vecDiff * scalar_of_0.5 )

 

I can't see an elegant way to do this scalar multiplication on the Vec3 class, and end up with the following.

 

Vec3 diffVec = ent2Vec.subtract( ent1Vec );
Vec3 halfVec = new Vec3( diffVec.xCoord / 2, diffVec.yCoord / 2, diffVec.zCoord / 2 );
Vec3 midPoint = ent1Vec.add( halfVec );

 

Am I missing the obvious?

 

Is there a cleaner way to say something like this made up function below?

 

halfBetween = betweenVec.scalar( 0.5 )

 

So I could get to

 

Vec3 midPoint = entVec1.add( entVec2.substract( entVec1 ).scalar( 0.5 ))

 

 

  • Author

Wow, that was fast.

 

Do I need to do casting into Vec3 at the end, or will forge functions take a Vector3d as a parameter transparently.

 

Happy to stare at examples, if there are any...

  • Author

While I am scratching around in here, am I going mad, or does

 

Entity.getVectorForRotation(float pitch, float yaw)

 

take parameters in degrees

 

but

 

Vec3.rotateYaw(float yaw)

 

take parameters in radians

 

Ouch...

 

 

Wow, that was fast.

 

Do I need to do casting into Vec3 at the end, or will forge functions take a Vector3d as a parameter transparently.

 

Happy to stare at examples, if there are any...

 

Minecraft's vector classes aren't compatible with the

javax.vecmath

classes, you'll need to manually convert between them (i.e. create a new instance of the other vector class using the same coordinates as the existing vector).

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.

Vec3 does have a lot of math methods though. Are you sure none of them work for your case? Looking at the type hierarchy there are subtractions, additions, dot products, multiply, get intermediate, normalize, etc.

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

I believe dotproduct and crossproduct are vector applied to vector, not scalar to vector

 

I don't see a "multiply" is it present in your version? if so, what version are you in.

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.