From d4e6a84ec96ce5d2043d2a1d5b4ee5d4cee113c3 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 18 Jun 2023 10:57:13 -0500 Subject: [PATCH] Remove usage of realms Pair class --- src/api/java/baritone/api/utils/Pair.java | 59 +++++++++++++++++++ .../baritone/behavior/ElytraBehavior.java | 14 ++--- .../java/baritone/utils/PathRenderer.java | 2 +- 3 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 src/api/java/baritone/api/utils/Pair.java diff --git a/src/api/java/baritone/api/utils/Pair.java b/src/api/java/baritone/api/utils/Pair.java new file mode 100644 index 000000000..ca7259520 --- /dev/null +++ b/src/api/java/baritone/api/utils/Pair.java @@ -0,0 +1,59 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.api.utils; + +import java.util.Objects; + +/** + * @author Brady + */ +public final class Pair { + + private final A a; + private final B b; + + public Pair(A a, B b) { + this.a = a; + this.b = b; + } + + public A first() { + return this.a; + } + + public B second() { + return this.b; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || o.getClass() != Pair.class) { + return false; + } + Pair pair = (Pair) o; + return Objects.equals(this.a, pair.a) && Objects.equals(this.b, pair.b); + } + + @Override + public int hashCode() { + return 31 * Objects.hashCode(this.a) + Objects.hashCode(this.b); + } +} diff --git a/src/main/java/baritone/behavior/ElytraBehavior.java b/src/main/java/baritone/behavior/ElytraBehavior.java index 8fdcb34f6..6ace0a4e1 100644 --- a/src/main/java/baritone/behavior/ElytraBehavior.java +++ b/src/main/java/baritone/behavior/ElytraBehavior.java @@ -21,14 +21,10 @@ import baritone.Baritone; import baritone.api.event.events.ChunkEvent; import baritone.api.event.events.TickEvent; import baritone.api.event.events.type.EventState; -import baritone.api.utils.BetterBlockPos; -import baritone.api.utils.Helper; -import baritone.api.utils.Rotation; -import baritone.api.utils.RotationUtils; +import baritone.api.utils.*; import baritone.behavior.elytra.NetherPathfinderContext; import baritone.behavior.elytra.UnpackedSegment; import baritone.utils.BlockStateInterface; -import com.mojang.realmsclient.util.Pair; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityFireworkRocket; @@ -381,15 +377,15 @@ public final class ElytraBehavior extends Behavior implements Helper { : relaxation == 0 ? 1.0d : 0.25d; if (isClear(start, dest, grow)) { - Rotation rot = RotationUtils.calcRotationFromVec3d(start, dest, ctx.playerRotations()); + float yaw = RotationUtils.calcRotationFromVec3d(start, dest, ctx.playerRotations()).getYaw(); Float pitch = solvePitch(dest.subtract(start), steps, relaxation == 2); if (pitch == null) { - baritone.getLookBehavior().updateTarget(new Rotation(rot.getYaw(), ctx.playerRotations().getPitch()), false); + baritone.getLookBehavior().updateTarget(new Rotation(yaw, ctx.playerRotations().getPitch()), false); continue; } this.pathManager.setGoingTo(i); this.aimPos = path.get(i).add(0, dy, 0); - baritone.getLookBehavior().updateTarget(new Rotation(rot.getYaw(), pitch), false); + baritone.getLookBehavior().updateTarget(new Rotation(yaw, pitch), false); break outermost; } } @@ -456,7 +452,7 @@ public final class ElytraBehavior extends Behavior implements Helper { } private boolean clearView(Vec3d start, Vec3d dest) { - lines.add(Pair.of(start, dest)); + lines.add(new Pair<>(start, dest)); RayTraceResult result = rayTraceBlocks(start, dest); return result == null || result.typeOfHit == RayTraceResult.Type.MISS; } diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index fa8925042..7274f5dbc 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -23,11 +23,11 @@ import baritone.api.event.events.RenderEvent; import baritone.api.pathing.goals.*; import baritone.api.utils.BetterBlockPos; import baritone.api.utils.IPlayerContext; +import baritone.api.utils.Pair; import baritone.api.utils.interfaces.IGoalRenderPos; import baritone.behavior.ElytraBehavior; import baritone.behavior.PathingBehavior; import baritone.pathing.path.PathExecutor; -import com.mojang.realmsclient.util.Pair; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer;