Minecraft PC IP: play.cubecraft.net
  • We're running an internal migration of all old players' stats to our new highly advanced statistics tracking backend. This means that stat changes will be a bit delayed while we ingest this huge backlog of data. Nothing is being lost, it'll just take a bit longer to show up in the in-game UIs.

caspar1500

Novice Member
Jun 24, 2017
45
18
58
22
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
22
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

Members online

Latest posts

Latest profile posts

LemonyBreak459! wrote on iTz1Hamood's profile.
Good luck for ur Life
And Thanks for being a Friend and the MOD !
AliWarrior wrote on iTz1Hamood's profile.
Thank you for everything and best of luck in your life!
kevin020007 wrote on iTz1Hamood's profile.
Dear Hamood, Thank you for being an amazing friend for me during my cubecraft time with you and your time as bedrock cubecraft moderator and upcoming java cubecraft moderator. Thank you for helping the ccl staff with hosting and the community by hosting pg's and thank you for the great time we had together. I hope to see you back sooner on the battlefield then I can imagine. We love you hamood❤️❤️
Red crits wrote on iTz1Hamood's profile.
Hey Hamood, you were a wonderful team member. Wish you the very best for your future endeavors:) see ya around!
ItzJuan wrote on iTz1Hamood's profile.
Onward with life, good luck from now on!
Top Bottom