From ce4b1e09edf44f08107b405bf8dd121c8fa38550 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 11 Jul 2019 12:46:24 -0700 Subject: [PATCH 01/29] fix parkour and multithread farm --- .../pathing/movement/movements/MovementParkour.java | 2 +- src/main/java/baritone/process/FarmProcess.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index b9f02c1ac..88ffb1d92 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -226,7 +226,7 @@ public class MovementParkour extends Movement { state.setStatus(MovementStatus.SUCCESS); } } else if (!ctx.playerFeet().equals(src)) { - if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - ctx.playerFeet().getY() > 0.0001) { + if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - src.y > 0.0001) { if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) { // go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory state.setInput(Input.CLICK_RIGHT, true); diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 9593a192b..a2d32f78c 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -54,6 +54,9 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro private boolean active; + private List locations; + private int tickCount; + private static final List FARMLAND_PLANTABLE = Arrays.asList( Items.BEETROOT_SEEDS, Items.MELON_SEEDS, @@ -93,6 +96,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro @Override public void farm() { active = true; + locations = null; } private enum Harvest { @@ -164,9 +168,12 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro if (Baritone.settings().replantNetherWart.value) { scan.add(Blocks.SOUL_SAND); } - - List locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 4); - + if (Baritone.settings().mineGoalUpdateInterval.value != 0 && tickCount++ % Baritone.settings().mineGoalUpdateInterval.value == 0) { + Baritone.getExecutor().execute(() -> locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 10)); + } + if (locations == null) { + return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); + } List toBreak = new ArrayList<>(); List openFarmland = new ArrayList<>(); List bonemealable = new ArrayList<>(); From b16f9edd2c8d950e8ce7ec4e1cad81201288c921 Mon Sep 17 00:00:00 2001 From: Baddeveloper Date: Fri, 12 Jul 2019 19:12:00 +0200 Subject: [PATCH 02/29] Added EntitySpider and EntityPigZombie conditions --- src/main/java/baritone/utils/pathing/Avoidance.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/baritone/utils/pathing/Avoidance.java b/src/main/java/baritone/utils/pathing/Avoidance.java index c4b12336e..c7b6a854f 100644 --- a/src/main/java/baritone/utils/pathing/Avoidance.java +++ b/src/main/java/baritone/utils/pathing/Avoidance.java @@ -22,6 +22,8 @@ import baritone.api.utils.BetterBlockPos; import baritone.api.utils.IPlayerContext; import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.monster.EntitySpider; import net.minecraft.util.math.BlockPos; import java.util.ArrayList; @@ -70,6 +72,8 @@ public class Avoidance { if (mobCoeff != 1.0D) { ctx.world().loadedEntityList.stream() .filter(entity -> entity instanceof EntityMob) + .filter(entity -> (!(entity instanceof EntitySpider)) || ctx.player().getBrightness() < 0.5) + .filter(entity -> !(entity instanceof EntityPigZombie) || ((EntityPigZombie) entity).isAngry()) .forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value))); } return res; From 6bb87d0a64d77435f6e26433e22cf3daa851c41b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 12 Jul 2019 23:27:02 -0700 Subject: [PATCH 03/29] address an absolutely critical gap in documentation --- src/api/java/baritone/api/IBaritone.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/java/baritone/api/IBaritone.java b/src/api/java/baritone/api/IBaritone.java index a356922cc..2c892d982 100644 --- a/src/api/java/baritone/api/IBaritone.java +++ b/src/api/java/baritone/api/IBaritone.java @@ -128,5 +128,8 @@ public interface IBaritone { */ IEventBus getGameEventHandler(); + /** + * Open click + */ void openClick(); } From 2b41012c5ba4ff8fe3374467fbb2214e3f5665c8 Mon Sep 17 00:00:00 2001 From: StijnSimons Date: Sat, 13 Jul 2019 17:17:10 +0200 Subject: [PATCH 04/29] Enderman angry condition --- src/main/java/baritone/utils/pathing/Avoidance.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/baritone/utils/pathing/Avoidance.java b/src/main/java/baritone/utils/pathing/Avoidance.java index c7b6a854f..11b4a73f4 100644 --- a/src/main/java/baritone/utils/pathing/Avoidance.java +++ b/src/main/java/baritone/utils/pathing/Avoidance.java @@ -21,6 +21,7 @@ import baritone.Baritone; import baritone.api.utils.BetterBlockPos; import baritone.api.utils.IPlayerContext; import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; +import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.monster.EntitySpider; @@ -74,6 +75,7 @@ public class Avoidance { .filter(entity -> entity instanceof EntityMob) .filter(entity -> (!(entity instanceof EntitySpider)) || ctx.player().getBrightness() < 0.5) .filter(entity -> !(entity instanceof EntityPigZombie) || ((EntityPigZombie) entity).isAngry()) + .filter(entity -> !(entity instanceof EntityEnderman) || ((EntityEnderman) entity).isScreaming()) .forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value))); } return res; From 38602dd141512fbd04f3eee30ceebad15609d741 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 14 Jul 2019 11:13:51 -0700 Subject: [PATCH 05/29] verify top side of block, fixes #541 --- src/main/java/baritone/process/FarmProcess.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index a2d32f78c..2702442bd 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -24,6 +24,7 @@ import baritone.api.pathing.goals.GoalComposite; import baritone.api.process.IFarmProcess; import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommandType; +import baritone.api.utils.RayTraceUtils; import baritone.api.utils.Rotation; import baritone.api.utils.RotationUtils; import baritone.api.utils.input.Input; @@ -40,7 +41,9 @@ import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemDye; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -223,11 +226,14 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro boolean soulsand = openSoulsand.contains(pos); Optional rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance()); if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) { - baritone.getLookBehavior().updateTarget(rot.get(), true); - if (ctx.isLookingAt(pos)) { - baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true); + RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), ctx.playerController().getBlockReachDistance()); + if (result.typeOfHit == RayTraceResult.Type.BLOCK && result.sideHit == EnumFacing.UP) { + baritone.getLookBehavior().updateTarget(rot.get(), true); + if (ctx.isLookingAt(pos)) { + baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true); + } + return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); } - return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); } } for (BlockPos pos : bonemealable) { From b51a261bd10483a0ec10527f92db2171f4b7f9fc Mon Sep 17 00:00:00 2001 From: StijnSimons Date: Mon, 15 Jul 2019 22:31:55 +0200 Subject: [PATCH 06/29] Added entityfollow Hey look i can cntrl + c v --- .../api/utils/ExampleBaritoneControl.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 2445f6341..29e2e9d17 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -411,6 +411,24 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener logDirect("Following any players"); return true; } + if (msg.startsWith("followentity")) { + String name = msg.substring(12).trim(); + Optional toFollow = Optional.empty(); + for (Entity entity : ctx.world().loadedEntityList) { + String entityName = entity.getName().trim().toLowerCase(); + if (entityName.contains(name) || name.contains(entityName)) { + toFollow = Optional.of(entity); + } + } + if (!toFollow.isPresent()) { + logDirect("Entity not found"); + return true; + } + Entity effectivelyFinal = toFollow.get(); + baritone.getFollowProcess().follow(effectivelyFinal::equals); + logDirect("Following entity " + toFollow.get()); + return true; + } if (msg.startsWith("follow")) { String name = msg.substring(6).trim(); Optional toFollow = Optional.empty(); From 3ba8824eb003aedec9edc334f2ec59c991ecad3b Mon Sep 17 00:00:00 2001 From: StijnSimons Date: Mon, 15 Jul 2019 22:34:52 +0200 Subject: [PATCH 07/29] More copy paste --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 29e2e9d17..1b47c8a56 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -406,6 +406,11 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener } return true; } + if (msg.startsWith("followentities")) { + baritone.getFollowProcess().follow(Entity.class::isInstance); + logDirect("Following any entities"); + return true; + } if (msg.startsWith("followplayers")) { baritone.getFollowProcess().follow(EntityPlayer.class::isInstance); // O P P A logDirect("Following any players"); From 72be046f34d703bb05497ab38177405a57385816 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 15 Jul 2019 14:44:16 -0700 Subject: [PATCH 08/29] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index e9a3c7cc1..877b6260c 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1 +1,28 @@ - +# Bug report + +## Some information +Operating system: +Java version: +Minecraft version: +Baritone version: +Forge mods (if used): + +## Exception, error or logs +You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac). + +## How to reproduce +Add your steps to reproduce here. + +## Final checklist +- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used). +- [ ] I have included logs, exceptions and / or steps to reproduce the issue. +- [ ] I have not used any OwO's or UwU's in this issue. + +# Suggestion +Give some information about your suggestion. + +## New features +Add feature ideas here. + +## New options +Add option ideas here. From e034437c633584c9d0893dc5a4201dfd02ac09bf Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 15 Jul 2019 17:55:15 -0500 Subject: [PATCH 09/29] Separate templates --- .../bug.md} | 21 ++++++++----------- .github/ISSUE_TEMPLATE/suggestion.md | 19 +++++++++++++++++ 2 files changed, 28 insertions(+), 12 deletions(-) rename .github/{ISSUE_TEMPLATE.md => ISSUE_TEMPLATE/bug.md} (64%) create mode 100644 .github/ISSUE_TEMPLATE/suggestion.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/bug.md similarity index 64% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/bug.md index 877b6260c..55e5ad06f 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -1,4 +1,10 @@ -# Bug report +--- +name: Bug report +about: Please file a separate report for each issue +title: Please add a brief but descriptive title +labels: bug +assignees: '' +--- ## Some information Operating system: @@ -11,18 +17,9 @@ Forge mods (if used): You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac). ## How to reproduce -Add your steps to reproduce here. +Add your steps to reproduce the issue/bug experienced here. ## Final checklist - [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used). - [ ] I have included logs, exceptions and / or steps to reproduce the issue. -- [ ] I have not used any OwO's or UwU's in this issue. - -# Suggestion -Give some information about your suggestion. - -## New features -Add feature ideas here. - -## New options -Add option ideas here. +- [ ] I have not used any OwO's or UwU's in this issue. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/suggestion.md b/.github/ISSUE_TEMPLATE/suggestion.md new file mode 100644 index 000000000..da61c638d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/suggestion.md @@ -0,0 +1,19 @@ +--- +name: Suggestion +about: Please file a separate report for each suggestion +title: Please add a brief but descriptive title +labels: enhancement +assignees: '' +--- + +## Describe your suggestion +With as much detail as possible, describe what your suggestion would do for Baritone. + +## Settings +If applicable, what settings/customizability should be offered to tweak the functionality of your suggestion. + +## Context +Describe how your suggestion would improve Baritone, or the reason behind it being added. + +## Final checklist +- [ ] I have not used any OwO's or UwU's in this issue. \ No newline at end of file From 0d9f233e33a8951df0e023d9879cfe21e4ee93bb Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 15 Jul 2019 18:00:51 -0500 Subject: [PATCH 10/29] Add question template --- .github/ISSUE_TEMPLATE/question.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/question.md diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 000000000..2482fd4c3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,13 @@ +--- +name: Question +about: Please file a separate report for each question +title: Please add a brief but descriptive title +labels: question +assignees: '' +--- + +## What do you need help with? +With as much detail as possible, describe your question and what you may need help with. + +## Final checklist +- [ ] I have not used any OwO's or UwU's in this issue. \ No newline at end of file From 09239f8180c725d21d5167bc24014c479b885eea Mon Sep 17 00:00:00 2001 From: ZakME <35682140+ZakME@users.noreply.github.com> Date: Tue, 16 Jul 2019 23:50:03 -0600 Subject: [PATCH 11/29] PICKUP_DROPPED - Remove 2nd Items.WHEAT PICKUP_DROPPED: Remove 2nd Items.WHEAT Re-order a few items for neatness --- src/main/java/baritone/process/FarmProcess.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 2702442bd..350b1ac81 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -71,17 +71,16 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro private static final List PICKUP_DROPPED = Arrays.asList( Items.BEETROOT_SEEDS, - Items.WHEAT, + Items.BEETROOT, Items.MELON_SEEDS, Items.MELON, + Item.getItemFromBlock(Blocks.MELON_BLOCK), Items.WHEAT_SEEDS, Items.WHEAT, Items.PUMPKIN_SEEDS, + Item.getItemFromBlock(Blocks.PUMPKIN), Items.POTATO, Items.CARROT, - Items.BEETROOT, - Item.getItemFromBlock(Blocks.PUMPKIN), - Item.getItemFromBlock(Blocks.MELON_BLOCK), Items.NETHER_WART, Items.REEDS, Item.getItemFromBlock(Blocks.CACTUS) From f32147d9d521ce3db1175463dd28fa44f160353c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 17 Jul 2019 22:41:09 -0700 Subject: [PATCH 12/29] privatize --- src/main/java/baritone/utils/BlockBreakHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index 36e2dfeac..95d021c29 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -38,7 +38,7 @@ public final class BlockBreakHelper implements Helper { this.playerContext = playerContext; } - public void tryBreakBlock(BlockPos pos, EnumFacing side) { + private void tryBreakBlock(BlockPos pos, EnumFacing side) { if (playerContext.playerController().onPlayerDamageBlock(pos, side)) { playerContext.player().swingArm(EnumHand.MAIN_HAND); } From 81514446713e22faf85ee76e917e0120c05ea355 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 18 Jul 2019 14:15:53 -0700 Subject: [PATCH 13/29] privatize this too --- src/main/java/baritone/utils/PathingControlManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index ccded35c1..14d921d0f 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -126,7 +126,7 @@ public class PathingControlManager implements IPathingControlManager { } } - public void postTick() { + private void postTick() { // if we did this in pretick, it would suck // we use the time between ticks as calculation time // therefore, we only cancel and recalculate after the tick for the current path has executed From af943a8253f538761b6421bb7a8bb2f2cbe19938 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 18 Jul 2019 21:18:02 -0500 Subject: [PATCH 14/29] Fix issue opening fence gates in some scenarios If there are 2 fence gates at the player height, and they are approached diagonally, there is a slight chance that Baritone will be caught in an infinite loop of opening and closing the upper fence gate, being unable to interact with the bottom one. --- .../movement/movements/MovementTraverse.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index d32573c00..4eab7144f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -37,6 +37,7 @@ import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import java.util.Optional; import java.util.Set; public class MovementTraverse extends Movement { @@ -202,12 +203,15 @@ public class MovementTraverse extends Movement { Block fd = BlockStateInterface.get(ctx, src.down()).getBlock(); boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE; - if ((pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor) - && (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) - || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) - && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { - return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true)) - .setInput(Input.CLICK_RIGHT, true); + if (pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor) { + + boolean notPassable = pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src); + boolean canOpen = !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock())); + + if (notPassable && canOpen) { + return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true)) + .setInput(Input.CLICK_RIGHT, true); + } } if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) { @@ -215,8 +219,10 @@ public class MovementTraverse extends Movement { : !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1] : null; if (blocked != null) { - return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), blocked), ctx.playerRotations()), true)) - .setInput(Input.CLICK_RIGHT, true); + Optional rotation = RotationUtils.reachable(ctx, blocked); + if (rotation.isPresent()) { + return state.setTarget(new MovementState.MovementTarget(rotation.get(), true)).setInput(Input.CLICK_RIGHT, true); + } } } From 8b43d9325916d78e5ccdb5800eed97d7eaf24437 Mon Sep 17 00:00:00 2001 From: StijnSimons Date: Sat, 20 Jul 2019 01:37:43 +0200 Subject: [PATCH 15/29] i forgot players and items were entities too --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 1b47c8a56..0f2e08156 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -35,6 +35,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.crash.CrashReport; import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ReportedException; @@ -421,7 +422,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener Optional toFollow = Optional.empty(); for (Entity entity : ctx.world().loadedEntityList) { String entityName = entity.getName().trim().toLowerCase(); - if (entityName.contains(name) || name.contains(entityName)) { + if ((entityName.contains(name) || name.contains(entityName)) && !(entity instanceof EntityItem || entity instanceof EntityPlayer)) { // We dont want it following players while `#follow` exists. toFollow = Optional.of(entity); } } From df900c9e64d80492391cef5860952ef7a3bebb79 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 19 Jul 2019 18:55:32 -0700 Subject: [PATCH 16/29] use origin --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 60b361195..97a768abe 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -134,7 +134,7 @@ public interface MovementHelper extends ActionCosts, Helper { // every block that overrides isPassable with anything more complicated than a "return true;" or "return false;" // has already been accounted for above // therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null - return block.isPassable(null, null); + return block.isPassable(null, BlockPos.ORIGIN); } /** From 4d127acb9aae88ea17e34f0ef0b272a4138489eb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 20 Jul 2019 23:47:51 -0700 Subject: [PATCH 17/29] reformat --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 0f2e08156..96d6ad2fc 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -610,7 +610,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener } if (msg.startsWith("delete")) { String name = msg.substring(6).trim(); - IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null); + IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null); if (waypoint == null) { logDirect("No user defined position under the name '" + name + "' found."); return true; @@ -714,7 +714,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener goal = new GoalBlock(playerFeet); break; case 1: - goal = new GoalYLevel(parseOrDefault(params[0], playerFeet.y)); break; case 2: From d505ec4f9f031a982d2c93ef40d675e396be75d9 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 20:54:02 -0400 Subject: [PATCH 18/29] build the schematic schematica has open --- build.gradle | 8 +++ scripts/proguard.pro | 5 ++ .../baritone/api/process/IBuilderProcess.java | 2 + .../api/utils/ExampleBaritoneControl.java | 4 ++ .../java/baritone/process/BuilderProcess.java | 15 ++++++ .../schematica/SchematicAdapter.java | 54 +++++++++++++++++++ .../schematica/SchematicaHelper.java | 50 +++++++++++++++++ .../lunatrius/core/util/math/MBlockPos.java | 30 +++++++++++ .../lunatrius/schematica/Schematica.java | 24 +++++++++ .../lunatrius/schematica/api/ISchematic.java | 31 +++++++++++ .../client/world/SchematicWorld.java | 32 +++++++++++ .../schematica/proxy/ClientProxy.java | 29 ++++++++++ .../schematica/proxy/CommonProxy.java | 20 +++++++ 13 files changed, 304 insertions(+) create mode 100644 src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java create mode 100644 src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java create mode 100644 src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/Schematica.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/api/ISchematic.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/proxy/CommonProxy.java diff --git a/build.gradle b/build.gradle index 00e35617c..1264f0fe1 100755 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,14 @@ sourceSets { launch { compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output } + + schematica_api { + compileClasspath += main.compileClasspath + } + + main { + compileClasspath += schematica_api.output + } } minecraft { diff --git a/scripts/proguard.pro b/scripts/proguard.pro index bb8df2aed..2e10986df 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -31,6 +31,11 @@ # need to keep mixin names -keep class baritone.launch.** { *; } +#try to keep usage of schematica in separate classes +-keep class baritone.utils.schematic.schematica.* +#proguard doesnt like it when it cant find our fake schematica classes +-dontwarn baritone.utils.schematic.schematica.* + # copy all necessary libraries into tempLibraries to build # The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with diff --git a/src/api/java/baritone/api/process/IBuilderProcess.java b/src/api/java/baritone/api/process/IBuilderProcess.java index d9397786b..f73f0e746 100644 --- a/src/api/java/baritone/api/process/IBuilderProcess.java +++ b/src/api/java/baritone/api/process/IBuilderProcess.java @@ -54,6 +54,8 @@ public interface IBuilderProcess extends IBaritoneProcess { return build(schematicFile, file, origin); } + void buildOpenSchematic(); + void pause(); void resume(); diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 96d6ad2fc..463001501 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -295,6 +295,10 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener logDirect(success ? "Loaded" : "Unable to load"); return true; } + if (msg.startsWith("schematica")) { + baritone.getBuilderProcess().buildOpenSchematic(); + return true; + } if (msg.equals("come")) { customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(Helper.mc.getRenderViewEntity()))); logDirect("Coming"); diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 52f21b769..5317c39aa 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -35,6 +35,7 @@ import baritone.utils.BlockStateInterface; import baritone.utils.PathingCommandContext; import baritone.utils.schematic.AirSchematic; import baritone.utils.schematic.Schematic; +import baritone.utils.schematic.schematica.SchematicaHelper; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockLiquid; @@ -106,6 +107,20 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return true; } + @Override + public void buildOpenSchematic() { + if (SchematicaHelper.isSchematicaPresent()) { + Optional> schematic = SchematicaHelper.getOpenSchematic(); + if (schematic.isPresent()) { + this.build(schematic.get().getFirst().toString(), schematic.get().getFirst(), schematic.get().getSecond()); + } else { + logDirect("No schematic currently open"); + } + } else { + logDirect("Schematica is not present"); + } + } + public void clearArea(BlockPos corner1, BlockPos corner2) { BlockPos origin = new BlockPos(Math.min(corner1.getX(), corner2.getX()), Math.min(corner1.getY(), corner2.getY()), Math.min(corner1.getZ(), corner2.getZ())); int widthX = Math.abs(corner1.getX() - corner2.getX()) + 1; diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java b/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java new file mode 100644 index 000000000..4e399348c --- /dev/null +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java @@ -0,0 +1,54 @@ +/* + * 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.schematic.schematica; + +import baritone.api.utils.ISchematic; + +import com.github.lunatrius.schematica.client.world.SchematicWorld; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; + +// TODO: this only works for the default rotation +public final class SchematicAdapter implements ISchematic { + private final SchematicWorld schematic; + + + public SchematicAdapter(SchematicWorld schematicWorld) { + this.schematic = schematicWorld; + } + + @Override + public IBlockState desiredState(int x, int y, int z) { + return schematic.getSchematic().getBlockState(new BlockPos(x, y, z)); + } + + @Override + public int widthX() { + return schematic.getSchematic().getWidth(); + } + + @Override + public int heightY() { + return schematic.getSchematic().getHeight(); + } + + @Override + public int lengthZ() { + return schematic.getSchematic().getLength(); + } +} diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java new file mode 100644 index 000000000..bf5d4678d --- /dev/null +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -0,0 +1,50 @@ +/* + * 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.schematic.schematica; + +import baritone.api.utils.ISchematic; +import com.github.lunatrius.core.util.math.MBlockPos; +import com.github.lunatrius.schematica.Schematica; +import com.github.lunatrius.schematica.proxy.ClientProxy; +import net.minecraft.util.Tuple; +import net.minecraft.util.math.BlockPos; + +import java.util.Optional; + +public enum SchematicaHelper { + ; + + public static boolean isSchematicaPresent() { + try { + Class.forName(Schematica.class.getName()); + return true; + } catch (ClassNotFoundException ex) { + return false; + } + } + + public static Optional> getOpenSchematic() { + return Optional.ofNullable(ClientProxy.schematic) + .map(world -> { + MBlockPos poz = world.position; + return new Tuple<>(new SchematicAdapter(world), new BlockPos(poz.field_177962_a, poz.field_177960_b, poz.field_177961_c)); + }); + } + + private static void meme(Class clazz) throws ClassNotFoundException {} +} diff --git a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java new file mode 100644 index 000000000..60cf6fae2 --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java @@ -0,0 +1,30 @@ +/* + * 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 com.github.lunatrius.core.util.math; + +import net.minecraft.util.math.BlockPos; + +public class MBlockPos extends BlockPos { + public int field_177962_a; // x + public int field_177960_b; // y + public int field_177961_c; // z + + private MBlockPos() { + super(6, 6, 6); + } +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/Schematica.java b/src/schematica_api/java/com/github/lunatrius/schematica/Schematica.java new file mode 100644 index 000000000..7d786dbd4 --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/Schematica.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 com.github.lunatrius.schematica; + +import com.github.lunatrius.schematica.proxy.CommonProxy; + +public class Schematica { + public static CommonProxy proxy; +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/api/ISchematic.java b/src/schematica_api/java/com/github/lunatrius/schematica/api/ISchematic.java new file mode 100644 index 000000000..6430dbfcc --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/api/ISchematic.java @@ -0,0 +1,31 @@ +/* + * 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 com.github.lunatrius.schematica.api; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; + +public interface ISchematic { + IBlockState getBlockState(BlockPos var1); + + int getWidth(); + + int getHeight(); + + int getLength(); +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java b/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java new file mode 100644 index 000000000..fc4b89f9a --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java @@ -0,0 +1,32 @@ +/* + * 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 com.github.lunatrius.schematica.client.world; + +import com.github.lunatrius.core.util.math.MBlockPos; +import com.github.lunatrius.schematica.api.ISchematic; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; + +public class SchematicWorld { + private ISchematic schematic; + public final MBlockPos position = (MBlockPos)(Object)"cringe"; + + public ISchematic getSchematic() { + throw new LinkageError("LOL"); + } +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java new file mode 100644 index 000000000..e58e76b56 --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java @@ -0,0 +1,29 @@ +/* + * 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 com.github.lunatrius.schematica.proxy; + +import com.github.lunatrius.schematica.client.world.SchematicWorld; +import net.minecraft.util.EnumFacing; + +public class ClientProxy extends CommonProxy { + public static SchematicWorld schematic; + + public static EnumFacing orientation; + public static EnumFacing axisFlip; + public static EnumFacing axisRotation; +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/proxy/CommonProxy.java b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/CommonProxy.java new file mode 100644 index 000000000..eb3c034e8 --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/CommonProxy.java @@ -0,0 +1,20 @@ +/* + * 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 com.github.lunatrius.schematica.proxy; + +public abstract class CommonProxy {} From 074ec333cf49a9382e7e8141aeb8717abc18243d Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 21:57:59 -0400 Subject: [PATCH 19/29] clean up a bit --- scripts/proguard.pro | 4 ++-- .../baritone/utils/schematic/schematica/SchematicAdapter.java | 2 -- .../baritone/utils/schematic/schematica/SchematicaHelper.java | 1 - .../lunatrius/schematica/client/world/SchematicWorld.java | 3 --- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 2e10986df..4ac0f7233 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -32,9 +32,9 @@ -keep class baritone.launch.** { *; } #try to keep usage of schematica in separate classes --keep class baritone.utils.schematic.schematica.* +-keep class baritone.utils.schematic.schematica.** #proguard doesnt like it when it cant find our fake schematica classes --dontwarn baritone.utils.schematic.schematica.* +-dontwarn baritone.utils.schematic.schematica.** # copy all necessary libraries into tempLibraries to build diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java b/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java index 4e399348c..fd0ace8ca 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java @@ -23,11 +23,9 @@ import com.github.lunatrius.schematica.client.world.SchematicWorld; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; -// TODO: this only works for the default rotation public final class SchematicAdapter implements ISchematic { private final SchematicWorld schematic; - public SchematicAdapter(SchematicWorld schematicWorld) { this.schematic = schematicWorld; } diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java index bf5d4678d..e929d0811 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -46,5 +46,4 @@ public enum SchematicaHelper { }); } - private static void meme(Class clazz) throws ClassNotFoundException {} } diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java b/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java index fc4b89f9a..80c1b2a21 100644 --- a/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java +++ b/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java @@ -19,11 +19,8 @@ package com.github.lunatrius.schematica.client.world; import com.github.lunatrius.core.util.math.MBlockPos; import com.github.lunatrius.schematica.api.ISchematic; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; public class SchematicWorld { - private ISchematic schematic; public final MBlockPos position = (MBlockPos)(Object)"cringe"; public ISchematic getSchematic() { From 8bf977060e1c379b130d02e08b59f5d6bf4147bf Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 22:06:36 -0400 Subject: [PATCH 20/29] dont need the fields --- .../baritone/utils/schematic/schematica/SchematicaHelper.java | 2 +- .../java/com/github/lunatrius/core/util/math/MBlockPos.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java index e929d0811..9120c5ac6 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -42,7 +42,7 @@ public enum SchematicaHelper { return Optional.ofNullable(ClientProxy.schematic) .map(world -> { MBlockPos poz = world.position; - return new Tuple<>(new SchematicAdapter(world), new BlockPos(poz.field_177962_a, poz.field_177960_b, poz.field_177961_c)); + return new Tuple<>(new SchematicAdapter(world), new BlockPos(poz.getX(), poz.getY(), poz.getZ())); }); } diff --git a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java index 60cf6fae2..338e3be47 100644 --- a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java +++ b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java @@ -20,10 +20,6 @@ package com.github.lunatrius.core.util.math; import net.minecraft.util.math.BlockPos; public class MBlockPos extends BlockPos { - public int field_177962_a; // x - public int field_177960_b; // y - public int field_177961_c; // z - private MBlockPos() { super(6, 6, 6); } From 21e9c0b7c11f158e4f47d474defd7f939a9110af Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 22:17:21 -0400 Subject: [PATCH 21/29] add get functions --- .../lunatrius/core/util/math/MBlockPos.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java index 338e3be47..80c296cc1 100644 --- a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java +++ b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java @@ -23,4 +23,19 @@ public class MBlockPos extends BlockPos { private MBlockPos() { super(6, 6, 6); } + + @Override + public int getX() { + throw new LinkageError("LOL"); + } + + @Override + public int getY() { + throw new LinkageError("LOL"); + } + + @Override + public int getZ() { + throw new LinkageError("LOL"); + } } From fe54372a5362a351155a3ad3193573aac37804a0 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 22:33:22 -0400 Subject: [PATCH 22/29] resolve the issue --- .../java/com/github/lunatrius/core/util/math/MBlockPos.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java index 80c296cc1..280b38a6a 100644 --- a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java +++ b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java @@ -20,7 +20,7 @@ package com.github.lunatrius.core.util.math; import net.minecraft.util.math.BlockPos; public class MBlockPos extends BlockPos { - private MBlockPos() { + MBlockPos() { super(6, 6, 6); } From 6b9737eb3fcfa4f2adc0e12b16f75324aac0af14 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 21 Jul 2019 22:04:15 -0700 Subject: [PATCH 23/29] fix double jump on paused overshot sprint ascend --- .../baritone/pathing/movement/movements/MovementAscend.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 24fe2285e..cbc8cdd86 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -168,7 +168,7 @@ public class MovementAscend extends Movement { return state; } - if (ctx.playerFeet().equals(dest)) { + if (ctx.playerFeet().equals(dest) || ctx.playerFeet().equals(dest.add(getDirection().down()))) { return state.setStatus(MovementStatus.SUCCESS); } From 61147536e59f6689e3e159b7c0bbcc5d7d1add15 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Mon, 22 Jul 2019 16:51:09 -0400 Subject: [PATCH 24/29] ok --- .../utils/schematic/schematica/SchematicaHelper.java | 6 +----- .../com/github/lunatrius/schematica/proxy/ClientProxy.java | 5 ----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java index 9120c5ac6..f7df0a4f7 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -18,7 +18,6 @@ package baritone.utils.schematic.schematica; import baritone.api.utils.ISchematic; -import com.github.lunatrius.core.util.math.MBlockPos; import com.github.lunatrius.schematica.Schematica; import com.github.lunatrius.schematica.proxy.ClientProxy; import net.minecraft.util.Tuple; @@ -40,10 +39,7 @@ public enum SchematicaHelper { public static Optional> getOpenSchematic() { return Optional.ofNullable(ClientProxy.schematic) - .map(world -> { - MBlockPos poz = world.position; - return new Tuple<>(new SchematicAdapter(world), new BlockPos(poz.getX(), poz.getY(), poz.getZ())); - }); + .map(world -> new Tuple<>(new SchematicAdapter(world), world.position)); } } diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java index e58e76b56..191d01109 100644 --- a/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java +++ b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java @@ -18,12 +18,7 @@ package com.github.lunatrius.schematica.proxy; import com.github.lunatrius.schematica.client.world.SchematicWorld; -import net.minecraft.util.EnumFacing; public class ClientProxy extends CommonProxy { public static SchematicWorld schematic; - - public static EnumFacing orientation; - public static EnumFacing axisFlip; - public static EnumFacing axisRotation; } From 4338e34734323d203bba13cd0f5edcede350f87d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 22 Jul 2019 23:37:43 -0700 Subject: [PATCH 25/29] while this is cool, nothing will ever conceivably use it --- .../utils/pathing/SegmentedCalculator.java | 110 ------------------ 1 file changed, 110 deletions(-) delete mode 100644 src/main/java/baritone/utils/pathing/SegmentedCalculator.java diff --git a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java deleted file mode 100644 index c1753a8b2..000000000 --- a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.utils.pathing; - -import baritone.Baritone; -import baritone.api.pathing.calc.IPath; -import baritone.api.pathing.goals.Goal; -import baritone.api.utils.BetterBlockPos; -import baritone.api.utils.PathCalculationResult; -import baritone.cache.CachedWorld; -import baritone.pathing.calc.AStarPathFinder; -import baritone.pathing.calc.AbstractNodeCostSearch; -import baritone.pathing.movement.CalculationContext; -import baritone.pathing.path.SplicedPath; -import net.minecraft.util.EnumFacing; - -import java.util.Optional; -import java.util.function.Consumer; - -/** - * Calculate and splice many path segments to reach a goal - * - * @author leijurv - */ -public class SegmentedCalculator { - private final BetterBlockPos start; - private final Goal goal; - private final CalculationContext context; - - private SegmentedCalculator(BetterBlockPos start, Goal goal, CalculationContext context) { - this.start = start; - this.goal = goal; - this.context = context; - } - - private Optional doCalc() { - Optional soFar = Optional.empty(); - while (true) { - PathCalculationResult result = segment(soFar.orElse(null)); - switch (result.getType()) { - case SUCCESS_SEGMENT: - case SUCCESS_TO_GOAL: - break; - case FAILURE: // if path calculation failed, we're done - case EXCEPTION: // if path calculation threw an exception, we're done - return soFar; - default: // CANCELLATION and null should not be possible, nothing else has access to this, so it can't have been canceled - throw new IllegalStateException(); - } - IPath segment = result.getPath().orElseThrow(IllegalStateException::new); // path calculation result type is SUCCESS_SEGMENT, so the path must be present - IPath combined = soFar.map(previous -> (IPath) SplicedPath.trySplice(previous, segment, true).orElseThrow(IllegalStateException::new)).orElse(segment); - loadAdjacent(combined.getDest().getX(), combined.getDest().getZ()); - soFar = Optional.of(combined); - if (result.getType() == PathCalculationResult.Type.SUCCESS_TO_GOAL) { - return soFar; - } - } - } - - private void loadAdjacent(int blockX, int blockZ) { - BetterBlockPos bp = new BetterBlockPos(blockX, 64, blockZ); - CachedWorld cached = (CachedWorld) context.getBaritone().getPlayerContext().worldData().getCachedWorld(); - for (int i = 0; i < 4; i++) { - // pathing thread is not allowed to load new cached regions from disk - // 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 - // 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); - cached.tryLoadFromDisk(toLoad.x >> 9, toLoad.z >> 9); - } - } - - private PathCalculationResult segment(IPath previous) { - BetterBlockPos segmentStart = previous != null ? previous.getDest() : start; - AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous, context), context); // this is on another thread, so cannot include mob avoidances. - return search.calculate(Baritone.settings().primaryTimeoutMS.value, Baritone.settings().failureTimeoutMS.value); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer - } - - public static void calculateSegmentsThreaded(BetterBlockPos start, Goal goal, CalculationContext context, Consumer onCompletion, Runnable onFailure) { - Baritone.getExecutor().execute(() -> { - Optional result; - try { - result = new SegmentedCalculator(start, goal, context).doCalc(); - } catch (Exception ex) { - ex.printStackTrace(); - result = Optional.empty(); - } - if (result.isPresent()) { - onCompletion.accept(result.get()); - } else { - onFailure.run(); - } - }); - } -} From 784bc52d6df3dc7c1e494f8b34d6e4e5750e72b3 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Tue, 23 Jul 2019 02:46:53 -0400 Subject: [PATCH 26/29] add to usage.md --- USAGE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/USAGE.md b/USAGE.md index f628d542d..916adc72e 100644 --- a/USAGE.md +++ b/USAGE.md @@ -28,6 +28,7 @@ Some common examples: - `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time). - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). +- 'schematica' to build the schematic that is currently open in schematica - `tunnel` to dig just straight ahead and make a tunnel - `farm` to automatically harvest, replant, or bone meal crops - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). From 821e73c1d34b44c1e801fb34ebf502db7ae68060 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Tue, 23 Jul 2019 02:48:40 -0400 Subject: [PATCH 27/29] fix usage.md --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index 916adc72e..865670b63 100644 --- a/USAGE.md +++ b/USAGE.md @@ -28,7 +28,7 @@ Some common examples: - `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time). - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). -- 'schematica' to build the schematic that is currently open in schematica +- `schematica` to build the schematic that is currently open in schematica - `tunnel` to dig just straight ahead and make a tunnel - `farm` to automatically harvest, replant, or bone meal crops - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). From 7000b6cda2399cac853f1cf68896d88d8c1d2c74 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Tue, 23 Jul 2019 02:56:24 -0400 Subject: [PATCH 28/29] fix crash --- .../baritone/utils/schematic/schematica/SchematicaHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java index f7df0a4f7..63b85670b 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -32,7 +32,7 @@ public enum SchematicaHelper { try { Class.forName(Schematica.class.getName()); return true; - } catch (ClassNotFoundException ex) { + } catch (ClassNotFoundException | NoClassDefFoundError ex) { return false; } } From 0e51a731496474b73fe772936c3041c38e91d19c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 23 Jul 2019 11:53:21 -0700 Subject: [PATCH 29/29] instanceof BlockLiquid checks this --- src/main/java/baritone/pathing/movement/MovementHelper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 97a768abe..520baa81c 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -254,7 +254,6 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean avoidWalkingInto(Block block) { return block instanceof BlockLiquid - || block instanceof BlockDynamicLiquid || block == Blocks.MAGMA || block == Blocks.CACTUS || block == Blocks.FIRE