From dc6c87b58de8fad7dd86fe3951fd207833083000 Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Mon, 7 Mar 2022 15:50:42 -0700 Subject: [PATCH 01/12] fix modded toolmaterials --- .../baritone/launch/mixins/MixinItemTool.java | 35 +++++++++++++++++++ src/launch/resources/mixins.baritone.json | 1 + src/main/java/baritone/utils/ToolSet.java | 8 +++-- .../baritone/utils/accessor/IItemTool.java | 24 +++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 src/launch/java/baritone/launch/mixins/MixinItemTool.java create mode 100644 src/main/java/baritone/utils/accessor/IItemTool.java diff --git a/src/launch/java/baritone/launch/mixins/MixinItemTool.java b/src/launch/java/baritone/launch/mixins/MixinItemTool.java new file mode 100644 index 000000000..4f5d025bf --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinItemTool.java @@ -0,0 +1,35 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.utils.accessor.IItemTool; +import net.minecraft.item.Item; +import net.minecraft.item.ItemTool; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(ItemTool.class) +public class MixinItemTool implements IItemTool { + @Shadow protected Item.ToolMaterial toolMaterial; + + @Override + public int getHarvestLevel() { + return toolMaterial.getHarvestLevel(); + } + +} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index eb31a2e76..fdcd14b92 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -21,6 +21,7 @@ "MixinEntityRenderer", "MixinGuiScreen", "MixinItemStack", + "MixinItemTool", "MixinMinecraft", "MixinNetHandlerPlayClient", "MixinNetworkManager", diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 4d17b4ea1..0ad4665d6 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -18,6 +18,7 @@ package baritone.utils; import baritone.Baritone; +import baritone.utils.accessor.IItemTool; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.entity.EntityPlayerSP; @@ -78,15 +79,16 @@ public class ToolSet { /** * Evaluate the material cost of a possible tool. The priority matches the - * listed order in the Item.ToolMaterial enum. + * harvest level order; there is a chance for multiple at the same with modded tools + * but in that case we don't really care. * * @param itemStack a possibly empty ItemStack - * @return values range from -1 to 4 + * @return values from 0 up */ private int getMaterialCost(ItemStack itemStack) { if (itemStack.getItem() instanceof ItemTool) { ItemTool tool = (ItemTool) itemStack.getItem(); - return ToolMaterial.valueOf(tool.getToolMaterialName()).ordinal(); + return ((IItemTool) tool).getHarvestLevel(); } else { return -1; } diff --git a/src/main/java/baritone/utils/accessor/IItemTool.java b/src/main/java/baritone/utils/accessor/IItemTool.java new file mode 100644 index 000000000..990cb672b --- /dev/null +++ b/src/main/java/baritone/utils/accessor/IItemTool.java @@ -0,0 +1,24 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.utils.accessor; + +public interface IItemTool { + + int getHarvestLevel(); + +} From 8aba97b577f49992894ec4a933be4587a7b00aa5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 8 Mar 2022 15:00:14 -0800 Subject: [PATCH 02/12] update for 1.8.3 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7222e4d89..e2acc7d83 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see de If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.2) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.2/baritone-api-fabric-1.7.2.jar)**. -If you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.2) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.2/baritone-api-fabric-1.8.2.jar)**. +If you need Forge or Fabric 1.18.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.3) and get the `api-forge` or `api-fabric` jar. **For 1.18.2 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.3/baritone-api-fabric-1.8.3.jar)**. **For 1.18.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.3/baritone-api-forge-1.8.3.jar)**. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). From 10430f8142374153f5f443b140b191f92874f5ce Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 8 Mar 2022 15:01:48 -0800 Subject: [PATCH 03/12] bump to 1.18.2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2acc7d83..2687c2291 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Minecraft Minecraft Minecraft - Minecraft + Minecraft

