Baritone 1.16.1
This commit is contained in:
@@ -30,7 +30,7 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.OptionalInt;
|
||||
@@ -137,7 +137,7 @@ public final class InventoryBehavior extends Behavior {
|
||||
|
||||
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
|
||||
BlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z, baritone.bsi.get0(x, y, z));
|
||||
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.world(), ctx.player(), Hand.MAIN_HAND, stack, new BlockRayTraceResult(new Vec3d(ctx.player().getPositionVec().x, ctx.player().getPositionVec().y, ctx.player().getPositionVec().z), Direction.UP, ctx.playerFeet(), false)) {}))))) {
|
||||
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.world(), ctx.player(), Hand.MAIN_HAND, stack, new BlockRayTraceResult(new Vector3d(ctx.player().getPositionVec().x, ctx.player().getPositionVec().y, ctx.player().getPositionVec().z), Direction.UP, ctx.playerFeet(), false)) {}))))) {
|
||||
return true; // gotem
|
||||
}
|
||||
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && ((BlockItem) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
|
||||
|
||||
@@ -380,7 +380,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
public BetterBlockPos pathStart() { // TODO move to a helper or util class
|
||||
BetterBlockPos feet = ctx.playerFeet();
|
||||
if (!MovementHelper.canWalkOn(ctx, feet.down())) {
|
||||
if (ctx.player().onGround) {
|
||||
if (ctx.player().func_233570_aj_()) {
|
||||
double playerX = ctx.player().getPositionVec().x;
|
||||
double playerZ = ctx.player().getPositionVec().z;
|
||||
ArrayList<BetterBlockPos> closest = new ArrayList<>();
|
||||
|
||||
@@ -24,7 +24,9 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
@@ -178,7 +180,7 @@ public final class CachedChunk {
|
||||
}
|
||||
}
|
||||
|
||||
public final BlockState getBlock(int x, int y, int z, int dimension) {
|
||||
public final BlockState getBlock(int x, int y, int z, RegistryKey<World> dimension) {
|
||||
int index = getPositionIndex(x, y, z);
|
||||
PathingBlockType type = getType(index);
|
||||
int internalPos = z << 4 | x;
|
||||
@@ -200,11 +202,11 @@ public final class CachedChunk {
|
||||
}
|
||||
|
||||
if (type == PathingBlockType.SOLID) {
|
||||
if (y == 127 && dimension == -1) {
|
||||
if (y == 127 && dimension == World.field_234919_h_) {
|
||||
// nether roof is always unbreakable
|
||||
return Blocks.BEDROCK.getDefaultState();
|
||||
}
|
||||
if (y < 5 && dimension == 0) {
|
||||
if (y < 5 && dimension == World.field_234918_g_) {
|
||||
// solid blocks below 5 are commonly bedrock
|
||||
// however, returning bedrock always would be a little yikes
|
||||
// discourage paths that include breaking blocks below 5 a little more heavily just so that it takes paths breaking what's known to be stone (at 5 or above) instead of what could maybe be bedrock (below 5)
|
||||
|
||||
@@ -21,7 +21,9 @@ import baritone.Baritone;
|
||||
import baritone.api.cache.ICachedRegion;
|
||||
import baritone.api.utils.BlockUtils;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
@@ -60,14 +62,14 @@ public final class CachedRegion implements ICachedRegion {
|
||||
*/
|
||||
private final int z;
|
||||
|
||||
private final int dimension;
|
||||
private final RegistryKey<World> dimension;
|
||||
|
||||
/**
|
||||
* Has this region been modified since its most recent load or save
|
||||
*/
|
||||
private boolean hasUnsavedChanges;
|
||||
|
||||
CachedRegion(int x, int z, int dimension) {
|
||||
CachedRegion(int x, int z, RegistryKey<World> dimension) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.hasUnsavedChanges = false;
|
||||
|
||||
@@ -25,7 +25,9 @@ import baritone.api.cache.IWorldData;
|
||||
import baritone.api.utils.Helper;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -58,9 +60,9 @@ public final class CachedWorld implements ICachedWorld, Helper {
|
||||
|
||||
private final LinkedBlockingQueue<Chunk> toPack = new LinkedBlockingQueue<>();
|
||||
|
||||
private final int dimension;
|
||||
private final RegistryKey<World> dimension;
|
||||
|
||||
CachedWorld(Path directory, int dimension) {
|
||||
CachedWorld(Path directory, RegistryKey<World> dimension) {
|
||||
if (!Files.exists(directory)) {
|
||||
try {
|
||||
Files.createDirectories(directory);
|
||||
|
||||
24
src/main/java/baritone/cache/ChunkPacker.java
vendored
24
src/main/java/baritone/cache/ChunkPacker.java
vendored
@@ -21,9 +21,11 @@ import baritone.api.utils.BlockUtils;
|
||||
import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.utils.pathing.PathingBlockType;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.palette.PalettedContainer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkSection;
|
||||
|
||||
@@ -123,7 +125,7 @@ public final class ChunkPacker {
|
||||
return PathingBlockType.AVOID;
|
||||
}
|
||||
if (x == 0 || x == 15 || z == 0 || z == 15) {
|
||||
Vec3d flow = state.getFluidState().getFlow(chunk.getWorld(), new BlockPos(x + chunk.getPos().x << 4, y, z + chunk.getPos().z << 4));
|
||||
Vector3d flow = state.getFluidState().getFlow(chunk.getWorld(), new BlockPos(x + chunk.getPos().x << 4, y, z + chunk.getPos().z << 4));
|
||||
if (flow.x != 0.0 || flow.z != 0.0) {
|
||||
return PathingBlockType.WATER;
|
||||
}
|
||||
@@ -146,7 +148,7 @@ public final class ChunkPacker {
|
||||
return PathingBlockType.SOLID;
|
||||
}
|
||||
|
||||
public static BlockState pathingTypeToBlock(PathingBlockType type, int dimension) {
|
||||
public static BlockState pathingTypeToBlock(PathingBlockType type, RegistryKey<World> dimension) {
|
||||
switch (type) {
|
||||
case AIR:
|
||||
return Blocks.AIR.getDefaultState();
|
||||
@@ -156,14 +158,14 @@ public final class ChunkPacker {
|
||||
return Blocks.LAVA.getDefaultState();
|
||||
case SOLID:
|
||||
// Dimension solid types
|
||||
switch (dimension) {
|
||||
case -1:
|
||||
return Blocks.NETHERRACK.getDefaultState();
|
||||
case 0:
|
||||
default: // The fallback solid type
|
||||
return Blocks.STONE.getDefaultState();
|
||||
case 1:
|
||||
return Blocks.END_STONE.getDefaultState();
|
||||
if (dimension == World.field_234918_g_) {
|
||||
return Blocks.STONE.getDefaultState();
|
||||
}
|
||||
if (dimension == World.field_234919_h_) {
|
||||
return Blocks.NETHERRACK.getDefaultState();
|
||||
}
|
||||
if (dimension == World.field_234920_i_) {
|
||||
return Blocks.END_STONE.getDefaultState();
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
|
||||
6
src/main/java/baritone/cache/WorldData.java
vendored
6
src/main/java/baritone/cache/WorldData.java
vendored
@@ -22,6 +22,8 @@ import baritone.api.cache.ICachedWorld;
|
||||
import baritone.api.cache.IContainerMemory;
|
||||
import baritone.api.cache.IWaypointCollection;
|
||||
import baritone.api.cache.IWorldData;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
@@ -38,9 +40,9 @@ public class WorldData implements IWorldData {
|
||||
private final ContainerMemory containerMemory;
|
||||
//public final MapData map;
|
||||
public final Path directory;
|
||||
public final int dimension;
|
||||
public final RegistryKey<World> dimension;
|
||||
|
||||
WorldData(Path directory, int dimension) {
|
||||
WorldData(Path directory, RegistryKey<World> dimension) {
|
||||
this.directory = directory;
|
||||
this.cache = new CachedWorld(directory.resolve("cache"), dimension);
|
||||
this.waypoints = new WaypointCollection(directory.resolve("waypoints"));
|
||||
|
||||
17
src/main/java/baritone/cache/WorldProvider.java
vendored
17
src/main/java/baritone/cache/WorldProvider.java
vendored
@@ -21,8 +21,10 @@ import baritone.Baritone;
|
||||
import baritone.api.cache.IWorldProvider;
|
||||
import baritone.api.utils.Helper;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.FolderName;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -51,10 +53,8 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
|
||||
/**
|
||||
* Called when a new world is initialized to discover the
|
||||
*
|
||||
* @param dimension The ID of the world's dimension
|
||||
*/
|
||||
public final void initWorld(DimensionType dimension) {
|
||||
public final void initWorld(RegistryKey<World> world) {
|
||||
File directory;
|
||||
File readme;
|
||||
|
||||
@@ -62,8 +62,7 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
|
||||
// If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file
|
||||
if (mc.isSingleplayer()) {
|
||||
ServerWorld localServerWorld = integratedServer.getWorld(dimension);
|
||||
directory = dimension.getDirectory(localServerWorld.getSaveHandler().getWorldDirectory());
|
||||
directory = DimensionType.func_236031_a_(world, integratedServer.func_240776_a_(FolderName.field_237253_i_).toFile());
|
||||
|
||||
// Gets the "depth" of this directory relative the the game's run directory, 2 is the location of the world
|
||||
if (directory.toPath().relativize(mc.gameDir.toPath()).getNameCount() != 2) {
|
||||
@@ -89,7 +88,7 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
} catch (IOException ignored) {}
|
||||
|
||||
// We will actually store the world data in a subfolder: "DIM<id>"
|
||||
Path dir = new File(directory, "DIM" + dimension.getId()).toPath();
|
||||
Path dir = DimensionType.func_236031_a_(world, directory).toPath();
|
||||
if (!Files.exists(dir)) {
|
||||
try {
|
||||
Files.createDirectories(dir);
|
||||
@@ -98,7 +97,7 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
|
||||
System.out.println("Baritone world data dir: " + dir);
|
||||
synchronized (worldCache) {
|
||||
this.currentWorld = worldCache.computeIfAbsent(dir, d -> new WorldData(d, dimension.getId()));
|
||||
this.currentWorld = worldCache.computeIfAbsent(dir, d -> new WorldData(d, world));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import baritone.command.manager.CommandManager;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
@@ -79,17 +80,17 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
||||
if (settings.echoCommands.value) {
|
||||
String msg = command + rest;
|
||||
String toDisplay = settings.censorRanCommands.value ? command + " ..." : msg;
|
||||
ITextComponent component = new StringTextComponent(String.format("> %s", toDisplay));
|
||||
component.getStyle()
|
||||
.setColor(TextFormatting.WHITE)
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent component = new StringTextComponent(String.format("> %s", toDisplay));
|
||||
component.func_230530_a_(component.getStyle()
|
||||
.func_240712_a_(TextFormatting.WHITE)
|
||||
.func_240716_a_(new HoverEvent(
|
||||
HoverEvent.Action.field_230550_a_,
|
||||
new StringTextComponent("Click to rerun command")
|
||||
))
|
||||
.setClickEvent(new ClickEvent(
|
||||
.func_240715_a_(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + msg
|
||||
));
|
||||
)));
|
||||
logDirect(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -54,8 +56,8 @@ public class ChestsCommand extends Command {
|
||||
IRememberedInventory inv = entry.getValue();
|
||||
logDirect(pos.toString());
|
||||
for (ItemStack item : inv.getContents()) {
|
||||
ITextComponent component = item.getTextComponent();
|
||||
component.appendText(String.format(" x %d", item.getCount()));
|
||||
IFormattableTextComponent component = (IFormattableTextComponent) item.getTextComponent();
|
||||
component.func_240702_b_(String.format(" x %d", item.getCount()));
|
||||
logDirect(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ComeCommand extends Command {
|
||||
if (entity == null) {
|
||||
throw new CommandInvalidStateException("render view entity is null");
|
||||
}
|
||||
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(entity)));
|
||||
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(entity.func_233580_cy_()));
|
||||
logDirect("Coming");
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import baritone.api.command.exception.CommandNotFoundException;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.helpers.Paginator;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
@@ -58,22 +58,22 @@ public class HelpCommand extends Command {
|
||||
command -> {
|
||||
String names = String.join("/", command.getNames());
|
||||
String name = command.getNames().get(0);
|
||||
ITextComponent shortDescComponent = new StringTextComponent(" - " + command.getShortDesc());
|
||||
shortDescComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
ITextComponent namesComponent = new StringTextComponent(names);
|
||||
namesComponent.getStyle().setColor(TextFormatting.WHITE);
|
||||
ITextComponent hoverComponent = new StringTextComponent("");
|
||||
hoverComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||
hoverComponent.appendSibling(namesComponent);
|
||||
hoverComponent.appendText("\n" + command.getShortDesc());
|
||||
hoverComponent.appendText("\n\nClick to view full help");
|
||||
TextComponent shortDescComponent = new StringTextComponent(" - " + command.getShortDesc());
|
||||
shortDescComponent.func_230530_a_(shortDescComponent.getStyle().func_240712_a_(TextFormatting.DARK_GRAY));
|
||||
TextComponent namesComponent = new StringTextComponent(names);
|
||||
namesComponent.func_230530_a_(namesComponent.getStyle().func_240712_a_(TextFormatting.WHITE));
|
||||
TextComponent hoverComponent = new StringTextComponent("");
|
||||
hoverComponent.func_230530_a_(hoverComponent.getStyle().func_240712_a_(TextFormatting.GRAY));
|
||||
hoverComponent.func_230529_a_(namesComponent);
|
||||
hoverComponent.func_240702_b_("\n" + command.getShortDesc());
|
||||
hoverComponent.func_240702_b_("\n\nClick to view full help");
|
||||
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.getNames().get(0));
|
||||
ITextComponent component = new StringTextComponent(name);
|
||||
component.getStyle().setColor(TextFormatting.GRAY);
|
||||
component.appendSibling(shortDescComponent);
|
||||
component.getStyle()
|
||||
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent))
|
||||
.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand));
|
||||
TextComponent component = new StringTextComponent(name);
|
||||
component.func_230530_a_(component.getStyle().func_240712_a_(TextFormatting.GRAY));
|
||||
component.func_230529_a_(shortDescComponent);
|
||||
component.func_230530_a_(component.getStyle()
|
||||
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, hoverComponent))
|
||||
.func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand)));
|
||||
return component;
|
||||
},
|
||||
FORCE_COMMAND_PREFIX + label
|
||||
@@ -88,11 +88,11 @@ public class HelpCommand extends Command {
|
||||
logDirect("");
|
||||
command.getLongDesc().forEach(this::logDirect);
|
||||
logDirect("");
|
||||
ITextComponent returnComponent = new StringTextComponent("Click to return to the help menu");
|
||||
returnComponent.getStyle().setClickEvent(new ClickEvent(
|
||||
TextComponent returnComponent = new StringTextComponent("Click to return to the help menu");
|
||||
returnComponent.func_230530_a_(returnComponent.getStyle().func_240715_a_(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + label
|
||||
));
|
||||
)));
|
||||
logDirect(returnComponent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,7 @@ import baritone.utils.IRenderer;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
@@ -84,7 +83,7 @@ public class SelCommand extends Command {
|
||||
if (action == Action.POS2 && pos1 == null) {
|
||||
throw new CommandInvalidStateException("Set pos1 first before using pos2");
|
||||
}
|
||||
BetterBlockPos playerPos = mc.getRenderViewEntity() != null ? BetterBlockPos.from(new BlockPos(mc.getRenderViewEntity())) : ctx.playerFeet();
|
||||
BetterBlockPos playerPos = mc.getRenderViewEntity() != null ? BetterBlockPos.from(mc.getRenderViewEntity().func_233580_cy_()) : ctx.playerFeet();
|
||||
BetterBlockPos pos = args.hasAny() ? args.getDatatypePost(RelativeBlockPos.INSTANCE, playerPos) : playerPos;
|
||||
args.requireMax(0);
|
||||
if (action == Action.POS1) {
|
||||
@@ -145,7 +144,7 @@ public class SelCommand extends Command {
|
||||
);
|
||||
}
|
||||
for (ISelection selection : selections) {
|
||||
Vec3i size = selection.size();
|
||||
Vector3i size = selection.size();
|
||||
BetterBlockPos min = selection.min();
|
||||
ISchematic schematic = new FillSchematic(size.getX(), size.getY(), size.getZ(), type);
|
||||
if (action == Action.WALLS) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import baritone.api.command.helpers.Paginator;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
@@ -78,23 +79,23 @@ public class SetCommand extends Command {
|
||||
: String.format("All %ssettings:", viewModified ? "modified " : "")
|
||||
),
|
||||
setting -> {
|
||||
ITextComponent typeComponent = new StringTextComponent(String.format(
|
||||
TextComponent typeComponent = new StringTextComponent(String.format(
|
||||
" (%s)",
|
||||
settingTypeToString(setting)
|
||||
));
|
||||
typeComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
ITextComponent hoverComponent = new StringTextComponent("");
|
||||
hoverComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||
hoverComponent.appendText(setting.getName());
|
||||
hoverComponent.appendText(String.format("\nType: %s", settingTypeToString(setting)));
|
||||
hoverComponent.appendText(String.format("\n\nValue:\n%s", settingValueToString(setting)));
|
||||
typeComponent.func_230530_a_(typeComponent.getStyle().func_240712_a_(TextFormatting.DARK_GRAY));
|
||||
TextComponent hoverComponent = new StringTextComponent("");
|
||||
hoverComponent.func_230530_a_(hoverComponent.getStyle().func_240712_a_(TextFormatting.GRAY));
|
||||
hoverComponent.func_240702_b_(setting.getName());
|
||||
hoverComponent.func_240702_b_(String.format("\nType: %s", settingTypeToString(setting)));
|
||||
hoverComponent.func_240702_b_(String.format("\n\nValue:\n%s", settingValueToString(setting)));
|
||||
String commandSuggestion = Baritone.settings().prefix.value + String.format("set %s ", setting.getName());
|
||||
ITextComponent component = new StringTextComponent(setting.getName());
|
||||
component.getStyle().setColor(TextFormatting.GRAY);
|
||||
component.appendSibling(typeComponent);
|
||||
component.getStyle()
|
||||
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent))
|
||||
.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion));
|
||||
TextComponent component = new StringTextComponent(setting.getName());
|
||||
component.func_230530_a_(component.getStyle().func_240712_a_(TextFormatting.GRAY));
|
||||
component.func_230529_a_(typeComponent);
|
||||
component.func_230530_a_(component.getStyle()
|
||||
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, hoverComponent))
|
||||
.func_240715_a_(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion)));
|
||||
return component;
|
||||
},
|
||||
FORCE_COMMAND_PREFIX + "set " + arg + " " + search
|
||||
@@ -163,17 +164,17 @@ public class SetCommand extends Command {
|
||||
settingValueToString(setting)
|
||||
));
|
||||
}
|
||||
ITextComponent oldValueComponent = new StringTextComponent(String.format("Old value: %s", oldValue));
|
||||
oldValueComponent.getStyle()
|
||||
.setColor(TextFormatting.GRAY)
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent oldValueComponent = new StringTextComponent(String.format("Old value: %s", oldValue));
|
||||
oldValueComponent.func_230530_a_(oldValueComponent.getStyle()
|
||||
.func_240712_a_(TextFormatting.GRAY)
|
||||
.func_240716_a_(new HoverEvent(
|
||||
HoverEvent.Action.field_230550_a_,
|
||||
new StringTextComponent("Click to set the setting back to this value")
|
||||
))
|
||||
.setClickEvent(new ClickEvent(
|
||||
.func_240715_a_(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + String.format("set %s %s", setting.getName(), oldValue)
|
||||
));
|
||||
)));
|
||||
logDirect(oldValueComponent);
|
||||
if ((setting.getName().equals("chatControl") && !(Boolean) setting.value && !Baritone.settings().chatControlAnyway.value) ||
|
||||
setting.getName().equals("chatControlAnyway") && !(Boolean) setting.value && !Baritone.settings().chatControl.value) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import baritone.api.command.helpers.Paginator;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
@@ -58,23 +59,23 @@ public class WaypointsCommand extends Command {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
||||
}
|
||||
BiFunction<IWaypoint, Action, ITextComponent> toComponent = (waypoint, _action) -> {
|
||||
ITextComponent component = new StringTextComponent("");
|
||||
ITextComponent tagComponent = new StringTextComponent(waypoint.getTag().name() + " ");
|
||||
tagComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||
TextComponent component = new StringTextComponent("");
|
||||
TextComponent tagComponent = new StringTextComponent(waypoint.getTag().name() + " ");
|
||||
tagComponent.func_230530_a_(tagComponent.getStyle().func_240712_a_(TextFormatting.GRAY));
|
||||
String name = waypoint.getName();
|
||||
ITextComponent nameComponent = new StringTextComponent(!name.isEmpty() ? name : "<empty>");
|
||||
nameComponent.getStyle().setColor(!name.isEmpty() ? TextFormatting.GRAY : TextFormatting.DARK_GRAY);
|
||||
ITextComponent timestamp = new StringTextComponent(" @ " + new Date(waypoint.getCreationTimestamp()));
|
||||
timestamp.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
component.appendSibling(tagComponent);
|
||||
component.appendSibling(nameComponent);
|
||||
component.appendSibling(timestamp);
|
||||
component.getStyle()
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent nameComponent = new StringTextComponent(!name.isEmpty() ? name : "<empty>");
|
||||
nameComponent.func_230530_a_(nameComponent.getStyle().func_240712_a_(!name.isEmpty() ? TextFormatting.GRAY : TextFormatting.DARK_GRAY));
|
||||
TextComponent timestamp = new StringTextComponent(" @ " + new Date(waypoint.getCreationTimestamp()));
|
||||
timestamp.func_230530_a_(timestamp.getStyle().func_240712_a_(TextFormatting.DARK_GRAY));
|
||||
component.func_230529_a_(tagComponent);
|
||||
component.func_230529_a_(nameComponent);
|
||||
component.func_230529_a_(timestamp);
|
||||
component.func_230530_a_(component.getStyle()
|
||||
.func_240716_a_(new HoverEvent(
|
||||
HoverEvent.Action.field_230550_a_,
|
||||
new StringTextComponent("Click to select")
|
||||
))
|
||||
.setClickEvent(new ClickEvent(
|
||||
.func_240715_a_(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s %s %s @ %d",
|
||||
@@ -84,7 +85,7 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getTag().getName(),
|
||||
waypoint.getCreationTimestamp()
|
||||
))
|
||||
);
|
||||
));
|
||||
return component;
|
||||
};
|
||||
Function<IWaypoint, ITextComponent> transform = waypoint ->
|
||||
@@ -136,9 +137,9 @@ public class WaypointsCommand extends Command {
|
||||
args.requireMax(0);
|
||||
IWaypoint waypoint = new Waypoint(name, tag, pos);
|
||||
ForWaypoints.waypoints(this.baritone).addWaypoint(waypoint);
|
||||
ITextComponent component = new StringTextComponent("Waypoint added: ");
|
||||
component.getStyle().setColor(TextFormatting.GRAY);
|
||||
component.appendSibling(toComponent.apply(waypoint, Action.INFO));
|
||||
TextComponent component = new StringTextComponent("Waypoint added: ");
|
||||
component.func_230530_a_(component.getStyle().func_240712_a_(TextFormatting.GRAY));
|
||||
component.func_230529_a_(toComponent.apply(waypoint, Action.INFO));
|
||||
logDirect(component);
|
||||
} else if (action == Action.CLEAR) {
|
||||
args.requireMax(1);
|
||||
@@ -194,8 +195,8 @@ public class WaypointsCommand extends Command {
|
||||
if (action == Action.INFO) {
|
||||
logDirect(transform.apply(waypoint));
|
||||
logDirect(String.format("Position: %s", waypoint.getLocation()));
|
||||
ITextComponent deleteComponent = new StringTextComponent("Click to delete this waypoint");
|
||||
deleteComponent.getStyle().setClickEvent(new ClickEvent(
|
||||
TextComponent deleteComponent = new StringTextComponent("Click to delete this waypoint");
|
||||
deleteComponent.func_230530_a_(deleteComponent.getStyle().func_240715_a_(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s delete %s @ %d",
|
||||
@@ -204,9 +205,9 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getTag().getName(),
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
));
|
||||
ITextComponent goalComponent = new StringTextComponent("Click to set goal to this waypoint");
|
||||
goalComponent.getStyle().setClickEvent(new ClickEvent(
|
||||
)));
|
||||
TextComponent goalComponent = new StringTextComponent("Click to set goal to this waypoint");
|
||||
goalComponent.func_230530_a_(goalComponent.getStyle().func_240715_a_(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s goal %s @ %d",
|
||||
@@ -215,16 +216,16 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getTag().getName(),
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
));
|
||||
ITextComponent backComponent = new StringTextComponent("Click to return to the waypoints list");
|
||||
backComponent.getStyle().setClickEvent(new ClickEvent(
|
||||
)));
|
||||
TextComponent backComponent = new StringTextComponent("Click to return to the waypoints list");
|
||||
backComponent.func_230530_a_(backComponent.getStyle().func_240715_a_(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s list",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
label
|
||||
)
|
||||
));
|
||||
)));
|
||||
logDirect(deleteComponent);
|
||||
logDirect(goalComponent);
|
||||
logDirect(backComponent);
|
||||
|
||||
@@ -115,7 +115,7 @@ public final class GameEventHandler implements IEventBus, Helper {
|
||||
if (event.getState() == EventState.POST) {
|
||||
cache.closeWorld();
|
||||
if (event.getWorld() != null) {
|
||||
cache.initWorld(event.getWorld().getDimension().getType());
|
||||
cache.initWorld(event.getWorld().func_234923_W_());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
||||
@@ -85,7 +86,7 @@ public class CalculationContext {
|
||||
this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread);
|
||||
this.toolSet = new ToolSet(player);
|
||||
this.hasThrowaway = Baritone.settings().allowPlace.value && ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway();
|
||||
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && PlayerInventory.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.getDimension().isNether();
|
||||
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && PlayerInventory.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && world.func_234922_V_() != DimensionType.field_236000_d_;
|
||||
this.canSprint = Baritone.settings().allowSprint.value && player.getFoodStats().getFoodLevel() > 6;
|
||||
this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value;
|
||||
this.allowBreak = Baritone.settings().allowBreak.value;
|
||||
|
||||
@@ -36,7 +36,7 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -125,7 +125,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (isFlowing(x, y, z, state, bsi)) {
|
||||
return false; // Don't walk through flowing liquids
|
||||
}
|
||||
IFluidState fluidState = state.getFluidState();
|
||||
FluidState fluidState = state.getFluidState();
|
||||
if (fluidState.getFluid() instanceof WaterFluid) {
|
||||
if (Baritone.settings().assumeWalkOnWater.value) {
|
||||
return false;
|
||||
@@ -493,13 +493,13 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
}
|
||||
|
||||
static boolean possiblyFlowing(BlockState state) {
|
||||
IFluidState fluidState = state.getFluidState();
|
||||
FluidState fluidState = state.getFluidState();
|
||||
return fluidState.getFluid() instanceof FlowingFluid
|
||||
&& fluidState.getFluid().getLevel(fluidState) != 8;
|
||||
}
|
||||
|
||||
static boolean isFlowing(int x, int y, int z, BlockState state, BlockStateInterface bsi) {
|
||||
IFluidState fluidState = state.getFluidState();
|
||||
FluidState fluidState = state.getFluidState();
|
||||
if (!(fluidState.getFluid() instanceof FlowingFluid)) {
|
||||
return false;
|
||||
}
|
||||
@@ -542,7 +542,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
double faceX = (placeAt.getX() + against1.getX() + 1.0D) * 0.5D;
|
||||
double faceY = (placeAt.getY() + against1.getY() + 0.5D) * 0.5D;
|
||||
double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D;
|
||||
Rotation place = RotationUtils.calcRotationFromVec3d(wouldSneak ? RayTraceUtils.inferSneakingEyePosition(ctx.player()) : ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
|
||||
Rotation place = RotationUtils.calcRotationFromVec3d(wouldSneak ? RayTraceUtils.inferSneakingEyePosition(ctx.player()) : ctx.playerHead(), new Vector3d(faceX, faceY, faceZ), ctx.playerRotations());
|
||||
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance(), wouldSneak);
|
||||
if (res != null && res.getType() == RayTraceResult.Type.BLOCK && ((BlockRayTraceResult) res).getPos().equals(against1) && ((BlockRayTraceResult) res).getPos().offset(((BlockRayTraceResult) res).getFace()).equals(placeAt)) {
|
||||
state.setTarget(new MovementState.MovementTarget(place, true));
|
||||
|
||||
@@ -36,7 +36,7 @@ import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -225,7 +225,7 @@ public class MovementDescend extends Movement {
|
||||
ClientPlayerEntity player = ctx.player();
|
||||
state.setTarget(new MovementState.MovementTarget(
|
||||
new Rotation(RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
|
||||
new Vec3d(destX, dest.getY(), destZ),
|
||||
new Vector3d(destX, dest.getY(), destZ),
|
||||
new Rotation(player.rotationYaw, player.rotationPitch)).getYaw(), player.rotationPitch),
|
||||
false
|
||||
)).setInput(Input.MOVE_FORWARD, true);
|
||||
|
||||
@@ -40,8 +40,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.world.DimensionType;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
@@ -96,11 +97,11 @@ public class MovementFall extends Movement {
|
||||
Block destBlock = destState.getBlock();
|
||||
boolean isWater = destState.getFluidState().getFluid() instanceof WaterFluid;
|
||||
if (!isWater && willPlaceBucket() && !playerFeet.equals(dest)) {
|
||||
if (!PlayerInventory.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().getDimension().isNether()) {
|
||||
if (!PlayerInventory.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().func_234922_V_() == DimensionType.field_236000_d_) {
|
||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||
}
|
||||
|
||||
if (ctx.player().getPositionVec().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().onGround) {
|
||||
if (ctx.player().getPositionVec().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().func_233570_aj_()) {
|
||||
ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER);
|
||||
|
||||
targetRotation = new Rotation(toDest.getYaw(), 90.0F);
|
||||
@@ -133,26 +134,26 @@ public class MovementFall extends Movement {
|
||||
return state.setStatus(MovementStatus.SUCCESS);
|
||||
}
|
||||
}
|
||||
Vec3d destCenter = VecUtils.getBlockPosCenter(dest); // we are moving to the 0.5 center not the edge (like if we were falling on a ladder)
|
||||
Vector3d destCenter = VecUtils.getBlockPosCenter(dest); // we are moving to the 0.5 center not the edge (like if we were falling on a ladder)
|
||||
if (Math.abs(ctx.player().getPositionVec().x + ctx.player().getMotion().x - destCenter.x) > 0.1 || Math.abs(ctx.player().getPositionVec().z + ctx.player().getMotion().z - destCenter.z) > 0.1) {
|
||||
if (!ctx.player().onGround && Math.abs(ctx.player().getMotion().y) > 0.4) {
|
||||
if (!ctx.player().func_233570_aj_() && Math.abs(ctx.player().getMotion().y) > 0.4) {
|
||||
state.setInput(Input.SNEAK, true);
|
||||
}
|
||||
state.setInput(Input.MOVE_FORWARD, true);
|
||||
}
|
||||
Vec3i avoid = Optional.ofNullable(avoid()).map(Direction::getDirectionVec).orElse(null);
|
||||
Vector3i avoid = Optional.ofNullable(avoid()).map(Direction::getDirectionVec).orElse(null);
|
||||
if (avoid == null) {
|
||||
avoid = src.subtract(dest);
|
||||
} else {
|
||||
double dist = Math.abs(avoid.getX() * (destCenter.x - avoid.getX() / 2.0 - ctx.player().getPositionVec().x)) + Math.abs(avoid.getZ() * (destCenter.z - avoid.getZ() / 2.0 - ctx.player().getPositionVec().z));
|
||||
if (dist < 0.6) {
|
||||
state.setInput(Input.MOVE_FORWARD, true);
|
||||
} else if (!ctx.player().onGround) {
|
||||
} else if (!ctx.player().func_233570_aj_()) {
|
||||
state.setInput(Input.SNEAK, false);
|
||||
}
|
||||
}
|
||||
if (targetRotation == null) {
|
||||
Vec3d destCenterOffset = new Vec3d(destCenter.x + 0.125 * avoid.getX(), destCenter.y, destCenter.z + 0.125 * avoid.getZ());
|
||||
Vector3d destCenterOffset = new Vector3d(destCenter.x + 0.125 * avoid.getX(), destCenter.y, destCenter.z + 0.125 * avoid.getZ());
|
||||
state.setTarget(new MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), destCenterOffset, ctx.playerRotations()), false));
|
||||
}
|
||||
return state;
|
||||
|
||||
@@ -251,7 +251,7 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
} else if (!ctx.playerFeet().equals(src)) {
|
||||
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().getPositionVec().y - src.y > 0.0001) {
|
||||
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true, false) == PlaceResult.READY_TO_PLACE) {
|
||||
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().func_233570_aj_() && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true, false) == PlaceResult.READY_TO_PLACE) {
|
||||
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
|
||||
state.setInput(Input.CLICK_RIGHT, true);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.state.properties.SlabType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -171,7 +171,7 @@ public class MovementPillar extends Movement {
|
||||
if (MovementHelper.isWater(fromDown) && MovementHelper.isWater(ctx, dest)) {
|
||||
// stay centered while swimming up a water column
|
||||
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations()), false));
|
||||
Vec3d destCenter = VecUtils.getBlockPosCenter(dest);
|
||||
Vector3d destCenter = VecUtils.getBlockPosCenter(dest);
|
||||
if (Math.abs(ctx.player().getPositionVec().x - destCenter.x) > 0.2 || Math.abs(ctx.player().getPositionVec().z - destCenter.z) > 0.2) {
|
||||
state.setInput(Input.MOVE_FORWARD, true);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import net.minecraft.block.*;
|
||||
import net.minecraft.fluid.WaterFluid;
|
||||
import net.minecraft.state.properties.SlabType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -143,7 +143,7 @@ public class MovementTraverse extends Movement {
|
||||
if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof SlabBlock && down.get(SlabBlock.TYPE) != SlabType.DOUBLE)) {
|
||||
return COST_INF; // can't sneak and backplace against soul sand or half slabs (regardless of whether it's top half or bottom half) =/
|
||||
}
|
||||
if (down.getFluidState() instanceof WaterFluid) {
|
||||
if (down.getFluidState().getFluid() instanceof WaterFluid) {
|
||||
return COST_INF; // this is obviously impossible
|
||||
}
|
||||
WC = WC * (SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST);//since we are sneak backplacing, we are sneaking lol
|
||||
@@ -245,7 +245,7 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
Block low = BlockStateInterface.get(ctx, src).getBlock();
|
||||
Block high = BlockStateInterface.get(ctx, src.up()).getBlock();
|
||||
if (ctx.player().getPositionVec().y > src.y + 0.1D && !ctx.player().onGround && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) {
|
||||
if (ctx.player().getPositionVec().y > src.y + 0.1D && !ctx.player().func_233570_aj_() && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) {
|
||||
// hitting W could cause us to climb the ladder instead of going forward
|
||||
// wait until we're on the ground
|
||||
return state;
|
||||
@@ -317,7 +317,7 @@ public class MovementTraverse extends Movement {
|
||||
// faceX, faceY, faceZ is the middle of the face between from and to
|
||||
BlockPos goalLook = src.down(); // this is the block we were just standing on, and the one we want to place against
|
||||
|
||||
Rotation backToFace = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
|
||||
Rotation backToFace = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vector3d(faceX, faceY, faceZ), ctx.playerRotations());
|
||||
float pitch = backToFace.getPitch();
|
||||
double dist2 = Math.max(Math.abs(ctx.player().getPositionVec().x - faceX), Math.abs(ctx.player().getPositionVec().z - faceZ));
|
||||
if (dist2 < 0.29) { // see issue #208
|
||||
|
||||
@@ -35,8 +35,8 @@ import baritone.utils.BlockStateInterface;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -274,7 +274,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
if (!current.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
if (!ctx.player().onGround) {
|
||||
if (!ctx.player().func_233570_aj_()) {
|
||||
return false;
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(ctx, ctx.playerFeet().down())) {
|
||||
@@ -323,7 +323,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
* @return Whether or not it was possible to snap to the current player feet
|
||||
*/
|
||||
public boolean snipsnapifpossible() {
|
||||
if (!ctx.player().onGround && ctx.world().getFluidState(ctx.playerFeet()).isEmpty()) {
|
||||
if (!ctx.player().func_233570_aj_() && ctx.world().getFluidState(ctx.playerFeet()).isEmpty()) {
|
||||
// if we're falling in the air, and not in water, don't splice
|
||||
return false;
|
||||
} else {
|
||||
@@ -424,7 +424,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
}
|
||||
}
|
||||
if (current instanceof MovementFall) {
|
||||
Tuple<Vec3d, BlockPos> data = overrideFall((MovementFall) current);
|
||||
Tuple<Vector3d, BlockPos> data = overrideFall((MovementFall) current);
|
||||
if (data != null) {
|
||||
BetterBlockPos fallDest = new BetterBlockPos(data.getB());
|
||||
if (!path.positions().contains(fallDest)) {
|
||||
@@ -445,15 +445,15 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Tuple<Vec3d, BlockPos> overrideFall(MovementFall movement) {
|
||||
Vec3i dir = movement.getDirection();
|
||||
private Tuple<Vector3d, BlockPos> overrideFall(MovementFall movement) {
|
||||
Vector3i dir = movement.getDirection();
|
||||
if (dir.getY() < -3) {
|
||||
return null;
|
||||
}
|
||||
if (!movement.toBreakCached.isEmpty()) {
|
||||
return null; // it's breaking
|
||||
}
|
||||
Vec3i flatDir = new Vec3i(dir.getX(), 0, dir.getZ());
|
||||
Vector3i flatDir = new Vector3i(dir.getX(), 0, dir.getZ());
|
||||
int i;
|
||||
outer:
|
||||
for (i = pathPosition + 1; i < path.length() - 1 && i < pathPosition + 3; i++) {
|
||||
@@ -480,7 +480,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
}
|
||||
double len = i - pathPosition - 0.4;
|
||||
return new Tuple<>(
|
||||
new Vec3d(flatDir.getX() * len + movement.getDest().x + 0.5, movement.getDest().y, flatDir.getZ() * len + movement.getDest().z + 0.5),
|
||||
new Vector3d(flatDir.getX() * len + movement.getDest().x + 0.5, movement.getDest().y, flatDir.getZ() * len + movement.getDest().z + 0.5),
|
||||
movement.getDest().add(flatDir.getX() * (i - pathPosition), 0, flatDir.getZ() * (i - pathPosition)));
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,9 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -71,7 +74,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
private String name;
|
||||
private ISchematic realSchematic;
|
||||
private ISchematic schematic;
|
||||
private Vec3i origin;
|
||||
private Vector3i origin;
|
||||
private int ticks;
|
||||
private boolean paused;
|
||||
private int layer;
|
||||
@@ -83,7 +86,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(String name, ISchematic schematic, Vec3i origin) {
|
||||
public void build(String name, ISchematic schematic, Vector3i origin) {
|
||||
this.name = name;
|
||||
this.schematic = schematic;
|
||||
this.realSchematic = null;
|
||||
@@ -99,7 +102,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
if (Baritone.settings().schematicOrientationZ.value) {
|
||||
z += schematic.lengthZ();
|
||||
}
|
||||
this.origin = new Vec3i(x, y, z);
|
||||
this.origin = new Vector3i(x, y, z);
|
||||
this.paused = false;
|
||||
this.layer = 0;
|
||||
this.numRepeats = 0;
|
||||
@@ -120,7 +123,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean build(String name, File schematic, Vec3i origin) {
|
||||
public boolean build(String name, File schematic, Vector3i origin) {
|
||||
Optional<ISchematicFormat> format = SchematicSystem.INSTANCE.getByFile(schematic);
|
||||
if (!format.isPresent()) {
|
||||
return false;
|
||||
@@ -286,11 +289,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
continue;
|
||||
}
|
||||
AxisAlignedBB aabb = placeAgainstState.getShape(ctx.world(), placeAgainstPos).getBoundingBox();
|
||||
for (Vec3d placementMultiplier : aabbSideMultipliers(against)) {
|
||||
for (Vector3d placementMultiplier : aabbSideMultipliers(against)) {
|
||||
double placeX = placeAgainstPos.x + aabb.minX * placementMultiplier.x + aabb.maxX * (1 - placementMultiplier.x);
|
||||
double placeY = placeAgainstPos.y + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y);
|
||||
double placeZ = placeAgainstPos.z + aabb.minZ * placementMultiplier.z + aabb.maxZ * (1 - placementMultiplier.z);
|
||||
Rotation rot = RotationUtils.calcRotationFromVec3d(RayTraceUtils.inferSneakingEyePosition(ctx.player()), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations());
|
||||
Rotation rot = RotationUtils.calcRotationFromVec3d(RayTraceUtils.inferSneakingEyePosition(ctx.player()), new Vector3d(placeX, placeY, placeZ), ctx.playerRotations());
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance(), true);
|
||||
if (result != null && result.getType() == RayTraceResult.Type.BLOCK && ((BlockRayTraceResult) result).getPos().equals(placeAgainstPos) && ((BlockRayTraceResult) result).getFace() == against.getOpposite()) {
|
||||
OptionalInt hotbar = hasAnyItemThatWouldPlace(toPlace, result, rot);
|
||||
@@ -337,19 +340,19 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
|
||||
private static Vec3d[] aabbSideMultipliers(Direction side) {
|
||||
private static Vector3d[] aabbSideMultipliers(Direction side) {
|
||||
switch (side) {
|
||||
case UP:
|
||||
return new Vec3d[]{new Vec3d(0.5, 1, 0.5), new Vec3d(0.1, 1, 0.5), new Vec3d(0.9, 1, 0.5), new Vec3d(0.5, 1, 0.1), new Vec3d(0.5, 1, 0.9)};
|
||||
return new Vector3d[]{new Vector3d(0.5, 1, 0.5), new Vector3d(0.1, 1, 0.5), new Vector3d(0.9, 1, 0.5), new Vector3d(0.5, 1, 0.1), new Vector3d(0.5, 1, 0.9)};
|
||||
case DOWN:
|
||||
return new Vec3d[]{new Vec3d(0.5, 0, 0.5), new Vec3d(0.1, 0, 0.5), new Vec3d(0.9, 0, 0.5), new Vec3d(0.5, 0, 0.1), new Vec3d(0.5, 0, 0.9)};
|
||||
return new Vector3d[]{new Vector3d(0.5, 0, 0.5), new Vector3d(0.1, 0, 0.5), new Vector3d(0.9, 0, 0.5), new Vector3d(0.5, 0, 0.1), new Vector3d(0.5, 0, 0.9)};
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
case EAST:
|
||||
case WEST:
|
||||
double x = side.getXOffset() == 0 ? 0.5 : (1 + side.getXOffset()) / 2D;
|
||||
double z = side.getZOffset() == 0 ? 0.5 : (1 + side.getZOffset()) / 2D;
|
||||
return new Vec3d[]{new Vec3d(x, 0.25, z), new Vec3d(x, 0.75, z)};
|
||||
return new Vector3d[]{new Vector3d(x, 0.25, z), new Vector3d(x, 0.75, z)};
|
||||
default: // null
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@@ -417,10 +420,10 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
layer++;
|
||||
return onTick(calcFailed, isSafeToCancel);
|
||||
}
|
||||
Vec3i repeat = Baritone.settings().buildRepeat.value;
|
||||
Vector3i repeat = Baritone.settings().buildRepeat.value;
|
||||
int max = Baritone.settings().buildRepeatCount.value;
|
||||
numRepeats++;
|
||||
if (repeat.equals(new Vec3i(0, 0, 0)) || (max != -1 && numRepeats >= max)) {
|
||||
if (repeat.equals(new Vector3i(0, 0, 0)) || (max != -1 && numRepeats >= max)) {
|
||||
logDirect("Done building");
|
||||
onLostControl();
|
||||
return null;
|
||||
@@ -436,7 +439,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
|
||||
Optional<Tuple<BetterBlockPos, Rotation>> toBreak = toBreakNearPlayer(bcc);
|
||||
if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround) {
|
||||
if (toBreak.isPresent() && isSafeToCancel && ctx.player().func_233570_aj_()) {
|
||||
// we'd like to pause to break this block
|
||||
// only change look direction if it's safe (don't want to fuck up an in progress parkour for example
|
||||
Rotation rot = toBreak.get().getB();
|
||||
@@ -456,7 +459,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
List<BlockState> desirableOnHotbar = new ArrayList<>();
|
||||
Optional<Placement> toPlace = searchForPlacables(bcc, desirableOnHotbar);
|
||||
if (toPlace.isPresent() && isSafeToCancel && ctx.player().onGround && ticks <= 0) {
|
||||
if (toPlace.isPresent() && isSafeToCancel && ctx.player().func_233570_aj_() && ticks <= 0) {
|
||||
Rotation rot = toPlace.get().rot;
|
||||
baritone.getLookBehavior().updateTarget(rot, true);
|
||||
ctx.player().inventory.currentItem = toPlace.get().hotbarSelection;
|
||||
@@ -521,7 +524,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
|
||||
private void trim() {
|
||||
HashSet<BetterBlockPos> copy = new HashSet<>(incorrectPositions);
|
||||
copy.removeIf(pos -> pos.distanceSq(new BlockPos(ctx.player())) > 200);
|
||||
copy.removeIf(pos -> pos.distanceSq(ctx.player().func_233580_cy_()) > 200);
|
||||
if (!copy.isEmpty()) {
|
||||
incorrectPositions = copy;
|
||||
}
|
||||
@@ -779,7 +782,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
continue;
|
||||
}
|
||||
// <toxic cloud>
|
||||
result.add(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.world(), ctx.player(), Hand.MAIN_HAND, stack, new BlockRayTraceResult(new Vec3d(ctx.player().getPositionVec().x, ctx.player().getPositionVec().y, ctx.player().getPositionVec().z), Direction.UP, ctx.playerFeet(), false)) {})));
|
||||
result.add(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.world(), ctx.player(), Hand.MAIN_HAND, stack, new BlockRayTraceResult(new Vector3d(ctx.player().getPositionVec().x, ctx.player().getPositionVec().y, ctx.player().getPositionVec().z), Direction.UP, ctx.playerFeet(), false)) {})));
|
||||
// </toxic cloud>
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -41,7 +41,7 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -229,7 +229,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
||||
both.addAll(openSoulsand);
|
||||
for (BlockPos pos : both) {
|
||||
boolean soulsand = openSoulsand.contains(pos);
|
||||
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance(), false);
|
||||
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vector3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance(), false);
|
||||
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) {
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), ctx.playerController().getBlockReachDistance());
|
||||
if (result instanceof BlockRayTraceResult && ((BlockRayTraceResult) result).getFace() == Direction.UP) {
|
||||
@@ -278,7 +278,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
||||
}
|
||||
}
|
||||
for (Entity entity : ctx.entities()) {
|
||||
if (entity instanceof ItemEntity && entity.onGround) {
|
||||
if (entity instanceof ItemEntity && entity.func_233570_aj_()) {
|
||||
ItemEntity ei = (ItemEntity) entity;
|
||||
if (PICKUP_DROPPED.contains(ei.getItem().getItem())) {
|
||||
// +0.1 because of farmland's 0.9375 dummy height lol
|
||||
|
||||
@@ -57,9 +57,9 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
||||
private Goal towards(Entity following) {
|
||||
BlockPos pos;
|
||||
if (Baritone.settings().followOffsetDistance.value == 0) {
|
||||
pos = new BlockPos(following);
|
||||
pos = following.func_233580_cy_();
|
||||
} else {
|
||||
GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.value, Baritone.settings().followOffsetDistance.value);
|
||||
GoalXZ g = GoalXZ.fromDirection(following.getPositionVec(), Baritone.settings().followOffsetDirection.value, Baritone.settings().followOffsetDistance.value);
|
||||
pos = new BlockPos(g.getX(), following.getPositionVec().y, g.getZ());
|
||||
}
|
||||
return new GoalNear(pos, Baritone.settings().followRadius.value);
|
||||
|
||||
@@ -114,7 +114,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
.filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof AirBlock)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =(
|
||||
.min(Comparator.comparingDouble(ctx.playerFeet()::distanceSq));
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
if (shaft.isPresent() && ctx.player().onGround) {
|
||||
if (shaft.isPresent() && ctx.player().func_233570_aj_()) {
|
||||
BlockPos pos = shaft.get();
|
||||
BlockState state = baritone.bsi.get0(pos);
|
||||
if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
|
||||
@@ -308,7 +308,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
if (entity instanceof ItemEntity) {
|
||||
ItemEntity ei = (ItemEntity) entity;
|
||||
if (filter.has(ei.getItem())) {
|
||||
ret.add(new BlockPos(entity));
|
||||
ret.add(entity.func_233580_cy_());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -399,7 +399,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
|
||||
.filter(pos -> !blacklist.contains(pos))
|
||||
|
||||
.sorted(Comparator.comparingDouble(new BlockPos(ctx.getBaritone().getPlayerContext().player())::distanceSq))
|
||||
.sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player().func_233580_cy_()::distanceSq))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (locs.size() > max) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import baritone.api.selection.ISelection;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
|
||||
public class Selection implements ISelection {
|
||||
|
||||
@@ -12,7 +12,7 @@ public class Selection implements ISelection {
|
||||
private final BetterBlockPos pos2;
|
||||
private final BetterBlockPos min;
|
||||
private final BetterBlockPos max;
|
||||
private final Vec3i size;
|
||||
private final Vector3i size;
|
||||
private final AxisAlignedBB aabb;
|
||||
|
||||
public Selection(BetterBlockPos pos1, BetterBlockPos pos2) {
|
||||
@@ -31,7 +31,7 @@ public class Selection implements ISelection {
|
||||
Math.max(pos1.z, pos2.z)
|
||||
);
|
||||
|
||||
this.size = new Vec3i(
|
||||
this.size = new Vector3i(
|
||||
max.x - min.x + 1,
|
||||
max.y - min.y + 1,
|
||||
max.z - min.z + 1
|
||||
@@ -61,7 +61,7 @@ public class Selection implements ISelection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3i size() {
|
||||
public Vector3i size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,14 +29,16 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||
import net.minecraft.client.settings.AmbientOcclusionStatus;
|
||||
import net.minecraft.client.settings.CloudOption;
|
||||
import net.minecraft.client.settings.GraphicsFanciness;
|
||||
import net.minecraft.client.settings.ParticleStatus;
|
||||
import net.minecraft.client.tutorial.TutorialSteps;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.IDynamicRegistries;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.util.HTTPUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.*;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import java.io.File;
|
||||
@@ -82,7 +84,7 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
|
||||
s.chatScale = 0.0F;
|
||||
s.ambientOcclusionStatus = AmbientOcclusionStatus.OFF;
|
||||
s.cloudOption = CloudOption.OFF;
|
||||
s.fancyGraphics = false;
|
||||
s.field_238330_f_ = GraphicsFanciness.FAST;
|
||||
s.tutorialStep = TutorialSteps.NONE;
|
||||
s.hideGUI = true;
|
||||
s.fov = 30.0F;
|
||||
@@ -90,24 +92,27 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
|
||||
|
||||
@Override
|
||||
public void onTick(TickEvent event) {
|
||||
// I don't want to make autotest work right now :)
|
||||
System.exit(0);
|
||||
/*
|
||||
IPlayerContext ctx = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext();
|
||||
// If we're on the main menu then create the test world and launch the integrated server
|
||||
if (mc.currentScreen instanceof MainMenuScreen) {
|
||||
System.out.println("Beginning Baritone automatic test routine");
|
||||
mc.displayGuiScreen(null);
|
||||
WorldSettings worldsettings = new WorldSettings(TEST_SEED, GameType.SURVIVAL, true, false, WorldType.DEFAULT);
|
||||
mc.launchIntegratedServer("BaritoneAutoTest", "BaritoneAutoTest", worldsettings);
|
||||
mc.func_238192_a_("BaritoneAutoTest", worldsettings, IDynamicRegistries.func_239770_b_(), DimensionGeneratorSettings.field_236202_b_);
|
||||
}
|
||||
|
||||
IntegratedServer server = mc.getIntegratedServer();
|
||||
|
||||
// If the integrated server is launched and the world has initialized, set the spawn point
|
||||
// to our defined starting position
|
||||
if (server != null && server.getWorld(DimensionType.OVERWORLD) != null) {
|
||||
if (server != null && server.getWorld(World.field_234918_g_) != null) {
|
||||
server.setDifficultyForAllWorlds(Difficulty.PEACEFUL, true);
|
||||
if (mc.player == null) {
|
||||
server.execute(() -> {
|
||||
server.getWorld(DimensionType.OVERWORLD).setSpawnPoint(STARTING_POSITION);
|
||||
server.getWorld(World.field_234918_g_).func_241124_a__(STARTING_POSITION);
|
||||
server.getCommandManager().handleCommand(server.getCommandSource(), "/difficulty peaceful");
|
||||
int result = server.getCommandManager().handleCommand(server.getCommandSource(), "/gamerule spawnRadius 0");
|
||||
if (result != 0) {
|
||||
@@ -117,12 +122,8 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
|
||||
for (final ServerWorld world : mc.getIntegratedServer().getWorlds()) {
|
||||
// If the world has initialized, set the spawn point to our defined starting position
|
||||
if (world != null) {
|
||||
// I would rather do this than try to mess with poz
|
||||
CompoundNBT nbt = world.getGameRules().write();
|
||||
nbt.putString("spawnRadius", "0");
|
||||
world.getGameRules().read(nbt);
|
||||
|
||||
world.setSpawnPoint(STARTING_POSITION);
|
||||
world.getGameRules().get(GameRules.SPAWN_RADIUS).func_234909_b_("0");
|
||||
world.func_241124_a__(STARTING_POSITION);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,6 +174,7 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
|
||||
throw new IllegalStateException("took too long");
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private BaritoneAutoTest() {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package baritone.utils;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
@@ -51,7 +51,7 @@ public final class BlockStateInterfaceAccessWrapper implements IBlockReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidState getFluidState(BlockPos blockPos) {
|
||||
public FluidState getFluidState(BlockPos blockPos) {
|
||||
return getBlockState(blockPos).getFluidState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,13 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector4f;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
|
||||
@@ -54,23 +55,24 @@ public class GuiClick extends Screen implements Helper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
public boolean func_231177_au__() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
public void func_230430_a_(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
|
||||
double mx = mc.mouseHelper.getMouseX();
|
||||
double my = mc.mouseHelper.getMouseY();
|
||||
|
||||
my = mc.getMainWindow().getHeight() - my;
|
||||
my *= mc.getMainWindow().getFramebufferHeight() / (double) mc.getMainWindow().getHeight();
|
||||
mx *= mc.getMainWindow().getFramebufferWidth() / (double) mc.getMainWindow().getWidth();
|
||||
Vec3d near = toWorld(mx, my, 0);
|
||||
Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv
|
||||
Vector3d near = toWorld(mx, my, 0);
|
||||
Vector3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv
|
||||
|
||||
if (near != null && far != null) {
|
||||
///
|
||||
Vec3d viewerPos = new Vec3d(PathRenderer.posX(), PathRenderer.posY(), PathRenderer.posZ());
|
||||
Vector3d viewerPos = new Vector3d(PathRenderer.posX(), PathRenderer.posY(), PathRenderer.posZ());
|
||||
ClientPlayerEntity player = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().player();
|
||||
RayTraceResult result = player.world.rayTraceBlocks(new RayTraceContext(near.add(viewerPos), far.add(viewerPos), RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player));
|
||||
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
|
||||
@@ -80,18 +82,18 @@ public class GuiClick extends Screen implements Helper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int mouseButton) {
|
||||
public boolean func_231048_c_(double mouseX, double mouseY, int mouseButton) {
|
||||
if (mouseButton == 0) {
|
||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().removeAllSelections();
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().addSelection(BetterBlockPos.from(clickStart), BetterBlockPos.from(currentMouseOver));
|
||||
ITextComponent component = new StringTextComponent("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel");
|
||||
component.getStyle()
|
||||
.setColor(TextFormatting.WHITE)
|
||||
.setClickEvent(new ClickEvent(
|
||||
TextComponent component = new StringTextComponent("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel");
|
||||
component.func_230530_a_(component.getStyle()
|
||||
.func_240712_a_(TextFormatting.WHITE)
|
||||
.func_240715_a_(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + "help sel"
|
||||
));
|
||||
)));
|
||||
Helper.HELPER.logDirect(component);
|
||||
clickStart = null;
|
||||
} else {
|
||||
@@ -101,13 +103,13 @@ public class GuiClick extends Screen implements Helper {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver.up()));
|
||||
}
|
||||
clickStart = null;
|
||||
return super.mouseReleased(mouseX, mouseY, mouseButton);
|
||||
return super.func_231048_c_(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||
public boolean func_231044_a_(double mouseX, double mouseY, int mouseButton) {
|
||||
clickStart = currentMouseOver;
|
||||
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
return super.func_231044_a_(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
public void onRender(MatrixStack modelViewStack, Matrix4f projectionMatrix) {
|
||||
@@ -139,7 +141,7 @@ public class GuiClick extends Screen implements Helper {
|
||||
}
|
||||
}
|
||||
|
||||
private Vec3d toWorld(double x, double y, double z) {
|
||||
private Vector3d toWorld(double x, double y, double z) {
|
||||
if (this.projectionViewMatrix == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -156,6 +158,6 @@ public class GuiClick extends Screen implements Helper {
|
||||
}
|
||||
|
||||
pos.perspectiveDivide();
|
||||
return new Vec3d(pos.getX(), pos.getY(), pos.getZ());
|
||||
return new Vector3d(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ import baritone.utils.accessor.IEntityRenderManager;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import baritone.pathing.path.PathExecutor;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -39,6 +38,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.world.DimensionType;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
@@ -77,8 +78,8 @@ public final class PathRenderer implements IRenderer, Helper {
|
||||
((GuiClick) Helper.mc.currentScreen).onRender(event.getModelViewStack(), event.getProjectionMatrix());
|
||||
}
|
||||
|
||||
int thisPlayerDimension = behavior.baritone.getPlayerContext().world().getDimension().getType().getId();
|
||||
int currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().getDimension().getType().getId();
|
||||
DimensionType thisPlayerDimension = behavior.baritone.getPlayerContext().world().func_230315_m_();
|
||||
DimensionType currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().func_230315_m_();
|
||||
|
||||
if (thisPlayerDimension != currentRenderViewDimension) {
|
||||
// this is a path for a bot in a different dimension, don't render it
|
||||
|
||||
@@ -161,7 +161,7 @@ public class ToolSet {
|
||||
}
|
||||
|
||||
speed /= hardness;
|
||||
if (state.getMaterial().isToolNotRequired() || (!item.isEmpty() && item.canHarvestBlock(state))) {
|
||||
if (!state.func_235783_q_() || (!item.isEmpty() && item.canHarvestBlock(state))) {
|
||||
return speed / 30;
|
||||
} else {
|
||||
return speed / 100;
|
||||
|
||||
@@ -24,7 +24,7 @@ import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.monster.EndermanEntity;
|
||||
import net.minecraft.entity.monster.SpiderEntity;
|
||||
import net.minecraft.entity.monster.ZombiePigmanEntity;
|
||||
import net.minecraft.entity.monster.ZombifiedPiglinEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -75,9 +75,9 @@ public class Avoidance {
|
||||
ctx.entitiesStream()
|
||||
.filter(entity -> entity instanceof MobEntity)
|
||||
.filter(entity -> (!(entity instanceof SpiderEntity)) || ctx.player().getBrightness() < 0.5)
|
||||
.filter(entity -> !(entity instanceof ZombiePigmanEntity) || ((ZombiePigmanEntity) entity).getRevengeTarget() != null)
|
||||
.filter(entity -> !(entity instanceof ZombifiedPiglinEntity) || ((ZombifiedPiglinEntity) entity).getRevengeTarget() != null)
|
||||
.filter(entity -> !(entity instanceof EndermanEntity) || ((EndermanEntity) entity).isScreaming())
|
||||
.forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
|
||||
.forEach(entity -> res.add(new Avoidance(entity.func_233580_cy_(), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.Property;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
@@ -111,7 +111,7 @@ public final class SpongeSchematic extends StaticSchematic {
|
||||
this.blockState = block.getDefaultState();
|
||||
|
||||
this.properties.keySet().stream().sorted(String::compareTo).forEachOrdered(key -> {
|
||||
IProperty<?> property = block.getStateContainer().getProperty(key);
|
||||
Property<?> property = block.getStateContainer().getProperty(key);
|
||||
if (property != null) {
|
||||
this.blockState = setPropertyValue(this.blockState, property, this.properties.get(key));
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public final class SpongeSchematic extends StaticSchematic {
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends Comparable<T>> BlockState setPropertyValue(BlockState state, IProperty<T> property, String value) {
|
||||
private static <T extends Comparable<T>> BlockState setPropertyValue(BlockState state, Property<T> property, String value) {
|
||||
Optional<T> parsed = property.parseValue(value);
|
||||
if (parsed.isPresent()) {
|
||||
return state.with(property, parsed.get());
|
||||
|
||||
Reference in New Issue
Block a user