11package com .wurstclient_v7 .feature ;
22
33import net .minecraft .client .Minecraft ;
4+ import net .minecraft .client .KeyMapping ;
45import net .minecraft .core .BlockPos ;
5- import net .minecraft .core . Direction ;
6+ import net .minecraft .world . phys . Vec3 ;
67import net .minecraft .world .InteractionHand ;
7- import net .minecraft .world .item .BlockItem ;
8- import net .minecraft .world .item .ItemStack ;
98import net .minecraft .world .phys .BlockHitResult ;
10- import net .minecraft .world .phys .Vec3 ;
9+ import net .minecraft .core .Direction ;
10+ import com .mojang .blaze3d .platform .InputConstants ;
11+ import org .lwjgl .glfw .GLFW ;
1112
1213public final class AndromedaBridge {
13- private static volatile boolean enabled = false ;
14+ private static boolean enabled = false ;
15+ private static float startYaw ;
16+ private static float startPitch ;
1417
1518 public static boolean isEnabled () { return enabled ; }
16- public static void toggle () { enabled = !enabled ; }
19+
20+ public static void toggle () {
21+ enabled = !enabled ;
22+ Minecraft mc = Minecraft .getInstance ();
23+ if (enabled && mc .player != null ) {
24+ // Lock the angles when we start
25+ startYaw = mc .player .getYRot ();
26+ startPitch = 80.0f ; // Standard Andromeda pitch
27+ } else {
28+ stopInput (mc );
29+ }
30+ }
1731
1832 public static void onClientTick () {
1933 if (!enabled ) return ;
2034 Minecraft mc = Minecraft .getInstance ();
21- if (mc .player == null || mc .level == null || mc . gameMode == null ) return ;
35+ if (mc .player == null || mc .level == null ) return ;
2236
23- ItemStack heldItem = mc .player .getMainHandItem ();
24- if (!(heldItem .getItem () instanceof BlockItem )) return ;
37+ // 1. Lock Rotation (Pitch 90 or close to it helps with specific reach)
38+ mc .player .setYRot (startYaw );
39+ mc .player .setXRot (startPitch );
2540
26- // Position directly under player feet
27- BlockPos belowPos = mc .player .blockPosition ().below ();
41+ // 2. Movement Inputs
42+ net .minecraft .client .KeyMapping .set (InputConstants .getKey (GLFW .GLFW_KEY_W , -1 ), true );
43+ net .minecraft .client .KeyMapping .set (InputConstants .getKey (GLFW .GLFW_KEY_LEFT_CONTROL , -1 ), true );
2844
29- // Andromeda specific: Also target the block in front of the belowPos
30- // based on where the player is looking/moving.
31- placeBlockAt (mc , belowPos );
45+ // 3. Jumping
46+ if (mc .player .onGround ()) {
47+ mc .player .jumpFromGround ();
48+ }
49+
50+ // 4. Placement Logic
51+ BlockPos playerPos = mc .player .blockPosition ();
52+ BlockPos underPlayer = playerPos .below ();
53+ BlockPos aboveHead = playerPos .above (2 );
54+
55+ // Place Floor
56+ if (mc .level .getBlockState (underPlayer ).isAir ()) {
57+ placeBlock (mc , underPlayer , Direction .UP );
58+ }
3259
33- // To get that "Andromeda" high-speed look, we often place
34- // a second block slightly in front
35- BlockPos frontPos = belowPos .relative (mc .player .getDirection ());
36- placeBlockAt (mc , frontPos );
60+ // Place Ceiling (The "Andromeda" part)
61+ // We check if it's air to avoid double-placing and wasting blocks
62+ if (mc .level .getBlockState (aboveHead ).isAir ()) {
63+ // We place against the BOTTOM face of the imaginary ceiling
64+ placeBlock (mc , aboveHead , Direction .DOWN );
65+ }
3766 }
3867
39- private static void placeBlockAt (Minecraft mc , BlockPos pos ) {
40- if (!mc .level .getBlockState (pos ).isAir ()) return ;
68+ private static void placeBlock (Minecraft mc , BlockPos pos , Direction side ) {
69+ // Determine the vector based on which side we are clicking
70+ Vec3 hitVec = new Vec3 (pos .getX () + 0.5 , pos .getY (), pos .getZ () + 0.5 );
4171
42- for ( Direction dir : Direction . values ()) {
43- BlockPos neighbor = pos . relative ( dir );
44- if ( mc . level . getBlockState ( neighbor ). isAir ()) continue ;
72+ // In a real Andromeda bridge, you're usually clicking the side of an existing block.
73+ // For this automation, we simulate clicking the target position directly.
74+ BlockHitResult hit = new BlockHitResult ( hitVec , side , pos , false ) ;
4575
46- // Calculate hit vector
47- Vec3 hitVec = Vec3 .atCenterOf (neighbor ).add (Vec3 .atLowerCornerOf (dir .getOpposite ().getNormal ()).scale (0.5 ));
76+ mc .gameMode .useItemOn (mc .player , InteractionHand .MAIN_HAND , hit );
77+ mc .player .swing (InteractionHand .MAIN_HAND );
78+ }
4879
49- BlockHitResult hitResult = new BlockHitResult (hitVec , dir .getOpposite (), neighbor , false );
5080
51- // Send placement to server
52- mc . gameMode . useItemOn (mc .player , InteractionHand . MAIN_HAND , hitResult ) ;
53- mc . player . swing ( InteractionHand . MAIN_HAND );
54- break ;
55- }
81+ private static void stopInput ( Minecraft mc ) {
82+ if (mc .options == null ) return ;
83+ net . minecraft . client . KeyMapping . set ( InputConstants . getKey ( GLFW . GLFW_KEY_W , - 1 ), false );
84+ net . minecraft . client . KeyMapping . set ( InputConstants . getKey ( GLFW . GLFW_KEY_LEFT_CONTROL , - 1 ), false ) ;
85+ net . minecraft . client . KeyMapping . set ( InputConstants . getKey ( GLFW . GLFW_KEY_SPACE , - 1 ), false );
5686 }
5787}
0 commit comments