Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Does not work for all sand dupers #2

Closed
laymanuel opened this issue Feb 12, 2022 · 8 comments
Closed

Does not work for all sand dupers #2

laymanuel opened this issue Feb 12, 2022 · 8 comments

Comments

@laymanuel
Copy link
Collaborator

laymanuel commented Feb 12, 2022

test world: https://cdn.discordapp.com/attachments/914215994908639273/941902303324168192/sand_generator_test_world.zip

right now only this type of duper and similar works with plugin. it is only type I knew exist when I design:
working duper
it is most common type.

here is new type that is not working, user bring it to me:
not working duper.

I do not know how to detect this movement, because velocity is all 0. I thought velocity not being 0 is what makes sand duper unique, but this is now not true. only some duper. I put more information here: https://forums.papermc.io/threads/how-to-detect-specific-entity-movement-collision.39/

if you have idea please comment! I am stuck.

@lynxplay
Copy link
Contributor

Can you share building details (e.g. tutorial youtube videos) for the two setups to ease replication ?

@laymanuel
Copy link
Collaborator Author

Even more simple, here is my test world I use. It includes both type of duper: https://cdn.discordapp.com/attachments/914215994908639273/941902303324168192/sand_generator_test_world.zip

@lynxplay
Copy link
Contributor

Well, if you want to be rather hacky you could abuse https://github.com/PaperMC/Paper/blob/master/patches/server/0674-Fix-dangerous-end-portal-logic.patch which is included in paper 1.16.5 till latest.

As the movement logic is executed first in the FallingBlockEntity implementation, the falling block entity (when it is passed to the EntityChangeBlockEvent) does have both portalBlock and portalWorld set to non-null values as it entered the end portal block previously in the method call.

You could hence force a dupe at exactly that point, however this solution requires NMS usage. Should be rather straight forward however for at least 1.17/1.18 with paperweight userdev.

@lynxplay
Copy link
Contributor

E.g. https://pastebin.com/aBEn64pF as a super hacky examples properly duplicates the sand for both dupers in the test world you linked.

@lynxplay
Copy link
Contributor

lynxplay commented Feb 12, 2022

Another possible solution to this issue is a partial replication of mojangs logic to determine teleportation. More specifically by checking if the entities hitbox is inside the end portal block on the change block event (which, in the case of a dupe, it is). E.g.

@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityChangeBlock(final EntityChangeBlockEvent event) {
    if (!(event.getEntity() instanceof final FallingBlock falling) || event.getTo() == Material.AIR) return;
    final var effectiveBB = falling.getBoundingBox().expand(-0.001D);

    for (final BlockFace face : DUPE_ALLOWED_PORTAL_FACES) {
        final Block relative = event.getBlock().getRelative(face);
        if (relative.getType() != Material.END_PORTAL) continue;

        if (relative.getBoundingBox().overlaps(effectiveBB)) {
            // Dupe it here
        }
    }
}

The method also passed the two dupers and did ignore normal blocks moving into the portal properly however would need more testing compared to the NMS method (which by definition only catches dupe cases).

@laymanuel
Copy link
Collaborator Author

Thank you very much for your comment! The solution with nms is very clever, I would not have thought of that because I thought it worked in reverse order.

Your other suggestion of checking if the hitbox collides is what I first did before I thought of using the velocity, but for some reason it was not sufficient. I do not remember why though, but I think it had false positives. so I will have to look again and see if I can reproduce.

In an ideal world my plugin would not use NMS, but I think here the NMS solution is the most reliable as it is internally what causes dupe, just reversed by paper. what I will probably do is have the NMS solution you suggest, with configurable fallback to the solution I have now.

Thank you again for looking! This is very helpful.

@lynxplay
Copy link
Contributor

Happy to help 👍 Yea looking into the hitbox overlaps and it detecting false positives is definitely a good idea imo. It should be rather close to the server impl that checks if the entity is inside the portal block as well and obviously does not rely on a pretty aggressive hack into the server software's implementation detail 👍

@laymanuel
Copy link
Collaborator Author

done some testing and talked to sulu of paper discord. this should work. thank you again ❤️

e-im pushed a commit that referenced this issue Mar 2, 2022
thank you for help from lynxplay and sulu from Paper.
I do not think I could have fixed this issue without.

Co-authored-by: Bjarne Koll <LynxPlay101@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants