Jump to content

Recommended Posts

Posted

Hey guys,

I am struggling a long time to figure out how to create a formula for my mod.

 

Overview:

I created a brake rail which should brake down a minecart when it's on it.

I found this formula in the internet and applied it:

Spoiler
this.currentBrakeForce = (Math.pow(targetVelocity, 2) - Math.pow(entryVelocity, 2)) / (2 * brakerunLength)

 

The minecart has an entry speed of 12m/s, the target velocity is 8m/s and the break run is 1m because it's one block.

 

I slow down the cart by multiplying the result of this formula with the current motion of the cart:

Spoiler
train.setMotion(train.getMotion().multiply(this.currentBrakeForce, 0, this.currentBrakeForce));

 

 

I figured out another thing: The wiki says that that 8m/s are 1.2 in motion.

So I changed the formula depending on the motion (I don't know if this is right but it made sense to me):

Spoiler
(0.15 * entryVelocity) / Math.abs(((Math.pow(targetVelocity, 2) - Math.pow(entryVelocity, 2)) / (2 * brakerunLength)));

 

Why 0.15?

As mentioned before 8m/s are 1.2.

So, 1m/s = 0.15 -> (8/1.2).

And then I multiplied it with the entry speed because it has to be changed to the "motion internal unit"?!

 

I am really frustrated right know, because I tried a lot of different changes within the formula. The problem is maybe the multiplication with the motion? I don't know.

Maybe someone can help me  :)

Thanks in advance!

Posted
3 hours ago, J3ramy said:

The wiki says that that 8m/s are 1.2 in motion.

Not sure where you're seeing this. BTW, minecarts already have a maximum speed of 8m/s per axis.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Maybe I should mention it. I changed the max speed and max speed on rail to 16m/s.

But my question is more, how do I convert the calculated force to the Minecraft motion?

Posted

Not sure, I haven't dug into the minecart code that much.

The only problem I see is that this:
Math.pow(targetVelocity, 2) - Math.pow(entryVelocity, 2)
Is guaranteed to return a negative value, which when multiplied against entity motion would cause the entity to reverse direction.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I might have understood it wrong, but if you are simply multiplying the x and z component of the velocity vector, then don't you just need the ratio between the target and entry velocity? So shouldn't your brake"force" be targetVelocity/entryVelocity?

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.