Search In
• More options...
Find results that contain...
Find results in...

# [1.16.5] Formula for brake force

## Recommended Posts

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

##### Share on other sites

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.

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

##### Share on other sites

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?

##### Share on other sites

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.

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

##### Share on other sites

Yeah I tried it with Math.abs but it isn’t working either…

##### Share on other sites

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?

##### Share on other sites

Hey Thorius,

I will try it tonight when I’m at home again but it seems like it could work. I’ll keep you up to date

##### Share on other sites

Finally I managed to check it.

It works perfectly.

Thank you all!

##### Share on other sites

You should know that this formula will also accelerate the carts to the specified speed. If you want to avoid that, use Math.min(brakeforce, 1).

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

• ### Posts

• KeyBindings are client side only, you need to use TickEvent.ClientTickEvent instead why did you call KeyBinding#consumeClick, you should only check KeyBinding#isDown? last but not least i would recommend you to check the Item also on server side (in the handle method of the Message), since you should never trust the client
• You should use 1.16.5 if you want to use 1.16. 1.16.4 is not supported. 1.16 requires Java 8.
• Hello ! I want to make a forge 1.16.4 server . I installed in a folder the forge server from the forge installer , a bat with java -Xmx1024M -Xms1024M -jar forge-1.16.4-35.1.37.jar --nogui PAUSE and when i try to start it , it says this https://prnt.sc/plXm6cy4NDTH If someone can help me pls Thanks !
• Optifine flat out replaces large parts of the rendering engine. It is expected that mods will often fail in its presence. You can try talking to the developers of Valhesia Core, but the better option would be to not use Optifine.

• 2
• 15
• 1
• 1
• 2
• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...