Minecraft PC IP: play.cubecraft.net

caspar1500

Novice Member
Jun 24, 2017
45
18
58
20
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:
  • Like
Reactions: Sulphate
D

Deleted member 352903

Guest
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 ^_^
In plugins and coding u share plugins u have made or ask things
This is a suggestion ._.
 

Sulphate

Novice Member
Oct 20, 2017
201
157
58
England
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.
 

caspar1500

Novice Member
Jun 24, 2017
45
18
58
20
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.
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
 
  • Like
Reactions: Sulphate

Sulphate

Novice Member
Oct 20, 2017
201
157
58
England
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.
Ah awesome, I didn't realise it could be spoofed :) in which case this is pretty solid! Good work :P

Thanks for finding some mistakes i made xD

No problem xP
Good luck with any future work you do!
 
Members Online

Team online

Latest posts

Latest profile posts

This is YOUR daily dose of facts #19-
The Sun makes a sound but we can't hear it.
Reesle wrote on xireu's profile.
Welcome to the Forums! Hope you enjoy your stay :D
Reesle wrote on Mantas2221's profile.
Welcome to the Forums! 👋
been working on chapter 4 + some changes to fhg
UncleSpect wrote on vk4zuta's profile.
thank you for the follow!
Top Bottom