Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc849daccb | ||
|
|
f5b4de023f | ||
|
|
6dc7a7788e | ||
|
|
0e51a73149 | ||
|
|
44a092cd94 | ||
|
|
7000b6cda2 | ||
|
|
7a17f7d253 | ||
|
|
821e73c1d3 | ||
|
|
784bc52d6d | ||
|
|
4338e34734 | ||
|
|
61147536e5 | ||
|
|
6b9737eb3f | ||
|
|
fe54372a53 | ||
|
|
21e9c0b7c1 | ||
|
|
8bf977060e | ||
|
|
074ec333cf | ||
|
|
d505ec4f9f | ||
|
|
4d127acb9a | ||
|
|
df900c9e64 | ||
|
|
93a090c56e | ||
|
|
8b43d93259 | ||
|
|
053662d0af | ||
|
|
af943a8253 | ||
|
|
8151444671 | ||
|
|
f32147d9d5 | ||
|
|
515e0364f7 | ||
|
|
09239f8180 | ||
|
|
0d9f233e33 | ||
|
|
e034437c63 | ||
|
|
72be046f34 | ||
|
|
3ba8824eb0 | ||
|
|
b51a261bd1 | ||
|
|
38602dd141 | ||
|
|
cdbec60da0 | ||
|
|
2b41012c5b | ||
|
|
6bb87d0a64 | ||
|
|
b16f9edd2c | ||
|
|
ce4b1e09ed | ||
|
|
01658286af | ||
|
|
aa90c8b7cd | ||
|
|
eba1011fd6 | ||
|
|
96a424c25a | ||
|
|
f4dd100345 | ||
|
|
4ff61f96df |
1
.github/ISSUE_TEMPLATE.md
vendored
1
.github/ISSUE_TEMPLATE.md
vendored
@@ -1 +0,0 @@
|
||||
<!-- No UwU's or OwO's allowed -->
|
||||
25
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
25
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
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:
|
||||
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 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.
|
||||
13
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
13
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -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.
|
||||
19
.github/ISSUE_TEMPLATE/suggestion.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE/suggestion.md
vendored
Normal file
@@ -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.
|
||||
19
README.md
19
README.md
@@ -1,15 +1,16 @@
|
||||
# Baritone
|
||||
[](https://travis-ci.com/cabaletta/baritone)
|
||||
[](https://github.com/cabaletta/baritone/releases)
|
||||
[](https://travis-ci.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
[](LICENSE)
|
||||
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
||||
[](http://hits.dwyl.com/cabaletta/baritone)
|
||||
[](https://github.com/cabaletta/baritone/releases)
|
||||
[](https://github.com/cabaletta/baritone/tree/master/)
|
||||
[](http://hits.dwyl.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
[](https://github.com/cabaletta/baritone/tree/master/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.13.2/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.14.4/)
|
||||
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
||||
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
||||
[](https://github.com/cabaletta/baritone/issues)
|
||||
[](https://github.com/cabaletta/baritone/issues/)
|
||||
[](https://github.com/cabaletta/baritone/issues/)
|
||||
[](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
|
||||
[](https://github.com/cabaletta/baritone/pulls/)
|
||||
@@ -31,6 +32,8 @@ Baritone is the pathfinding system used in [Impact](https://impactdevelopment.gi
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the forge jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1).
|
||||
|
||||
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 and 1.13.2. 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).
|
||||
|
||||
@@ -46,7 +49,7 @@ Here are some links to help to get started:
|
||||
|
||||
- [Installation & setup](SETUP.md)
|
||||
|
||||
- [API Javadocs](https://baritone.leijurv.com)
|
||||
- [API Javadocs](https://baritone.leijurv.com/)
|
||||
|
||||
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
|
||||
|
||||
@@ -75,7 +78,7 @@ That's what it's for, sure! (As long as usage is in compliance with the LGPL 3.0
|
||||
|
||||
## How is it so fast?
|
||||
|
||||
Magic. (Hours of [leijurv](https://github.com/leijurv) enduring excruciating pain)
|
||||
Magic. (Hours of [leijurv](https://github.com/leijurv/) enduring excruciating pain)
|
||||
|
||||
## Why is it called Baritone?
|
||||
|
||||
|
||||
2
SETUP.md
2
SETUP.md
@@ -2,6 +2,8 @@
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone.
|
||||
|
||||
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1).
|
||||
|
||||
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
## Prebuilt official releases
|
||||
|
||||
6
USAGE.md
6
USAGE.md
@@ -18,16 +18,18 @@ To toggle a boolean setting, just say its name in chat (for example saying `allo
|
||||
|
||||
Some common examples:
|
||||
- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks
|
||||
- `goal x y z` or `goal x z` or `goal y`, then `path` to go to a certain coordinate
|
||||
- `goal x y z` or `goal x z` or `goal y`, then `path` to set a goal to a certain coordinate then path to it
|
||||
- `goto x y z` or `goto x z` or `goto y` to go to a certain coordinate (in a single step, starts going immediately)
|
||||
- `goal` to set the goal to your player's feet
|
||||
- `goal clear` to clear the goal
|
||||
- `cancel` or `stop` to stop everything
|
||||
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
|
||||
- `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.)
|
||||
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
|
||||
- `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).
|
||||
- `follow playerName` to follow a player. `followplayers` to follow any players in range (combine with Kill Aura for a fun time). `followentities` to follow any entities. `followentity pig` to follow entities of a specific type.
|
||||
- `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).
|
||||
|
||||
10
build.gradle
10
build.gradle
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
group 'baritone'
|
||||
version '1.2.7'
|
||||
version '1.2.8'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
@@ -55,6 +55,14 @@ sourceSets {
|
||||
launch {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
}
|
||||
|
||||
schematica_api {
|
||||
compileClasspath += main.compileClasspath
|
||||
}
|
||||
|
||||
main {
|
||||
compileClasspath += schematica_api.output
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
|
||||
5
scripts/proguard.pro
vendored
5
scripts/proguard.pro
vendored
@@ -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
|
||||
|
||||
@@ -128,5 +128,8 @@ public interface IBaritone {
|
||||
*/
|
||||
IEventBus getGameEventHandler();
|
||||
|
||||
/**
|
||||
* Open click
|
||||
*/
|
||||
void openClick();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
return build(schematicFile, file, origin);
|
||||
}
|
||||
|
||||
void buildOpenSchematic();
|
||||
|
||||
void pause();
|
||||
|
||||
void resume();
|
||||
|
||||
@@ -35,48 +35,21 @@ 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;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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.world.chunk.Chunk;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
public class ExampleBaritoneControl implements Helper, AbstractGameEventListener {
|
||||
|
||||
private static final String HELP_MSG =
|
||||
"baritone - Output settings into chat\n" +
|
||||
"settings - Same as baritone\n" +
|
||||
"goal - Create a goal (one number is '<Y>', two is '<X> <Z>', three is '<X> <Y> <Z>, 'clear' to clear)\n" +
|
||||
"path - Go towards goal\n" +
|
||||
"repack - (debug) Repacks chunk cache\n" +
|
||||
"rescan - (debug) Same as repack\n" +
|
||||
"axis - Paths towards the closest axis or diagonal axis, at y=120\n" +
|
||||
"cancel - Cancels current path\n" +
|
||||
"forcecancel - sudo cancel (only use if very glitched, try toggling 'pause' first)\n" +
|
||||
"gc - Calls System.gc();\n" +
|
||||
"invert - Runs away from the goal instead of towards it\n" +
|
||||
"follow - Follows a player 'follow username'\n" +
|
||||
"reloadall - (debug) Reloads chunk cache\n" +
|
||||
"saveall - (debug) Saves chunk cache\n" +
|
||||
"find - (debug) outputs how many blocks of a certain type are within the cache\n" +
|
||||
"mine - Paths to and mines specified blocks 'mine x_ore y_ore ...'\n" +
|
||||
"thisway - Creates a goal X blocks where you're facing\n" +
|
||||
"list - Lists waypoints under a category\n" +
|
||||
"get - Same as list\n" +
|
||||
"show - Same as list\n" +
|
||||
"save - Saves a waypoint (works but don't try to make sense of it)\n" +
|
||||
"delete - Deletes a waypoint\n" +
|
||||
"goto - Paths towards specified block or waypoint\n" +
|
||||
"spawn - Paths towards world spawn or your most recent bed right-click\n" +
|
||||
"sethome - Sets \"home\"\n" +
|
||||
"home - Paths towards \"home\" \n" +
|
||||
"costs - (debug) all movement costs from current location\n" +
|
||||
"damn - Daniel\n" +
|
||||
"Go to https://github.com/cabaletta/baritone/blob/master/USAGE.md for more information";
|
||||
|
||||
private static final String COMMAND_PREFIX = "#";
|
||||
|
||||
public final IBaritone baritone;
|
||||
@@ -147,9 +120,12 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("") || msg.equals("help") || msg.equals("?")) {
|
||||
for (String line : HELP_MSG.split("\n")) {
|
||||
logDirect(line);
|
||||
}
|
||||
ITextComponent component = MESSAGE_PREFIX.createCopy();
|
||||
component.getStyle().setColor(TextFormatting.GRAY);
|
||||
TextComponentString helpLink = new TextComponentString(" Click here for instructions on how to use Baritone (https://github.com/cabaletta/baritone/blob/master/USAGE.md)");
|
||||
helpLink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/cabaletta/baritone/blob/master/USAGE.md"));
|
||||
component.appendSibling(helpLink);
|
||||
BaritoneAPI.getSettings().logger.value.accept(component);
|
||||
return true;
|
||||
}
|
||||
if (msg.contains(" ")) {
|
||||
@@ -294,6 +270,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");
|
||||
@@ -406,11 +386,34 @@ 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");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("followentity")) {
|
||||
String name = msg.substring(12).trim();
|
||||
Optional<Entity> toFollow = Optional.empty();
|
||||
for (Entity entity : ctx.world().loadedEntityList) {
|
||||
String entityName = entity.getName().trim().toLowerCase();
|
||||
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);
|
||||
}
|
||||
}
|
||||
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<Entity> toFollow = Optional.empty();
|
||||
@@ -586,7 +589,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;
|
||||
@@ -690,7 +693,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:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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> rotation = RotationUtils.reachable(ctx, blocked);
|
||||
if (rotation.isPresent()) {
|
||||
return state.setTarget(new MovementState.MovementTarget(rotation.get(), true)).setInput(Input.CLICK_RIGHT, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -427,7 +427,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
if (current instanceof MovementFall) {
|
||||
Tuple<Vec3d, BlockPos> data = overrideFall((MovementFall) current);
|
||||
if (data != null) {
|
||||
BlockPos fallDest = data.getSecond();
|
||||
BetterBlockPos fallDest = new BetterBlockPos(data.getSecond());
|
||||
if (!path.positions().contains(fallDest)) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public final class BackfillProcess extends BaritoneProcessHelper {
|
||||
return new PathingCommand(null, PathingCommandType.DEFER); // cede to other process
|
||||
}
|
||||
|
||||
public void amIBreakingABlockHMMMMMMM() {
|
||||
private void amIBreakingABlockHMMMMMMM() {
|
||||
if (!ctx.getSelectedBlock().isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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<Tuple<ISchematic, BlockPos>> 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -54,6 +57,9 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
||||
|
||||
private boolean active;
|
||||
|
||||
private List<BlockPos> locations;
|
||||
private int tickCount;
|
||||
|
||||
private static final List<Item> FARMLAND_PLANTABLE = Arrays.asList(
|
||||
Items.BEETROOT_SEEDS,
|
||||
Items.MELON_SEEDS,
|
||||
@@ -65,17 +71,16 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
||||
|
||||
private static final List<Item> 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)
|
||||
@@ -93,6 +98,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
||||
@Override
|
||||
public void farm() {
|
||||
active = true;
|
||||
locations = null;
|
||||
}
|
||||
|
||||
private enum Harvest {
|
||||
@@ -164,9 +170,12 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
||||
if (Baritone.settings().replantNetherWart.value) {
|
||||
scan.add(Blocks.SOUL_SAND);
|
||||
}
|
||||
|
||||
List<BlockPos> 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<BlockPos> toBreak = new ArrayList<>();
|
||||
List<BlockPos> openFarmland = new ArrayList<>();
|
||||
List<BlockPos> bonemealable = new ArrayList<>();
|
||||
@@ -216,11 +225,14 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
||||
boolean soulsand = openSoulsand.contains(pos);
|
||||
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance());
|
||||
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) {
|
||||
|
||||
@@ -99,6 +99,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!Baritone.settings().allowBreak.value) {
|
||||
logDirect("Unable to mine when allowBreak is false!");
|
||||
cancel();
|
||||
return null;
|
||||
}
|
||||
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value;
|
||||
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
||||
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
||||
@@ -395,6 +400,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
@Override
|
||||
public void mine(int quantity, Block... blocks) {
|
||||
this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks);
|
||||
if (mining != null && !Baritone.settings().allowBreak.value) {
|
||||
logDirect("Unable to mine when allowBreak is false!");
|
||||
mining = null;
|
||||
}
|
||||
this.desiredQuantity = quantity;
|
||||
this.knownOreLocations = new ArrayList<>();
|
||||
this.blacklist = new ArrayList<>();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -97,8 +97,6 @@ public final class PathRenderer implements Helper {
|
||||
}
|
||||
|
||||
//drawManySelectionBoxes(player, Collections.singletonList(behavior.pathStart()), partialTicks, Color.WHITE);
|
||||
//long start = System.nanoTime();
|
||||
|
||||
|
||||
// Render the current path, if there is one
|
||||
if (current != null && current.getPath() != null) {
|
||||
@@ -109,8 +107,6 @@ public final class PathRenderer implements Helper {
|
||||
drawPath(next.getPath(), 0, renderView, partialTicks, Baritone.settings().colorNextPath.value, Baritone.settings().fadePath.value, 10, 20);
|
||||
}
|
||||
|
||||
//long split = System.nanoTime();
|
||||
|
||||
// If there is a path calculation currently running, render the path calculation process
|
||||
behavior.getInProgress().ifPresent(currentlyRunning -> {
|
||||
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
||||
@@ -122,11 +118,6 @@ public final class PathRenderer implements Helper {
|
||||
drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.value);
|
||||
});
|
||||
});
|
||||
//long end = System.nanoTime();
|
||||
//System.out.println((end - split) + " " + (split - start));
|
||||
// if (end - start > 0) {
|
||||
// System.out.println("Frame took " + (split - start) + " " + (end - split));
|
||||
//}
|
||||
}
|
||||
|
||||
public static void drawPath(IPath path, int startIndex, Entity player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,7 +21,10 @@ 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;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -70,6 +73,9 @@ 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())
|
||||
.filter(entity -> !(entity instanceof EntityEnderman) || ((EntityEnderman) entity).isScreaming())
|
||||
.forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<IPath> doCalc() {
|
||||
Optional<IPath> 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<IPath> onCompletion, Runnable onFailure) {
|
||||
Baritone.getExecutor().execute(() -> {
|
||||
Optional<IPath> 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.schematic.schematica;
|
||||
|
||||
import baritone.api.utils.ISchematic;
|
||||
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 | NoClassDefFoundError ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<Tuple<ISchematic, BlockPos>> getOpenSchematic() {
|
||||
return Optional.ofNullable(ClientProxy.schematic)
|
||||
.map(world -> new Tuple<>(new SchematicAdapter(world), world.position));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.lunatrius.core.util.math;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class MBlockPos extends BlockPos {
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.lunatrius.schematica;
|
||||
|
||||
import com.github.lunatrius.schematica.proxy.CommonProxy;
|
||||
|
||||
public class Schematica {
|
||||
public static CommonProxy proxy;
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.lunatrius.schematica.client.world;
|
||||
|
||||
import com.github.lunatrius.core.util.math.MBlockPos;
|
||||
import com.github.lunatrius.schematica.api.ISchematic;
|
||||
|
||||
public class SchematicWorld {
|
||||
public final MBlockPos position = (MBlockPos)(Object)"cringe";
|
||||
|
||||
public ISchematic getSchematic() {
|
||||
throw new LinkageError("LOL");
|
||||
}
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.lunatrius.schematica.proxy;
|
||||
|
||||
import com.github.lunatrius.schematica.client.world.SchematicWorld;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
public static SchematicWorld schematic;
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.lunatrius.schematica.proxy;
|
||||
|
||||
public abstract class CommonProxy {}
|
||||
Reference in New Issue
Block a user