From 25d418e96bf854d597d68dbdc00b64f827f4ffa3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 8 Mar 2022 15:04:34 -0800 Subject: [PATCH 04/12] 1.15 is deprecated --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 2687c2291..75c04553d 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,6 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.15/baritone-api-forge-1.2.15.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. -For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description. If you need Forge 1.15.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.5.3), follow the instructions, and get the `api-forge` jar. - For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**. If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.2) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.2/baritone-api-fabric-1.7.2.jar)**. From 02711a73ed6db6ee22c4943efc77cc7222ed30ed Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 8 Mar 2022 15:14:00 -0800 Subject: [PATCH 05/12] fix codacy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75c04553d..c50caf56a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Build Status Release License - Codacy Badge + Codacy Badge Code of Conduct Known Vulnerabilities Contributions welcome From e58220e2c4b33278991e063cf7d2d4e192ed19a3 Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Tue, 8 Mar 2022 19:45:05 -0700 Subject: [PATCH 06/12] fix inner class attribute being stripped --- scripts/proguard.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index eea6fc23d..517494f46 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -1,5 +1,6 @@ -keepattributes Signature -keepattributes *Annotation* +-keepattributes InnerClasses -optimizationpasses 5 -verbose From 511941c7146135f28bde29dbe48f8459cd5efccb Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Tue, 15 Mar 2022 18:39:19 -0700 Subject: [PATCH 07/12] reimplement death and bed waypoints --- src/api/java/baritone/api/Settings.java | 11 +++ src/main/java/baritone/Baritone.java | 2 + .../baritone/behavior/WaypointBehavior.java | 92 +++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 src/main/java/baritone/behavior/WaypointBehavior.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index b0eda7489..0637f859c 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -550,6 +550,17 @@ public final class Settings { */ public final Setting slowPathTimeoutMS = new Setting<>(40000L); + + /** + * allows baritone to save bed waypoints when interacting with beds + */ + public final Setting doBedWaypoints = new Setting<>(true); + + /** + * allows baritone to save death waypoints + */ + public final Setting doDeathWaypoints = new Setting<>(true); + /** * The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing. */ diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 82451514f..71c2c455a 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -69,6 +69,7 @@ public class Baritone implements IBaritone { private PathingBehavior pathingBehavior; private LookBehavior lookBehavior; private InventoryBehavior inventoryBehavior; + private WaypointBehavior waypointBehavior; private InputOverrideHandler inputOverrideHandler; private FollowProcess followProcess; @@ -101,6 +102,7 @@ public class Baritone implements IBaritone { lookBehavior = new LookBehavior(this); inventoryBehavior = new InventoryBehavior(this); inputOverrideHandler = new InputOverrideHandler(this); + waypointBehavior = new WaypointBehavior(this); } this.pathingControlManager = new PathingControlManager(this); diff --git a/src/main/java/baritone/behavior/WaypointBehavior.java b/src/main/java/baritone/behavior/WaypointBehavior.java new file mode 100644 index 000000000..b21e080e7 --- /dev/null +++ b/src/main/java/baritone/behavior/WaypointBehavior.java @@ -0,0 +1,92 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.behavior; + +import baritone.Baritone; +import baritone.api.cache.IWaypoint; +import baritone.api.cache.Waypoint; +import baritone.api.event.events.BlockInteractEvent; +import baritone.api.utils.BetterBlockPos; +import baritone.api.utils.Helper; +import baritone.utils.BlockStateInterface; +import net.minecraft.block.BlockBed; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraft.util.text.event.HoverEvent; + +import java.util.Set; + +import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; + +public class WaypointBehavior extends Behavior { + + + public WaypointBehavior(Baritone baritone) { + super(baritone); + } + + @Override + public void onBlockInteract(BlockInteractEvent event) { + if (!Baritone.settings().doBedWaypoints.value) + return; + if (event.getType() == BlockInteractEvent.Type.USE) { + BetterBlockPos pos = BetterBlockPos.from(event.getPos()); + IBlockState state = BlockStateInterface.get(ctx, pos); + if (state.getBlock() instanceof BlockBed) { + if (state.getValue(BlockBed.PART) == BlockBed.EnumPartType.FOOT) { + pos = pos.offset(state.getValue(BlockBed.FACING)); + } + Set waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(IWaypoint.Tag.BED); + boolean exists = waypoints.stream().map(IWaypoint::getLocation).filter(pos::equals).findFirst().isPresent(); + if (!exists) { + baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, pos)); + } + } + } + } + + @Override + public void onPlayerDeath() { + if (!Baritone.settings().doDeathWaypoints.value) + return; + Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet()); + baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint); + ITextComponent component = new TextComponentString("Death position saved."); + component.getStyle() + .setColor(TextFormatting.WHITE) + .setHoverEvent(new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + new TextComponentString("Click to goto death") + )) + .setClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + String.format( + "%s%s goto %s @ %d", + FORCE_COMMAND_PREFIX, + "wp", + deathWaypoint.getTag().getName(), + deathWaypoint.getCreationTimestamp() + ) + )); + Helper.HELPER.logDirect(component); + } + +} From e036f5360c49819c3fa4c83649bff5a8ad5dc542 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Wed, 16 Mar 2022 20:12:56 +0000 Subject: [PATCH 08/12] If context.player() returns none we don't want to use its position for pruning. --- src/main/java/baritone/cache/CachedWorld.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index 1d1132465..6b3959fe3 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -209,7 +209,7 @@ public final class CachedWorld implements ICachedWorld, Helper { private BlockPos guessPosition() { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { IWorldData data = ibaritone.getWorldProvider().getCurrentWorld(); - if (data != null && data.getCachedWorld() == this) { + if (data != null && data.getCachedWorld() == this && ibaritone.getPlayerContext().player() != null) { return ibaritone.getPlayerContext().playerFeet(); } } From 6aadd00e72af1b55a750eb47566a0ef4418497ba Mon Sep 17 00:00:00 2001 From: PhlegethonAcheron <53194290+PhlegethonAcheron@users.noreply.github.com> Date: Sun, 20 Mar 2022 15:41:25 -0400 Subject: [PATCH 09/12] Added usage syntax to the documentation for buildValidSubstitutes and buildSubstitutes --- src/api/java/baritone/api/Settings.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 0637f859c..99ffcea20 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -234,6 +234,8 @@ public final class Settings { * A mapping of blocks to blocks treated as correct in their position *

