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 profile posts

IAmEclipsy wrote on slimebuster120's profile.
Happy birthday!
Only non-staff member online. It's weird how quiet the forums gets at this time of day
Screen Shot 2024-11-16 at 5.58.39 PM.png
ItzJuan wrote on Reesle's profile.
Thanks for the follow, Reesle!
(1/2)
I was going through my old “suggestion archives” and found my old “Outer Space Bundle” suggestion that I had made before the Galaxy Bundle was ever announced.
IMG_6810.jpeg
lorilambthecoolgamer wrote on Reesle's profile.
BRUV NICE JOB AT GETTING 6,000+ REACTION SCORE!
Top Bottom