From 7f4ea9cae3eb683cd953dea21b62a10214d6772e Mon Sep 17 00:00:00 2001 From: joe Date: Sun, 3 Mar 2024 20:31:45 +0000 Subject: [PATCH] Make enchantment cracking cancelable --- .../clientcommands/command/CEnchantCommand.java | 4 +++- .../clientcommands/features/EnchantmentCracker.java | 9 +++++---- src/main/resources/assets/clientcommands/lang/en_us.json | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java b/src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java index 3af9f7f7f..d4d474a72 100644 --- a/src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java +++ b/src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java @@ -79,7 +79,9 @@ private static int cenchant(FabricClientCommandSource source, ItemAndEnchantment source.sendFeedback(Component.literal("- ").append(ench.enchantment.getFullname(ench.level))); } if (!simulate) { - source.sendFeedback(Component.translatable("commands.cenchant.success")); + source.sendFeedback(Component.translatable("commands.cenchant.success") + .append(" ") + .append(getCommandTextComponent("commands.client.cancel", "/ctask stop " + result.taskName()))); } } return Command.SINGLE_SUCCESS; diff --git a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java index 869dd2ac9..c63259ab5 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java @@ -32,6 +32,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.EnchantmentTableBlock; +import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import java.util.ArrayList; @@ -361,7 +362,7 @@ public static ManipulateResult manipulateEnchantments(Item item, Predicate getEnchantmentsInTable(int slot) { } } - public record ManipulateResult(int itemThrows, int bookshelves, int slot, List enchantments) {} + public record ManipulateResult(int itemThrows, int bookshelves, int slot, List enchantments, @Nullable String taskName) {} public enum CrackState implements StringRepresentable { UNCRACKED("uncracked"), CRACKED("cracked"), CRACKING("cracking"); diff --git a/src/main/resources/assets/clientcommands/lang/en_us.json b/src/main/resources/assets/clientcommands/lang/en_us.json index a43bc2ef2..e63ba9d68 100644 --- a/src/main/resources/assets/clientcommands/lang/en_us.json +++ b/src/main/resources/assets/clientcommands/lang/en_us.json @@ -49,7 +49,7 @@ "commands.cenchant.help.uncrackedPlayerSeed": "Help: you have not fully cracked the player seed", "commands.cenchant.incompatible": "Incompatible enchantments", "commands.cenchant.needEnchantingPrediction": "This command requires enchanting prediction to be enabled", - "commands.cenchant.success": "Starting enchantment manipulation", + "commands.cenchant.success": "Starting enchantment manipulation.", "commands.cenchant.uncracked": "Seed needs to be cracked", "commands.cfind.found.left": "Found %1$s at ",