From 60f81fb89d6bb0c4c3adbf419a55878bf4b9831d Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Sun, 1 Nov 2020 17:18:31 +0000 Subject: [PATCH 1/2] notify users that their death position has been saved. Signed-off-by: scorbett123 --- .../baritone/behavior/MemoryBehavior.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 66ab10f3..061677d5 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -25,6 +25,7 @@ import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.TickEvent; import baritone.api.event.events.type.EventState; import baritone.api.utils.BetterBlockPos; +import baritone.api.utils.Helper; import baritone.cache.ContainerMemory; import baritone.utils.BlockStateInterface; import net.minecraft.block.Block; @@ -40,13 +41,20 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityLockable; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraft.util.text.event.HoverEvent; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; +import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; + /** * doesn't work for horse inventories :^) * @@ -166,7 +174,26 @@ public final class MemoryBehavior extends Behavior { @Override public void onPlayerDeath() { + Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet()); baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet())); + ITextComponent component = new TextComponentString("Death position saved."); + component.getStyle() + .setColor(TextFormatting.WHITE) + .setHoverEvent(new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + new TextComponentString("Click to goto death") + )) + .setClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + String.format( + "%s%s goto %s @ %d", + FORCE_COMMAND_PREFIX, + "wp", + deathWaypoint.getTag().getName(), + deathWaypoint.getCreationTimestamp() + ) + )); + Helper.HELPER.logDirect(component); } From c0f7d5ab44b362f5bea045c77bca0514ea841b50 Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Sun, 1 Nov 2020 17:30:53 +0000 Subject: [PATCH 2/2] fix error made while copying and pasting. Signed-off-by: scorbett123 --- src/main/java/baritone/behavior/MemoryBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 061677d5..b7d31223 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -175,7 +175,7 @@ public final class MemoryBehavior extends Behavior { @Override public void onPlayerDeath() { Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet()); - baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(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)