* If a schematic asks for a block on this mapping, all blocks on the mapped list will be accepted at that location as well + *

+ * Syntax same as buildSubstitutes */ public final Setting>> buildValidSubstitutes = new Setting<>(new HashMap<>()); @@ -241,6 +243,15 @@ public final class Settings { * A mapping of blocks to blocks to be built instead *

* If a schematic asks for a block on this mapping, Baritone will place the first placeable block in the mapped list + *

+ * Usage Syntax: + *

+     *      sourceblockA->blockToSubstituteA1,blockToSubstituteA2,...blockToSubstituteAN,sourceBlockB->blockToSubstituteB1,blockToSubstituteB2,...blockToSubstituteBN,...sourceBlockX->blockToSubstituteX1,blockToSubstituteX2...blockToSubstituteXN
+     * 
+ * Example: + *
+     *     stone->cobblestone,andesite,oak_planks->birch_planks,acacia_planks,glass
+     * 
*/ public final Setting>> buildSubstitutes = new Setting<>(new HashMap<>()); From 4e6b6d97ce785341f6471520cd4f91b545386f38 Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Thu, 24 Mar 2022 17:33:33 -0700 Subject: [PATCH 10/12] add forceAllowBreak setting --- src/api/java/baritone/api/Settings.java | 5 +++++ .../baritone/pathing/movement/CalculationContext.java | 9 ++++++++- src/main/java/baritone/process/BuilderProcess.java | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 0637f859c..f8dc196cc 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -49,6 +49,11 @@ public final class Settings { */ public final Setting allowBreak = new Setting<>(true); + /** + * Blocks that baritone will be allowed to break even with allowBreak set to false + */ + public final Setting> forceAllowBreak = new Setting<>(new ArrayList<>()); + /** * Allow Baritone to sprint */ diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index fca6bc990..02e5557b7 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -34,6 +34,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import java.util.ArrayList; +import java.util.List; + import static baritone.api.pathing.movement.ActionCosts.COST_INF; /** @@ -55,6 +58,7 @@ public class CalculationContext { public final boolean canSprint; protected final double placeBlockCost; // protected because you should call the function instead public final boolean allowBreak; + public final List forceAllowBreak; public final boolean allowParkour; public final boolean allowParkourPlace; public final boolean allowJumpAt256; @@ -89,6 +93,7 @@ public class CalculationContext { this.canSprint = Baritone.settings().allowSprint.value && player.getFoodStats().getFoodLevel() > 6; this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value; this.allowBreak = Baritone.settings().allowBreak.value; + this.forceAllowBreak = new ArrayList<>(Baritone.settings().forceAllowBreak.value); this.allowParkour = Baritone.settings().allowParkour.value; this.allowParkourPlace = Baritone.settings().allowParkourPlace.value; this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value; @@ -150,7 +155,9 @@ public class CalculationContext { public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) { if (!allowBreak) { - return COST_INF; + if (!forceAllowBreak.contains(current.getBlock())) { + return COST_INF; + } } if (isPossiblyProtected(x, y, z)) { return COST_INF; diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 604dbb2bc..3d98a710e 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -947,7 +947,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil @Override public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) { - if (!allowBreak || isPossiblyProtected(x, y, z)) { + if (!allowBreak) { + if (!forceAllowBreak.contains(current.getBlock())) { + return COST_INF; + } + } + if (isPossiblyProtected(x, y, z)) { return COST_INF; } IBlockState sch = getSchematic(x, y, z, current); From bf450b7d68ac1dba9703cfc36809a2f475dcf105 Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Thu, 24 Mar 2022 17:34:31 -0700 Subject: [PATCH 11/12] rename to allowBreakAnyway --- src/api/java/baritone/api/Settings.java | 2 +- .../java/baritone/pathing/movement/CalculationContext.java | 6 +++--- src/main/java/baritone/process/BuilderProcess.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index f8dc196cc..c883413b3 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -52,7 +52,7 @@ public final class Settings { /** * Blocks that baritone will be allowed to break even with allowBreak set to false */ - public final Setting> forceAllowBreak = new Setting<>(new ArrayList<>()); + public final Setting> allowBreakAnyway = new Setting<>(new ArrayList<>()); /** * Allow Baritone to sprint diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index 02e5557b7..7a67acffe 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -58,7 +58,7 @@ public class CalculationContext { public final boolean canSprint; protected final double placeBlockCost; // protected because you should call the function instead public final boolean allowBreak; - public final List forceAllowBreak; + public final List allowBreakAnyway; public final boolean allowParkour; public final boolean allowParkourPlace; public final boolean allowJumpAt256; @@ -93,7 +93,7 @@ public class CalculationContext { this.canSprint = Baritone.settings().allowSprint.value && player.getFoodStats().getFoodLevel() > 6; this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value; this.allowBreak = Baritone.settings().allowBreak.value; - this.forceAllowBreak = new ArrayList<>(Baritone.settings().forceAllowBreak.value); + this.allowBreakAnyway = new ArrayList<>(Baritone.settings().allowBreakAnyway.value); this.allowParkour = Baritone.settings().allowParkour.value; this.allowParkourPlace = Baritone.settings().allowParkourPlace.value; this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value; @@ -155,7 +155,7 @@ public class CalculationContext { public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) { if (!allowBreak) { - if (!forceAllowBreak.contains(current.getBlock())) { + if (!allowBreakAnyway.contains(current.getBlock())) { return COST_INF; } } diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 3d98a710e..751900df6 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -948,7 +948,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil @Override public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) { if (!allowBreak) { - if (!forceAllowBreak.contains(current.getBlock())) { + if (!allowBreakAnyway.contains(current.getBlock())) { return COST_INF; } } From 2953e2c522b9c37d59d1407f79a5ee7b581f5676 Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Thu, 24 Mar 2022 18:16:19 -0700 Subject: [PATCH 12/12] make codacy happy --- .../java/baritone/pathing/movement/CalculationContext.java | 6 ++---- src/main/java/baritone/process/BuilderProcess.java | 7 +------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index 7a67acffe..d5d6c93c8 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -154,10 +154,8 @@ public class CalculationContext { } public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) { - if (!allowBreak) { - if (!allowBreakAnyway.contains(current.getBlock())) { - return COST_INF; - } + if (!allowBreak && !allowBreakAnyway.contains(current.getBlock())) { + return COST_INF; } if (isPossiblyProtected(x, y, z)) { return COST_INF; diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 751900df6..e3ff4fbd9 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -947,12 +947,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil @Override public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) { - if (!allowBreak) { - if (!allowBreakAnyway.contains(current.getBlock())) { - return COST_INF; - } - } - if (isPossiblyProtected(x, y, z)) { + if ((!allowBreak && !allowBreakAnyway.contains(current.getBlock())) || isPossiblyProtected(x, y, z)) { return COST_INF; } IBlockState sch = getSchematic(x, y, z, current);