Code Monkey home page Code Monkey logo

Comments (8)

laymanuel avatar laymanuel commented on June 25, 2024 1

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

from gravitycontrol.

lynxplay avatar lynxplay commented on June 25, 2024

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

from gravitycontrol.

lynxplay avatar lynxplay commented on June 25, 2024

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.

from gravitycontrol.

lynxplay avatar lynxplay commented on June 25, 2024

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

from gravitycontrol.

lynxplay avatar lynxplay commented on June 25, 2024

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

from gravitycontrol.

laymanuel avatar laymanuel commented on June 25, 2024

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.

from gravitycontrol.

lynxplay avatar lynxplay commented on June 25, 2024

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 👍

from gravitycontrol.

laymanuel avatar laymanuel commented on June 25, 2024

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

from gravitycontrol.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.