Nofall Detection

Discussion in 'Plugins and Coding' started by caspar1500, Jul 8, 2019.

  1. caspar1500

    caspar1500 Member

    Messages:
    43
    Likes Received:
    18
    Trophy Points:
    33
    caspar1500
    Emerald
    Hey, lately i've been diving into anti-cheat dev.
    I wouldn't say i'm good in it, but i might have an handy peace of code to detect nofall:


    Code:
    @EventHandler
        void onMove(PlayerMoveEvent e) {
            
            Player p = e.getPlayer();
            
            if(p.isOnGround() && inAir(e.getFrom(), e.getTo()) && p.getFallDistance() > 2.0D) {
                
                //Using nofall or any other kind of ground spoofing
                
            }
            
        }
        
        boolean inAir(Location from, Location to) {
            
            double expand = 0.35;
            
            for(double x = -expand; x < expand; x += expand) {
                for(double z = -expand; z < expand; z += expand) {
                    
                    if(from.add(x, from.getY() - 0.2D, z).clone().getBlock().getType() == Material.AIR) {
                        if(to.add(x, from.getY() - 0.2D, z).clone().getBlock().getType() == Material.AIR) {
                            return true;
                        }
                    }
                    
                }
            }
            
            return false;
            
        }

    Hope this helps or is even usefull xD.
    It was made with just simple thinking, you could modify the code to make it work better or fix some issues.
     
    Last edited: Jul 9, 2019
    Sulphate likes this.
  2. Deleted Member 311185

    Deleted Member 311185 Member

    Messages:
    429
    Likes Received:
    445
    Trophy Points:
    88
    _LilStxrry
    Emerald
  3. Fedde2001

    Fedde2001 Member

    Messages:
    170
    Likes Received:
    128
    Trophy Points:
    78
    Fedde2001
    Emerald
    PLUS
    Isn't it a little of both?

    I do not understand anything about coding either, but it seems like a code/plugin thing :p
    Even though its also a suggestion ^_^
     
  4. In plugins and coding u share plugins u have made or ask things
    This is a suggestion ._.
     
  5. Story

    Story Designer
    Staff Member Designer

    Messages:
    3,504
    Likes Received:
    8,084
    Trophy Points:
    583
    StorySays
    Designer
    PLUS
    I dont understand what it is hes suggesting, nothing in his post implies its a suggestion. Hes just sharing so it should be in Plugins and Coding.
     
  6. Sulphate

    Sulphate Member

    Messages:
    202
    Likes Received:
    151
    Trophy Points:
    58
    Sulphate
    Diamond
    Looks like a pretty good start! However, I believe that Player.isOnGround() is a state that is only updated by the server after the entity moves, so I don't think a client could spoof it this way. I may of course, be wrong (I have no clue how this really works), but it seems to be what the API suggests.

    I also want to clear up a few things so I can understand what you're doing here - I'm not quite sure what #isInAir() is doing, could you explain it to me? :) I think you may have made a mistake with your calls to #clone() in the for loops - you probably want to do the from.clone() and to.clone() first, otherwise you'll be changing the x, y and z values for the from and to locations instead of the clones.

    Finally, I can't find a getFallDistance(double param) method, are you sure that is correct?

    Overall seems to be some good logic :) with a few things corrected (I think) this could be quite helpful!

    P.S. If you're putting code into a post, you can use the CODE tag to format it nicely :) you can find it by clicking the icon next to the save one in the text editor.
     
    Buuuddy and Fedde2001 like this.
  7. caspar1500

    caspar1500 Member

    Messages:
    43
    Likes Received:
    18
    Trophy Points:
    33
    caspar1500
    Emerald
    ow yea, my bad. was pretty tired, i'll update the code at teh started.

    And the void IsInAir checks 9 spots below you, if all these spots are indeed air it means your in the air. And the player.IsOnGround can be spoofed by the client and this is just getting allowed. So if the client says he's on the ground but is in the air he is using some kind of ground spoofing method. there are indeed some things that could be better, thats my bad. I'm not the best in plugin dev. But with some tweaks it could work out pretty well.

    Thanks for finding some mistakes i made xD
     
    Sulphate likes this.
  8. caspar1500

    caspar1500 Member

    Messages:
    43
    Likes Received:
    18
    Trophy Points:
    33
    caspar1500
    Emerald
    my bad, sorry
     
  9. Sulphate

    Sulphate Member

    Messages:
    202
    Likes Received:
    151
    Trophy Points:
    58
    Sulphate
    Diamond
    Ah awesome, I didn't realise it could be spoofed :) in which case this is pretty solid! Good work :p

    No problem xP
    Good luck with any future work you do!
     
  10. nnce

    nnce Member

    Messages:
    155
    Likes Received:
    73
    Trophy Points:
    29
    You can bypass this by sending packets
     
    SippyCup likes this.
  11. Marco09MC

    Marco09MC Member

    Messages:
    35
    Likes Received:
    30
    Trophy Points:
    19
    This is ez to bypass
     
    SippyCup likes this.
  12. SippyCup

    SippyCup Member

    Messages:
    35
    Likes Received:
    7
    Trophy Points:
    34
    Cryoprecipitate
    Obsidian
    What a basic trash code. Learn how to code or do not open any IDE again.
     
  13. PedrocasPirocas

    PedrocasPirocas Member

    Messages:
    88
    Likes Received:
    403
    Trophy Points:
    93
    iiPedro_
    Diamond
    He tried his best there's no need to insult him lol
     
  14. CraftCreatures

    CraftCreatures Member

    Messages:
    717
    Likes Received:
    315
    Trophy Points:
    103
    CraftCreatures
    Emerald
    Good job on making a code (for the anti-cheat), and if you keep practicing, you will become better at coding :)
     
  15. Sulphate

    Sulphate Member

    Messages:
    202
    Likes Received:
    151
    Trophy Points:
    58
    Sulphate
    Diamond
    What a basic trash reply. Learn how to be encouraging or do not reply to anyone else's content again.
     
  16. CraftCreatures

    CraftCreatures Member

    Messages:
    717
    Likes Received:
    315
    Trophy Points:
    103
    CraftCreatures
    Emerald
    Why are people so toxic, right? :rolleyes: He won’t become better at coding then, it’s practicing :)