diff --git a/README.md b/README.md index ba4897ee..cdd31b0d 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ PathingBehavior.INSTANCE.path(); ## Can I use Baritone as a library in my hacked client? -Sure! +Sure! (As long as usage is in compliance with the GPL 3 License) ## How is it so fast? diff --git a/src/launch/java/baritone/launch/BaritoneTweaker.java b/src/launch/java/baritone/launch/BaritoneTweaker.java index e281ece3..9638214c 100644 --- a/src/launch/java/baritone/launch/BaritoneTweaker.java +++ b/src/launch/java/baritone/launch/BaritoneTweaker.java @@ -39,9 +39,15 @@ public class BaritoneTweaker implements ITweaker { @Override public void acceptOptions(List args, File gameDir, File assetsDir, String profile) { this.args = new ArrayList<>(args); - if (gameDir != null) addArg("gameDir", gameDir.getAbsolutePath()); - if (assetsDir != null) addArg("assetsDir", assetsDir.getAbsolutePath()); - if (profile != null) addArg("version", profile); + if (gameDir != null) { + addArg("gameDir", gameDir.getAbsolutePath()); + } + if (assetsDir != null) { + addArg("assetsDir", assetsDir.getAbsolutePath()); + } + if (profile != null) { + addArg("version", profile); + } } @Override diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index 9da39df3..9a45659e 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -42,8 +42,9 @@ public class MixinEntityPlayerSP { private void sendChatMessage(String msg, CallbackInfo ci) { ChatEvent event = new ChatEvent(msg); Baritone.INSTANCE.getGameEventHandler().onSendChatMessage(event); - if (event.isCancelled()) + if (event.isCancelled()) { ci.cancel(); + } } @Inject( diff --git a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index 838802cd..4285c14d 100644 --- a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -37,7 +37,8 @@ public class MixinKeyBinding { cancellable = true ) private void isKeyDown(CallbackInfoReturnable cir) { - if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) + if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) { cir.setReturnValue(true); + } } } diff --git a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java index 46664e7c..b0fedc62 100644 --- a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java +++ b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java @@ -39,13 +39,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(NetworkManager.class) public class MixinNetworkManager { - @Shadow private Channel channel; + @Shadow + private Channel channel; @Inject( method = "dispatchPacket", at = @At("HEAD") ) - private void preDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { + private void preDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.PRE, inPacket)); } @@ -53,7 +54,7 @@ public class MixinNetworkManager { method = "dispatchPacket", at = @At("RETURN") ) - private void postDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { + private void postDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.POST, inPacket)); } @@ -73,7 +74,8 @@ public class MixinNetworkManager { at = @At("RETURN") ) private void postProcessPacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { - if (this.channel.isOpen()) + if (this.channel.isOpen()) { Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.POST, packet)); + } } } diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/api/event/GameEventHandler.java index 1ec2d834..32634213 100644 --- a/src/main/java/baritone/api/event/GameEventHandler.java +++ b/src/main/java/baritone/api/event/GameEventHandler.java @@ -49,7 +49,6 @@ import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.List; -import java.util.function.Consumer; /** * @author Brady @@ -61,12 +60,20 @@ public final class GameEventHandler implements IGameEventListener, Helper { @Override public final void onTick(TickEvent event) { - dispatch(listener -> listener.onTick(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onTick(event); + } + } } @Override public final void onPlayerUpdate(PlayerUpdateEvent event) { - dispatch(listener -> listener.onPlayerUpdate(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onPlayerUpdate(event); + } + } } @Override @@ -80,17 +87,26 @@ public final class GameEventHandler implements IGameEventListener, Helper { if (inputHandler.isInputForcedDown(keyBinding) && !keyBinding.isKeyDown()) { int keyCode = keyBinding.getKeyCode(); - if (keyCode < Keyboard.KEYBOARD_SIZE) + if (keyCode < Keyboard.KEYBOARD_SIZE) { KeyBinding.onTick(keyCode < 0 ? keyCode + 100 : keyCode); + } } } - dispatch(IGameEventListener::onProcessKeyBinds); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onProcessKeyBinds(); + } + } } @Override public final void onSendChatMessage(ChatEvent event) { - dispatch(listener -> listener.onSendChatMessage(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onSendChatMessage(event); + } + } } @Override @@ -116,18 +132,20 @@ public final class GameEventHandler implements IGameEventListener, Helper { } - dispatch(listener -> listener.onChunkEvent(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onChunkEvent(event); + } + } } @Override public final void onRenderPass(RenderEvent event) { - /* - WorldProvider.INSTANCE.ifWorldLoaded(world -> world.forEachRegion(region -> region.forEachChunk(chunk -> { - drawChunkLine(region.getX() * 512 + chunk.getX() * 16, region.getZ() * 512 + chunk.getZ() * 16, event.getPartialTicks()); - }))); - */ - - dispatch(listener -> listener.onRenderPass(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onRenderPass(event); + } + } } @Override @@ -141,52 +159,77 @@ public final class GameEventHandler implements IGameEventListener, Helper { break; case POST: cache.closeWorld(); - if (event.getWorld() != null) + if (event.getWorld() != null) { cache.initWorld(event.getWorld()); + } break; } - dispatch(listener -> listener.onWorldEvent(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onWorldEvent(event); + } + } } @Override public final void onSendPacket(PacketEvent event) { - dispatch(listener -> listener.onSendPacket(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onSendPacket(event); + } + } } @Override public final void onReceivePacket(PacketEvent event) { - dispatch(listener -> listener.onReceivePacket(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onReceivePacket(event); + } + } } @Override public void onPlayerRelativeMove(RelativeMoveEvent event) { - dispatch(listener -> listener.onPlayerRelativeMove(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onPlayerRelativeMove(event); + } + } } @Override public void onBlockInteract(BlockInteractEvent event) { - dispatch(listener -> listener.onBlockInteract(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onBlockInteract(event); + } + } } @Override public void onPlayerDeath() { - dispatch(IGameEventListener::onPlayerDeath); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onPlayerDeath(); + } + } } @Override public void onPathEvent(PathEvent event) { - dispatch(listener -> listener.onPathEvent(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onPathEvent(event); + } + } } public final void registerEventListener(IGameEventListener listener) { this.listeners.add(listener); } - private void dispatch(Consumer dispatchFunction) { - this.listeners.stream().filter(this::canDispatch).forEach(dispatchFunction); - } - private boolean canDispatch(IGameEventListener listener) { return !(listener instanceof Toggleable) || ((Toggleable) listener).isEnabled(); } diff --git a/src/main/java/baritone/behavior/Behavior.java b/src/main/java/baritone/behavior/Behavior.java index ad5e3a88..5bf6c5c6 100644 --- a/src/main/java/baritone/behavior/Behavior.java +++ b/src/main/java/baritone/behavior/Behavior.java @@ -52,8 +52,9 @@ public class Behavior implements AbstractGameEventListener, Toggleable, Helper { @Override public final boolean setEnabled(boolean enabled) { boolean newState = getNewState(this.enabled, enabled); - if (newState == this.enabled) + if (newState == this.enabled) { return this.enabled; + } if (this.enabled = newState) { onStart(); diff --git a/src/main/java/baritone/behavior/impl/LookBehavior.java b/src/main/java/baritone/behavior/impl/LookBehavior.java index 080d75d5..b740618a 100644 --- a/src/main/java/baritone/behavior/impl/LookBehavior.java +++ b/src/main/java/baritone/behavior/impl/LookBehavior.java @@ -19,9 +19,9 @@ package baritone.behavior.impl; import baritone.Baritone; import baritone.Settings; -import baritone.behavior.Behavior; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RelativeMoveEvent; +import baritone.behavior.Behavior; import baritone.utils.Rotation; public class LookBehavior extends Behavior { @@ -57,8 +57,9 @@ public class LookBehavior extends Behavior { @Override public void onPlayerUpdate(PlayerUpdateEvent event) { - if (this.target == null) + if (this.target == null) { return; + } // Whether or not we're going to silently set our angles boolean silent = Baritone.settings().antiCheatCompatibility.get(); @@ -102,8 +103,9 @@ public class LookBehavior extends Behavior { player().rotationYaw = this.lastYaw; // If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate() - if (!Baritone.settings().antiCheatCompatibility.get()) + if (!Baritone.settings().antiCheatCompatibility.get()) { this.target = null; + } break; } } diff --git a/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java b/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java index 91b046e0..a7896d03 100644 --- a/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java +++ b/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java @@ -67,9 +67,10 @@ public final class LookBehaviorUtils implements Helper { return Optional.of(new Rotation(mc.player.rotationYaw, mc.player.rotationPitch + 0.0001f)); } Optional possibleRotation = reachableCenter(pos); - System.out.println("center: " + possibleRotation); - if (possibleRotation.isPresent()) + //System.out.println("center: " + possibleRotation); + if (possibleRotation.isPresent()) { return possibleRotation; + } IBlockState state = BlockStateInterface.get(pos); AxisAlignedBB aabb = state.getBoundingBox(mc.world, pos); @@ -78,8 +79,9 @@ public final class LookBehaviorUtils implements Helper { double yDiff = aabb.minY * sideOffset.y + aabb.maxY * (1 - sideOffset.y); double zDiff = aabb.minZ * sideOffset.z + aabb.maxZ * (1 - sideOffset.z); possibleRotation = reachableOffset(pos, new Vec3d(pos).add(xDiff, yDiff, zDiff)); - if (possibleRotation.isPresent()) + if (possibleRotation.isPresent()) { return possibleRotation; + } } return Optional.empty(); } diff --git a/src/main/java/baritone/behavior/impl/MemoryBehavior.java b/src/main/java/baritone/behavior/impl/MemoryBehavior.java index 8f43a8e8..93657988 100644 --- a/src/main/java/baritone/behavior/impl/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/impl/MemoryBehavior.java @@ -1,9 +1,9 @@ package baritone.behavior.impl; -import baritone.behavior.Behavior; import baritone.api.event.events.PacketEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.type.EventState; +import baritone.behavior.Behavior; import net.minecraft.item.ItemStack; import net.minecraft.network.Packet; import net.minecraft.network.play.client.CPacketCloseWindow; @@ -38,8 +38,9 @@ public class MemoryBehavior extends Behavior { @Override public void onPlayerUpdate(PlayerUpdateEvent event) { - if (event.getState() == EventState.PRE) + if (event.getState() == EventState.PRE) { updateInventory(); + } } @Override @@ -86,13 +87,13 @@ public class MemoryBehavior extends Behavior { this.futureInventories.stream() .filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount()) .findFirst().ifPresent(matched -> { - // Remove the future inventory - this.futureInventories.remove(matched); + // Remove the future inventory + this.futureInventories.remove(matched); - // Setup the remembered inventory - RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory()); - inventory.windowId = packet.getWindowId(); - inventory.size = packet.getSlotCount(); + // Setup the remembered inventory + RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory()); + inventory.windowId = packet.getWindowId(); + inventory.size = packet.getSlotCount(); }); } diff --git a/src/main/java/baritone/behavior/impl/PathingBehavior.java b/src/main/java/baritone/behavior/impl/PathingBehavior.java index fa651a87..14060fba 100644 --- a/src/main/java/baritone/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/behavior/impl/PathingBehavior.java @@ -389,8 +389,9 @@ public class PathingBehavior extends Behavior { }); long end = System.nanoTime(); //System.out.println((end - split) + " " + (split - start)); - // if (end - start > 0) + // if (end - start > 0) { // System.out.println("Frame took " + (split - start) + " " + (end - split)); + //} } } diff --git a/src/main/java/baritone/chunk/CachedChunk.java b/src/main/java/baritone/chunk/CachedChunk.java index 418a015e..56f7662a 100644 --- a/src/main/java/baritone/chunk/CachedChunk.java +++ b/src/main/java/baritone/chunk/CachedChunk.java @@ -199,7 +199,8 @@ public final class CachedChunk implements IBlockTypeAccess { * @throws IllegalArgumentException if the bitset size exceeds the maximum size */ private static void validateSize(BitSet data) { - if (data.size() > SIZE) + if (data.size() > SIZE) { throw new IllegalArgumentException("BitSet of invalid length provided"); + } } } diff --git a/src/main/java/baritone/chunk/CachedRegion.java b/src/main/java/baritone/chunk/CachedRegion.java index e15164e4..ee305527 100644 --- a/src/main/java/baritone/chunk/CachedRegion.java +++ b/src/main/java/baritone/chunk/CachedRegion.java @@ -112,13 +112,15 @@ public final class CachedRegion implements IBlockTypeAccess { } try { Path path = Paths.get(directory); - if (!Files.exists(path)) + if (!Files.exists(path)) { Files.createDirectories(path); + } System.out.println("Saving region " + x + "," + z + " to disk " + path); Path regionFile = getRegionFile(path, this.x, this.z); - if (!Files.exists(regionFile)) + if (!Files.exists(regionFile)) { Files.createFile(regionFile); + } try ( FileOutputStream fileOut = new FileOutputStream(regionFile.toFile()); GZIPOutputStream gzipOut = new GZIPOutputStream(fileOut, 16384); @@ -175,12 +177,14 @@ public final class CachedRegion implements IBlockTypeAccess { public synchronized void load(String directory) { try { Path path = Paths.get(directory); - if (!Files.exists(path)) + if (!Files.exists(path)) { Files.createDirectories(path); + } Path regionFile = getRegionFile(path, this.x, this.z); - if (!Files.exists(regionFile)) + if (!Files.exists(regionFile)) { return; + } System.out.println("Loading region " + x + "," + z + " from disk " + path); long start = System.nanoTime() / 1000000L; diff --git a/src/main/java/baritone/chunk/CachedWorld.java b/src/main/java/baritone/chunk/CachedWorld.java index 56d8ef38..14097c16 100644 --- a/src/main/java/baritone/chunk/CachedWorld.java +++ b/src/main/java/baritone/chunk/CachedWorld.java @@ -128,9 +128,11 @@ public final class CachedWorld implements IBlockTypeAccess { int regionX = xoff + playerRegionX; int regionZ = zoff + playerRegionZ; CachedRegion region = getOrCreateRegion(regionX, regionZ); - if (region != null) - for (BlockPos pos : region.getLocationsOf(block)) + if (region != null) { + for (BlockPos pos : region.getLocationsOf(block)) { res.add(pos); + } + } } } if (res.size() >= minimum) { @@ -153,8 +155,9 @@ public final class CachedWorld implements IBlockTypeAccess { } long start = System.nanoTime() / 1000000L; this.cachedRegions.values().parallelStream().forEach(region -> { - if (region != null) + if (region != null) { region.save(this.directory); + } }); long now = System.nanoTime() / 1000000L; System.out.println("World save took " + (now - start) + "ms"); @@ -163,8 +166,9 @@ public final class CachedWorld implements IBlockTypeAccess { public final void reloadAllFromDisk() { long start = System.nanoTime() / 1000000L; this.cachedRegions.values().forEach(region -> { - if (region != null) + if (region != null) { region.load(this.directory); + } }); long now = System.nanoTime() / 1000000L; System.out.println("World load took " + (now - start) + "ms"); @@ -199,8 +203,9 @@ public final class CachedWorld implements IBlockTypeAccess { public void forEachRegion(Consumer consumer) { this.cachedRegions.forEach((id, r) -> { - if (r != null) + if (r != null) { consumer.accept(r); + } }); } @@ -213,8 +218,9 @@ public final class CachedWorld implements IBlockTypeAccess { * @return The region ID */ private long getRegionID(int regionX, int regionZ) { - if (!isRegionInWorld(regionX, regionZ)) + if (!isRegionInWorld(regionX, regionZ)) { return 0; + } return (long) regionX & 0xFFFFFFFFL | ((long) regionZ & 0xFFFFFFFFL) << 32; } diff --git a/src/main/java/baritone/chunk/Waypoints.java b/src/main/java/baritone/chunk/Waypoints.java index d75ff733..ec587fea 100644 --- a/src/main/java/baritone/chunk/Waypoints.java +++ b/src/main/java/baritone/chunk/Waypoints.java @@ -61,8 +61,9 @@ public class Waypoints { waypoints.put(tag, new HashSet<>()); Path fileName = directory.resolve(tag.name().toLowerCase() + ".mp4"); - if (!Files.exists(fileName)) + if (!Files.exists(fileName)) { return; + } try ( FileInputStream fileIn = new FileInputStream(fileName.toFile()); diff --git a/src/main/java/baritone/chunk/WorldProvider.java b/src/main/java/baritone/chunk/WorldProvider.java index 275b6ac1..007f037d 100644 --- a/src/main/java/baritone/chunk/WorldProvider.java +++ b/src/main/java/baritone/chunk/WorldProvider.java @@ -18,9 +18,9 @@ package baritone.chunk; import baritone.Baritone; +import baritone.utils.Helper; import baritone.utils.accessor.IAnvilChunkLoader; import baritone.utils.accessor.IChunkProviderServer; -import baritone.utils.Helper; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.world.WorldServer; @@ -69,7 +69,7 @@ public enum WorldProvider implements Helper { directory = new File(directory, "baritone"); readme = directory; - + } else { //remote directory = new File(Baritone.INSTANCE.getDir(), mc.getCurrentServerData().serverIP); @@ -102,7 +102,8 @@ public enum WorldProvider implements Helper { } public final void ifWorldLoaded(Consumer currentWorldConsumer) { - if (this.currentWorld != null) + if (this.currentWorld != null) { currentWorldConsumer.accept(this.currentWorld); + } } } diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index 314c996b..45190fa7 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -26,7 +26,7 @@ import baritone.utils.pathing.BetterBlockPos; * * @author leijurv */ -public class PathNode { +public final class PathNode { /** * The position of this node @@ -103,8 +103,9 @@ public class PathNode { // GOTTA GO FAST // ALL THESE CHECKS ARE FOR PEOPLE WHO WANT SLOW CODE // SKRT SKRT - //if (obj == null || !(obj instanceof PathNode)) + //if (obj == null || !(obj instanceof PathNode)) { // return false; + //} //final PathNode other = (PathNode) obj; //return Objects.equals(this.pos, other.pos) && Objects.equals(this.goal, other.goal); diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 9d4c51d6..0ee4a35f 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -70,8 +70,9 @@ public abstract class Movement implements Helper, MovementHelper { public double getCost(CalculationContext context) { if (cost == null) { - if (context == null) + if (context == null) { context = new CalculationContext(); + } cost = calculateCost(context); } return cost; @@ -132,13 +133,15 @@ public abstract class Movement implements Helper, MovementHelper { }); latestState.getInputStates().replaceAll((input, forced) -> false); - if (!this.didBreakLastTick) + if (!this.didBreakLastTick) { BlockBreakHelper.stopBreakingBlock(); + } currentState = latestState; - if (isFinished()) + if (isFinished()) { onFinish(latestState); + } return currentState.getStatus(); } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 994a6443..79ad6371 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -73,10 +73,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (block == Blocks.AIR) { return true; } - if (block instanceof BlockFire - || block instanceof BlockTripWire - || block instanceof BlockWeb - || block instanceof BlockEndPortal) {//you can't actually walk through a lilypad from the side, and you shouldn't walk through fire + if (block instanceof BlockFire || block instanceof BlockTripWire || block instanceof BlockWeb || block instanceof BlockEndPortal) { return false; } if (block instanceof BlockDoor || block instanceof BlockFenceGate) { @@ -162,30 +159,35 @@ public interface MovementHelper extends ActionCosts, Helper { } static boolean isDoorPassable(BlockPos doorPos, BlockPos playerPos) { - if (playerPos.equals(doorPos)) + if (playerPos.equals(doorPos)) { return false; + } IBlockState state = BlockStateInterface.get(doorPos); - if (!(state.getBlock() instanceof BlockDoor)) + if (!(state.getBlock() instanceof BlockDoor)) { return true; + } return isHorizontalBlockPassable(doorPos, state, playerPos, BlockDoor.OPEN); } static boolean isGatePassable(BlockPos gatePos, BlockPos playerPos) { - if (playerPos.equals(gatePos)) + if (playerPos.equals(gatePos)) { return false; + } IBlockState state = BlockStateInterface.get(gatePos); - if (!(state.getBlock() instanceof BlockFenceGate)) + if (!(state.getBlock() instanceof BlockFenceGate)) { return true; + } return isHorizontalBlockPassable(gatePos, state, playerPos, BlockFenceGate.OPEN); } static boolean isHorizontalBlockPassable(BlockPos blockPos, IBlockState blockState, BlockPos playerPos, PropertyBool propertyOpen) { - if (playerPos.equals(blockPos)) + if (playerPos.equals(blockPos)) { return false; + } EnumFacing.Axis facing = blockState.getValue(BlockHorizontal.FACING).getAxis(); boolean open = blockState.getValue(propertyOpen); @@ -295,8 +297,9 @@ public interface MovementHelper extends ActionCosts, Helper { } double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table double strVsBlock = context.getToolSet().getStrVsBlock(state); - if (strVsBlock < 0) + if (strVsBlock < 0) { return COST_INF; + } double result = m / strVsBlock; if (includeFalling) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index e79929be..474fd162 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -123,8 +123,9 @@ public class MovementAscend extends Movement { super.updateState(state); // TODO incorporate some behavior from ActionClimb (specifically how it waited until it was at most 1.2 blocks away before starting to jump // for efficiency in ascending minimal height staircases, which is just repeated MovementAscend, so that it doesn't bonk its head on the ceiling repeatedly) - if (state.getStatus() != MovementStatus.RUNNING) + if (state.getStatus() != MovementStatus.RUNNING) { return state; + } if (playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 86d9db99..d8d9d3b2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -67,8 +67,9 @@ public class MovementDescend extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementStatus.RUNNING) + if (state.getStatus() != MovementStatus.RUNNING) { return state; + } BlockPos playerFeet = playerFeet(); if (playerFeet.equals(dest)) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 1a11295e..d343234c 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -119,8 +119,9 @@ public class MovementDiagonal extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementState.MovementStatus.RUNNING) + if (state.getStatus() != MovementState.MovementStatus.RUNNING) { return state; + } if (playerFeet().equals(dest)) { state.setStatus(MovementState.MovementStatus.SUCCESS); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 3be854ad..9565e932 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -60,8 +60,9 @@ public class MovementDownward extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementState.MovementStatus.RUNNING) + if (state.getStatus() != MovementState.MovementStatus.RUNNING) { return state; + } if (playerFeet().equals(dest)) { state.setStatus(MovementState.MovementStatus.SUCCESS); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index db3b997a..40fa291d 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -96,8 +96,9 @@ public class MovementFall extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementStatus.RUNNING) + if (state.getStatus() != MovementStatus.RUNNING) { return state; + } BlockPos playerFeet = playerFeet(); Rotation targetRotation = null; @@ -123,8 +124,7 @@ public class MovementFall extends Movement { } else { state.setTarget(new MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.getBlockPosCenter(dest)), false)); } - if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 // lilypads - || BlockStateInterface.isWater(dest))) { + if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 || BlockStateInterface.isWater(dest))) { // 0.094 because lilypads if (BlockStateInterface.isWater(dest) && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) { player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_EMPTY); if (player().motionY >= 0) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 6d5a1a05..6933a83f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -121,8 +121,9 @@ public class MovementPillar extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementState.MovementStatus.RUNNING) + if (state.getStatus() != MovementState.MovementStatus.RUNNING) { return state; + } IBlockState fromDown = BlockStateInterface.get(src); boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index b12088d9..44c594c0 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -125,9 +125,9 @@ public class MovementTraverse extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementState.MovementStatus.RUNNING) + if (state.getStatus() != MovementState.MovementStatus.RUNNING) { return state; - + } state.setInput(InputOverrideHandler.Input.SNEAK, false); Block fd = BlockStateInterface.get(src.down()).getBlock(); diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index cd3ca646..efb83e36 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -35,8 +35,9 @@ public class BlockStateInterface implements Helper { public static IBlockState get(BlockPos pos) { // wrappers for chunk caching capability // Invalid vertical position - if (pos.getY() < 0 || pos.getY() >= 256) + if (pos.getY() < 0 || pos.getY() >= 256) { return Blocks.AIR.getDefaultState(); + } if (!Baritone.settings().pathThroughCachedOnly.get()) { Chunk cached = prev; diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 8f3cf37b..ae078268 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -216,11 +216,13 @@ public final class PathRenderer implements Helper { y2 = 0; minY = 0 - renderPosY; maxY = 256 - renderPosY; - } else { + } else if (goal instanceof GoalComposite) { for (Goal g : ((GoalComposite) goal).goals()) { drawLitDankGoalBox(player, g, partialTicks, color); } return; + } else { + return; } GlStateManager.enableBlend(); diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index e31fe09e..9a6ca4d7 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -87,8 +87,9 @@ public class ToolSet implements Helper { ItemStack contents = player().inventory.getStackInSlot(slot); float blockHard = state.getBlockHardness(null, null); - if (blockHard < 0) + if (blockHard < 0) { return -1; + } float speed = contents.getDestroySpeed(state); if (speed > 1) { diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index 6a05c109..d25812c0 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -60,12 +60,12 @@ public final class BetterBlockPos extends BlockPos { } @Override - public final int hashCode() { + public int hashCode() { return (int) hashCode; } @Override - public final boolean equals(Object o) { + public boolean equals(Object o) { if (o == null) { return false; }