2323import baritone .api .process .IFarmProcess ;
2424import baritone .api .process .IMineProcess ;
2525import baritone .api .pathing .goals .GoalBlock ;
26+ import baritone .api .pathing .goals .GoalNear ;
2627import baritone .api .utils .BlockOptionalMeta ;
2728import com .pathmind .execution .ExecutionManager ;
2829import com .pathmind .execution .PreciseCompletionTracker ;
@@ -3369,8 +3370,74 @@ private boolean gotoBlockFromParameter(Node parameterNode, IBaritone baritone, C
33693370 return false ;
33703371 }
33713372
3372- IGetToBlockProcess getToBlockProcess = baritone != null ? baritone .getGetToBlockProcess () : null ;
33733373 net .minecraft .client .MinecraftClient client = net .minecraft .client .MinecraftClient .getInstance ();
3374+ RuntimeParameterData parameterData = runtimeParameterData ;
3375+ BlockPos targetPos = parameterData != null ? parameterData .targetBlockPos : null ;
3376+ String sanitized = sanitizeResourceId (blockId );
3377+ String normalized = (sanitized != null && !sanitized .isEmpty ())
3378+ ? normalizeResourceId (sanitized , "minecraft" )
3379+ : null ;
3380+ Block targetBlock = null ;
3381+
3382+ if (client != null && client .world != null ) {
3383+ if (normalized == null || normalized .isEmpty ()) {
3384+ sendNodeErrorMessage (client , "Cannot navigate to block: no block selected." );
3385+ future .complete (null );
3386+ return true ;
3387+ }
3388+
3389+ Identifier identifier = Identifier .tryParse (normalized );
3390+ if (identifier == null || !Registries .BLOCK .containsId (identifier )) {
3391+ sendNodeErrorMessage (client , "Cannot navigate to block \" " + blockId + "\" : unknown identifier." );
3392+ future .complete (null );
3393+ return true ;
3394+ }
3395+
3396+ targetBlock = Registries .BLOCK .get (identifier );
3397+ if (targetPos == null ) {
3398+ Optional <BlockPos > nearest = findNearestBlock (client , Collections .singletonList (targetBlock ), PARAMETER_SEARCH_RADIUS );
3399+ if (nearest .isEmpty ()) {
3400+ sendNodeErrorMessage (client , "No " + normalized + " found nearby for " + type .getDisplayName () + "." );
3401+ future .complete (null );
3402+ return true ;
3403+ }
3404+ targetPos = nearest .get ();
3405+ }
3406+
3407+ setParameterValueAndPropagate ("Block" , normalized );
3408+
3409+ if (client .player != null && targetPos != null && targetBlock != null
3410+ && client .world .getBlockState (targetPos ).isOf (targetBlock )) {
3411+ BlockPos playerBlockPos = client .player .getBlockPos ();
3412+ if (playerBlockPos .equals (targetPos )) {
3413+ future .complete (null );
3414+ return true ;
3415+ }
3416+ double distanceSq = client .player .squaredDistanceTo (targetPos .getX () + 0.5 , targetPos .getY () + 0.5 , targetPos .getZ () + 0.5 );
3417+ if (distanceSq <= 2.25D ) { // already within ~1.5 blocks, treat as complete
3418+ future .complete (null );
3419+ return true ;
3420+ }
3421+ }
3422+ }
3423+
3424+ if (targetPos != null ) {
3425+ ICustomGoalProcess customGoalProcess = baritone != null ? baritone .getCustomGoalProcess () : null ;
3426+ if (customGoalProcess == null ) {
3427+ if (client != null ) {
3428+ sendNodeErrorMessage (client , "Cannot navigate to block: goal process unavailable." );
3429+ }
3430+ future .complete (null );
3431+ return true ;
3432+ }
3433+
3434+ PreciseCompletionTracker .getInstance ().startTrackingTask (PreciseCompletionTracker .TASK_GOTO , future );
3435+ GoalNear goal = new GoalNear (targetPos , 1 );
3436+ customGoalProcess .setGoalAndPath (goal );
3437+ return true ;
3438+ }
3439+
3440+ IGetToBlockProcess getToBlockProcess = baritone != null ? baritone .getGetToBlockProcess () : null ;
33743441 if (getToBlockProcess == null ) {
33753442 if (client != null ) {
33763443 sendNodeErrorMessage (client , "Cannot navigate to block: block search process unavailable." );
@@ -3380,7 +3447,8 @@ private boolean gotoBlockFromParameter(Node parameterNode, IBaritone baritone, C
33803447 }
33813448
33823449 PreciseCompletionTracker .getInstance ().startTrackingTask (PreciseCompletionTracker .TASK_GOTO , future );
3383- getToBlockProcess .getToBlock (new BlockOptionalMeta (blockId ));
3450+ String targetId = (normalized != null && !normalized .isEmpty ()) ? normalized : blockId ;
3451+ getToBlockProcess .getToBlock (new BlockOptionalMeta (targetId ));
33843452 return true ;
33853453 }
33863454
@@ -6527,13 +6595,6 @@ private void executeInteractCommand(CompletableFuture<Void> future) {
65276595
65286596 String blockDisplayName = targetBlock .getName ().getString ();
65296597
6530- if (state .createScreenHandlerFactory (client .world , targetPos ) == null ) {
6531- restoreSneakState .run ();
6532- sendNodeErrorMessage (client , blockDisplayName + " cannot be opened." );
6533- future .complete (null );
6534- return ;
6535- }
6536-
65376598 Vec3d eyePos = client .player .getEyePos ();
65386599 Vec3d hitVec = Vec3d .ofCenter (targetPos );
65396600 if (eyePos .squaredDistanceTo (hitVec ) > DEFAULT_REACH_DISTANCE_SQUARED ) {
0 commit comments