1010import net .minecraft .network .protocol .game .ServerboundMovePlayerPacket .Pos ;
1111import net .minecraft .world .entity .Entity ;
1212import net .minecraft .world .item .Items ;
13+ import net .minecraft .world .phys .AABB ;
1314import net .wurstclient .Category ;
1415import net .wurstclient .SearchTags ;
1516import net .wurstclient .events .PlayerAttacksEntityListener ;
1617import net .wurstclient .hack .Hack ;
18+ import net .wurstclient .settings .CheckboxSetting ;
1719import net .wurstclient .settings .SliderSetting ;
1820import net .wurstclient .settings .SliderSetting .ValueDisplay ;
1921
@@ -22,18 +24,26 @@ public final class MaceDmgHack extends Hack
2224 implements PlayerAttacksEntityListener
2325{
2426 private static final double DEFAULT_HEIGHT = Math .sqrt (500 );
25-
27+ private static final double MIN_FALL = 1.6 ;
28+ private static final double SCAN_STEP = 0.25 ;
29+
2630 private final SliderSetting height = new SliderSetting ("Height" ,
2731 "How high to fake before slamming. Height determines the damage boost." ,
2832 DEFAULT_HEIGHT , 1.6 , 50 , 0.1 , ValueDisplay .DECIMAL );
29-
33+
34+ private final CheckboxSetting caveMode = new CheckboxSetting ("Cave mode" ,
35+ "Scans for an air gap above you to fall through, so smashes work under"
36+ + " a ceiling. Fully sealed spaces still can't be smashed." ,
37+ true );
38+
3039 private long lastSmashTick = -1 ;
31-
40+
3241 public MaceDmgHack ()
3342 {
3443 super ("MaceDMG" );
3544 setCategory (Category .COMBAT );
3645 addSetting (height );
46+ addSetting (caveMode );
3747 }
3848
3949 @ Override
@@ -70,10 +80,26 @@ public void doSmash()
7080 // Also, let me know if you find a way to bypass that check.
7181 for (int i = 0 ; i < 4 ; i ++)
7282 sendFakeY (0 );
73- sendFakeY (height . getValue ());
83+ sendFakeY (findFallOffset ());
7484 sendFakeY (0 );
7585 }
76-
86+
87+ private double findFallOffset ()
88+ {
89+ double cap = height .getValue ();
90+ if (!caveMode .isChecked () || MC .level == null )
91+ return cap ;
92+
93+ for (double off = cap ; off >= MIN_FALL ; off -= SCAN_STEP )
94+ {
95+ AABB box = MC .player .getBoundingBox ().move (0 , off , 0 );
96+ if (MC .level .noCollision (MC .player , box ))
97+ return off ;
98+ }
99+
100+ return cap ;
101+ }
102+
77103 private void sendFakeY (double offset )
78104 {
79105 MC .player .connection
0 commit comments