Merge pull request #3324 from wagyourtail/master
reimplement death and bed waypoints
This commit is contained in:
commit
8c2aae2ddc
@ -550,6 +550,17 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
|
public final Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* allows baritone to save bed waypoints when interacting with beds
|
||||||
|
*/
|
||||||
|
public final Setting<Boolean> doBedWaypoints = new Setting<>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* allows baritone to save death waypoints
|
||||||
|
*/
|
||||||
|
public final Setting<Boolean> doDeathWaypoints = new Setting<>(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
|
* The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
|
||||||
*/
|
*/
|
||||||
|
@ -69,6 +69,7 @@ public class Baritone implements IBaritone {
|
|||||||
private PathingBehavior pathingBehavior;
|
private PathingBehavior pathingBehavior;
|
||||||
private LookBehavior lookBehavior;
|
private LookBehavior lookBehavior;
|
||||||
private InventoryBehavior inventoryBehavior;
|
private InventoryBehavior inventoryBehavior;
|
||||||
|
private WaypointBehavior waypointBehavior;
|
||||||
private InputOverrideHandler inputOverrideHandler;
|
private InputOverrideHandler inputOverrideHandler;
|
||||||
|
|
||||||
private FollowProcess followProcess;
|
private FollowProcess followProcess;
|
||||||
@ -101,6 +102,7 @@ public class Baritone implements IBaritone {
|
|||||||
lookBehavior = new LookBehavior(this);
|
lookBehavior = new LookBehavior(this);
|
||||||
inventoryBehavior = new InventoryBehavior(this);
|
inventoryBehavior = new InventoryBehavior(this);
|
||||||
inputOverrideHandler = new InputOverrideHandler(this);
|
inputOverrideHandler = new InputOverrideHandler(this);
|
||||||
|
waypointBehavior = new WaypointBehavior(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pathingControlManager = new PathingControlManager(this);
|
this.pathingControlManager = new PathingControlManager(this);
|
||||||
|
92
src/main/java/baritone/behavior/WaypointBehavior.java
Normal file
92
src/main/java/baritone/behavior/WaypointBehavior.java
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.behavior;
|
||||||
|
|
||||||
|
import baritone.Baritone;
|
||||||
|
import baritone.api.cache.IWaypoint;
|
||||||
|
import baritone.api.cache.Waypoint;
|
||||||
|
import baritone.api.event.events.BlockInteractEvent;
|
||||||
|
import baritone.api.utils.BetterBlockPos;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import net.minecraft.block.BlockBed;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TextComponentString;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.util.text.event.ClickEvent;
|
||||||
|
import net.minecraft.util.text.event.HoverEvent;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||||
|
|
||||||
|
public class WaypointBehavior extends Behavior {
|
||||||
|
|
||||||
|
|
||||||
|
public WaypointBehavior(Baritone baritone) {
|
||||||
|
super(baritone);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockInteract(BlockInteractEvent event) {
|
||||||
|
if (!Baritone.settings().doBedWaypoints.value)
|
||||||
|
return;
|
||||||
|
if (event.getType() == BlockInteractEvent.Type.USE) {
|
||||||
|
BetterBlockPos pos = BetterBlockPos.from(event.getPos());
|
||||||
|
IBlockState state = BlockStateInterface.get(ctx, pos);
|
||||||
|
if (state.getBlock() instanceof BlockBed) {
|
||||||
|
if (state.getValue(BlockBed.PART) == BlockBed.EnumPartType.FOOT) {
|
||||||
|
pos = pos.offset(state.getValue(BlockBed.FACING));
|
||||||
|
}
|
||||||
|
Set<IWaypoint> waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(IWaypoint.Tag.BED);
|
||||||
|
boolean exists = waypoints.stream().map(IWaypoint::getLocation).filter(pos::equals).findFirst().isPresent();
|
||||||
|
if (!exists) {
|
||||||
|
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerDeath() {
|
||||||
|
if (!Baritone.settings().doDeathWaypoints.value)
|
||||||
|
return;
|
||||||
|
Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet());
|
||||||
|
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint);
|
||||||
|
ITextComponent component = new TextComponentString("Death position saved.");
|
||||||
|
component.getStyle()
|
||||||
|
.setColor(TextFormatting.WHITE)
|
||||||
|
.setHoverEvent(new HoverEvent(
|
||||||
|
HoverEvent.Action.SHOW_TEXT,
|
||||||
|
new TextComponentString("Click to goto death")
|
||||||
|
))
|
||||||
|
.setClickEvent(new ClickEvent(
|
||||||
|
ClickEvent.Action.RUN_COMMAND,
|
||||||
|
String.format(
|
||||||
|
"%s%s goto %s @ %d",
|
||||||
|
FORCE_COMMAND_PREFIX,
|
||||||
|
"wp",
|
||||||
|
deathWaypoint.getTag().getName(),
|
||||||
|
deathWaypoint.getCreationTimestamp()
|
||||||
|
)
|
||||||
|
));
|
||||||
|
Helper.HELPER.logDirect(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user