Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking damage on TP #5542

Open
seem0nster opened this issue Dec 29, 2023 · 4 comments · May be fixed by #5544
Open

Taking damage on TP #5542

seem0nster opened this issue Dec 29, 2023 · 4 comments · May be fixed by #5544

Comments

@seem0nster
Copy link

Client version: 1.8.9
Server OS: Linux

Expected behavior

To do "/home" from 0,75,0 - -200,25,150 Without taking damage while teleporting.

Actual behavior

Taking damage if the coordinates you are teleporting to are below the Y coord you are at

Maybe the solution

Setting the velocity to 0 while teleporting.

English might be Horrible

@tonitch
Copy link
Contributor

tonitch commented Dec 29, 2023

Confirmed: I tried with a simple /tp and the same happen.
I also noticed that when you /tp ~ ~50 ~ you don't get fall damages.
That is strange I think this is supposed to be handled by https://github.com/cuberite/cuberite/blob/master/src/Entities/Player.cpp#L2530-L2559 which is called by Player:TeleportToCords()

@tonitch
Copy link
Contributor

tonitch commented Dec 29, 2023

duped tho : #5286

@seem0nster
Copy link
Author

hmm, i think it is because it handles fall damage like if you go from Y- 80 to Y- 20, it takes where you fell to, not how long you have spent in the air.

English may be horrible.

@NiLSPACE
Copy link
Member

Fall damage is currently not handled well. We currently don't look at the y-speed of the player to calculate the damage amount but by looking at the current y-level compared to the previous on-ground y-level:

const auto FallHeight = m_LastGroundHeight - GetPosY();
auto Damage = static_cast<int>(FallHeight - 3.0);
const auto Below = POS_TOINT.addedY(-1);
const auto BlockBelow = (cChunkDef::IsValidHeight(Below)) ? GetWorld()->GetBlock(Below) : static_cast<BLOCKTYPE>(E_BLOCK_AIR);
if ((Damage > 0) && !FallDamageAbsorbed)
{
if (IsElytraFlying())
{
Damage = static_cast<int>(static_cast<float>(Damage) * 0.33);
}
if (BlockBelow == E_BLOCK_HAY_BALE)
{
Damage = std::clamp(static_cast<int>(static_cast<float>(Damage) * 0.2), 1, 20);
}
// Fall particles
// TODO: falling on a partial (e.g. slab) block shouldn't broadcast particles of the block below
GetWorld()->BroadcastParticleEffect(
"blockdust",
GetPosition(),
{ 0, 0, 0 },
(Damage - 1.f) * ((0.3f - 0.1f) / (15.f - 1.f)) + 0.1f, // Map damage (1 - 15) to particle speed (0.1 - 0.3)
static_cast<int>((Damage - 1.f) * ((50.f - 20.f) / (15.f - 1.f)) + 20.f), // Map damage (1 - 15) to particle quantity (20 - 50)
{ { BlockBelow, 0 } }
);
TakeDamage(dtFalling, nullptr, Damage, static_cast<float>(Damage), 0);

tonitch pushed a commit to tonitch/cuberite that referenced this issue Feb 20, 2024
Reseting the LastGroundHeight on teleport
tonitch pushed a commit to tonitch/cuberite that referenced this issue Feb 20, 2024
Reseting the LastGroundHeight on teleport
Using inheritence for teleporting to avoid rewriting code
@tonitch tonitch linked a pull request Feb 20, 2024 that will close this issue
tonitch pushed a commit to tonitch/cuberite that referenced this issue Feb 26, 2024
Reseting the LastGroundHeight on teleport
Using inheritence for teleporting to avoid rewriting code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants