Merge upstream master
This commit is contained in:
commit
48f6d338a6
@ -602,6 +602,11 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> preferSilkTouch = new Setting<>(false);
|
||||
|
||||
/*
|
||||
* Censor coordinates in goals and block positions
|
||||
*/
|
||||
public final Setting<Boolean> censorCoordinates = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Don't stop walking forward when you need to break blocks in your way
|
||||
*/
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.cache;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Date;
|
||||
@ -80,7 +81,12 @@ public class Waypoint implements IWaypoint {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + " " + location.toString() + " " + new Date(creationTimestamp).toString();
|
||||
return String.format(
|
||||
"%s %s %s",
|
||||
name,
|
||||
BetterBlockPos.from(location).toString(),
|
||||
new Date(creationTimestamp).toString()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@ -67,7 +68,12 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalBlock{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||
return String.format(
|
||||
"GoalBlock{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@ -61,6 +62,11 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalGetToBlock{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||
return String.format(
|
||||
"GoalGetToBlock{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@ -56,11 +57,12 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalNear{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
", rangeSq=" + rangeSq +
|
||||
"}";
|
||||
return String.format(
|
||||
"GoalNear{x=%s, y=%s, z=%s, rangeSq=%d}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z),
|
||||
rangeSq
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -82,7 +83,11 @@ public class GoalRunAway implements Goal {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (maintainY != null) {
|
||||
return "GoalRunAwayFromMaintainY y=" + maintainY + ", " + Arrays.asList(from);
|
||||
return String.format(
|
||||
"GoalRunAwayFromMaintainY y=%s, %s",
|
||||
SettingsUtil.maybeCensor(maintainY),
|
||||
Arrays.asList(from)
|
||||
);
|
||||
} else {
|
||||
return "GoalRunAwayFrom" + Arrays.asList(from);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@ -64,12 +65,13 @@ public class GoalStrictDirection implements Goal {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalStrictDirection{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
", dx=" + dx +
|
||||
", dz=" + dz +
|
||||
"}";
|
||||
return String.format(
|
||||
"GoalStrictDirection{x=%s, y=%s, z=%s, dx=%s, dz=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z),
|
||||
SettingsUtil.maybeCensor(dx),
|
||||
SettingsUtil.maybeCensor(dz)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@ -73,6 +74,11 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalTwoBlocks{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||
return String.format(
|
||||
"GoalTwoBlocks{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@ -59,7 +60,11 @@ public class GoalXZ implements Goal {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalXZ{x=" + x + ",z=" + z + "}";
|
||||
return String.format(
|
||||
"GoalXZ{x=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
|
||||
public static double calculate(double xDiff, double zDiff) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.pathing.movement.ActionCosts;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
|
||||
/**
|
||||
* Useful for mining (getting to diamond / iron level)
|
||||
@ -59,6 +60,9 @@ public class GoalYLevel implements Goal, ActionCosts {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalYLevel{y=" + level + "}";
|
||||
return String.format(
|
||||
"GoalYLevel{y=%s}",
|
||||
SettingsUtil.maybeCensor(level)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* A better BlockPos that has fewer hash collisions (and slightly more performant offsets)
|
||||
* <p>
|
||||
@ -51,6 +53,20 @@ public final class BetterBlockPos extends BlockPos {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Like constructor but returns null if pos is null, good if you just need to possibly censor coordinates
|
||||
*
|
||||
* @param pos The BlockPos, possibly null, to convert
|
||||
* @return A BetterBlockPos or null if pos was null
|
||||
*/
|
||||
public static BetterBlockPos from(BlockPos pos) {
|
||||
if (pos == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BetterBlockPos(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) longHash(x, y, z);
|
||||
@ -182,4 +198,15 @@ public final class BetterBlockPos extends BlockPos {
|
||||
public BetterBlockPos west(int amt) {
|
||||
return amt == 0 ? this : new BetterBlockPos(x - amt, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"BetterBlockPos{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
||||
}
|
||||
if (msg.equals("chests")) {
|
||||
for (Map.Entry<BlockPos, IRememberedInventory> entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) {
|
||||
logDirect(entry.getKey() + "");
|
||||
logDirect(BetterBlockPos.from(entry.getKey()) + "");
|
||||
log(entry.getValue().getContents());
|
||||
}
|
||||
return true;
|
||||
@ -576,6 +576,12 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
||||
}
|
||||
name = parts[0];
|
||||
}
|
||||
for (IWaypoint.Tag tag : IWaypoint.Tag.values()) {
|
||||
if (tag.name().equalsIgnoreCase(name)) {
|
||||
logDirect("Unable to use tags as name. Tags are: " + Arrays.asList(IWaypoint.Tag.values()).toString().toLowerCase());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, IWaypoint.Tag.USER, pos));
|
||||
logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints.");
|
||||
return true;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
@ -120,6 +121,14 @@ public class SettingsUtil {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public static String maybeCensor(int coord) {
|
||||
if (BaritoneAPI.getSettings().censorCoordinates.value) {
|
||||
return "<censored>";
|
||||
}
|
||||
|
||||
return Integer.toString(coord);
|
||||
}
|
||||
|
||||
public static String settingToString(Settings.Setting setting) throws IllegalStateException {
|
||||
if (setting.getName().equals("logger")) {
|
||||
return "logger";
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.launch.mixins;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/25/2018
|
||||
*/
|
||||
@Mixin(BlockPos.class)
|
||||
public class MixinBlockPos extends Vec3i {
|
||||
|
||||
public MixinBlockPos(int xIn, int yIn, int zIn) {
|
||||
super(xIn, yIn, zIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* The purpose of this was to ensure a friendly name for when we print raw
|
||||
* block positions to chat in the context of an obfuscated environment.
|
||||
*
|
||||
* @return a string representation of the object.
|
||||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper("BlockPos").add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString();
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@
|
||||
},
|
||||
"client": [
|
||||
"MixinAnvilChunkLoader",
|
||||
"MixinBlockPos",
|
||||
"MixinChunkProviderClient",
|
||||
"MixinChunkProviderServer",
|
||||
"MixinChunkRenderContainer",
|
||||
|
@ -24,6 +24,7 @@ import baritone.api.event.events.PacketEvent;
|
||||
import baritone.api.event.events.PlayerUpdateEvent;
|
||||
import baritone.api.event.events.TickEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.cache.ContainerMemory;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import net.minecraft.block.Block;
|
||||
@ -99,8 +100,8 @@ public final class MemoryBehavior extends Behavior {
|
||||
|
||||
TileEntityLockable lockable = (TileEntityLockable) tileEntity;
|
||||
int size = lockable.getSizeInventory();
|
||||
BlockPos position = tileEntity.getPos();
|
||||
BlockPos adj = neighboringConnectedBlock(position);
|
||||
BetterBlockPos position = BetterBlockPos.from(tileEntity.getPos());
|
||||
BetterBlockPos adj = BetterBlockPos.from(neighboringConnectedBlock(position));
|
||||
System.out.println(position + " " + adj);
|
||||
if (adj != null) {
|
||||
size *= 2; // double chest or double trapped chest
|
||||
@ -239,7 +240,8 @@ public final class MemoryBehavior extends Behavior {
|
||||
this.slots = slots;
|
||||
this.type = type;
|
||||
this.pos = pos;
|
||||
System.out.println("Future inventory created " + time + " " + slots + " " + type + " " + pos);
|
||||
// betterblockpos has censoring
|
||||
System.out.println("Future inventory created " + time + " " + slots + " " + type + " " + BetterBlockPos.from(pos));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user