api sourceset done
This commit is contained in:
+2
-2
@@ -74,7 +74,7 @@ task sourceJar(type: Jar, dependsOn: classes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'snapshot', version: '20190307-1.13.1'
|
mappings channel: 'snapshot', version: '20190608-1.14.2'
|
||||||
reobfMappings 'notch'
|
reobfMappings 'notch'
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
@@ -130,7 +130,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'com.github.ImpactDevelopment:Vanilla:1.13.2'
|
minecraft 'com.github.ImpactDevelopment:Vanilla:1.14.2'
|
||||||
|
|
||||||
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
|
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
|
||||||
exclude module: 'lwjgl'
|
exclude module: 'lwjgl'
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.api;
|
package baritone.api;
|
||||||
|
|
||||||
import baritone.api.cache.IWorldScanner;
|
import baritone.api.cache.IWorldScanner;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -43,19 +43,19 @@ public interface IBaritoneProvider {
|
|||||||
* returned by {@link #getPrimaryBaritone()}.
|
* returned by {@link #getPrimaryBaritone()}.
|
||||||
*
|
*
|
||||||
* @return All active {@link IBaritone} instances.
|
* @return All active {@link IBaritone} instances.
|
||||||
* @see #getBaritoneForPlayer(EntityPlayerSP)
|
* @see #getBaritoneForPlayer(ClientPlayerEntity)
|
||||||
*/
|
*/
|
||||||
List<IBaritone> getAllBaritones();
|
List<IBaritone> getAllBaritones();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}. This will likely be
|
* Provides the {@link IBaritone} instance for a given {@link ClientPlayerEntity}. This will likely be
|
||||||
* replaced with or be overloaded in addition to {@code #getBaritoneForUser(IBaritoneUser)} when
|
* replaced with or be overloaded in addition to {@code #getBaritoneForUser(IBaritoneUser)} when
|
||||||
* {@code bot-system} is merged into {@code master}.
|
* {@code bot-system} is merged into {@code master}.
|
||||||
*
|
*
|
||||||
* @param player The player
|
* @param player The player
|
||||||
* @return The {@link IBaritone} instance.
|
* @return The {@link IBaritone} instance.
|
||||||
*/
|
*/
|
||||||
default IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
|
default IBaritone getBaritoneForPlayer(ClientPlayerEntity player) {
|
||||||
for (IBaritone baritone : getAllBaritones()) {
|
for (IBaritone baritone : getAllBaritones()) {
|
||||||
if (player.equals(baritone.getPlayerContext().player())) {
|
if (player.equals(baritone.getPlayerContext().player())) {
|
||||||
return baritone;
|
return baritone;
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ package baritone.api;
|
|||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
import baritone.api.utils.TypeUtils;
|
import baritone.api.utils.TypeUtils;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
@@ -807,7 +807,7 @@ public final class Settings {
|
|||||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||||
* {@link Setting#value};
|
* {@link Setting#value};
|
||||||
*/
|
*/
|
||||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
|
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().field_71456_v.getChatGUI()::printChatMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the box that is rendered when the current goal is a GoalYLevel
|
* The size of the box that is rendered when the current goal is a GoalYLevel
|
||||||
|
|||||||
+3
-3
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.cache;
|
package baritone.api.cache;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,9 +26,9 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
*/
|
*/
|
||||||
public interface IBlockTypeAccess {
|
public interface IBlockTypeAccess {
|
||||||
|
|
||||||
IBlockState getBlock(int x, int y, int z);
|
BlockState getBlock(int x, int y, int z);
|
||||||
|
|
||||||
default IBlockState getBlock(BlockPos pos) {
|
default BlockState getBlock(BlockPos pos) {
|
||||||
return getBlock(pos.getX(), pos.getY(), pos.getZ());
|
return getBlock(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package baritone.api.event.events;
|
|||||||
|
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.IPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@@ -31,9 +31,9 @@ public final class PacketEvent {
|
|||||||
|
|
||||||
private final EventState state;
|
private final EventState state;
|
||||||
|
|
||||||
private final Packet<?> packet;
|
private final IPacket<?> packet;
|
||||||
|
|
||||||
public PacketEvent(NetworkManager networkManager, EventState state, Packet<?> packet) {
|
public PacketEvent(NetworkManager networkManager, EventState state, IPacket<?> packet) {
|
||||||
this.networkManager = networkManager;
|
this.networkManager = networkManager;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.packet = packet;
|
this.packet = packet;
|
||||||
@@ -47,12 +47,12 @@ public final class PacketEvent {
|
|||||||
return this.state;
|
return this.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Packet<?> getPacket() {
|
public final IPacket<?> getPacket() {
|
||||||
return this.packet;
|
return this.packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final <T extends Packet<?>> T cast() {
|
public final <T extends IPacket<?>> T cast() {
|
||||||
return (T) this.packet;
|
return (T) this.packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package baritone.api.event.events;
|
package baritone.api.event.events;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.api.event.events;
|
package baritone.api.event.events;
|
||||||
|
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@@ -29,14 +29,14 @@ public final class WorldEvent {
|
|||||||
/**
|
/**
|
||||||
* The new world that is being loaded. {@code null} if being unloaded.
|
* The new world that is being loaded. {@code null} if being unloaded.
|
||||||
*/
|
*/
|
||||||
private final WorldClient world;
|
private final ClientWorld world;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The state of the event
|
* The state of the event
|
||||||
*/
|
*/
|
||||||
private final EventState state;
|
private final EventState state;
|
||||||
|
|
||||||
public WorldEvent(WorldClient world, EventState state) {
|
public WorldEvent(ClientWorld world, EventState state) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ public final class WorldEvent {
|
|||||||
/**
|
/**
|
||||||
* @return The new world that is being loaded. {@code null} if being unloaded.
|
* @return The new world that is being loaded. {@code null} if being unloaded.
|
||||||
*/
|
*/
|
||||||
public final WorldClient getWorld() {
|
public final ClientWorld getWorld() {
|
||||||
return this.world;
|
return this.world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,11 @@ package baritone.api.event.listener;
|
|||||||
|
|
||||||
import baritone.api.event.events.*;
|
import baritone.api.event.events.*;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.gui.GuiGameOver;
|
import net.minecraft.client.gui.screen.DeathScreen;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.network.Packet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@@ -44,7 +43,7 @@ public interface IGameEventListener {
|
|||||||
* Run once per game tick from before and after the player rotation is sent to the server.
|
* Run once per game tick from before and after the player rotation is sent to the server.
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see EntityPlayerSP#tick()
|
* @see ClientPlayerEntity#tick()
|
||||||
*/
|
*/
|
||||||
void onPlayerUpdate(PlayerUpdateEvent event);
|
void onPlayerUpdate(PlayerUpdateEvent event);
|
||||||
|
|
||||||
@@ -52,7 +51,7 @@ public interface IGameEventListener {
|
|||||||
* Runs whenever the client player sends a message to the server.
|
* Runs whenever the client player sends a message to the server.
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see EntityPlayerSP#sendChatMessage(String)
|
* @see ClientPlayerEntity#sendChatMessage(String)
|
||||||
*/
|
*/
|
||||||
void onSendChatMessage(ChatEvent event);
|
void onSendChatMessage(ChatEvent event);
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ public interface IGameEventListener {
|
|||||||
* Runs before and after whenever a new world is loaded
|
* Runs before and after whenever a new world is loaded
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see Minecraft#loadWorld(WorldClient, GuiScreen)
|
* @see Minecraft#loadWorld(ClientWorld, Screen)
|
||||||
*/
|
*/
|
||||||
void onWorldEvent(WorldEvent event);
|
void onWorldEvent(WorldEvent event);
|
||||||
|
|
||||||
@@ -104,10 +103,10 @@ public interface IGameEventListener {
|
|||||||
void onPlayerRotationMove(RotationMoveEvent event);
|
void onPlayerRotationMove(RotationMoveEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called whenever the sprint keybind state is checked in {@link EntityPlayerSP#livingTick}
|
* Called whenever the sprint keybind state is checked in {@link ClientPlayerEntity#livingTick}
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see EntityPlayerSP#livingTick()
|
* @see ClientPlayerEntity#livingTick()
|
||||||
*/
|
*/
|
||||||
void onPlayerSprintState(SprintStateEvent event);
|
void onPlayerSprintState(SprintStateEvent event);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +30,7 @@ public class GoalStrictDirection implements Goal {
|
|||||||
public final int dx;
|
public final int dx;
|
||||||
public final int dz;
|
public final int dz;
|
||||||
|
|
||||||
public GoalStrictDirection(BlockPos origin, EnumFacing direction) {
|
public GoalStrictDirection(BlockPos origin, Direction direction) {
|
||||||
x = origin.getX();
|
x = origin.getX();
|
||||||
y = origin.getY();
|
y = origin.getY();
|
||||||
z = origin.getZ();
|
z = origin.getZ();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
@@ -101,10 +101,10 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
// this is unimaginably faster than blockpos.up
|
// this is unimaginably faster than blockpos.up
|
||||||
// that literally calls
|
// that literally calls
|
||||||
// this.up(1)
|
// this.up(1)
|
||||||
// which calls this.offset(EnumFacing.UP, 1)
|
// which calls this.offset(Direction.UP, 1)
|
||||||
// which does return n == 0 ? this : new BlockPos(this.getX() + facing.getXOffset() * n, this.getY() + facing.getYOffset() * n, this.getZ() + facing.getZOffset() * n);
|
// which does return n == 0 ? this : new BlockPos(this.getX() + facing.getXOffset() * n, this.getY() + facing.getYOffset() * n, this.getZ() + facing.getZOffset() * n);
|
||||||
|
|
||||||
// how many function calls is that? up(), up(int), offset(EnumFacing, int), new BlockPos, getX, getXOffset, getY, getYOffset, getZ, getZOffset
|
// how many function calls is that? up(), up(int), offset(Direction, int), new BlockPos, getX, getXOffset, getY, getYOffset, getZ, getZOffset
|
||||||
// that's ten.
|
// that's ten.
|
||||||
// this is one function call.
|
// this is one function call.
|
||||||
return new BetterBlockPos(x, y + 1, z);
|
return new BetterBlockPos(x, y + 1, z);
|
||||||
@@ -129,13 +129,13 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BetterBlockPos offset(EnumFacing dir) {
|
public BetterBlockPos offset(Direction dir) {
|
||||||
Vec3i vec = dir.getDirectionVec();
|
Vec3i vec = dir.getDirectionVec();
|
||||||
return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ());
|
return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BetterBlockPos offset(EnumFacing dir, int dist) {
|
public BetterBlockPos offset(Direction dir, int dist) {
|
||||||
if (dist == 0) {
|
if (dist == 0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package baritone.api.utils;
|
|||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.registry.IRegistry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -29,7 +29,7 @@ public class BlockUtils {
|
|||||||
private static transient Map<String, Block> resourceCache = new HashMap<>();
|
private static transient Map<String, Block> resourceCache = new HashMap<>();
|
||||||
|
|
||||||
public static String blockToString(Block block) {
|
public static String blockToString(Block block) {
|
||||||
ResourceLocation loc = IRegistry.BLOCK.getKey(block);
|
ResourceLocation loc = Registry.field_212618_g.getKey(block);
|
||||||
String name = loc.getPath(); // normally, only write the part after the minecraft:
|
String name = loc.getPath(); // normally, only write the part after the minecraft:
|
||||||
if (!loc.getNamespace().equals("minecraft")) {
|
if (!loc.getNamespace().equals("minecraft")) {
|
||||||
// Baritone is running on top of forge with mods installed, perhaps?
|
// Baritone is running on top of forge with mods installed, perhaps?
|
||||||
@@ -56,7 +56,8 @@ public class BlockUtils {
|
|||||||
if (resourceCache.containsKey(name)) {
|
if (resourceCache.containsKey(name)) {
|
||||||
return null; // cached as null
|
return null; // cached as null
|
||||||
}
|
}
|
||||||
block = IRegistry.BLOCK.get(ResourceLocation.tryCreate(name.contains(":") ? name : "minecraft:" + name));
|
block = Registry.field_212618_g.getOrDefault(ResourceLocation.tryCreate(name.contains(":") ? name : "minecraft:" + name));
|
||||||
|
// TODO this again returns air instead of null!
|
||||||
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
|
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
|
||||||
copy.put(name, block);
|
copy.put(name, block);
|
||||||
resourceCache = copy;
|
resourceCache = copy;
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ import baritone.api.process.ICustomGoalProcess;
|
|||||||
import baritone.api.process.IGetToBlockProcess;
|
import baritone.api.process.IGetToBlockProcess;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
import net.minecraft.client.multiplayer.ClientChunkProvider;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
@@ -260,13 +260,13 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("repack") || msg.equals("rescan")) {
|
if (msg.equals("repack") || msg.equals("rescan")) {
|
||||||
ChunkProviderClient cli = (ChunkProviderClient) ctx.world().getChunkProvider();
|
ClientChunkProvider cli = (ClientChunkProvider) ctx.world().getChunkProvider();
|
||||||
int playerChunkX = ctx.playerFeet().getX() >> 4;
|
int playerChunkX = ctx.playerFeet().getX() >> 4;
|
||||||
int playerChunkZ = ctx.playerFeet().getZ() >> 4;
|
int playerChunkZ = ctx.playerFeet().getZ() >> 4;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) {
|
for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) {
|
||||||
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
|
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
|
||||||
Chunk chunk = cli.getChunk(x, z, false, false);
|
Chunk chunk = cli.getChunk(x, z, null, false);
|
||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
count++;
|
count++;
|
||||||
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk);
|
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk);
|
||||||
@@ -405,7 +405,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.startsWith("followplayers")) {
|
if (msg.startsWith("followplayers")) {
|
||||||
baritone.getFollowProcess().follow(EntityPlayer.class::isInstance); // O P P A
|
baritone.getFollowProcess().follow(PlayerEntity.class::isInstance); // O P P A
|
||||||
logDirect("Following any players");
|
logDirect("Following any players");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -415,7 +415,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
toFollow = ctx.getSelectedEntity();
|
toFollow = ctx.getSelectedEntity();
|
||||||
} else {
|
} else {
|
||||||
for (EntityPlayer pl : ctx.world().playerEntities) {
|
for (PlayerEntity pl : ctx.world().getPlayers()) {
|
||||||
String theirName = pl.getName().getString().trim().toLowerCase();
|
String theirName = pl.getName().getString().trim().toLowerCase();
|
||||||
if (!theirName.equals(ctx.player().getName().getString().trim().toLowerCase()) && (theirName.contains(name) || name.contains(theirName))) { // don't follow ourselves lol
|
if (!theirName.equals(ctx.player().getName().getString().trim().toLowerCase()) && (theirName.contains(name) || name.contains(theirName))) { // don't follow ourselves lol
|
||||||
toFollow = Optional.of(pl);
|
toFollow = Optional.of(pl);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package baritone.api.utils;
|
|||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +34,7 @@ public interface Helper {
|
|||||||
*/
|
*/
|
||||||
Helper HELPER = new Helper() {};
|
Helper HELPER = new Helper() {};
|
||||||
|
|
||||||
ITextComponent MESSAGE_PREFIX = new TextComponentString(String.format(
|
ITextComponent MESSAGE_PREFIX = new StringTextComponent(String.format(
|
||||||
"%s[%sBaritone%s]%s",
|
"%s[%sBaritone%s]%s",
|
||||||
TextFormatting.DARK_PURPLE,
|
TextFormatting.DARK_PURPLE,
|
||||||
TextFormatting.LIGHT_PURPLE,
|
TextFormatting.LIGHT_PURPLE,
|
||||||
@@ -66,7 +66,7 @@ public interface Helper {
|
|||||||
default void logDirect(String message) {
|
default void logDirect(String message) {
|
||||||
ITextComponent component = MESSAGE_PREFIX.shallowCopy();
|
ITextComponent component = MESSAGE_PREFIX.shallowCopy();
|
||||||
component.getStyle().setColor(TextFormatting.GRAY);
|
component.getStyle().setColor(TextFormatting.GRAY);
|
||||||
component.appendSibling(new TextComponentString(" " + message));
|
component.appendSibling(new StringTextComponent(" " + message));
|
||||||
Minecraft.getInstance().addScheduledTask(() -> BaritoneAPI.getSettings().logger.value.accept(component));
|
Minecraft.getInstance().execute(() -> BaritoneAPI.getSettings().logger.value.accept(component));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,10 @@
|
|||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import baritone.api.cache.IWorldData;
|
import baritone.api.cache.IWorldData;
|
||||||
import net.minecraft.block.BlockSlab;
|
import net.minecraft.block.SlabBlock;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -34,7 +32,7 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
public interface IPlayerContext {
|
public interface IPlayerContext {
|
||||||
|
|
||||||
EntityPlayerSP player();
|
ClientPlayerEntity player();
|
||||||
|
|
||||||
IPlayerController playerController();
|
IPlayerController playerController();
|
||||||
|
|
||||||
@@ -47,7 +45,7 @@ public interface IPlayerContext {
|
|||||||
default BetterBlockPos playerFeet() {
|
default BetterBlockPos playerFeet() {
|
||||||
// TODO find a better way to deal with soul sand!!!!!
|
// TODO find a better way to deal with soul sand!!!!!
|
||||||
BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ);
|
BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ);
|
||||||
if (world().getBlockState(feet).getBlock() instanceof BlockSlab) {
|
if (world().getBlockState(feet).getBlock() instanceof SlabBlock) {
|
||||||
return feet.up();
|
return feet.up();
|
||||||
}
|
}
|
||||||
return feet;
|
return feet;
|
||||||
@@ -72,8 +70,8 @@ public interface IPlayerContext {
|
|||||||
*/
|
*/
|
||||||
default Optional<BlockPos> getSelectedBlock() {
|
default Optional<BlockPos> getSelectedBlock() {
|
||||||
RayTraceResult result = objectMouseOver();
|
RayTraceResult result = objectMouseOver();
|
||||||
if (result != null && result.type == RayTraceResult.Type.BLOCK) {
|
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
|
||||||
return Optional.of(result.getBlockPos());
|
return Optional.of(((BlockRayTraceResult) result).getPos());
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@@ -89,8 +87,8 @@ public interface IPlayerContext {
|
|||||||
*/
|
*/
|
||||||
default Optional<Entity> getSelectedEntity() {
|
default Optional<Entity> getSelectedEntity() {
|
||||||
RayTraceResult result = objectMouseOver();
|
RayTraceResult result = objectMouseOver();
|
||||||
if (result != null && result.type == RayTraceResult.Type.ENTITY) {
|
if (result != null && result.getType() == RayTraceResult.Type.ENTITY) {
|
||||||
return Optional.of(result.entity);
|
return Optional.of(((EntityRayTraceResult) result).getEntity());
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,13 @@
|
|||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.ClickType;
|
import net.minecraft.inventory.container.ClickType;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.GameType;
|
import net.minecraft.world.GameType;
|
||||||
@@ -35,11 +35,11 @@ import net.minecraft.world.World;
|
|||||||
*/
|
*/
|
||||||
public interface IPlayerController {
|
public interface IPlayerController {
|
||||||
|
|
||||||
boolean onPlayerDamageBlock(BlockPos pos, EnumFacing side);
|
boolean onPlayerDamageBlock(BlockPos pos, Direction side);
|
||||||
|
|
||||||
void resetBlockRemoving();
|
void resetBlockRemoving();
|
||||||
|
|
||||||
ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player);
|
ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, PlayerEntity player);
|
||||||
|
|
||||||
void setGameType(GameType type);
|
void setGameType(GameType type);
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public interface IPlayerController {
|
|||||||
return this.getGameType().isCreative() ? 5.0F : 4.5F;
|
return this.getGameType().isCreative() ? 5.0F : 4.5F;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumActionResult processRightClickBlock(EntityPlayerSP player, World world, BlockPos pos, EnumFacing direction, Vec3d vec, EnumHand hand);
|
ActionResultType processRightClickBlock(ClientPlayerEntity player, World world, BlockPos pos, Direction direction, Vec3d vec, Hand hand);
|
||||||
|
|
||||||
EnumActionResult processRightClick(EntityPlayerSP player, World world, EnumHand hand);
|
ActionResultType processRightClick(ClientPlayerEntity player, World world, Hand hand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic representation of a schematic. Provides the dimensions and
|
* Basic representation of a schematic. Provides the dimensions and
|
||||||
@@ -45,7 +45,7 @@ public interface ISchematic {
|
|||||||
return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ();
|
return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
default int size(EnumFacing.Axis axis) {
|
default int size(Direction.Axis axis) {
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
case X:
|
case X:
|
||||||
return widthX();
|
return widthX();
|
||||||
@@ -66,7 +66,7 @@ public interface ISchematic {
|
|||||||
* @param z The z position of the block, relative to the origin
|
* @param z The z position of the block, relative to the origin
|
||||||
* @return The desired block state at the specified position
|
* @return The desired block state at the specified position
|
||||||
*/
|
*/
|
||||||
IBlockState desiredState(int x, int y, int z);
|
BlockState desiredState(int x, int y, int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The width (X axis length) of this schematic
|
* @return The width (X axis length) of this schematic
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.RayTraceFluidMode;
|
import net.minecraft.util.math.RayTraceContext;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
@@ -48,6 +48,6 @@ public final class RayTraceUtils {
|
|||||||
direction.y * blockReachDistance,
|
direction.y * blockReachDistance,
|
||||||
direction.z * blockReachDistance
|
direction.z * blockReachDistance
|
||||||
);
|
);
|
||||||
return entity.world.rayTraceBlocks(start, end, RayTraceFluidMode.NEVER, false, true);
|
return entity.world.func_217299_a(new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,15 +19,12 @@ package baritone.api.utils;
|
|||||||
|
|
||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import net.minecraft.block.BlockFire;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.FireBlock;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
|
|
||||||
@@ -140,7 +137,7 @@ public final class RotationUtils {
|
|||||||
* @param ctx Context for the viewing entity
|
* @param ctx Context for the viewing entity
|
||||||
* @param pos The target block position
|
* @param pos The target block position
|
||||||
* @return The optional rotation
|
* @return The optional rotation
|
||||||
* @see #reachable(EntityPlayerSP, BlockPos, double)
|
* @see #reachable(ClientPlayerEntity, BlockPos, double)
|
||||||
*/
|
*/
|
||||||
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos) {
|
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos) {
|
||||||
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
||||||
@@ -158,7 +155,7 @@ public final class RotationUtils {
|
|||||||
* @param blockReachDistance The block reach distance of the entity
|
* @param blockReachDistance The block reach distance of the entity
|
||||||
* @return The optional rotation
|
* @return The optional rotation
|
||||||
*/
|
*/
|
||||||
public static Optional<Rotation> reachable(EntityPlayerSP entity, BlockPos pos, double blockReachDistance) {
|
public static Optional<Rotation> reachable(ClientPlayerEntity entity, BlockPos pos, double blockReachDistance) {
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
|
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
|
||||||
if (baritone.getPlayerContext().isLookingAt(pos)) {
|
if (baritone.getPlayerContext().isLookingAt(pos)) {
|
||||||
/*
|
/*
|
||||||
@@ -179,15 +176,15 @@ public final class RotationUtils {
|
|||||||
return possibleRotation;
|
return possibleRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState state = entity.world.getBlockState(pos);
|
BlockState state = entity.world.getBlockState(pos);
|
||||||
VoxelShape shape = state.getShape(entity.world, pos);
|
VoxelShape shape = state.getShape(entity.world, pos);
|
||||||
if (shape.isEmpty()) {
|
if (shape.isEmpty()) {
|
||||||
shape = VoxelShapes.fullCube();
|
shape = VoxelShapes.fullCube();
|
||||||
}
|
}
|
||||||
for (Vec3d sideOffset : BLOCK_SIDE_MULTIPLIERS) {
|
for (Vec3d sideOffset : BLOCK_SIDE_MULTIPLIERS) {
|
||||||
double xDiff = shape.getStart(EnumFacing.Axis.X) * sideOffset.x + shape.getEnd(EnumFacing.Axis.X) * (1 - sideOffset.x);
|
double xDiff = shape.getStart(Direction.Axis.X) * sideOffset.x + shape.getEnd(Direction.Axis.X) * (1 - sideOffset.x);
|
||||||
double yDiff = shape.getStart(EnumFacing.Axis.Y) * sideOffset.y + shape.getEnd(EnumFacing.Axis.Y) * (1 - sideOffset.y);
|
double yDiff = shape.getStart(Direction.Axis.Y) * sideOffset.y + shape.getEnd(Direction.Axis.Y) * (1 - sideOffset.y);
|
||||||
double zDiff = shape.getStart(EnumFacing.Axis.Z) * sideOffset.z + shape.getEnd(EnumFacing.Axis.Z) * (1 - sideOffset.z);
|
double zDiff = shape.getStart(Direction.Axis.Z) * sideOffset.z + shape.getEnd(Direction.Axis.Z) * (1 - sideOffset.z);
|
||||||
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance);
|
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance);
|
||||||
if (possibleRotation.isPresent()) {
|
if (possibleRotation.isPresent()) {
|
||||||
return possibleRotation;
|
return possibleRotation;
|
||||||
@@ -211,11 +208,11 @@ public final class RotationUtils {
|
|||||||
Rotation rotation = calcRotationFromVec3d(entity.getEyePosition(1.0F), offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
|
Rotation rotation = calcRotationFromVec3d(entity.getEyePosition(1.0F), offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
|
||||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance);
|
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance);
|
||||||
//System.out.println(result);
|
//System.out.println(result);
|
||||||
if (result != null && result.type == RayTraceResult.Type.BLOCK) {
|
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
|
||||||
if (result.getBlockPos().equals(pos)) {
|
if (((BlockRayTraceResult) result).getPos().equals(pos)) {
|
||||||
return Optional.of(rotation);
|
return Optional.of(rotation);
|
||||||
}
|
}
|
||||||
if (entity.world.getBlockState(pos).getBlock() instanceof BlockFire && result.getBlockPos().equals(pos.down())) {
|
if (entity.world.getBlockState(pos).getBlock() instanceof FireBlock && ((BlockRayTraceResult) result).getPos().equals(pos.down())) {
|
||||||
return Optional.of(rotation);
|
return Optional.of(rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import baritone.api.Settings;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.registry.IRegistry;
|
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -176,7 +176,7 @@ public class SettingsUtil {
|
|||||||
INTEGER(Integer.class, Integer::parseInt),
|
INTEGER(Integer.class, Integer::parseInt),
|
||||||
FLOAT(Float.class, Float::parseFloat),
|
FLOAT(Float.class, Float::parseFloat),
|
||||||
LONG(Long.class, Long::parseLong),
|
LONG(Long.class, Long::parseLong),
|
||||||
ENUMFACING(EnumFacing.class, EnumFacing::byName),
|
ENUMFACING(Direction.class, Direction::byName),
|
||||||
COLOR(
|
COLOR(
|
||||||
Color.class,
|
Color.class,
|
||||||
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
||||||
@@ -194,8 +194,8 @@ public class SettingsUtil {
|
|||||||
),
|
),
|
||||||
ITEM(
|
ITEM(
|
||||||
Item.class,
|
Item.class,
|
||||||
str -> IRegistry.ITEM.get(new ResourceLocation(str.trim())),
|
str -> Registry.field_212630_s.getOrDefault(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
|
||||||
item -> IRegistry.ITEM.getKey(item).toString()
|
item -> Registry.field_212630_s.getKey(item).toString()
|
||||||
),
|
),
|
||||||
LIST() {
|
LIST() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import net.minecraft.block.BlockFire;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.FireBlock;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
@@ -43,18 +43,18 @@ public final class VecUtils {
|
|||||||
* @see #getBlockPosCenter(BlockPos)
|
* @see #getBlockPosCenter(BlockPos)
|
||||||
*/
|
*/
|
||||||
public static Vec3d calculateBlockCenter(World world, BlockPos pos) {
|
public static Vec3d calculateBlockCenter(World world, BlockPos pos) {
|
||||||
IBlockState b = world.getBlockState(pos);
|
BlockState b = world.getBlockState(pos);
|
||||||
VoxelShape shape = b.getCollisionShape(world, pos);
|
VoxelShape shape = b.getCollisionShape(world, pos);
|
||||||
if (shape.isEmpty()) {
|
if (shape.isEmpty()) {
|
||||||
return getBlockPosCenter(pos);
|
return getBlockPosCenter(pos);
|
||||||
}
|
}
|
||||||
double xDiff = (shape.getStart(EnumFacing.Axis.X) + shape.getEnd(EnumFacing.Axis.X)) / 2;
|
double xDiff = (shape.getStart(Direction.Axis.X) + shape.getEnd(Direction.Axis.X)) / 2;
|
||||||
double yDiff = (shape.getStart(EnumFacing.Axis.Y) + shape.getEnd(EnumFacing.Axis.Y)) / 2;
|
double yDiff = (shape.getStart(Direction.Axis.Y) + shape.getEnd(Direction.Axis.Y)) / 2;
|
||||||
double zDiff = (shape.getStart(EnumFacing.Axis.Z) + shape.getEnd(EnumFacing.Axis.Z)) / 2;
|
double zDiff = (shape.getStart(Direction.Axis.Z) + shape.getEnd(Direction.Axis.Z)) / 2;
|
||||||
if (Double.isNaN(xDiff) || Double.isNaN(yDiff) || Double.isNaN(zDiff)) {
|
if (Double.isNaN(xDiff) || Double.isNaN(yDiff) || Double.isNaN(zDiff)) {
|
||||||
throw new IllegalStateException(b + " " + pos + " " + shape);
|
throw new IllegalStateException(b + " " + pos + " " + shape);
|
||||||
}
|
}
|
||||||
if (b.getBlock() instanceof BlockFire) {//look at bottom of fire when putting it out
|
if (b.getBlock() instanceof FireBlock) {//look at bottom of fire when putting it out
|
||||||
yDiff = 0;
|
yDiff = 0;
|
||||||
}
|
}
|
||||||
return new Vec3d(
|
return new Vec3d(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package baritone.launch.mixins;
|
|||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.event.events.RotationMoveEvent;
|
import baritone.api.event.events.RotationMoveEvent;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.ClientPlayerEntity;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
@@ -55,8 +55,8 @@ public abstract class MixinEntityLivingBase extends Entity {
|
|||||||
)
|
)
|
||||||
private void preMoveRelative(CallbackInfo ci) {
|
private void preMoveRelative(CallbackInfo ci) {
|
||||||
// noinspection ConstantConditions
|
// noinspection ConstantConditions
|
||||||
if (EntityPlayerSP.class.isInstance(this)) {
|
if (ClientPlayerEntity.class.isInstance(this)) {
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||||
if (baritone != null) {
|
if (baritone != null) {
|
||||||
this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.rotationYaw);
|
this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.rotationYaw);
|
||||||
baritone.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
|
baritone.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
|
||||||
@@ -73,7 +73,7 @@ public abstract class MixinEntityLivingBase extends Entity {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private float overrideYaw(EntityLivingBase self) {
|
private float overrideYaw(EntityLivingBase self) {
|
||||||
if (self instanceof EntityPlayerSP && BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this) != null) {
|
if (self instanceof ClientPlayerEntity && BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this) != null) {
|
||||||
return this.jumpRotationEvent.getYaw();
|
return this.jumpRotationEvent.getYaw();
|
||||||
}
|
}
|
||||||
return self.rotationYaw;
|
return self.rotationYaw;
|
||||||
@@ -88,12 +88,12 @@ public abstract class MixinEntityLivingBase extends Entity {
|
|||||||
)
|
)
|
||||||
private void travel(EntityLivingBase self, float strafe, float up, float forward, float friction) {
|
private void travel(EntityLivingBase self, float strafe, float up, float forward, float friction) {
|
||||||
// noinspection ConstantConditions
|
// noinspection ConstantConditions
|
||||||
if (!EntityPlayerSP.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this) == null) {
|
if (!ClientPlayerEntity.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this) == null) {
|
||||||
moveRelative(strafe, up, forward, friction);
|
moveRelative(strafe, up, forward, friction);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
|
RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
|
||||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent);
|
BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent);
|
||||||
float originalYaw = this.rotationYaw;
|
float originalYaw = this.rotationYaw;
|
||||||
this.rotationYaw = motionUpdateRotationEvent.getYaw();
|
this.rotationYaw = motionUpdateRotationEvent.getYaw();
|
||||||
this.moveRelative(strafe, up, forward, friction);
|
this.moveRelative(strafe, up, forward, friction);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import baritone.api.event.events.PlayerUpdateEvent;
|
|||||||
import baritone.api.event.events.SprintStateEvent;
|
import baritone.api.event.events.SprintStateEvent;
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import baritone.behavior.LookBehavior;
|
import baritone.behavior.LookBehavior;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.ClientPlayerEntity;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.entity.player.PlayerCapabilities;
|
import net.minecraft.entity.player.PlayerCapabilities;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -37,8 +37,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/1/2018
|
* @since 8/1/2018
|
||||||
*/
|
*/
|
||||||
@Mixin(EntityPlayerSP.class)
|
@Mixin(ClientPlayerEntity.class)
|
||||||
public class MixinEntityPlayerSP {
|
public class MixinClientPlayerEntity {
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "sendChatMessage",
|
method = "sendChatMessage",
|
||||||
@@ -47,7 +47,7 @@ public class MixinEntityPlayerSP {
|
|||||||
)
|
)
|
||||||
private void sendChatMessage(String msg, CallbackInfo ci) {
|
private void sendChatMessage(String msg, CallbackInfo ci) {
|
||||||
ChatEvent event = new ChatEvent(msg);
|
ChatEvent event = new ChatEvent(msg);
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||||
if (baritone == null) {
|
if (baritone == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -61,13 +61,13 @@ public class MixinEntityPlayerSP {
|
|||||||
method = "tick",
|
method = "tick",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/entity/EntityPlayerSP.isPassenger()Z",
|
target = "net/minecraft/client/entity/ClientPlayerEntity.isPassenger()Z",
|
||||||
shift = At.Shift.BY,
|
shift = At.Shift.BY,
|
||||||
by = -3
|
by = -3
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void onPreUpdate(CallbackInfo ci) {
|
private void onPreUpdate(CallbackInfo ci) {
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||||
if (baritone != null) {
|
if (baritone != null) {
|
||||||
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE));
|
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE));
|
||||||
}
|
}
|
||||||
@@ -77,13 +77,13 @@ public class MixinEntityPlayerSP {
|
|||||||
method = "tick",
|
method = "tick",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/entity/EntityPlayerSP.onUpdateWalkingPlayer()V",
|
target = "net/minecraft/client/entity/ClientPlayerEntity.onUpdateWalkingPlayer()V",
|
||||||
shift = At.Shift.BY,
|
shift = At.Shift.BY,
|
||||||
by = 2
|
by = 2
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void onPostUpdate(CallbackInfo ci) {
|
private void onPostUpdate(CallbackInfo ci) {
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||||
if (baritone != null) {
|
if (baritone != null) {
|
||||||
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
|
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ public class MixinEntityPlayerSP {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private boolean isAllowFlying(PlayerCapabilities capabilities) {
|
private boolean isAllowFlying(PlayerCapabilities capabilities) {
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||||
if (baritone == null) {
|
if (baritone == null) {
|
||||||
return capabilities.allowFlying;
|
return capabilities.allowFlying;
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ public class MixinEntityPlayerSP {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private boolean isKeyDown(KeyBinding keyBinding) {
|
private boolean isKeyDown(KeyBinding keyBinding) {
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||||
if (baritone == null) {
|
if (baritone == null) {
|
||||||
return keyBinding.isKeyDown();
|
return keyBinding.isKeyDown();
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ public class MixinEntityPlayerSP {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void updateRidden(CallbackInfo cb) {
|
private void updateRidden(CallbackInfo cb) {
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||||
if (baritone != null) {
|
if (baritone != null) {
|
||||||
((LookBehavior) baritone.getLookBehavior()).pig();
|
((LookBehavior) baritone.getLookBehavior()).pig();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ import baritone.api.event.events.WorldEvent;
|
|||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import baritone.utils.BaritoneAutoTest;
|
import baritone.utils.BaritoneAutoTest;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.ClientPlayerEntity;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.Screen;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.multiplayer.ClientWorld;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
@@ -50,9 +50,9 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|||||||
public class MixinMinecraft {
|
public class MixinMinecraft {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public EntityPlayerSP player;
|
public ClientPlayerEntity player;
|
||||||
@Shadow
|
@Shadow
|
||||||
public WorldClient world;
|
public ClientWorld world;
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "init",
|
method = "init",
|
||||||
@@ -78,7 +78,7 @@ public class MixinMinecraft {
|
|||||||
at = @At(
|
at = @At(
|
||||||
value = "FIELD",
|
value = "FIELD",
|
||||||
opcode = Opcodes.GETFIELD,
|
opcode = Opcodes.GETFIELD,
|
||||||
target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/GuiScreen;",
|
target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/Screen;",
|
||||||
ordinal = 5,
|
ordinal = 5,
|
||||||
shift = At.Shift.BY,
|
shift = At.Shift.BY,
|
||||||
by = -3
|
by = -3
|
||||||
@@ -97,10 +97,10 @@ public class MixinMinecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/gui/GuiScreen;)V",
|
method = "loadWorld(Lnet/minecraft/client/multiplayer/ClientWorld;Lnet/minecraft/client/gui/Screen;)V",
|
||||||
at = @At("HEAD")
|
at = @At("HEAD")
|
||||||
)
|
)
|
||||||
private void preLoadWorld(WorldClient world, GuiScreen loadingScreen, CallbackInfo ci) {
|
private void preLoadWorld(ClientWorld world, Screen loadingScreen, CallbackInfo ci) {
|
||||||
// If we're unloading the world but one doesn't exist, ignore it
|
// If we're unloading the world but one doesn't exist, ignore it
|
||||||
if (this.world == null && world == null) {
|
if (this.world == null && world == null) {
|
||||||
return;
|
return;
|
||||||
@@ -117,10 +117,10 @@ public class MixinMinecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/gui/GuiScreen;)V",
|
method = "loadWorld(Lnet/minecraft/client/multiplayer/ClientWorld;Lnet/minecraft/client/gui/Screen;)V",
|
||||||
at = @At("RETURN")
|
at = @At("RETURN")
|
||||||
)
|
)
|
||||||
private void postLoadWorld(WorldClient world, GuiScreen loadingScreen, CallbackInfo ci) {
|
private void postLoadWorld(ClientWorld world, Screen loadingScreen, CallbackInfo ci) {
|
||||||
// still fire event for both null, as that means we've just finished exiting a world
|
// still fire event for both null, as that means we've just finished exiting a world
|
||||||
|
|
||||||
// mc.world changing is only the primary baritone
|
// mc.world changing is only the primary baritone
|
||||||
@@ -137,10 +137,10 @@ public class MixinMinecraft {
|
|||||||
at = @At(
|
at = @At(
|
||||||
value = "FIELD",
|
value = "FIELD",
|
||||||
opcode = Opcodes.GETFIELD,
|
opcode = Opcodes.GETFIELD,
|
||||||
target = "net/minecraft/client/gui/GuiScreen.allowUserInput:Z"
|
target = "net/minecraft/client/gui/Screen.allowUserInput:Z"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private boolean isAllowUserInput(GuiScreen screen) {
|
private boolean isAllowUserInput(Screen screen) {
|
||||||
// allow user input is only the primary baritone
|
// allow user input is only the primary baritone
|
||||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.allowUserInput;
|
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.allowUserInput;
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ public class MixinMinecraft {
|
|||||||
method = "clickMouse",
|
method = "clickMouse",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z"
|
target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/Direction;)Z"
|
||||||
),
|
),
|
||||||
locals = LocalCapture.CAPTURE_FAILHARD
|
locals = LocalCapture.CAPTURE_FAILHARD
|
||||||
)
|
)
|
||||||
@@ -162,7 +162,7 @@ public class MixinMinecraft {
|
|||||||
method = "rightClickMouse",
|
method = "rightClickMouse",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/entity/EntityPlayerSP.swingArm(Lnet/minecraft/util/EnumHand;)V"
|
target = "net/minecraft/client/entity/ClientPlayerEntity.swingArm(Lnet/minecraft/util/EnumHand;)V"
|
||||||
),
|
),
|
||||||
locals = LocalCapture.CAPTURE_FAILHARD
|
locals = LocalCapture.CAPTURE_FAILHARD
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class MixinNetHandlerPlayClient {
|
|||||||
method = "handleCombatEvent",
|
method = "handleCombatEvent",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/Minecraft.displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V"
|
target = "net/minecraft/client/Minecraft.displayScreen(Lnet/minecraft/client/gui/Screen;)V"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) {
|
private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package baritone.launch.mixins;
|
|||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunkCache;
|
import net.minecraft.client.renderer.chunk.RenderChunkCache;
|
||||||
@@ -40,10 +40,10 @@ public class MixinRenderChunk {
|
|||||||
method = "rebuildChunk",
|
method = "rebuildChunk",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/renderer/chunk/RenderChunkCache.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;"
|
target = "net/minecraft/client/renderer/chunk/RenderChunkCache.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/BlockState;"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private IBlockState getBlockState(RenderChunkCache chunkCache, BlockPos pos) {
|
private BlockState getBlockState(RenderChunkCache chunkCache, BlockPos pos) {
|
||||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
IPlayerContext ctx = baritone.getPlayerContext();
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ public class Baritone implements IBaritone {
|
|||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
Helper.mc.addScheduledTask(() -> Helper.mc.displayGuiScreen(new GuiClick()));
|
Helper.mc.addScheduledTask(() -> Helper.mc.displayScreen(new GuiClick()));
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import baritone.Baritone;
|
|||||||
import baritone.api.event.events.TickEvent;
|
import baritone.api.event.events.TickEvent;
|
||||||
import baritone.utils.ToolSet;
|
import baritone.utils.ToolSet;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.ClientPlayerEntity;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.inventory.ClickType;
|
import net.minecraft.inventory.ClickType;
|
||||||
import net.minecraft.item.*;
|
import net.minecraft.item.*;
|
||||||
@@ -131,7 +131,7 @@ public final class InventoryBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
|
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
|
||||||
IBlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z);
|
BlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z);
|
||||||
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
|
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
|
||||||
return true; // gotem
|
return true; // gotem
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ public final class InventoryBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean throwaway(boolean select, Predicate<? super ItemStack> desired) {
|
public boolean throwaway(boolean select, Predicate<? super ItemStack> desired) {
|
||||||
EntityPlayerSP p = ctx.player();
|
ClientPlayerEntity p = ctx.player();
|
||||||
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
||||||
for (byte i = 0; i < 9; i++) {
|
for (byte i = 0; i < 9; i++) {
|
||||||
ItemStack item = inv.get(i);
|
ItemStack item = inv.get(i);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import net.minecraft.network.play.server.SPacketCloseWindow;
|
|||||||
import net.minecraft.network.play.server.SPacketOpenWindow;
|
import net.minecraft.network.play.server.SPacketOpenWindow;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityLockable;
|
import net.minecraft.tileentity.TileEntityLockable;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ public final class MemoryBehavior extends Behavior {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
futureInventories.stream()
|
futureInventories.stream()
|
||||||
.filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount())
|
.filter(i -> i.getType().equals(packet.getGuiId()) && i.slots == packet.getSlotCount())
|
||||||
.findFirst().ifPresent(matched -> {
|
.findFirst().ifPresent(matched -> {
|
||||||
// Remove the future inventory
|
// Remove the future inventory
|
||||||
futureInventories.remove(matched);
|
futureInventories.remove(matched);
|
||||||
@@ -201,7 +201,7 @@ public final class MemoryBehavior extends Behavior {
|
|||||||
return null; // other things that have contents, but can be placed adjacent without combining
|
return null; // other things that have contents, but can be placed adjacent without combining
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
BlockPos adj = in.offset(EnumFacing.byHorizontalIndex(i));
|
BlockPos adj = in.offset(Direction.byHorizontalIndex(i));
|
||||||
if (bsi.get0(adj).getBlock() == block) {
|
if (bsi.get0(adj).getBlock() == block) {
|
||||||
return adj;
|
return adj;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -22,7 +22,7 @@ import baritone.utils.pathing.PathingBlockType;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ public final class CachedChunk {
|
|||||||
/**
|
/**
|
||||||
* The block names of each surface level block for generating an overview
|
* The block names of each surface level block for generating an overview
|
||||||
*/
|
*/
|
||||||
private final IBlockState[] overview;
|
private final BlockState[] overview;
|
||||||
|
|
||||||
private final int[] heightMap;
|
private final int[] heightMap;
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ public final class CachedChunk {
|
|||||||
|
|
||||||
public final long cacheTimestamp;
|
public final long cacheTimestamp;
|
||||||
|
|
||||||
CachedChunk(int x, int z, BitSet data, IBlockState[] overview, Map<String, List<BlockPos>> specialBlockLocations, long cacheTimestamp) {
|
CachedChunk(int x, int z, BitSet data, BlockState[] overview, Map<String, List<BlockPos>> specialBlockLocations, long cacheTimestamp) {
|
||||||
validateSize(data);
|
validateSize(data);
|
||||||
|
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@@ -178,7 +178,7 @@ public final class CachedChunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final IBlockState getBlock(int x, int y, int z, int dimension) {
|
public final BlockState getBlock(int x, int y, int z, int dimension) {
|
||||||
int index = getPositionIndex(x, y, z);
|
int index = getPositionIndex(x, y, z);
|
||||||
PathingBlockType type = getType(index);
|
PathingBlockType type = getType(index);
|
||||||
int internalPos = z << 4 | x;
|
int internalPos = z << 4 | x;
|
||||||
@@ -225,7 +225,7 @@ public final class CachedChunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final IBlockState[] getOverview() {
|
public final BlockState[] getOverview() {
|
||||||
return overview;
|
return overview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -20,7 +20,7 @@ package baritone.cache;
|
|||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.cache.ICachedRegion;
|
import baritone.api.cache.ICachedRegion;
|
||||||
import baritone.api.utils.BlockUtils;
|
import baritone.api.utils.BlockUtils;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@@ -75,7 +75,7 @@ public final class CachedRegion implements ICachedRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final IBlockState getBlock(int x, int y, int z) {
|
public final BlockState getBlock(int x, int y, int z) {
|
||||||
CachedChunk chunk = chunks[x >> 4][z >> 4];
|
CachedChunk chunk = chunks[x >> 4][z >> 4];
|
||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
return chunk.getBlock(x & 15, y, z & 15, dimension);
|
return chunk.getBlock(x & 15, y, z & 15, dimension);
|
||||||
@@ -216,7 +216,7 @@ public final class CachedRegion implements ICachedRegion {
|
|||||||
boolean[][] present = new boolean[32][32];
|
boolean[][] present = new boolean[32][32];
|
||||||
BitSet[][] bitSets = new BitSet[32][32];
|
BitSet[][] bitSets = new BitSet[32][32];
|
||||||
Map<String, List<BlockPos>>[][] location = new Map[32][32];
|
Map<String, List<BlockPos>>[][] location = new Map[32][32];
|
||||||
IBlockState[][][] overview = new IBlockState[32][32][];
|
BlockState[][][] overview = new BlockState[32][32][];
|
||||||
long[][] cacheTimestamp = new long[32][32];
|
long[][] cacheTimestamp = new long[32][32];
|
||||||
for (int x = 0; x < 32; x++) {
|
for (int x = 0; x < 32; x++) {
|
||||||
for (int z = 0; z < 32; z++) {
|
for (int z = 0; z < 32; z++) {
|
||||||
@@ -227,7 +227,7 @@ public final class CachedRegion implements ICachedRegion {
|
|||||||
in.readFully(bytes);
|
in.readFully(bytes);
|
||||||
bitSets[x][z] = BitSet.valueOf(bytes);
|
bitSets[x][z] = BitSet.valueOf(bytes);
|
||||||
location[x][z] = new HashMap<>();
|
location[x][z] = new HashMap<>();
|
||||||
overview[x][z] = new IBlockState[256];
|
overview[x][z] = new BlockState[256];
|
||||||
present[x][z] = true;
|
present[x][z] = true;
|
||||||
break;
|
break;
|
||||||
case CHUNK_NOT_PRESENT:
|
case CHUNK_NOT_PRESENT:
|
||||||
|
|||||||
+6
-6
@@ -21,7 +21,7 @@ import baritone.api.utils.BlockUtils;
|
|||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.utils.pathing.PathingBlockType;
|
import baritone.utils.pathing.PathingBlockType;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
@@ -59,7 +59,7 @@ public final class ChunkPacker {
|
|||||||
// since a bitset is initialized to all zero, and air is saved as zeros
|
// since a bitset is initialized to all zero, and air is saved as zeros
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BlockStateContainer<IBlockState> bsc = extendedblockstorage.getData();
|
BlockStateContainer<BlockState> bsc = extendedblockstorage.getData();
|
||||||
int yReal = y0 << 4;
|
int yReal = y0 << 4;
|
||||||
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
||||||
// for better cache locality, iterate in that order
|
// for better cache locality, iterate in that order
|
||||||
@@ -68,7 +68,7 @@ public final class ChunkPacker {
|
|||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
int index = CachedChunk.getPositionIndex(x, y, z);
|
int index = CachedChunk.getPositionIndex(x, y, z);
|
||||||
IBlockState state = bsc.get(x, y1, z);
|
BlockState state = bsc.get(x, y1, z);
|
||||||
boolean[] bits = getPathingBlockType(state, chunk, x, y, z).getBits();
|
boolean[] bits = getPathingBlockType(state, chunk, x, y, z).getBits();
|
||||||
bitSet.set(index, bits[0]);
|
bitSet.set(index, bits[0]);
|
||||||
bitSet.set(index + 1, bits[1]);
|
bitSet.set(index + 1, bits[1]);
|
||||||
@@ -86,7 +86,7 @@ public final class ChunkPacker {
|
|||||||
}
|
}
|
||||||
//long end = System.nanoTime() / 1000000L;
|
//long end = System.nanoTime() / 1000000L;
|
||||||
//System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z);
|
//System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z);
|
||||||
IBlockState[] blocks = new IBlockState[256];
|
BlockState[] blocks = new BlockState[256];
|
||||||
|
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html
|
https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html
|
||||||
@@ -104,7 +104,7 @@ public final class ChunkPacker {
|
|||||||
return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks, System.currentTimeMillis());
|
return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PathingBlockType getPathingBlockType(IBlockState state, Chunk chunk, int x, int y, int z) {
|
private static PathingBlockType getPathingBlockType(BlockState state, Chunk chunk, int x, int y, int z) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (MovementHelper.isWater(state)) {
|
if (MovementHelper.isWater(state)) {
|
||||||
// only water source blocks are plausibly usable, flowing water should be avoid
|
// only water source blocks are plausibly usable, flowing water should be avoid
|
||||||
@@ -144,7 +144,7 @@ public final class ChunkPacker {
|
|||||||
return PathingBlockType.SOLID;
|
return PathingBlockType.SOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBlockState pathingTypeToBlock(PathingBlockType type, int dimension) {
|
public static BlockState pathingTypeToBlock(PathingBlockType type, int dimension) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AIR:
|
case AIR:
|
||||||
return Blocks.AIR.getDefaultState();
|
return Blocks.AIR.getDefaultState();
|
||||||
|
|||||||
+3
-3
@@ -20,7 +20,7 @@ package baritone.cache;
|
|||||||
import baritone.api.cache.IWorldScanner;
|
import baritone.api.cache.IWorldScanner;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.ChunkPos;
|
import net.minecraft.util.math.ChunkPos;
|
||||||
@@ -119,13 +119,13 @@ public enum WorldScanner implements IWorldScanner {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int yReal = y0 << 4;
|
int yReal = y0 << 4;
|
||||||
BlockStateContainer<IBlockState> bsc = extendedblockstorage.getData();
|
BlockStateContainer<BlockState> bsc = extendedblockstorage.getData();
|
||||||
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
||||||
// for better cache locality, iterate in that order
|
// for better cache locality, iterate in that order
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
IBlockState state = bsc.get(x, y, z);
|
BlockState state = bsc.get(x, y, z);
|
||||||
if (search.contains(state.getBlock())) {
|
if (search.contains(state.getBlock())) {
|
||||||
int yy = yReal | y;
|
int yy = yReal | y;
|
||||||
if (result.size() >= max) {
|
if (result.size() >= max) {
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import baritone.utils.BlockStateInterface;
|
|||||||
import baritone.utils.ToolSet;
|
import baritone.utils.ToolSet;
|
||||||
import baritone.utils.pathing.BetterWorldBorder;
|
import baritone.utils.pathing.BetterWorldBorder;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.ClientPlayerEntity;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
@@ -77,7 +77,7 @@ public class CalculationContext {
|
|||||||
public CalculationContext(IBaritone baritone, boolean forUseOnAnotherThread) {
|
public CalculationContext(IBaritone baritone, boolean forUseOnAnotherThread) {
|
||||||
this.safeForThreadedUse = forUseOnAnotherThread;
|
this.safeForThreadedUse = forUseOnAnotherThread;
|
||||||
this.baritone = baritone;
|
this.baritone = baritone;
|
||||||
EntityPlayerSP player = baritone.getPlayerContext().player();
|
ClientPlayerEntity player = baritone.getPlayerContext().player();
|
||||||
this.world = baritone.getPlayerContext().world();
|
this.world = baritone.getPlayerContext().world();
|
||||||
this.worldData = (WorldData) baritone.getWorldProvider().getCurrentWorld();
|
this.worldData = (WorldData) baritone.getWorldProvider().getCurrentWorld();
|
||||||
this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread);
|
this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread);
|
||||||
@@ -115,7 +115,7 @@ public class CalculationContext {
|
|||||||
return baritone;
|
return baritone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBlockState get(int x, int y, int z) {
|
public BlockState get(int x, int y, int z) {
|
||||||
return bsi.get0(x, y, z); // laughs maniacally
|
return bsi.get0(x, y, z); // laughs maniacally
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public class CalculationContext {
|
|||||||
return bsi.isLoaded(x, z);
|
return bsi.isLoaded(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBlockState get(BlockPos pos) {
|
public BlockState get(BlockPos pos) {
|
||||||
return get(pos.getX(), pos.getY(), pos.getZ());
|
return get(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import baritone.api.utils.*;
|
|||||||
import baritone.api.utils.input.Input;
|
import baritone.api.utils.input.Input;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import net.minecraft.entity.item.EntityFallingBlock;
|
import net.minecraft.entity.item.EntityFallingBlock;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public abstract class Movement implements IMovement, MovementHelper {
|
public abstract class Movement implements IMovement, MovementHelper {
|
||||||
|
|
||||||
public static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN};
|
public static final Direction[] HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP = {Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST, Direction.DOWN};
|
||||||
|
|
||||||
protected final IBaritone baritone;
|
protected final IBaritone baritone;
|
||||||
protected final IPlayerContext ctx;
|
protected final IPlayerContext ctx;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import baritone.pathing.movement.MovementState.MovementTarget;
|
|||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.ToolSet;
|
import baritone.utils.ToolSet;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.fluid.FlowingFluid;
|
import net.minecraft.fluid.FlowingFluid;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.fluid.IFluidState;
|
import net.minecraft.fluid.IFluidState;
|
||||||
@@ -37,7 +37,7 @@ import net.minecraft.init.Fluids;
|
|||||||
import net.minecraft.pathfinding.PathType;
|
import net.minecraft.pathfinding.PathType;
|
||||||
import net.minecraft.state.BooleanProperty;
|
import net.minecraft.state.BooleanProperty;
|
||||||
import net.minecraft.state.properties.SlabType;
|
import net.minecraft.state.properties.SlabType;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
@@ -53,7 +53,7 @@ import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____S
|
|||||||
*/
|
*/
|
||||||
public interface MovementHelper extends ActionCosts, Helper {
|
public interface MovementHelper extends ActionCosts, Helper {
|
||||||
|
|
||||||
static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||||
Block b = state.getBlock();
|
Block b = state.getBlock();
|
||||||
return b == Blocks.ICE // ice becomes water, and water can mess up the path
|
return b == Blocks.ICE // ice becomes water, and water can mess up the path
|
||||||
|| b instanceof BlockSilverfish // obvious reasons
|
|| b instanceof BlockSilverfish // obvious reasons
|
||||||
@@ -69,7 +69,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
// returns true if you should avoid breaking a block that's adjacent to this one (e.g. lava that will start flowing if you give it a path)
|
// returns true if you should avoid breaking a block that's adjacent to this one (e.g. lava that will start flowing if you give it a path)
|
||||||
// this is only called for north, south, east, west, and up. this is NOT called for down.
|
// this is only called for north, south, east, west, and up. this is NOT called for down.
|
||||||
// we assume that it's ALWAYS okay to break the block thats ABOVE liquid
|
// we assume that it's ALWAYS okay to break the block thats ABOVE liquid
|
||||||
IBlockState state = bsi.get0(x, y, z);
|
BlockState state = bsi.get0(x, y, z);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (!directlyAbove // it is fine to mine a block that has a falling block directly above, this (the cost of breaking the stacked fallings) is included in cost calculations
|
if (!directlyAbove // it is fine to mine a block that has a falling block directly above, this (the cost of breaking the stacked fallings) is included in cost calculations
|
||||||
// therefore if directlyAbove is true, we will actually ignore if this is falling
|
// therefore if directlyAbove is true, we will actually ignore if this is falling
|
||||||
@@ -89,7 +89,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return canWalkThrough(bsi, x, y, z, bsi.get0(x, y, z));
|
return canWalkThrough(bsi, x, y, z, bsi.get0(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof BlockAir) { // early return for most common case
|
if (block instanceof BlockAir) { // early return for most common case
|
||||||
return true;
|
return true;
|
||||||
@@ -133,7 +133,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (Baritone.settings().assumeWalkOnWater.value) {
|
if (Baritone.settings().assumeWalkOnWater.value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IBlockState up = bsi.get0(x, y + 1, z);
|
BlockState up = bsi.get0(x, y + 1, z);
|
||||||
if (!up.getFluidState().isEmpty() || up.getBlock() instanceof BlockLilyPad) {
|
if (!up.getFluidState().isEmpty() || up.getBlock() instanceof BlockLilyPad) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return fullyPassable(context.get(x, y, z));
|
return fullyPassable(context.get(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean fullyPassable(IBlockState state) {
|
static boolean fullyPassable(BlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof BlockAir) { // early return for most common case
|
if (block instanceof BlockAir) { // early return for most common case
|
||||||
return true;
|
return true;
|
||||||
@@ -185,7 +185,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return state.allowsMovement(null, null, PathType.LAND);
|
return state.allowsMovement(null, null, PathType.LAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isReplacable(int x, int y, int z, IBlockState state, BlockStateInterface bsi) {
|
static boolean isReplacable(int x, int y, int z, BlockState state, BlockStateInterface bsi) {
|
||||||
// for MovementTraverse and MovementAscend
|
// for MovementTraverse and MovementAscend
|
||||||
// block double plant defaults to true when the block doesn't match, so don't need to check that case
|
// block double plant defaults to true when the block doesn't match, so don't need to check that case
|
||||||
// all other overrides just return true or false
|
// all other overrides just return true or false
|
||||||
@@ -219,7 +219,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState state = BlockStateInterface.get(ctx, doorPos);
|
BlockState state = BlockStateInterface.get(ctx, doorPos);
|
||||||
if (!(state.getBlock() instanceof BlockDoor)) {
|
if (!(state.getBlock() instanceof BlockDoor)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState state = BlockStateInterface.get(ctx, gatePos);
|
BlockState state = BlockStateInterface.get(ctx, gatePos);
|
||||||
if (!(state.getBlock() instanceof BlockFenceGate)) {
|
if (!(state.getBlock() instanceof BlockFenceGate)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -240,19 +240,19 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return state.get(BlockFenceGate.OPEN);
|
return state.get(BlockFenceGate.OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isHorizontalBlockPassable(BlockPos blockPos, IBlockState blockState, BlockPos playerPos, BooleanProperty propertyOpen) {
|
static boolean isHorizontalBlockPassable(BlockPos blockPos, BlockState blockState, BlockPos playerPos, BooleanProperty propertyOpen) {
|
||||||
if (playerPos.equals(blockPos)) {
|
if (playerPos.equals(blockPos)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumFacing.Axis facing = blockState.get(BlockHorizontal.HORIZONTAL_FACING).getAxis();
|
Direction.Axis facing = blockState.get(BlockHorizontal.HORIZONTAL_FACING).getAxis();
|
||||||
boolean open = blockState.get(propertyOpen);
|
boolean open = blockState.get(propertyOpen);
|
||||||
|
|
||||||
EnumFacing.Axis playerFacing;
|
Direction.Axis playerFacing;
|
||||||
if (playerPos.north().equals(blockPos) || playerPos.south().equals(blockPos)) {
|
if (playerPos.north().equals(blockPos) || playerPos.south().equals(blockPos)) {
|
||||||
playerFacing = EnumFacing.Axis.Z;
|
playerFacing = Direction.Axis.Z;
|
||||||
} else if (playerPos.east().equals(blockPos) || playerPos.west().equals(blockPos)) {
|
} else if (playerPos.east().equals(blockPos) || playerPos.west().equals(blockPos)) {
|
||||||
playerFacing = EnumFacing.Axis.X;
|
playerFacing = Direction.Axis.X;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return (facing == playerFacing) == open;
|
return (facing == playerFacing) == open;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean avoidWalkingInto(IBlockState state) {
|
static boolean avoidWalkingInto(BlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
return !state.getFluidState().isEmpty()
|
return !state.getFluidState().isEmpty()
|
||||||
|| block == Blocks.MAGMA_BLOCK
|
|| block == Blocks.MAGMA_BLOCK
|
||||||
@@ -283,7 +283,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* @param state The state of the block at the specified location
|
* @param state The state of the block at the specified location
|
||||||
* @return Whether or not the specified block can be walked on
|
* @return Whether or not the specified block can be walked on
|
||||||
*/
|
*/
|
||||||
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof BlockAir || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN) {
|
if (block instanceof BlockAir || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN) {
|
||||||
// early return for most common case (air)
|
// early return for most common case (air)
|
||||||
@@ -305,7 +305,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (isWater(state)) {
|
if (isWater(state)) {
|
||||||
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
||||||
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
||||||
IBlockState upState = bsi.get0(x, y + 1, z);
|
BlockState upState = bsi.get0(x, y + 1, z);
|
||||||
Block up = upState.getBlock();
|
Block up = upState.getBlock();
|
||||||
if (up == Blocks.LILY_PAD || up instanceof BlockCarpet) {
|
if (up == Blocks.LILY_PAD || up instanceof BlockCarpet) {
|
||||||
return true;
|
return true;
|
||||||
@@ -333,7 +333,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return block instanceof BlockStairs;
|
return block instanceof BlockStairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkOn(IPlayerContext ctx, BetterBlockPos pos, IBlockState state) {
|
static boolean canWalkOn(IPlayerContext ctx, BetterBlockPos pos, BlockState state) {
|
||||||
return canWalkOn(new BlockStateInterface(ctx), pos.x, pos.y, pos.z, state);
|
return canWalkOn(new BlockStateInterface(ctx), pos.x, pos.y, pos.z, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,7 +361,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return canPlaceAgainst(new BlockStateInterface(ctx), pos);
|
return canPlaceAgainst(new BlockStateInterface(ctx), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||||
// can we look at the center of a side face of this block and likely be able to place?
|
// can we look at the center of a side face of this block and likely be able to place?
|
||||||
// (thats how this check is used)
|
// (thats how this check is used)
|
||||||
// therefore dont include weird things that we technically could place against (like carpet) but practically can't
|
// therefore dont include weird things that we technically could place against (like carpet) but practically can't
|
||||||
@@ -372,7 +372,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return getMiningDurationTicks(context, x, y, z, context.get(x, y, z), includeFalling);
|
return getMiningDurationTicks(context, x, y, z, context.get(x, y, z), includeFalling);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, IBlockState state, boolean includeFalling) {
|
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, BlockState state, boolean includeFalling) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (!canWalkThrough(context.bsi, x, y, z, state)) {
|
if (!canWalkThrough(context.bsi, x, y, z, state)) {
|
||||||
if (!state.getFluidState().isEmpty()) {
|
if (!state.getFluidState().isEmpty()) {
|
||||||
@@ -393,7 +393,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
result += context.breakBlockAdditionalCost;
|
result += context.breakBlockAdditionalCost;
|
||||||
result *= mult;
|
result *= mult;
|
||||||
if (includeFalling) {
|
if (includeFalling) {
|
||||||
IBlockState above = context.get(x, y + 1, z);
|
BlockState above = context.get(x, y + 1, z);
|
||||||
if (above.getBlock() instanceof BlockFalling) {
|
if (above.getBlock() instanceof BlockFalling) {
|
||||||
result += getMiningDurationTicks(context, x, y + 1, z, above, true);
|
result += getMiningDurationTicks(context, x, y + 1, z, above, true);
|
||||||
}
|
}
|
||||||
@@ -403,7 +403,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return 0; // we won't actually mine it, so don't check fallings above
|
return 0; // we won't actually mine it, so don't check fallings above
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isBottomSlab(IBlockState state) {
|
static boolean isBottomSlab(BlockState state) {
|
||||||
return state.getBlock() instanceof BlockSlab
|
return state.getBlock() instanceof BlockSlab
|
||||||
&& state.get(BlockSlab.TYPE) == SlabType.BOTTOM;
|
&& state.get(BlockSlab.TYPE) == SlabType.BOTTOM;
|
||||||
}
|
}
|
||||||
@@ -414,7 +414,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* @param ctx The player context
|
* @param ctx The player context
|
||||||
* @param b the blockstate to mine
|
* @param b the blockstate to mine
|
||||||
*/
|
*/
|
||||||
static void switchToBestToolFor(IPlayerContext ctx, IBlockState b) {
|
static void switchToBestToolFor(IPlayerContext ctx, BlockState b) {
|
||||||
switchToBestToolFor(ctx, b, new ToolSet(ctx.player()));
|
switchToBestToolFor(ctx, b, new ToolSet(ctx.player()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,7 +425,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* @param b the blockstate to mine
|
* @param b the blockstate to mine
|
||||||
* @param ts previously calculated ToolSet
|
* @param ts previously calculated ToolSet
|
||||||
*/
|
*/
|
||||||
static void switchToBestToolFor(IPlayerContext ctx, IBlockState b, ToolSet ts) {
|
static void switchToBestToolFor(IPlayerContext ctx, BlockState b, ToolSet ts) {
|
||||||
ctx.player().inventory.currentItem = ts.getBestSlot(b.getBlock());
|
ctx.player().inventory.currentItem = ts.getBestSlot(b.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,7 +445,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* @param state The block state
|
* @param state The block state
|
||||||
* @return Whether or not the block is water
|
* @return Whether or not the block is water
|
||||||
*/
|
*/
|
||||||
static boolean isWater(IBlockState state) {
|
static boolean isWater(BlockState state) {
|
||||||
Fluid f = state.getFluidState().getFluid();
|
Fluid f = state.getFluidState().getFluid();
|
||||||
return f == Fluids.WATER || f == Fluids.FLOWING_WATER;
|
return f == Fluids.WATER || f == Fluids.FLOWING_WATER;
|
||||||
}
|
}
|
||||||
@@ -462,7 +462,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return isWater(BlockStateInterface.get(ctx, bp));
|
return isWater(BlockStateInterface.get(ctx, bp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isLava(IBlockState state) {
|
static boolean isLava(BlockState state) {
|
||||||
Fluid f = state.getFluidState().getFluid();
|
Fluid f = state.getFluidState().getFluid();
|
||||||
return f == Fluids.LAVA || f == Fluids.FLOWING_LAVA;
|
return f == Fluids.LAVA || f == Fluids.FLOWING_LAVA;
|
||||||
}
|
}
|
||||||
@@ -478,17 +478,17 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return isLiquid(BlockStateInterface.get(ctx, p));
|
return isLiquid(BlockStateInterface.get(ctx, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isLiquid(IBlockState blockState) {
|
static boolean isLiquid(BlockState blockState) {
|
||||||
return !blockState.getFluidState().isEmpty();
|
return !blockState.getFluidState().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean possiblyFlowing(IBlockState state) {
|
static boolean possiblyFlowing(BlockState state) {
|
||||||
IFluidState fluidState = state.getFluidState();
|
IFluidState fluidState = state.getFluidState();
|
||||||
return fluidState.getFluid() instanceof FlowingFluid
|
return fluidState.getFluid() instanceof FlowingFluid
|
||||||
&& fluidState.getFluid().getLevel(fluidState) != 8;
|
&& fluidState.getFluid().getLevel(fluidState) != 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isFlowing(int x, int y, int z, IBlockState state, BlockStateInterface bsi) {
|
static boolean isFlowing(int x, int y, int z, BlockState state, BlockStateInterface bsi) {
|
||||||
IFluidState fluidState = state.getFluidState();
|
IFluidState fluidState = state.getFluidState();
|
||||||
if (!(fluidState.getFluid() instanceof FlowingFluid)) {
|
if (!(fluidState.getFluid() instanceof FlowingFluid)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -524,7 +524,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D;
|
double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D;
|
||||||
Rotation place = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
|
Rotation place = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
|
||||||
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance());
|
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance());
|
||||||
if (res != null && res.type == RayTraceResult.Type.BLOCK && res.getBlockPos().equals(against1) && res.getBlockPos().offset(res.sideHit).equals(placeAt)) {
|
if (res != null && res.getType() == RayTraceResult.Type.BLOCK && res.getBlockPos().equals(against1) && res.getBlockPos().offset(res.sideHit).equals(placeAt)) {
|
||||||
state.setTarget(new MovementState.MovementTarget(place, true));
|
state.setTarget(new MovementState.MovementTarget(place, true));
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
@@ -538,7 +538,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
}
|
}
|
||||||
if (ctx.getSelectedBlock().isPresent()) {
|
if (ctx.getSelectedBlock().isPresent()) {
|
||||||
BlockPos selectedBlock = ctx.getSelectedBlock().get();
|
BlockPos selectedBlock = ctx.getSelectedBlock().get();
|
||||||
EnumFacing side = ctx.objectMouseOver().sideHit;
|
Direction side = ctx.objectMouseOver().sideHit;
|
||||||
// only way for selectedBlock.equals(placeAt) to be true is if it's replacable
|
// only way for selectedBlock.equals(placeAt) to be true is if it's replacable
|
||||||
if (selectedBlock.equals(placeAt) || (MovementHelper.canPlaceAgainst(ctx, selectedBlock) && selectedBlock.offset(side).equals(placeAt))) {
|
if (selectedBlock.equals(placeAt) || (MovementHelper.canPlaceAgainst(ctx, selectedBlock) && selectedBlock.offset(side).equals(placeAt))) {
|
||||||
((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ());
|
((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ());
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package baritone.pathing.movement;
|
|||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import baritone.pathing.movement.movements.*;
|
import baritone.pathing.movement.movements.*;
|
||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enum of all possible movements attached to all possible directions they could be taken in
|
* An enum of all possible movements attached to all possible directions they could be taken in
|
||||||
@@ -225,7 +225,7 @@ public enum Moves {
|
|||||||
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
||||||
MutableMoveResult res = new MutableMoveResult();
|
MutableMoveResult res = new MutableMoveResult();
|
||||||
apply(context, src.x, src.y, src.z, res);
|
apply(context, src.x, src.y, src.z, res);
|
||||||
return new MovementDiagonal(context.getBaritone(), src, EnumFacing.NORTH, EnumFacing.EAST, res.y - src.y);
|
return new MovementDiagonal(context.getBaritone(), src, Direction.NORTH, Direction.EAST, res.y - src.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -239,7 +239,7 @@ public enum Moves {
|
|||||||
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
||||||
MutableMoveResult res = new MutableMoveResult();
|
MutableMoveResult res = new MutableMoveResult();
|
||||||
apply(context, src.x, src.y, src.z, res);
|
apply(context, src.x, src.y, src.z, res);
|
||||||
return new MovementDiagonal(context.getBaritone(), src, EnumFacing.NORTH, EnumFacing.WEST, res.y - src.y);
|
return new MovementDiagonal(context.getBaritone(), src, Direction.NORTH, Direction.WEST, res.y - src.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -253,7 +253,7 @@ public enum Moves {
|
|||||||
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
||||||
MutableMoveResult res = new MutableMoveResult();
|
MutableMoveResult res = new MutableMoveResult();
|
||||||
apply(context, src.x, src.y, src.z, res);
|
apply(context, src.x, src.y, src.z, res);
|
||||||
return new MovementDiagonal(context.getBaritone(), src, EnumFacing.SOUTH, EnumFacing.EAST, res.y - src.y);
|
return new MovementDiagonal(context.getBaritone(), src, Direction.SOUTH, Direction.EAST, res.y - src.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -267,7 +267,7 @@ public enum Moves {
|
|||||||
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
||||||
MutableMoveResult res = new MutableMoveResult();
|
MutableMoveResult res = new MutableMoveResult();
|
||||||
apply(context, src.x, src.y, src.z, res);
|
apply(context, src.x, src.y, src.z, res);
|
||||||
return new MovementDiagonal(context.getBaritone(), src, EnumFacing.SOUTH, EnumFacing.WEST, res.y - src.y);
|
return new MovementDiagonal(context.getBaritone(), src, Direction.SOUTH, Direction.WEST, res.y - src.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -279,48 +279,48 @@ public enum Moves {
|
|||||||
PARKOUR_NORTH(0, 0, -4, true, false) {
|
PARKOUR_NORTH(0, 0, -4, true, false) {
|
||||||
@Override
|
@Override
|
||||||
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
||||||
return MovementParkour.cost(context, src, EnumFacing.NORTH);
|
return MovementParkour.cost(context, src, Direction.NORTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(CalculationContext context, int x, int y, int z, MutableMoveResult result) {
|
public void apply(CalculationContext context, int x, int y, int z, MutableMoveResult result) {
|
||||||
MovementParkour.cost(context, x, y, z, EnumFacing.NORTH, result);
|
MovementParkour.cost(context, x, y, z, Direction.NORTH, result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
PARKOUR_SOUTH(0, 0, +4, true, false) {
|
PARKOUR_SOUTH(0, 0, +4, true, false) {
|
||||||
@Override
|
@Override
|
||||||
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
||||||
return MovementParkour.cost(context, src, EnumFacing.SOUTH);
|
return MovementParkour.cost(context, src, Direction.SOUTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(CalculationContext context, int x, int y, int z, MutableMoveResult result) {
|
public void apply(CalculationContext context, int x, int y, int z, MutableMoveResult result) {
|
||||||
MovementParkour.cost(context, x, y, z, EnumFacing.SOUTH, result);
|
MovementParkour.cost(context, x, y, z, Direction.SOUTH, result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
PARKOUR_EAST(+4, 0, 0, true, false) {
|
PARKOUR_EAST(+4, 0, 0, true, false) {
|
||||||
@Override
|
@Override
|
||||||
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
||||||
return MovementParkour.cost(context, src, EnumFacing.EAST);
|
return MovementParkour.cost(context, src, Direction.EAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(CalculationContext context, int x, int y, int z, MutableMoveResult result) {
|
public void apply(CalculationContext context, int x, int y, int z, MutableMoveResult result) {
|
||||||
MovementParkour.cost(context, x, y, z, EnumFacing.EAST, result);
|
MovementParkour.cost(context, x, y, z, Direction.EAST, result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
PARKOUR_WEST(-4, 0, 0, true, false) {
|
PARKOUR_WEST(-4, 0, 0, true, false) {
|
||||||
@Override
|
@Override
|
||||||
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
public Movement apply0(CalculationContext context, BetterBlockPos src) {
|
||||||
return MovementParkour.cost(context, src, EnumFacing.WEST);
|
return MovementParkour.cost(context, src, Direction.WEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(CalculationContext context, int x, int y, int z, MutableMoveResult result) {
|
public void apply(CalculationContext context, int x, int y, int z, MutableMoveResult result) {
|
||||||
MovementParkour.cost(context, x, y, z, EnumFacing.WEST, result);
|
MovementParkour.cost(context, x, y, z, Direction.WEST, result);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ import baritone.pathing.movement.MovementHelper;
|
|||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import net.minecraft.block.BlockFalling;
|
import net.minecraft.block.BlockFalling;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class MovementAscend extends Movement {
|
public class MovementAscend extends Movement {
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class MovementAscend extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||||
IBlockState toPlace = context.get(destX, y, destZ);
|
BlockState toPlace = context.get(destX, y, destZ);
|
||||||
double additionalPlacementCost = 0;
|
double additionalPlacementCost = 0;
|
||||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y, destZ, toPlace)) {
|
if (!MovementHelper.canWalkOn(context.bsi, destX, y, destZ, toPlace)) {
|
||||||
additionalPlacementCost = context.costOfPlacingAt(destX, y, destZ);
|
additionalPlacementCost = context.costOfPlacingAt(destX, y, destZ);
|
||||||
@@ -79,7 +79,7 @@ public class MovementAscend extends Movement {
|
|||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IBlockState srcUp2 = context.get(x, y + 2, z); // used lower down anyway
|
BlockState srcUp2 = context.get(x, y + 2, z); // used lower down anyway
|
||||||
if (context.get(x, y + 3, z).getBlock() instanceof BlockFalling && (MovementHelper.canWalkThrough(context.bsi, x, y + 1, z) || !(srcUp2.getBlock() instanceof BlockFalling))) {//it would fall on us and possibly suffocate us
|
if (context.get(x, y + 3, z).getBlock() instanceof BlockFalling && (MovementHelper.canWalkThrough(context.bsi, x, y + 1, z) || !(srcUp2.getBlock() instanceof BlockFalling))) {//it would fall on us and possibly suffocate us
|
||||||
// HOWEVER, we assume that we're standing in the start position
|
// HOWEVER, we assume that we're standing in the start position
|
||||||
// that means that src and src.up(1) are both air
|
// that means that src and src.up(1) are both air
|
||||||
@@ -98,7 +98,7 @@ public class MovementAscend extends Movement {
|
|||||||
// it's possible srcUp is AIR from the start, and srcUp2 is falling
|
// it's possible srcUp is AIR from the start, and srcUp2 is falling
|
||||||
// and in that scenario, when we arrive and break srcUp2, that lets srcUp3 fall on us and suffocate us
|
// and in that scenario, when we arrive and break srcUp2, that lets srcUp3 fall on us and suffocate us
|
||||||
}
|
}
|
||||||
IBlockState srcDown = context.get(x, y - 1, z);
|
BlockState srcDown = context.get(x, y - 1, z);
|
||||||
if (srcDown.getBlock() == Blocks.LADDER || srcDown.getBlock() == Blocks.VINE) {
|
if (srcDown.getBlock() == Blocks.LADDER || srcDown.getBlock() == Blocks.VINE) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ public class MovementAscend extends Movement {
|
|||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
|
BlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
|
||||||
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
|
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
|
||||||
ticksWithoutPlacement++;
|
ticksWithoutPlacement++;
|
||||||
if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false) == PlaceResult.READY_TO_PLACE) {
|
if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false) == PlaceResult.READY_TO_PLACE) {
|
||||||
@@ -211,7 +211,7 @@ public class MovementAscend extends Movement {
|
|||||||
public boolean headBonkClear() {
|
public boolean headBonkClear() {
|
||||||
BetterBlockPos startUp = src.up(2);
|
BetterBlockPos startUp = src.up(2);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
BetterBlockPos check = startUp.offset(EnumFacing.byHorizontalIndex(i));
|
BetterBlockPos check = startUp.offset(Direction.byHorizontalIndex(i));
|
||||||
if (!MovementHelper.canWalkThrough(ctx, check)) {
|
if (!MovementHelper.canWalkThrough(ctx, check)) {
|
||||||
// We might bonk our head
|
// We might bonk our head
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ import baritone.utils.BlockStateInterface;
|
|||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockFalling;
|
import net.minecraft.block.BlockFalling;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.ClientPlayerEntity;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
@@ -63,7 +63,7 @@ public class MovementDescend extends Movement {
|
|||||||
|
|
||||||
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
||||||
double totalCost = 0;
|
double totalCost = 0;
|
||||||
IBlockState destDown = context.get(destX, y - 1, destZ);
|
BlockState destDown = context.get(destX, y - 1, destZ);
|
||||||
totalCost += MovementHelper.getMiningDurationTicks(context, destX, y - 1, destZ, destDown, false);
|
totalCost += MovementHelper.getMiningDurationTicks(context, destX, y - 1, destZ, destDown, false);
|
||||||
if (totalCost >= COST_INF) {
|
if (totalCost >= COST_INF) {
|
||||||
return;
|
return;
|
||||||
@@ -92,7 +92,7 @@ public class MovementDescend extends Movement {
|
|||||||
//A is plausibly breakable by either descend or fall
|
//A is plausibly breakable by either descend or fall
|
||||||
//C, D, etc determine the length of the fall
|
//C, D, etc determine the length of the fall
|
||||||
|
|
||||||
IBlockState below = context.get(destX, y - 2, destZ);
|
BlockState below = context.get(destX, y - 2, destZ);
|
||||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 2, destZ, below)) {
|
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 2, destZ, below)) {
|
||||||
dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below, res);
|
dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below, res);
|
||||||
return;
|
return;
|
||||||
@@ -115,7 +115,7 @@ public class MovementDescend extends Movement {
|
|||||||
res.cost = totalCost;
|
res.cost = totalCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below, MutableMoveResult res) {
|
public static boolean dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, BlockState below, MutableMoveResult res) {
|
||||||
if (frontBreak != 0 && context.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) {
|
if (frontBreak != 0 && context.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) {
|
||||||
// if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall
|
// if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall
|
||||||
// but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column,
|
// but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column,
|
||||||
@@ -134,7 +134,7 @@ public class MovementDescend extends Movement {
|
|||||||
// this check prevents it from getting the block at y=-1 and crashing
|
// this check prevents it from getting the block at y=-1 and crashing
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IBlockState ontoBlock = context.get(destX, newY, destZ);
|
BlockState ontoBlock = context.get(destX, newY, destZ);
|
||||||
int unprotectedFallHeight = fallHeight - (y - effectiveStartHeight); // equal to fallHeight - y + effectiveFallHeight, which is equal to -newY + effectiveFallHeight, which is equal to effectiveFallHeight - newY
|
int unprotectedFallHeight = fallHeight - (y - effectiveStartHeight); // equal to fallHeight - y + effectiveFallHeight, which is equal to -newY + effectiveFallHeight, which is equal to effectiveFallHeight - newY
|
||||||
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[unprotectedFallHeight] + frontBreak + costSoFar;
|
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[unprotectedFallHeight] + frontBreak + costSoFar;
|
||||||
if (MovementHelper.isWater(ontoBlock)) {
|
if (MovementHelper.isWater(ontoBlock)) {
|
||||||
@@ -214,7 +214,7 @@ public class MovementDescend extends Movement {
|
|||||||
if (safeMode()) {
|
if (safeMode()) {
|
||||||
double destX = (src.getX() + 0.5) * 0.17 + (dest.getX() + 0.5) * 0.83;
|
double destX = (src.getX() + 0.5) * 0.17 + (dest.getX() + 0.5) * 0.83;
|
||||||
double destZ = (src.getZ() + 0.5) * 0.17 + (dest.getZ() + 0.5) * 0.83;
|
double destZ = (src.getZ() + 0.5) * 0.17 + (dest.getZ() + 0.5) * 0.83;
|
||||||
EntityPlayerSP player = ctx.player();
|
ClientPlayerEntity player = ctx.player();
|
||||||
state.setTarget(new MovementState.MovementTarget(
|
state.setTarget(new MovementState.MovementTarget(
|
||||||
new Rotation(RotationUtils.calcRotationFromVec3d(player.getEyePosition(1.0F),
|
new Rotation(RotationUtils.calcRotationFromVec3d(player.getEyePosition(1.0F),
|
||||||
new Vec3d(destX, dest.getY(), destZ),
|
new Vec3d(destX, dest.getY(), destZ),
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ import baritone.pathing.movement.MovementState;
|
|||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -41,12 +41,12 @@ public class MovementDiagonal extends Movement {
|
|||||||
|
|
||||||
private static final double SQRT_2 = Math.sqrt(2);
|
private static final double SQRT_2 = Math.sqrt(2);
|
||||||
|
|
||||||
public MovementDiagonal(IBaritone baritone, BetterBlockPos start, EnumFacing dir1, EnumFacing dir2, int dy) {
|
public MovementDiagonal(IBaritone baritone, BetterBlockPos start, Direction dir1, Direction dir2, int dy) {
|
||||||
this(baritone, start, start.offset(dir1), start.offset(dir2), dir2, dy);
|
this(baritone, start, start.offset(dir1), start.offset(dir2), dir2, dy);
|
||||||
// super(start, start.offset(dir1).offset(dir2), new BlockPos[]{start.offset(dir1), start.offset(dir1).up(), start.offset(dir2), start.offset(dir2).up(), start.offset(dir1).offset(dir2), start.offset(dir1).offset(dir2).up()}, new BlockPos[]{start.offset(dir1).offset(dir2).down()});
|
// super(start, start.offset(dir1).offset(dir2), new BlockPos[]{start.offset(dir1), start.offset(dir1).up(), start.offset(dir2), start.offset(dir2).up(), start.offset(dir1).offset(dir2), start.offset(dir1).offset(dir2).up()}, new BlockPos[]{start.offset(dir1).offset(dir2).down()});
|
||||||
}
|
}
|
||||||
|
|
||||||
private MovementDiagonal(IBaritone baritone, BetterBlockPos start, BetterBlockPos dir1, BetterBlockPos dir2, EnumFacing drr2, int dy) {
|
private MovementDiagonal(IBaritone baritone, BetterBlockPos start, BetterBlockPos dir1, BetterBlockPos dir2, Direction drr2, int dy) {
|
||||||
this(baritone, start, dir1.offset(drr2).up(dy), dir1, dir2);
|
this(baritone, start, dir1.offset(drr2).up(dy), dir1, dir2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,11 +65,11 @@ public class MovementDiagonal extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
||||||
IBlockState destInto = context.get(destX, y, destZ);
|
BlockState destInto = context.get(destX, y, destZ);
|
||||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi, destX, y + 1, destZ)) {
|
if (!MovementHelper.canWalkThrough(context.bsi, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi, destX, y + 1, destZ)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState destWalkOn = context.get(destX, y - 1, destZ);
|
BlockState destWalkOn = context.get(destX, y - 1, destZ);
|
||||||
boolean descend = false;
|
boolean descend = false;
|
||||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
||||||
descend = true;
|
descend = true;
|
||||||
@@ -91,16 +91,16 @@ public class MovementDiagonal extends Movement {
|
|||||||
if (fromDown == Blocks.SOUL_SAND) {
|
if (fromDown == Blocks.SOUL_SAND) {
|
||||||
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||||
}
|
}
|
||||||
IBlockState cuttingOver1 = context.get(x, y - 1, destZ);
|
BlockState cuttingOver1 = context.get(x, y - 1, destZ);
|
||||||
if (cuttingOver1.getBlock() == Blocks.MAGMA_BLOCK || MovementHelper.isLava(cuttingOver1)) {
|
if (cuttingOver1.getBlock() == Blocks.MAGMA_BLOCK || MovementHelper.isLava(cuttingOver1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState cuttingOver2 = context.get(destX, y - 1, z);
|
BlockState cuttingOver2 = context.get(destX, y - 1, z);
|
||||||
if (cuttingOver2.getBlock() == Blocks.MAGMA_BLOCK || MovementHelper.isLava(cuttingOver2)) {
|
if (cuttingOver2.getBlock() == Blocks.MAGMA_BLOCK || MovementHelper.isLava(cuttingOver2)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState pb0 = context.get(x, y, destZ);
|
BlockState pb0 = context.get(x, y, destZ);
|
||||||
IBlockState pb2 = context.get(destX, y, z);
|
BlockState pb2 = context.get(destX, y, z);
|
||||||
double optionA = MovementHelper.getMiningDurationTicks(context, x, y, destZ, pb0, false);
|
double optionA = MovementHelper.getMiningDurationTicks(context, x, y, destZ, pb0, false);
|
||||||
double optionB = MovementHelper.getMiningDurationTicks(context, destX, y, z, pb2, false);
|
double optionB = MovementHelper.getMiningDurationTicks(context, destX, y, z, pb2, false);
|
||||||
if (optionA != 0 && optionB != 0) {
|
if (optionA != 0 && optionB != 0) {
|
||||||
@@ -108,13 +108,13 @@ public class MovementDiagonal extends Movement {
|
|||||||
// so no need to check pb1 as well, might as well return early here
|
// so no need to check pb1 as well, might as well return early here
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState pb1 = context.get(x, y + 1, destZ);
|
BlockState pb1 = context.get(x, y + 1, destZ);
|
||||||
optionA += MovementHelper.getMiningDurationTicks(context, x, y + 1, destZ, pb1, true);
|
optionA += MovementHelper.getMiningDurationTicks(context, x, y + 1, destZ, pb1, true);
|
||||||
if (optionA != 0 && optionB != 0) {
|
if (optionA != 0 && optionB != 0) {
|
||||||
// same deal, if pb1 makes optionA nonzero and option B already was nonzero, pb3 can't affect the result
|
// same deal, if pb1 makes optionA nonzero and option B already was nonzero, pb3 can't affect the result
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState pb3 = context.get(destX, y + 1, z);
|
BlockState pb3 = context.get(destX, y + 1, z);
|
||||||
if (optionA == 0 && ((MovementHelper.avoidWalkingInto(pb2) && pb2.getBlock() != Blocks.WATER) || MovementHelper.avoidWalkingInto(pb3))) {
|
if (optionA == 0 && ((MovementHelper.avoidWalkingInto(pb2) && pb2.getBlock() != Blocks.WATER) || MovementHelper.avoidWalkingInto(pb3))) {
|
||||||
// at this point we're done calculating optionA, so we can check if it's actually possible to edge around in that direction
|
// at this point we're done calculating optionA, so we can check if it's actually possible to edge around in that direction
|
||||||
return;
|
return;
|
||||||
@@ -129,7 +129,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean water = false;
|
boolean water = false;
|
||||||
IBlockState startState = context.get(x, y, z);
|
BlockState startState = context.get(x, y, z);
|
||||||
Block startIn = startState.getBlock();
|
Block startIn = startState.getBlock();
|
||||||
if (MovementHelper.isWater(startState) || MovementHelper.isWater(destInto)) {
|
if (MovementHelper.isWater(startState) || MovementHelper.isWater(destInto)) {
|
||||||
// Ignore previous multiplier
|
// Ignore previous multiplier
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import baritone.pathing.movement.Movement;
|
|||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
|
||||||
public class MovementDownward extends Movement {
|
public class MovementDownward extends Movement {
|
||||||
@@ -54,7 +54,7 @@ public class MovementDownward extends Movement {
|
|||||||
if (!MovementHelper.canWalkOn(context.bsi, x, y - 2, z)) {
|
if (!MovementHelper.canWalkOn(context.bsi, x, y - 2, z)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState down = context.get(x, y - 1, z);
|
BlockState down = context.get(x, y - 1, z);
|
||||||
Block downBlock = down.getBlock();
|
Block downBlock = down.getBlock();
|
||||||
if (downBlock == Blocks.LADDER || downBlock == Blocks.VINE) {
|
if (downBlock == Blocks.LADDER || downBlock == Blocks.VINE) {
|
||||||
return LADDER_DOWN_ONE_COST;
|
return LADDER_DOWN_ONE_COST;
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ import baritone.pathing.movement.MovementState.MovementTarget;
|
|||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockLadder;
|
import net.minecraft.block.BlockLadder;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.fluid.WaterFluid;
|
import net.minecraft.fluid.WaterFluid;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
@@ -80,7 +80,7 @@ public class MovementFall extends Movement {
|
|||||||
BlockPos playerFeet = ctx.playerFeet();
|
BlockPos playerFeet = ctx.playerFeet();
|
||||||
Rotation toDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations());
|
Rotation toDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations());
|
||||||
Rotation targetRotation = null;
|
Rotation targetRotation = null;
|
||||||
IBlockState destState = ctx.world().getBlockState(dest);
|
BlockState destState = ctx.world().getBlockState(dest);
|
||||||
Block destBlock = destState.getBlock();
|
Block destBlock = destState.getBlock();
|
||||||
boolean isWater = destState.getFluidState().getFluid() instanceof WaterFluid;
|
boolean isWater = destState.getFluidState().getFluid() instanceof WaterFluid;
|
||||||
if (!isWater && willPlaceBucket() && !playerFeet.equals(dest)) {
|
if (!isWater && willPlaceBucket() && !playerFeet.equals(dest)) {
|
||||||
@@ -128,7 +128,7 @@ public class MovementFall extends Movement {
|
|||||||
}
|
}
|
||||||
state.setInput(Input.MOVE_FORWARD, true);
|
state.setInput(Input.MOVE_FORWARD, true);
|
||||||
}
|
}
|
||||||
Vec3i avoid = Optional.ofNullable(avoid()).map(EnumFacing::getDirectionVec).orElse(null);
|
Vec3i avoid = Optional.ofNullable(avoid()).map(Direction::getDirectionVec).orElse(null);
|
||||||
if (avoid == null) {
|
if (avoid == null) {
|
||||||
avoid = src.subtract(dest);
|
avoid = src.subtract(dest);
|
||||||
} else {
|
} else {
|
||||||
@@ -146,9 +146,9 @@ public class MovementFall extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EnumFacing avoid() {
|
private Direction avoid() {
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
IBlockState state = ctx.world().getBlockState(ctx.playerFeet().down(i));
|
BlockState state = ctx.world().getBlockState(ctx.playerFeet().down(i));
|
||||||
if (state.getBlock() == Blocks.LADDER) {
|
if (state.getBlock() == Blocks.LADDER) {
|
||||||
return state.get(BlockLadder.FACING);
|
return state.get(BlockLadder.FACING);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,33 +29,33 @@ import baritone.utils.BlockStateInterface;
|
|||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockStairs;
|
import net.minecraft.block.BlockStairs;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.fluid.WaterFluid;
|
import net.minecraft.fluid.WaterFluid;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Fluids;
|
import net.minecraft.init.Fluids;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class MovementParkour extends Movement {
|
public class MovementParkour extends Movement {
|
||||||
|
|
||||||
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
|
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
|
||||||
|
|
||||||
private final EnumFacing direction;
|
private final Direction direction;
|
||||||
private final int dist;
|
private final int dist;
|
||||||
|
|
||||||
private MovementParkour(IBaritone baritone, BetterBlockPos src, int dist, EnumFacing dir) {
|
private MovementParkour(IBaritone baritone, BetterBlockPos src, int dist, Direction dir) {
|
||||||
super(baritone, src, src.offset(dir, dist), EMPTY, src.offset(dir, dist).down());
|
super(baritone, src, src.offset(dir, dist), EMPTY, src.offset(dir, dist).down());
|
||||||
this.direction = dir;
|
this.direction = dir;
|
||||||
this.dist = dist;
|
this.dist = dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MovementParkour cost(CalculationContext context, BetterBlockPos src, EnumFacing direction) {
|
public static MovementParkour cost(CalculationContext context, BetterBlockPos src, Direction direction) {
|
||||||
MutableMoveResult res = new MutableMoveResult();
|
MutableMoveResult res = new MutableMoveResult();
|
||||||
cost(context, src.x, src.y, src.z, direction, res);
|
cost(context, src.x, src.y, src.z, direction, res);
|
||||||
int dist = Math.abs(res.x - src.x) + Math.abs(res.z - src.z);
|
int dist = Math.abs(res.x - src.x) + Math.abs(res.z - src.z);
|
||||||
return new MovementParkour(context.getBaritone(), src, dist, direction);
|
return new MovementParkour(context.getBaritone(), src, dist, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void cost(CalculationContext context, int x, int y, int z, EnumFacing dir, MutableMoveResult res) {
|
public static void cost(CalculationContext context, int x, int y, int z, Direction dir, MutableMoveResult res) {
|
||||||
if (!context.allowParkour) {
|
if (!context.allowParkour) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ public class MovementParkour extends Movement {
|
|||||||
// most common case at the top -- the adjacent block isn't air
|
// most common case at the top -- the adjacent block isn't air
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState adj = context.get(x + xDiff, y - 1, z + zDiff);
|
BlockState adj = context.get(x + xDiff, y - 1, z + zDiff);
|
||||||
if (MovementHelper.canWalkOn(context.bsi, x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
if (MovementHelper.canWalkOn(context.bsi, x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
||||||
// second most common case -- we could just traverse not parkour
|
// second most common case -- we could just traverse not parkour
|
||||||
return;
|
return;
|
||||||
@@ -86,7 +86,7 @@ public class MovementParkour extends Movement {
|
|||||||
if (!MovementHelper.fullyPassable(context, x, y + 2, z)) {
|
if (!MovementHelper.fullyPassable(context, x, y + 2, z)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState standingOn = context.get(x, y - 1, z);
|
BlockState standingOn = context.get(x, y - 1, z);
|
||||||
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof BlockStairs || MovementHelper.isBottomSlab(standingOn) || standingOn.getFluidState().getFluid() != Fluids.EMPTY) {
|
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof BlockStairs || MovementHelper.isBottomSlab(standingOn) || standingOn.getFluidState().getFluid() != Fluids.EMPTY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ public class MovementParkour extends Movement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IBlockState landingOn = context.bsi.get0(x + xDiff * i, y - 1, z + zDiff * i);
|
BlockState landingOn = context.bsi.get0(x + xDiff * i, y - 1, z + zDiff * i);
|
||||||
// farmland needs to be canwalkon otherwise farm can never work at all, but we want to specifically disallow ending a jumy on farmland haha
|
// farmland needs to be canwalkon otherwise farm can never work at all, but we want to specifically disallow ending a jumy on farmland haha
|
||||||
if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, x + xDiff * i, y - 1, z + zDiff * i, landingOn)) {
|
if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, x + xDiff * i, y - 1, z + zDiff * i, landingOn)) {
|
||||||
res.x = x + xDiff * i;
|
res.x = x + xDiff * i;
|
||||||
@@ -130,7 +130,7 @@ public class MovementParkour extends Movement {
|
|||||||
if (placeCost >= COST_INF) {
|
if (placeCost >= COST_INF) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState toReplace = context.get(destX, y - 1, destZ);
|
BlockState toReplace = context.get(destX, y - 1, destZ);
|
||||||
if (!MovementHelper.isReplacable(destX, y - 1, destZ, toReplace, context.bsi)) {
|
if (!MovementHelper.isReplacable(destX, y - 1, destZ, toReplace, context.bsi)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import baritone.pathing.movement.MovementHelper;
|
|||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
@@ -50,10 +50,10 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z) {
|
public static double cost(CalculationContext context, int x, int y, int z) {
|
||||||
IBlockState fromState = context.get(x, y, z);
|
BlockState fromState = context.get(x, y, z);
|
||||||
Block from = fromState.getBlock();
|
Block from = fromState.getBlock();
|
||||||
boolean ladder = from == Blocks.LADDER || from == Blocks.VINE;
|
boolean ladder = from == Blocks.LADDER || from == Blocks.VINE;
|
||||||
IBlockState fromDown = context.get(x, y - 1, z);
|
BlockState fromDown = context.get(x, y - 1, z);
|
||||||
if (!ladder) {
|
if (!ladder) {
|
||||||
if (fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE) {
|
if (fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE) {
|
||||||
return COST_INF; // can't pillar from a ladder or vine onto something that isn't also climbable
|
return COST_INF; // can't pillar from a ladder or vine onto something that isn't also climbable
|
||||||
@@ -65,12 +65,12 @@ public class MovementPillar extends Movement {
|
|||||||
if (from == Blocks.VINE && !hasAgainst(context, x, y, z)) { // TODO this vine can't be climbed, but we could place a pillar still since vines are replacable, no? perhaps the pillar jump would be impossible because of the slowdown actually.
|
if (from == Blocks.VINE && !hasAgainst(context, x, y, z)) { // TODO this vine can't be climbed, but we could place a pillar still since vines are replacable, no? perhaps the pillar jump would be impossible because of the slowdown actually.
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState toBreak = context.get(x, y + 2, z);
|
BlockState toBreak = context.get(x, y + 2, z);
|
||||||
Block toBreakBlock = toBreak.getBlock();
|
Block toBreakBlock = toBreak.getBlock();
|
||||||
if (toBreakBlock instanceof BlockFenceGate) { // see issue #172
|
if (toBreakBlock instanceof BlockFenceGate) { // see issue #172
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState srcUp = null;
|
BlockState srcUp = null;
|
||||||
if (MovementHelper.isWater(toBreak) && MovementHelper.isWater(fromState)) { // TODO should this also be allowed if toBreakBlock is air?
|
if (MovementHelper.isWater(toBreak) && MovementHelper.isWater(fromState)) { // TODO should this also be allowed if toBreakBlock is air?
|
||||||
srcUp = context.get(x, y + 1, z);
|
srcUp = context.get(x, y + 1, z);
|
||||||
if (MovementHelper.isWater(srcUp)) {
|
if (MovementHelper.isWater(srcUp)) {
|
||||||
@@ -102,7 +102,7 @@ public class MovementPillar extends Movement {
|
|||||||
if (toBreakBlock == Blocks.LADDER || toBreakBlock == Blocks.VINE) {
|
if (toBreakBlock == Blocks.LADDER || toBreakBlock == Blocks.VINE) {
|
||||||
hardness = 0; // we won't actually need to break the ladder / vine because we're going to use it
|
hardness = 0; // we won't actually need to break the ladder / vine because we're going to use it
|
||||||
} else {
|
} else {
|
||||||
IBlockState check = context.get(x, y + 3, z); // the block on top of the one we're going to break, could it fall on us?
|
BlockState check = context.get(x, y + 3, z); // the block on top of the one we're going to break, could it fall on us?
|
||||||
if (check.getBlock() instanceof BlockFalling) {
|
if (check.getBlock() instanceof BlockFalling) {
|
||||||
// see MovementAscend's identical check for breaking a falling block above our head
|
// see MovementAscend's identical check for breaking a falling block above our head
|
||||||
if (srcUp == null) {
|
if (srcUp == null) {
|
||||||
@@ -162,7 +162,7 @@ public class MovementPillar extends Movement {
|
|||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState fromDown = BlockStateInterface.get(ctx, src);
|
BlockState fromDown = BlockStateInterface.get(ctx, src);
|
||||||
if (MovementHelper.isWater(fromDown) && MovementHelper.isWater(ctx, dest)) {
|
if (MovementHelper.isWater(fromDown) && MovementHelper.isWater(ctx, dest)) {
|
||||||
// stay centered while swimming up a water column
|
// stay centered while swimming up a water column
|
||||||
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations()), false));
|
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations()), false));
|
||||||
@@ -236,7 +236,7 @@ public class MovementPillar extends Movement {
|
|||||||
|
|
||||||
|
|
||||||
if (!blockIsThere) {
|
if (!blockIsThere) {
|
||||||
IBlockState frState = BlockStateInterface.get(ctx, src);
|
BlockState frState = BlockStateInterface.get(ctx, src);
|
||||||
Block fr = frState.getBlock();
|
Block fr = frState.getBlock();
|
||||||
// TODO: Evaluate usage of getMaterial().isReplaceable()
|
// TODO: Evaluate usage of getMaterial().isReplaceable()
|
||||||
if (!(fr instanceof BlockAir || frState.getMaterial().isReplaceable())) {
|
if (!(fr instanceof BlockAir || frState.getMaterial().isReplaceable())) {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import baritone.pathing.movement.MovementHelper;
|
|||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.fluid.WaterFluid;
|
import net.minecraft.fluid.WaterFluid;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.state.properties.SlabType;
|
import net.minecraft.state.properties.SlabType;
|
||||||
@@ -61,10 +61,10 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||||
IBlockState pb0 = context.get(destX, y + 1, destZ);
|
BlockState pb0 = context.get(destX, y + 1, destZ);
|
||||||
IBlockState pb1 = context.get(destX, y, destZ);
|
BlockState pb1 = context.get(destX, y, destZ);
|
||||||
IBlockState destOn = context.get(destX, y - 1, destZ);
|
BlockState destOn = context.get(destX, y - 1, destZ);
|
||||||
IBlockState down = context.get(x, y - 1, z);
|
BlockState down = context.get(x, y - 1, z);
|
||||||
Block srcDown = down.getBlock();
|
Block srcDown = down.getBlock();
|
||||||
if (MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
if (MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
||||||
double WC = WALK_ONE_BLOCK_COST;
|
double WC = WALK_ONE_BLOCK_COST;
|
||||||
@@ -149,8 +149,8 @@ public class MovementTraverse extends Movement {
|
|||||||
@Override
|
@Override
|
||||||
public MovementState updateState(MovementState state) {
|
public MovementState updateState(MovementState state) {
|
||||||
super.updateState(state);
|
super.updateState(state);
|
||||||
IBlockState pb0 = BlockStateInterface.get(ctx, positionsToBreak[0]);
|
BlockState pb0 = BlockStateInterface.get(ctx, positionsToBreak[0]);
|
||||||
IBlockState pb1 = BlockStateInterface.get(ctx, positionsToBreak[1]);
|
BlockState pb1 = BlockStateInterface.get(ctx, positionsToBreak[1]);
|
||||||
if (state.getStatus() != MovementStatus.RUNNING) {
|
if (state.getStatus() != MovementStatus.RUNNING) {
|
||||||
// if the setting is enabled
|
// if the setting is enabled
|
||||||
if (!Baritone.settings().walkWhileBreaking.value) {
|
if (!Baritone.settings().walkWhileBreaking.value) {
|
||||||
@@ -241,13 +241,13 @@ public class MovementTraverse extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
BlockPos into = dest.subtract(src).add(dest);
|
BlockPos into = dest.subtract(src).add(dest);
|
||||||
IBlockState intoBelow = BlockStateInterface.get(ctx, into);
|
BlockState intoBelow = BlockStateInterface.get(ctx, into);
|
||||||
IBlockState intoAbove = BlockStateInterface.get(ctx, into.up());
|
BlockState intoAbove = BlockStateInterface.get(ctx, into.up());
|
||||||
if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, feet) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) {
|
if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, feet) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) {
|
||||||
state.setInput(Input.SPRINT, true);
|
state.setInput(Input.SPRINT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState destDown = BlockStateInterface.get(ctx, dest.down());
|
BlockState destDown = BlockStateInterface.get(ctx, dest.down());
|
||||||
BlockPos against = positionsToBreak[0];
|
BlockPos against = positionsToBreak[0];
|
||||||
if (feet.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) {
|
if (feet.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) {
|
||||||
against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.get(BlockLadder.FACING).getOpposite());
|
against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.get(BlockLadder.FACING).getOpposite());
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import baritone.pathing.movement.MovementHelper;
|
|||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.pathing.path.PathExecutor;
|
import baritone.pathing.path.PathExecutor;
|
||||||
import baritone.utils.BaritoneProcessHelper;
|
import baritone.utils.BaritoneProcessHelper;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.chunk.EmptyChunk;
|
import net.minecraft.world.chunk.EmptyChunk;
|
||||||
@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public final class BackfillProcess extends BaritoneProcessHelper {
|
public final class BackfillProcess extends BaritoneProcessHelper {
|
||||||
|
|
||||||
public HashMap<BlockPos, IBlockState> blocksToReplace = new HashMap<>();
|
public HashMap<BlockPos, BlockState> blocksToReplace = new HashMap<>();
|
||||||
|
|
||||||
public BackfillProcess(Baritone baritone) {
|
public BackfillProcess(Baritone baritone) {
|
||||||
super(baritone);
|
super(baritone);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import baritone.utils.schematic.Schematic;
|
|||||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||||
import net.minecraft.block.BlockAir;
|
import net.minecraft.block.BlockAir;
|
||||||
import net.minecraft.block.BlockFlowingFluid;
|
import net.minecraft.block.BlockFlowingFluid;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
@@ -46,7 +46,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.item.ItemUseContext;
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.nbt.CompressedStreamTools;
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
@@ -126,14 +126,14 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
return schematic != null;
|
return schematic != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBlockState placeAt(int x, int y, int z) {
|
public BlockState placeAt(int x, int y, int z) {
|
||||||
if (!isActive()) {
|
if (!isActive()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!schematic.inSchematic(x - origin.getX(), y - origin.getY(), z - origin.getZ())) {
|
if (!schematic.inSchematic(x - origin.getX(), y - origin.getY(), z - origin.getZ())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
IBlockState state = schematic.desiredState(x - origin.getX(), y - origin.getY(), z - origin.getZ());
|
BlockState state = schematic.desiredState(x - origin.getX(), y - origin.getY(), z - origin.getZ());
|
||||||
if (state.getBlock() instanceof BlockAir) {
|
if (state.getBlock() instanceof BlockAir) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -152,11 +152,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
if (dy == -1 && x == pathStart.x && z == pathStart.z) {
|
if (dy == -1 && x == pathStart.x && z == pathStart.z) {
|
||||||
continue; // dont mine what we're supported by, but not directly standing on
|
continue; // dont mine what we're supported by, but not directly standing on
|
||||||
}
|
}
|
||||||
IBlockState desired = bcc.getSchematic(x, y, z);
|
BlockState desired = bcc.getSchematic(x, y, z);
|
||||||
if (desired == null) {
|
if (desired == null) {
|
||||||
continue; // irrelevant
|
continue; // irrelevant
|
||||||
}
|
}
|
||||||
IBlockState curr = bcc.bsi.get0(x, y, z);
|
BlockState curr = bcc.bsi.get0(x, y, z);
|
||||||
if (!(curr.getBlock() instanceof BlockAir) && !valid(curr, desired)) {
|
if (!(curr.getBlock() instanceof BlockAir) && !valid(curr, desired)) {
|
||||||
BetterBlockPos pos = new BetterBlockPos(x, y, z);
|
BetterBlockPos pos = new BetterBlockPos(x, y, z);
|
||||||
Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
||||||
@@ -173,10 +173,10 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
public class Placement {
|
public class Placement {
|
||||||
private final int hotbarSelection;
|
private final int hotbarSelection;
|
||||||
private final BlockPos placeAgainst;
|
private final BlockPos placeAgainst;
|
||||||
private final EnumFacing side;
|
private final Direction side;
|
||||||
private final Rotation rot;
|
private final Rotation rot;
|
||||||
|
|
||||||
public Placement(int hotbarSelection, BlockPos placeAgainst, EnumFacing side, Rotation rot) {
|
public Placement(int hotbarSelection, BlockPos placeAgainst, Direction side, Rotation rot) {
|
||||||
this.hotbarSelection = hotbarSelection;
|
this.hotbarSelection = hotbarSelection;
|
||||||
this.placeAgainst = placeAgainst;
|
this.placeAgainst = placeAgainst;
|
||||||
this.side = side;
|
this.side = side;
|
||||||
@@ -184,7 +184,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Placement> searchForPlacables(BuilderCalculationContext bcc, List<IBlockState> desirableOnHotbar) {
|
private Optional<Placement> searchForPlacables(BuilderCalculationContext bcc, List<BlockState> desirableOnHotbar) {
|
||||||
BetterBlockPos center = ctx.playerFeet();
|
BetterBlockPos center = ctx.playerFeet();
|
||||||
for (int dx = -5; dx <= 5; dx++) {
|
for (int dx = -5; dx <= 5; dx++) {
|
||||||
for (int dy = -5; dy <= 1; dy++) {
|
for (int dy = -5; dy <= 1; dy++) {
|
||||||
@@ -192,11 +192,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
int x = center.x + dx;
|
int x = center.x + dx;
|
||||||
int y = center.y + dy;
|
int y = center.y + dy;
|
||||||
int z = center.z + dz;
|
int z = center.z + dz;
|
||||||
IBlockState desired = bcc.getSchematic(x, y, z);
|
BlockState desired = bcc.getSchematic(x, y, z);
|
||||||
if (desired == null) {
|
if (desired == null) {
|
||||||
continue; // irrelevant
|
continue; // irrelevant
|
||||||
}
|
}
|
||||||
IBlockState curr = bcc.bsi.get0(x, y, z);
|
BlockState curr = bcc.bsi.get0(x, y, z);
|
||||||
if (MovementHelper.isReplacable(x, y, z, curr, bcc.bsi) && !valid(curr, desired)) {
|
if (MovementHelper.isReplacable(x, y, z, curr, bcc.bsi) && !valid(curr, desired)) {
|
||||||
if (dy == 1 && bcc.bsi.get0(x, y + 1, z).getBlock() instanceof BlockAir) {
|
if (dy == 1 && bcc.bsi.get0(x, y + 1, z).getBlock() instanceof BlockAir) {
|
||||||
continue;
|
continue;
|
||||||
@@ -213,15 +213,15 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean placementPlausible(BlockPos pos, IBlockState state) {
|
public boolean placementPlausible(BlockPos pos, BlockState state) {
|
||||||
VoxelShape voxelshape = state.getCollisionShape(ctx.world(), pos);
|
VoxelShape voxelshape = state.getCollisionShape(ctx.world(), pos);
|
||||||
return voxelshape.isEmpty() || ctx.world().checkNoEntityCollision(null, voxelshape.withOffset(pos.getX(), pos.getY(), pos.getZ()));
|
return voxelshape.isEmpty() || ctx.world().checkNoEntityCollision(null, voxelshape.withOffset(pos.getX(), pos.getY(), pos.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Placement> possibleToPlace(IBlockState toPlace, int x, int y, int z, BlockStateInterface bsi) {
|
private Optional<Placement> possibleToPlace(BlockState toPlace, int x, int y, int z, BlockStateInterface bsi) {
|
||||||
for (EnumFacing against : EnumFacing.values()) {
|
for (Direction against : Direction.values()) {
|
||||||
BetterBlockPos placeAgainstPos = new BetterBlockPos(x, y, z).offset(against);
|
BetterBlockPos placeAgainstPos = new BetterBlockPos(x, y, z).offset(against);
|
||||||
IBlockState placeAgainstState = bsi.get0(placeAgainstPos);
|
BlockState placeAgainstState = bsi.get0(placeAgainstPos);
|
||||||
if (MovementHelper.isReplacable(placeAgainstPos.x, placeAgainstPos.y, placeAgainstPos.z, placeAgainstState, bsi)) {
|
if (MovementHelper.isReplacable(placeAgainstPos.x, placeAgainstPos.y, placeAgainstPos.z, placeAgainstState, bsi)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
double placeZ = placeAgainstPos.z + aabb.minZ * placementMultiplier.z + aabb.maxZ * (1 - placementMultiplier.z);
|
double placeZ = placeAgainstPos.z + aabb.minZ * placementMultiplier.z + aabb.maxZ * (1 - placementMultiplier.z);
|
||||||
Rotation rot = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations());
|
Rotation rot = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations());
|
||||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance());
|
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance());
|
||||||
if (result != null && result.type == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(placeAgainstPos) && result.sideHit == against.getOpposite()) {
|
if (result != null && result.getType() == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(placeAgainstPos) && result.sideHit == against.getOpposite()) {
|
||||||
OptionalInt hotbar = hasAnyItemThatWouldPlace(toPlace, result, rot);
|
OptionalInt hotbar = hasAnyItemThatWouldPlace(toPlace, result, rot);
|
||||||
if (hotbar.isPresent()) {
|
if (hotbar.isPresent()) {
|
||||||
return Optional.of(new Placement(hotbar.getAsInt(), placeAgainstPos, against.getOpposite(), rot));
|
return Optional.of(new Placement(hotbar.getAsInt(), placeAgainstPos, against.getOpposite(), rot));
|
||||||
@@ -249,7 +249,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private OptionalInt hasAnyItemThatWouldPlace(IBlockState desired, RayTraceResult result, Rotation rot) {
|
private OptionalInt hasAnyItemThatWouldPlace(BlockState desired, RayTraceResult result, Rotation rot) {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
ItemStack stack = ctx.player().inventory.mainInventory.get(i);
|
ItemStack stack = ctx.player().inventory.mainInventory.get(i);
|
||||||
if (stack.isEmpty() || !(stack.getItem() instanceof ItemBlock)) {
|
if (stack.isEmpty() || !(stack.getItem() instanceof ItemBlock)) {
|
||||||
@@ -269,7 +269,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
(float) result.hitVec.y - result.getBlockPos().getY(),
|
(float) result.hitVec.y - result.getBlockPos().getY(),
|
||||||
(float) result.hitVec.z - result.getBlockPos().getZ()
|
(float) result.hitVec.z - result.getBlockPos().getZ()
|
||||||
));
|
));
|
||||||
IBlockState wouldBePlaced = ((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(meme);
|
BlockState wouldBePlaced = ((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(meme);
|
||||||
ctx.player().rotationYaw = originalYaw;
|
ctx.player().rotationYaw = originalYaw;
|
||||||
ctx.player().rotationPitch = originalPitch;
|
ctx.player().rotationPitch = originalPitch;
|
||||||
if (wouldBePlaced == null) {
|
if (wouldBePlaced == null) {
|
||||||
@@ -285,7 +285,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
return OptionalInt.empty();
|
return OptionalInt.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vec3d[] aabbSideMultipliers(EnumFacing side) {
|
private static Vec3d[] aabbSideMultipliers(Direction side) {
|
||||||
switch (side) {
|
switch (side) {
|
||||||
case UP:
|
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 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)};
|
||||||
@@ -332,7 +332,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
}
|
}
|
||||||
schematic = new ISchematic() {
|
schematic = new ISchematic() {
|
||||||
@Override
|
@Override
|
||||||
public IBlockState desiredState(int x, int y, int z) {
|
public BlockState desiredState(int x, int y, int z) {
|
||||||
return realSchematic.desiredState(x, y, z);
|
return realSchematic.desiredState(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +397,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
}
|
}
|
||||||
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
||||||
}
|
}
|
||||||
List<IBlockState> desirableOnHotbar = new ArrayList<>();
|
List<BlockState> desirableOnHotbar = new ArrayList<>();
|
||||||
Optional<Placement> toPlace = searchForPlacables(bcc, desirableOnHotbar);
|
Optional<Placement> toPlace = searchForPlacables(bcc, desirableOnHotbar);
|
||||||
if (toPlace.isPresent() && isSafeToCancel && ctx.player().onGround && ticks <= 0) {
|
if (toPlace.isPresent() && isSafeToCancel && ctx.player().onGround && ticks <= 0) {
|
||||||
Rotation rot = toPlace.get().rot;
|
Rotation rot = toPlace.get().rot;
|
||||||
@@ -410,12 +410,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IBlockState> approxPlacable = placable(36);
|
List<BlockState> approxPlacable = placable(36);
|
||||||
if (Baritone.settings().allowInventory.value) {
|
if (Baritone.settings().allowInventory.value) {
|
||||||
ArrayList<Integer> usefulSlots = new ArrayList<>();
|
ArrayList<Integer> usefulSlots = new ArrayList<>();
|
||||||
List<IBlockState> noValidHotbarOption = new ArrayList<>();
|
List<BlockState> noValidHotbarOption = new ArrayList<>();
|
||||||
outer:
|
outer:
|
||||||
for (IBlockState desired : desirableOnHotbar) {
|
for (BlockState desired : desirableOnHotbar) {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
if (valid(approxPlacable.get(i), desired)) {
|
if (valid(approxPlacable.get(i), desired)) {
|
||||||
usefulSlots.add(i);
|
usefulSlots.add(i);
|
||||||
@@ -427,7 +427,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
|
|
||||||
outer:
|
outer:
|
||||||
for (int i = 9; i < 36; i++) {
|
for (int i = 9; i < 36; i++) {
|
||||||
for (IBlockState desired : noValidHotbarOption) {
|
for (BlockState desired : noValidHotbarOption) {
|
||||||
if (valid(approxPlacable.get(i), desired)) {
|
if (valid(approxPlacable.get(i), desired)) {
|
||||||
baritone.getInventoryBehavior().attemptToPutOnHotbar(i, usefulSlots::contains);
|
baritone.getInventoryBehavior().attemptToPutOnHotbar(i, usefulSlots::contains);
|
||||||
break outer;
|
break outer;
|
||||||
@@ -480,7 +480,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
int x = center.x + dx;
|
int x = center.x + dx;
|
||||||
int y = center.y + dy;
|
int y = center.y + dy;
|
||||||
int z = center.z + dz;
|
int z = center.z + dz;
|
||||||
IBlockState desired = bcc.getSchematic(x, y, z);
|
BlockState desired = bcc.getSchematic(x, y, z);
|
||||||
if (desired != null) {
|
if (desired != null) {
|
||||||
// we care about this position
|
// we care about this position
|
||||||
BetterBlockPos pos = new BetterBlockPos(x, y, z);
|
BetterBlockPos pos = new BetterBlockPos(x, y, z);
|
||||||
@@ -529,12 +529,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Goal assemble(BuilderCalculationContext bcc, List<IBlockState> approxPlacable) {
|
private Goal assemble(BuilderCalculationContext bcc, List<BlockState> approxPlacable) {
|
||||||
List<BetterBlockPos> placable = new ArrayList<>();
|
List<BetterBlockPos> placable = new ArrayList<>();
|
||||||
List<BetterBlockPos> breakable = new ArrayList<>();
|
List<BetterBlockPos> breakable = new ArrayList<>();
|
||||||
List<BetterBlockPos> sourceLiquids = new ArrayList<>();
|
List<BetterBlockPos> sourceLiquids = new ArrayList<>();
|
||||||
incorrectPositions.forEach(pos -> {
|
incorrectPositions.forEach(pos -> {
|
||||||
IBlockState state = bcc.bsi.get0(pos);
|
BlockState state = bcc.bsi.get0(pos);
|
||||||
if (state.getBlock() instanceof BlockAir) {
|
if (state.getBlock() instanceof BlockAir) {
|
||||||
if (approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))) {
|
if (approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))) {
|
||||||
placable.add(pos);
|
placable.add(pos);
|
||||||
@@ -619,7 +619,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
return new GoalPlace(pos);
|
return new GoalPlace(pos);
|
||||||
}
|
}
|
||||||
boolean allowSameLevel = !(ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir);
|
boolean allowSameLevel = !(ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir);
|
||||||
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP) {
|
for (Direction facing : Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP) {
|
||||||
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && placementPlausible(pos, bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()))) {
|
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && placementPlausible(pos, bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()))) {
|
||||||
return new GoalAdjacent(pos, allowSameLevel);
|
return new GoalAdjacent(pos, allowSameLevel);
|
||||||
}
|
}
|
||||||
@@ -696,8 +696,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
return paused ? "Builder Paused" : "Building " + name;
|
return paused ? "Builder Paused" : "Building " + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IBlockState> placable(int size) {
|
private List<BlockState> placable(int size) {
|
||||||
List<IBlockState> result = new ArrayList<>();
|
List<BlockState> result = new ArrayList<>();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
ItemStack stack = ctx.player().inventory.mainInventory.get(i);
|
ItemStack stack = ctx.player().inventory.mainInventory.get(i);
|
||||||
if (stack.isEmpty() || !(stack.getItem() instanceof ItemBlock)) {
|
if (stack.isEmpty() || !(stack.getItem() instanceof ItemBlock)) {
|
||||||
@@ -705,13 +705,13 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// <toxic cloud>
|
// <toxic cloud>
|
||||||
result.add(((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.player(), stack, ctx.playerFeet(), EnumFacing.UP, (float) ctx.player().posX, (float) ctx.player().posY, (float) ctx.player().posZ))));
|
result.add(((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.player(), stack, ctx.playerFeet(), Direction.UP, (float) ctx.player().posX, (float) ctx.player().posY, (float) ctx.player().posZ))));
|
||||||
// </toxic cloud>
|
// </toxic cloud>
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean valid(IBlockState current, IBlockState desired) {
|
private boolean valid(BlockState current, BlockState desired) {
|
||||||
if (desired == null) {
|
if (desired == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -723,7 +723,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class BuilderCalculationContext extends CalculationContext {
|
public class BuilderCalculationContext extends CalculationContext {
|
||||||
private final List<IBlockState> placable;
|
private final List<BlockState> placable;
|
||||||
private final ISchematic schematic;
|
private final ISchematic schematic;
|
||||||
private final int originX;
|
private final int originX;
|
||||||
private final int originY;
|
private final int originY;
|
||||||
@@ -741,7 +741,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
this.backtrackCostFavoringCoefficient = 1;
|
this.backtrackCostFavoringCoefficient = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBlockState getSchematic(int x, int y, int z) {
|
private BlockState getSchematic(int x, int y, int z) {
|
||||||
if (schematic.inSchematic(x - originX, y - originY, z - originZ)) {
|
if (schematic.inSchematic(x - originX, y - originY, z - originZ)) {
|
||||||
return schematic.desiredState(x - originX, y - originY, z - originZ);
|
return schematic.desiredState(x - originX, y - originY, z - originZ);
|
||||||
} else {
|
} else {
|
||||||
@@ -754,7 +754,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
if (isPossiblyProtected(x, y, z) || !worldBorder.canPlaceAt(x, z)) { // make calculation fail properly if we can't build
|
if (isPossiblyProtected(x, y, z) || !worldBorder.canPlaceAt(x, z)) { // make calculation fail properly if we can't build
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState sch = getSchematic(x, y, z);
|
BlockState sch = getSchematic(x, y, z);
|
||||||
if (sch != null) {
|
if (sch != null) {
|
||||||
// TODO this can return true even when allowPlace is off.... is that an issue?
|
// TODO this can return true even when allowPlace is off.... is that an issue?
|
||||||
if (sch.getBlock() instanceof BlockAir) {
|
if (sch.getBlock() instanceof BlockAir) {
|
||||||
@@ -788,7 +788,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
if (!allowBreak || isPossiblyProtected(x, y, z)) {
|
if (!allowBreak || isPossiblyProtected(x, y, z)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState sch = getSchematic(x, y, z);
|
BlockState sch = getSchematic(x, y, z);
|
||||||
if (sch != null) {
|
if (sch != null) {
|
||||||
if (sch.getBlock() instanceof BlockAir) {
|
if (sch.getBlock() instanceof BlockAir) {
|
||||||
// it should be air
|
// it should be air
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import baritone.cache.WorldScanner;
|
|||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.utils.BaritoneProcessHelper;
|
import baritone.utils.BaritoneProcessHelper;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
@@ -103,35 +103,35 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
|||||||
NETHERWART(Blocks.NETHER_WART, state -> state.get(BlockNetherWart.AGE) >= 3),
|
NETHERWART(Blocks.NETHER_WART, state -> state.get(BlockNetherWart.AGE) >= 3),
|
||||||
SUGARCANE(Blocks.SUGAR_CANE, null) {
|
SUGARCANE(Blocks.SUGAR_CANE, null) {
|
||||||
@Override
|
@Override
|
||||||
public boolean readyToHarvest(World world, BlockPos pos, IBlockState state) {
|
public boolean readyToHarvest(World world, BlockPos pos, BlockState state) {
|
||||||
return world.getBlockState(pos.down()).getBlock() instanceof BlockReed;
|
return world.getBlockState(pos.down()).getBlock() instanceof BlockReed;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CACTUS(Blocks.CACTUS, null) {
|
CACTUS(Blocks.CACTUS, null) {
|
||||||
@Override
|
@Override
|
||||||
public boolean readyToHarvest(World world, BlockPos pos, IBlockState state) {
|
public boolean readyToHarvest(World world, BlockPos pos, BlockState state) {
|
||||||
return world.getBlockState(pos.down()).getBlock() instanceof BlockCactus;
|
return world.getBlockState(pos.down()).getBlock() instanceof BlockCactus;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public final Block block;
|
public final Block block;
|
||||||
public final Predicate<IBlockState> readyToHarvest;
|
public final Predicate<BlockState> readyToHarvest;
|
||||||
|
|
||||||
Harvest(BlockCrops blockCrops) {
|
Harvest(BlockCrops blockCrops) {
|
||||||
this(blockCrops, blockCrops::isMaxAge);
|
this(blockCrops, blockCrops::isMaxAge);
|
||||||
// max age is 7 for wheat, carrots, and potatoes, but 3 for beetroot
|
// max age is 7 for wheat, carrots, and potatoes, but 3 for beetroot
|
||||||
}
|
}
|
||||||
|
|
||||||
Harvest(Block block, Predicate<IBlockState> readyToHarvest) {
|
Harvest(Block block, Predicate<BlockState> readyToHarvest) {
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.readyToHarvest = readyToHarvest;
|
this.readyToHarvest = readyToHarvest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean readyToHarvest(World world, BlockPos pos, IBlockState state) {
|
public boolean readyToHarvest(World world, BlockPos pos, BlockState state) {
|
||||||
return readyToHarvest.test(state);
|
return readyToHarvest.test(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean readyForHarvest(World world, BlockPos pos, IBlockState state) {
|
private boolean readyForHarvest(World world, BlockPos pos, BlockState state) {
|
||||||
for (Harvest harvest : Harvest.values()) {
|
for (Harvest harvest : Harvest.values()) {
|
||||||
if (harvest.block == state.getBlock()) {
|
if (harvest.block == state.getBlock()) {
|
||||||
return harvest.readyToHarvest(world, pos, state);
|
return harvest.readyToHarvest(world, pos, state);
|
||||||
@@ -170,7 +170,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
|||||||
List<BlockPos> bonemealable = new ArrayList<>();
|
List<BlockPos> bonemealable = new ArrayList<>();
|
||||||
List<BlockPos> openSoulsand = new ArrayList<>();
|
List<BlockPos> openSoulsand = new ArrayList<>();
|
||||||
for (BlockPos pos : locations) {
|
for (BlockPos pos : locations) {
|
||||||
IBlockState state = ctx.world().getBlockState(pos);
|
BlockState state = ctx.world().getBlockState(pos);
|
||||||
boolean airAbove = ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir;
|
boolean airAbove = ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir;
|
||||||
if (state.getBlock() == Blocks.FARMLAND) {
|
if (state.getBlock() == Blocks.FARMLAND) {
|
||||||
if (airAbove) {
|
if (airAbove) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import baritone.utils.BlockStateInterface;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockAir;
|
import net.minecraft.block.BlockAir;
|
||||||
import net.minecraft.block.BlockFalling;
|
import net.minecraft.block.BlockFalling;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
@@ -116,7 +116,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
baritone.getInputOverrideHandler().clearAllKeys();
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
if (shaft.isPresent()) {
|
if (shaft.isPresent()) {
|
||||||
BlockPos pos = shaft.get();
|
BlockPos pos = shaft.get();
|
||||||
IBlockState state = baritone.bsi.get0(pos);
|
BlockState state = baritone.bsi.get0(pos);
|
||||||
if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
|
if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
|
||||||
Optional<Rotation> rot = RotationUtils.reachable(ctx, pos);
|
Optional<Rotation> rot = RotationUtils.reachable(ctx, pos);
|
||||||
if (rot.isPresent() && isSafeToCancel) {
|
if (rot.isPresent() && isSafeToCancel) {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
|
|||||||
// If we're on the main menu then create the test world and launch the integrated server
|
// If we're on the main menu then create the test world and launch the integrated server
|
||||||
if (mc.currentScreen instanceof GuiMainMenu) {
|
if (mc.currentScreen instanceof GuiMainMenu) {
|
||||||
System.out.println("Beginning Baritone automatic test routine");
|
System.out.println("Beginning Baritone automatic test routine");
|
||||||
mc.displayGuiScreen(null);
|
mc.displayScreen(null);
|
||||||
WorldSettings worldsettings = new WorldSettings(TEST_SEED, GameType.getByName("survival"), true, false, WorldType.DEFAULT);
|
WorldSettings worldsettings = new WorldSettings(TEST_SEED, GameType.getByName("survival"), true, false, WorldType.DEFAULT);
|
||||||
mc.launchIntegratedServer("BaritoneAutoTest", "BaritoneAutoTest", worldsettings);
|
mc.launchIntegratedServer("BaritoneAutoTest", "BaritoneAutoTest", worldsettings);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package baritone.utils;
|
|||||||
|
|
||||||
import baritone.api.utils.Helper;
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
@@ -38,7 +38,7 @@ public final class BlockBreakHelper implements Helper {
|
|||||||
this.playerContext = playerContext;
|
this.playerContext = playerContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tryBreakBlock(BlockPos pos, EnumFacing side) {
|
public void tryBreakBlock(BlockPos pos, Direction side) {
|
||||||
if (playerContext.playerController().onPlayerDamageBlock(pos, side)) {
|
if (playerContext.playerController().onPlayerDamageBlock(pos, side)) {
|
||||||
playerContext.player().swingArm(EnumHand.MAIN_HAND);
|
playerContext.player().swingArm(EnumHand.MAIN_HAND);
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ public final class BlockBreakHelper implements Helper {
|
|||||||
|
|
||||||
public void tick(boolean isLeftClick) {
|
public void tick(boolean isLeftClick) {
|
||||||
RayTraceResult trace = playerContext.objectMouseOver();
|
RayTraceResult trace = playerContext.objectMouseOver();
|
||||||
boolean isBlockTrace = trace != null && trace.type == RayTraceResult.Type.BLOCK;
|
boolean isBlockTrace = trace != null && trace.getType() == RayTraceResult.Type.BLOCK;
|
||||||
|
|
||||||
if (isLeftClick && isBlockTrace) {
|
if (isLeftClick && isBlockTrace) {
|
||||||
tryBreakBlock(trace.getBlockPos(), trace.sideHit);
|
tryBreakBlock(trace.getBlockPos(), trace.sideHit);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class BlockPlaceHelper implements Helper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RayTraceResult mouseOver = ctx.objectMouseOver();
|
RayTraceResult mouseOver = ctx.objectMouseOver();
|
||||||
if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.type != RayTraceResult.Type.BLOCK) {
|
if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.getType() != RayTraceResult.Type.BLOCK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rightClickTimer = Baritone.settings().rightClickSpeed.value;
|
rightClickTimer = Baritone.settings().rightClickSpeed.value;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import baritone.utils.accessor.IChunkProviderClient;
|
|||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -48,7 +48,7 @@ public class BlockStateInterface {
|
|||||||
|
|
||||||
private final boolean useTheRealWorld;
|
private final boolean useTheRealWorld;
|
||||||
|
|
||||||
private static final IBlockState AIR = Blocks.AIR.getDefaultState();
|
private static final BlockState AIR = Blocks.AIR.getDefaultState();
|
||||||
|
|
||||||
public BlockStateInterface(IPlayerContext ctx) {
|
public BlockStateInterface(IPlayerContext ctx) {
|
||||||
this(ctx, false);
|
this(ctx, false);
|
||||||
@@ -80,17 +80,17 @@ public class BlockStateInterface {
|
|||||||
return get(ctx, pos).getBlock();
|
return get(ctx, pos).getBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBlockState get(IPlayerContext ctx, BlockPos pos) {
|
public static BlockState get(IPlayerContext ctx, BlockPos pos) {
|
||||||
return new BlockStateInterface(ctx).get0(pos.getX(), pos.getY(), pos.getZ()); // immense iq
|
return new BlockStateInterface(ctx).get0(pos.getX(), pos.getY(), pos.getZ()); // immense iq
|
||||||
// can't just do world().get because that doesn't work for out of bounds
|
// can't just do world().get because that doesn't work for out of bounds
|
||||||
// and toBreak and stuff fails when the movement is instantiated out of load range but it's not able to BlockStateInterface.get what it's going to walk on
|
// and toBreak and stuff fails when the movement is instantiated out of load range but it's not able to BlockStateInterface.get what it's going to walk on
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBlockState get0(BlockPos pos) {
|
public BlockState get0(BlockPos pos) {
|
||||||
return get0(pos.getX(), pos.getY(), pos.getZ());
|
return get0(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBlockState get0(int x, int y, int z) { // Mickey resigned
|
public BlockState get0(int x, int y, int z) { // Mickey resigned
|
||||||
|
|
||||||
// Invalid vertical position
|
// Invalid vertical position
|
||||||
if (y < 0 || y >= 256) {
|
if (y < 0 || y >= 256) {
|
||||||
@@ -129,7 +129,7 @@ public class BlockStateInterface {
|
|||||||
prevCached = region;
|
prevCached = region;
|
||||||
cached = region;
|
cached = region;
|
||||||
}
|
}
|
||||||
IBlockState type = cached.getBlock(x & 511, y, z & 511);
|
BlockState type = cached.getBlock(x & 511, y, z & 511);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return AIR;
|
return AIR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import baritone.api.BaritoneAPI;
|
|||||||
import baritone.api.pathing.goals.GoalBlock;
|
import baritone.api.pathing.goals.GoalBlock;
|
||||||
import baritone.api.pathing.goals.GoalTwoBlocks;
|
import baritone.api.pathing.goals.GoalTwoBlocks;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.Screen;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.util.math.*;
|
||||||
@@ -36,7 +36,7 @@ import java.util.Collections;
|
|||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
import static org.lwjgl.opengl.GL11.*;
|
||||||
|
|
||||||
public class GuiClick extends GuiScreen {
|
public class GuiClick extends Screen {
|
||||||
|
|
||||||
// My name is Brady and I grant leijurv permission to use this pasted code
|
// My name is Brady and I grant leijurv permission to use this pasted code
|
||||||
private final FloatBuffer MODELVIEW = BufferUtils.createFloatBuffer(16);
|
private final FloatBuffer MODELVIEW = BufferUtils.createFloatBuffer(16);
|
||||||
@@ -64,7 +64,7 @@ public class GuiClick extends GuiScreen {
|
|||||||
if (near != null && far != null) {
|
if (near != null && far != null) {
|
||||||
Vec3d viewerPos = new Vec3d(mc.getRenderManager().viewerPosX, mc.getRenderManager().viewerPosY, mc.getRenderManager().viewerPosZ);
|
Vec3d viewerPos = new Vec3d(mc.getRenderManager().viewerPosX, mc.getRenderManager().viewerPosY, mc.getRenderManager().viewerPosZ);
|
||||||
RayTraceResult result = mc.world.rayTraceBlocks(near.add(viewerPos), far.add(viewerPos), RayTraceFluidMode.NEVER, false, true);
|
RayTraceResult result = mc.world.rayTraceBlocks(near.add(viewerPos), far.add(viewerPos), RayTraceFluidMode.NEVER, false, true);
|
||||||
if (result != null && result.type == RayTraceResult.Type.BLOCK) {
|
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
|
||||||
currentMouseOver = result.getBlockPos();
|
currentMouseOver = result.getBlockPos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import baritone.api.utils.Helper;
|
|||||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import baritone.behavior.PathingBehavior;
|
import baritone.behavior.PathingBehavior;
|
||||||
import baritone.pathing.path.PathExecutor;
|
import baritone.pathing.path.PathExecutor;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
@@ -219,7 +219,7 @@ public final class PathRenderer implements Helper {
|
|||||||
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
|
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
|
||||||
BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe?
|
BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe?
|
||||||
positions.forEach(pos -> {
|
positions.forEach(pos -> {
|
||||||
IBlockState state = bsi.get0(pos);
|
BlockState state = bsi.get0(pos);
|
||||||
VoxelShape shape = state.getShape(player.world, pos);
|
VoxelShape shape = state.getShape(player.world, pos);
|
||||||
AxisAlignedBB toDraw = shape.isEmpty() ? VoxelShapes.fullCube().getBoundingBox() : shape.getBoundingBox();
|
AxisAlignedBB toDraw = shape.isEmpty() ? VoxelShapes.fullCube().getBoundingBox() : shape.getBoundingBox();
|
||||||
toDraw = toDraw.offset(pos);
|
toDraw = toDraw.offset(pos);
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package baritone.utils;
|
|||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.ClientPlayerEntity;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.init.Enchantments;
|
import net.minecraft.init.Enchantments;
|
||||||
import net.minecraft.init.MobEffects;
|
import net.minecraft.init.MobEffects;
|
||||||
@@ -48,9 +48,9 @@ public class ToolSet {
|
|||||||
*/
|
*/
|
||||||
private final Function<Block, Double> backendCalculation;
|
private final Function<Block, Double> backendCalculation;
|
||||||
|
|
||||||
private final EntityPlayerSP player;
|
private final ClientPlayerEntity player;
|
||||||
|
|
||||||
public ToolSet(EntityPlayerSP player) {
|
public ToolSet(ClientPlayerEntity player) {
|
||||||
breakStrengthCache = new HashMap<>();
|
breakStrengthCache = new HashMap<>();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class ToolSet {
|
|||||||
* @param state the blockstate to be mined
|
* @param state the blockstate to be mined
|
||||||
* @return the speed of how fast we'll mine it. 1/(time in ticks)
|
* @return the speed of how fast we'll mine it. 1/(time in ticks)
|
||||||
*/
|
*/
|
||||||
public double getStrVsBlock(IBlockState state) {
|
public double getStrVsBlock(BlockState state) {
|
||||||
return breakStrengthCache.computeIfAbsent(state.getBlock(), backendCalculation);
|
return breakStrengthCache.computeIfAbsent(state.getBlock(), backendCalculation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ public class ToolSet {
|
|||||||
byte best = 0;
|
byte best = 0;
|
||||||
double value = Double.NEGATIVE_INFINITY;
|
double value = Double.NEGATIVE_INFINITY;
|
||||||
int materialCost = Integer.MIN_VALUE;
|
int materialCost = Integer.MIN_VALUE;
|
||||||
IBlockState blockState = b.getDefaultState();
|
BlockState blockState = b.getDefaultState();
|
||||||
for (byte i = 0; i < 9; i++) {
|
for (byte i = 0; i < 9; i++) {
|
||||||
ItemStack itemStack = player.inventory.getStackInSlot(i);
|
ItemStack itemStack = player.inventory.getStackInSlot(i);
|
||||||
double v = calculateSpeedVsBlock(itemStack, blockState);
|
double v = calculateSpeedVsBlock(itemStack, blockState);
|
||||||
@@ -136,7 +136,7 @@ public class ToolSet {
|
|||||||
* @param state the blockstate to be mined
|
* @param state the blockstate to be mined
|
||||||
* @return how long it would take in ticks
|
* @return how long it would take in ticks
|
||||||
*/
|
*/
|
||||||
public static double calculateSpeedVsBlock(ItemStack item, IBlockState state) {
|
public static double calculateSpeedVsBlock(ItemStack item, BlockState state) {
|
||||||
float hardness = state.getBlockHardness(null, null);
|
float hardness = state.getBlockHardness(null, null);
|
||||||
if (hardness < 0) {
|
if (hardness < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import baritone.pathing.calc.AStarPathFinder;
|
|||||||
import baritone.pathing.calc.AbstractNodeCostSearch;
|
import baritone.pathing.calc.AbstractNodeCostSearch;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.path.SplicedPath;
|
import baritone.pathing.path.SplicedPath;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -80,7 +80,7 @@ public class SegmentedCalculator {
|
|||||||
// it checks if every chunk is loaded before getting blocks from it
|
// it checks if every chunk is loaded before getting blocks from it
|
||||||
// so you see path segments ending at multiples of 512 (plus or minus one) on either x or z axis
|
// so you see path segments ending at multiples of 512 (plus or minus one) on either x or z axis
|
||||||
// this loads every adjacent chunk to the segment end, so it can continue into the next cached region
|
// this loads every adjacent chunk to the segment end, so it can continue into the next cached region
|
||||||
BetterBlockPos toLoad = bp.offset(EnumFacing.byHorizontalIndex(i), 16);
|
BetterBlockPos toLoad = bp.offset(Direction.byHorizontalIndex(i), 16);
|
||||||
cached.tryLoadFromDisk(toLoad.x >> 9, toLoad.z >> 9);
|
cached.tryLoadFromDisk(toLoad.x >> 9, toLoad.z >> 9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import baritone.api.utils.Helper;
|
|||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import baritone.api.utils.IPlayerController;
|
import baritone.api.utils.IPlayerController;
|
||||||
import baritone.api.utils.RayTraceUtils;
|
import baritone.api.utils.RayTraceUtils;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.ClientPlayerEntity;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ public enum PrimaryPlayerContext implements IPlayerContext, Helper {
|
|||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPlayerSP player() {
|
public ClientPlayerEntity player() {
|
||||||
return mc.player;
|
return mc.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ package baritone.utils.player;
|
|||||||
|
|
||||||
import baritone.api.utils.Helper;
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerController;
|
import baritone.api.utils.IPlayerController;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.ClientPlayerEntity;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.multiplayer.ClientWorld;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.ClickType;
|
import net.minecraft.inventory.ClickType;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
@@ -43,7 +43,7 @@ public enum PrimaryPlayerController implements IPlayerController, Helper {
|
|||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPlayerDamageBlock(BlockPos pos, EnumFacing side) {
|
public boolean onPlayerDamageBlock(BlockPos pos, Direction side) {
|
||||||
return mc.playerController.onPlayerDamageBlock(pos, side);
|
return mc.playerController.onPlayerDamageBlock(pos, side);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public enum PrimaryPlayerController implements IPlayerController, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player) {
|
public ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, PlayerEntity player) {
|
||||||
return mc.playerController.windowClick(windowId, slotId, mouseButton, type, player);
|
return mc.playerController.windowClick(windowId, slotId, mouseButton, type, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,13 +68,13 @@ public enum PrimaryPlayerController implements IPlayerController, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult processRightClickBlock(EntityPlayerSP player, World world, BlockPos pos, EnumFacing direction, Vec3d vec, EnumHand hand) {
|
public EnumActionResult processRightClickBlock(ClientPlayerEntity player, World world, BlockPos pos, Direction direction, Vec3d vec, EnumHand hand) {
|
||||||
// primaryplayercontroller is always in a WorldClient so this is ok
|
// primaryplayercontroller is always in a ClientWorld so this is ok
|
||||||
return mc.playerController.processRightClickBlock(player, (WorldClient) world, pos, direction, vec, hand);
|
return mc.playerController.processRightClickBlock(player, (ClientWorld) world, pos, direction, vec, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult processRightClick(EntityPlayerSP player, World world, EnumHand hand) {
|
public EnumActionResult processRightClick(ClientPlayerEntity player, World world, EnumHand hand) {
|
||||||
return mc.playerController.processRightClick(player, world, hand);
|
return mc.playerController.processRightClick(player, world, hand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.utils.schematic;
|
package baritone.utils.schematic;
|
||||||
|
|
||||||
import baritone.api.utils.ISchematic;
|
import baritone.api.utils.ISchematic;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
|
||||||
public class AirSchematic implements ISchematic {
|
public class AirSchematic implements ISchematic {
|
||||||
@@ -34,7 +34,7 @@ public class AirSchematic implements ISchematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState desiredState(int x, int y, int z) {
|
public BlockState desiredState(int x, int y, int z) {
|
||||||
return Blocks.AIR.getDefaultState();
|
return Blocks.AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.utils.schematic;
|
package baritone.utils.schematic;
|
||||||
|
|
||||||
import net.minecraft.block.BlockAir;
|
import net.minecraft.block.BlockAir;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
@@ -34,7 +34,7 @@ public class MapArtSchematic extends Schematic {
|
|||||||
|
|
||||||
for (int x = 0; x < widthX; x++) {
|
for (int x = 0; x < widthX; x++) {
|
||||||
for (int z = 0; z < lengthZ; z++) {
|
for (int z = 0; z < lengthZ; z++) {
|
||||||
IBlockState[] column = states[x][z];
|
BlockState[] column = states[x][z];
|
||||||
|
|
||||||
OptionalInt lowestBlockY = lastIndexMatching(column, block -> !(block instanceof BlockAir));
|
OptionalInt lowestBlockY = lastIndexMatching(column, block -> !(block instanceof BlockAir));
|
||||||
if (lowestBlockY.isPresent()) {
|
if (lowestBlockY.isPresent()) {
|
||||||
|
|||||||
@@ -18,14 +18,14 @@
|
|||||||
package baritone.utils.schematic;
|
package baritone.utils.schematic;
|
||||||
|
|
||||||
import baritone.api.utils.ISchematic;
|
import baritone.api.utils.ISchematic;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
public class Schematic implements ISchematic {
|
public class Schematic implements ISchematic {
|
||||||
public final int widthX;
|
public final int widthX;
|
||||||
public final int heightY;
|
public final int heightY;
|
||||||
public final int lengthZ;
|
public final int lengthZ;
|
||||||
protected final IBlockState[][][] states;
|
protected final BlockState[][][] states;
|
||||||
|
|
||||||
public Schematic(NBTTagCompound schematic) {
|
public Schematic(NBTTagCompound schematic) {
|
||||||
/*String type = schematic.getString("Materials");
|
/*String type = schematic.getString("Materials");
|
||||||
@@ -47,7 +47,7 @@ public class Schematic implements ISchematic {
|
|||||||
additional[i * 2 + 1] = (byte) ((addBlocks[i] >> 0) & 0xF); // upper nibble
|
additional[i * 2 + 1] = (byte) ((addBlocks[i] >> 0) & 0xF); // upper nibble
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
states = new IBlockState[widthX][lengthZ][heightY];
|
states = new BlockState[widthX][lengthZ][heightY];
|
||||||
for (int y = 0; y < heightY; y++) {
|
for (int y = 0; y < heightY; y++) {
|
||||||
for (int z = 0; z < lengthZ; z++) {
|
for (int z = 0; z < lengthZ; z++) {
|
||||||
for (int x = 0; x < widthX; x++) {
|
for (int x = 0; x < widthX; x++) {
|
||||||
@@ -68,7 +68,7 @@ public class Schematic implements ISchematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState desiredState(int x, int y, int z) {
|
public BlockState desiredState(int x, int y, int z) {
|
||||||
return states[x][z][y];
|
return states[x][z][y];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.utils.pathing;
|
package baritone.utils.pathing;
|
||||||
|
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public class BetterBlockPosTest {
|
|||||||
assertEquals(pos.south(), better.south());
|
assertEquals(pos.south(), better.south());
|
||||||
assertEquals(pos.east(), better.east());
|
assertEquals(pos.east(), better.east());
|
||||||
assertEquals(pos.west(), better.west());
|
assertEquals(pos.west(), better.west());
|
||||||
for (EnumFacing dir : EnumFacing.values()) {
|
for (Direction dir : Direction.values()) {
|
||||||
assertEquals(pos.offset(dir), better.offset(dir));
|
assertEquals(pos.offset(dir), better.offset(dir));
|
||||||
assertEquals(pos.offset(dir, 0), pos);
|
assertEquals(pos.offset(dir, 0), pos);
|
||||||
assertEquals(better.offset(dir, 0), better);
|
assertEquals(better.offset(dir, 0), better);
|
||||||
|
|||||||
Reference in New Issue
Block a user