Remove usage of realms Pair class

This commit is contained in:
Brady
2023-06-18 10:57:13 -05:00
parent d66b8f1dd8
commit d4e6a84ec9
3 changed files with 65 additions and 10 deletions

View File

@@ -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 <https://www.gnu.org/licenses/>.
*/
package baritone.api.utils;
import java.util.Objects;
/**
* @author Brady
*/
public final class Pair<A, B> {
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);
}
}

View File

@@ -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;
}

View File

@@ -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;