Changeling

Changeling

71.9k Downloads

Crash/Kick with Slime Blocks and Iron Golem morph (caused by exponential gravity)

James103 opened this issue ยท 4 comments

commented

See mchorse#206 (reposted here because of same root cause)

When you are morphed as an Iron Golem, some weird things happen in regards to gravity and motion:

  1. If you start bouncing on a Slime Block from high enough (about 20 blocks), you will bounce exponentially higher with each subsequent bounce. This reaches a point where you will lag very severely at the end of each bounce (as in several seconds per frame) and eventually crash and/or kick.

  2. To fall from 10,000 blocks only takes twice as long as to fall from 100 blocks for you, compared to 10x longer for others. To fall from 100 million blocks only takes four times as long as to fall from just 100 blocks, compared to 1000x longer for others. This does not make sense at all.

Both of those things are caused by the following code below, which, multiplies the motion instead of adding to it every tick. There are a few possible solutions to this:

  1. Regular gravity, but fluids like water don't slow you down vertically as much.
  2. Have the exponential growth taper off the closer you get to a set terminal velocity.
  3. Regular gravity, but stronger than normal, with the jump strength increased to compensate.

if (target.motionY > 0)
{
target.motionY *= 0.9;
}
else
{
target.motionX *= 0.5;
target.motionZ *= 0.5;
target.motionY *= 1.3;

commented

I've talked with @mchorse about this, and he said that my second idea would be a perfect solution to this, with my third solution being a possible alternative.

The code for the second idea would be as follows:

if (target.motionY < 5)
{
    target.motionY *= (1.1 - target.motionY / 50.0);
}

Which would replace:

As for my third idea, since a gravity of 0.10 meters per tick squared supposedly still allows jumping 1 meter despite a 25% increase over standard gravity (0.08 meters per tick squared), either the gravity should be increased by 0.02 (target.motionY -= 0.02;) or the gravity multiplied by 1.25.

I'm still waiting for @asanetargoss on what would be the best possible solution to this.

commented

As per mchorse#206 , this is fine, waiting on McHorse to decide if survival-related code contributions should target Changeling only (and machinima-related code Metamorph only); would hopefully make our git sorcery a bit simpler and changes would make their way to the other mod eventually.

commented

A new version of Changeling has been released on GitHub with the fix:

https://github.com/asanetargoss/Changeling/releases

I decided to postpone important maintenance, because I want to get a build up before McHorse's 1.12-only version of McLib gets released, and the possible confusion which could result from that.

commented

I have tested this, a terminal velocity of approximately 100 m/s is reached while morphed as an Iron Golem, compared to 78.4 m/s for others. Jump height is about 1.1 m. No crash/kick is made.