(RenderEvent event, PathingBehavior behavior)
| 65 | } |
| 66 | |
| 67 | public static void render(RenderEvent event, PathingBehavior behavior) { |
| 68 | final IPlayerContext ctx = behavior.ctx; |
| 69 | if (ctx.world() == null) { |
| 70 | return; |
| 71 | } |
| 72 | if (ctx.minecraft().screen instanceof GuiClick) { |
| 73 | ((GuiClick) ctx.minecraft().screen).onRender(event.getModelViewStack(), event.getProjectionMatrix()); |
| 74 | } |
| 75 | |
| 76 | final float partialTicks = event.getPartialTicks(); |
| 77 | final Goal goal = behavior.getGoal(); |
| 78 | |
| 79 | final DimensionType thisPlayerDimension = ctx.world().dimensionType(); |
| 80 | final DimensionType currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().dimensionType(); |
| 81 | |
| 82 | if (thisPlayerDimension != currentRenderViewDimension) { |
| 83 | // this is a path for a bot in a different dimension, don't render it |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | if (goal != null && settings.renderGoal.value) { |
| 88 | drawGoal(event.getModelViewStack(), ctx, goal, partialTicks, settings.colorGoalBox.value); |
| 89 | } |
| 90 | |
| 91 | if (!settings.renderPath.value) { |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | PathExecutor current = behavior.getCurrent(); // this should prevent most race conditions? |
| 96 | PathExecutor next = behavior.getNext(); // like, now it's not possible for current!=null to be true, then suddenly false because of another thread |
| 97 | if (current != null && settings.renderSelectionBoxes.value) { |
| 98 | drawManySelectionBoxes(event.getModelViewStack(), ctx.player(), current.toBreak(), settings.colorBlocksToBreak.value); |
| 99 | drawManySelectionBoxes(event.getModelViewStack(), ctx.player(), current.toPlace(), settings.colorBlocksToPlace.value); |
| 100 | drawManySelectionBoxes(event.getModelViewStack(), ctx.player(), current.toWalkInto(), settings.colorBlocksToWalkInto.value); |
| 101 | } |
| 102 | |
| 103 | //drawManySelectionBoxes(player, Collections.singletonList(behavior.pathStart()), partialTicks, Color.WHITE); |
| 104 | |
| 105 | // Render the current path, if there is one |
| 106 | if (current != null && current.getPath() != null) { |
| 107 | int renderBegin = Math.max(current.getPosition() - 3, 0); |
| 108 | drawPath(event.getModelViewStack(), current.getPath().positions(), renderBegin, settings.colorCurrentPath.value, settings.fadePath.value, 10, 20); |
| 109 | } |
| 110 | |
| 111 | if (next != null && next.getPath() != null) { |
| 112 | drawPath(event.getModelViewStack(), next.getPath().positions(), 0, settings.colorNextPath.value, settings.fadePath.value, 10, 20); |
| 113 | } |
| 114 | |
| 115 | // If there is a path calculation currently running, render the path calculation process |
| 116 | behavior.getInProgress().ifPresent(currentlyRunning -> { |
| 117 | currentlyRunning.bestPathSoFar().ifPresent(p -> { |
| 118 | drawPath(event.getModelViewStack(), p.positions(), 0, settings.colorBestPathSoFar.value, settings.fadePath.value, 10, 20); |
| 119 | }); |
| 120 | |
| 121 | currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> { |
| 122 | drawPath(event.getModelViewStack(), mr.positions(), 0, settings.colorMostRecentConsidered.value, settings.fadePath.value, 10, 20); |
| 123 | drawManySelectionBoxes(event.getModelViewStack(), ctx.player(), Collections.singletonList(mr.getDest()), settings.colorMostRecentConsidered.value); |
| 124 | }); |
no test coverage detected