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

rewrite bed compat code #81

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

rewrite bed compat code #81

wants to merge 7 commits into from

Conversation

BuckarooBanzay
Copy link
Member

This PR rewrites the beds compatiibilty code to the new movenode-definition and callback system (see here: https://github.com/mt-mods/jumpdrive#movenode-compatibility and here: https://github.com/mt-mods/jumpdrive#hooks)
The new API removes lots of duplicate and expensive calls to minetest.find_nodes_in_area and should make jumping faster in general while also providing a generic way to listen to movement events.

I ended up rewriting larger portions of the code you made @tuedel (sorry 😋)
Let me know if you have issues/suggestions with the way it is now

The new file is best viewed standalone and not as diff:
https://github.com/mt-mods/jumpdrive/blob/bed-compat-ng/compat/beds.lua

NOTE: this isn't tested yet, only a first draft

@BuckarooBanzay BuckarooBanzay added the enhancement New feature or request label Oct 27, 2020
@tuedel
Copy link
Contributor

tuedel commented Nov 11, 2020

Sure, go ahead 😉 My code was just quickly hacked together, I was planning on rewriting/simplifying it anyway.

@tuedel
Copy link
Contributor

tuedel commented Nov 11, 2020

The sleeping position has changed in minetest/minetest_game@9bf64b6, but just setting y = y + 0.07 and using vector.equals() to check didn't work for me because of floating point (im)precision.

I solved this on my server by just rounding down y for the check:

if sleep_pos.x == player_pos.x and
    math.floor(sleep_pos.y) == math.floor(player_pos.y) and
    sleep_pos.z == player_pos.z then

[...]

This conveniently also keeps backwards compatibility with the old sleeping positions.

compat/beds.lua Outdated Show resolved Hide resolved
@SwissalpS
Copy link
Contributor

At this sate it seems to work.
What I was not able to test, is how players, currently in bed(s), are treated during a jump.
(Yes multiple players can be in multiple or the same one at the same time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants