MCPcopy Create free account
hub / github.com/cabaletta/baritone / SelCommand

Class SelCommand

src/main/java/baritone/command/defaults/SelCommand.java:59–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57import java.util.stream.Stream;
58
59public class SelCommand extends Command {
60
61 private ISelectionManager manager = baritone.getSelectionManager();
62 private BetterBlockPos pos1 = null;
63 private ISchematic clipboard = null;
64 private Vec3i clipboardOffset = null;
65
66 public SelCommand(IBaritone baritone) {
67 super(baritone, "sel", "selection", "s");
68 baritone.getGameEventHandler().registerEventListener(new AbstractGameEventListener() {
69 @Override
70 public void onRenderPass(RenderEvent event) {
71 if (!Baritone.settings().renderSelectionCorners.value || pos1 == null) {
72 return;
73 }
74 Color color = Baritone.settings().colorSelectionPos1.value;
75 float opacity = Baritone.settings().selectionOpacity.value;
76 float lineWidth = Baritone.settings().selectionLineWidth.value;
77 boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value;
78 BufferBuilder bufferBuilder = IRenderer.startLines(color, opacity, lineWidth);
79 IRenderer.emitAABB(bufferBuilder, event.getModelViewStack(), new AABB(pos1));
80 IRenderer.endLines(bufferBuilder, ignoreDepth);
81 }
82 });
83 }
84
85 @Override
86 public void execute(String label, IArgConsumer args) throws CommandException {
87 Action action = Action.getByName(args.getString());
88 if (action == null) {
89 throw new CommandInvalidTypeException(args.consumed(), "an action");
90 }
91 if (action == Action.POS1 || action == Action.POS2) {
92 if (action == Action.POS2 && pos1 == null) {
93 throw new CommandInvalidStateException("Set pos1 first before using pos2");
94 }
95 BetterBlockPos playerPos = ctx.viewerPos();
96 BetterBlockPos pos = args.hasAny() ? args.getDatatypePost(RelativeBlockPos.INSTANCE, playerPos) : playerPos;
97 args.requireMax(0);
98 if (action == Action.POS1) {
99 pos1 = pos;
100 logDirect("Position 1 has been set");
101 } else {
102 manager.addSelection(pos1, pos);
103 pos1 = null;
104 logDirect("Selection added");
105 }
106 } else if (action == Action.CLEAR) {
107 args.requireMax(0);
108 pos1 = null;
109 logDirect(String.format("Removed %d selections", manager.removeAllSelections().length));
110 } else if (action == Action.UNDO) {
111 args.requireMax(0);
112 if (pos1 != null) {
113 pos1 = null;
114 logDirect("Undid pos1");
115 } else {
116 ISelection[] selections = manager.getSelections();

Callers

nothing calls this directly

Calls 1

getSelectionManagerMethod · 0.65

Tested by

no test coverage detected