From 2572190b07e115894a22fecc818d4e864592da24 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 31 Oct 2024 14:35:34 +0900 Subject: [PATCH] 2/2 Player-specific TBMM battle config Add support for custom stats per-player by player username. --- .../client/ClientProxy.java | 211 ++++++++++++------ .../common/TurnBasedMinecraftMod.java | 104 ++++++++- 2 files changed, 237 insertions(+), 78 deletions(-) diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java index ed07861..9e16b4a 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java @@ -482,22 +482,27 @@ public class ClientProxy extends CommonProxy { MutableComponent text = Component.literal("Edit what value? "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); - MutableComponent option = Component.literal("IgB"); - // HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("IgnoreBattle")))); - MutableComponent value = Component.literal("(" + pkt.getEntityInfo().ignoreBattle + ") "); - value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - option.getSiblings().add(value); - text.getSiblings().add(option); + MutableComponent option; + MutableComponent value; - option = Component.literal("AP"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackPower")))); - value = Component.literal("(" + pkt.getEntityInfo().attackPower + ") "); - value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - option.getSiblings().add(value); - text.getSiblings().add(option); + if (pkt.getEntityInfo().playerName.isEmpty()) { + option = Component.literal("IgB"); + // HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("IgnoreBattle")))); + value = Component.literal("(" + pkt.getEntityInfo().ignoreBattle + ") "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); + + option = Component.literal("AP"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackPower")))); + value = Component.literal("(" + pkt.getEntityInfo().attackPower + ") "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); + } option = Component.literal("APr"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability")) @@ -507,45 +512,47 @@ public class ClientProxy extends CommonProxy { option.getSiblings().add(value); text.getSiblings().add(option); - option = Component.literal("AV"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackVariance")))); - value = Component.literal("(" + pkt.getEntityInfo().attackVariance + ") "); - value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - option.getSiblings().add(value); - text.getSiblings().add(option); + if (pkt.getEntityInfo().playerName.isEmpty()) { + option = Component.literal("AV"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackVariance")))); + value = Component.literal("(" + pkt.getEntityInfo().attackVariance + ") "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); - option = Component.literal("AE"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackEffect")))); - value = Component.literal("(" + pkt.getEntityInfo().attackEffect.toString() + ") "); - value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - option.getSiblings().add(value); - text.getSiblings().add(option); + option = Component.literal("AE"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackEffect")))); + value = Component.literal("(" + pkt.getEntityInfo().attackEffect.toString() + ") "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); - option = Component.literal("AEPr"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackEffectProbability")))); - value = Component.literal("(" + pkt.getEntityInfo().attackEffectProbability + "%) "); - value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - option.getSiblings().add(value); - text.getSiblings().add(option); + option = Component.literal("AEPr"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackEffectProbability")))); + value = Component.literal("(" + pkt.getEntityInfo().attackEffectProbability + "%) "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); - option = Component.literal("DD"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamage")))); - value = Component.literal("(" + pkt.getEntityInfo().defenseDamage + ") "); - value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - option.getSiblings().add(value); - text.getSiblings().add(option); + option = Component.literal("DD"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamage")))); + value = Component.literal("(" + pkt.getEntityInfo().defenseDamage + ") "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); - option = Component.literal("DDPr"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamageProbability")))); - value = Component.literal("(" + pkt.getEntityInfo().defenseDamageProbability + "%) "); - value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - option.getSiblings().add(value); - text.getSiblings().add(option); + option = Component.literal("DDPr"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamageProbability")))); + value = Component.literal("(" + pkt.getEntityInfo().defenseDamageProbability + "%) "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); + } option = Component.literal("E"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion")) @@ -563,37 +570,55 @@ public class ClientProxy extends CommonProxy { option.getSiblings().add(value); text.getSiblings().add(option); - option = Component.literal("C"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Category")))); - value = Component.literal("(" + pkt.getEntityInfo().category + ") "); + option = Component.literal("HS"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit hasteSpeed")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("HasteSpeed")))); + value = Component.literal("(" + pkt.getEntityInfo().hasteSpeed + ") "); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); option.getSiblings().add(value); text.getSiblings().add(option); - option = Component.literal("DecA"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionAttack")))); - value = Component.literal("(" + pkt.getEntityInfo().decisionAttack + "%) "); + option = Component.literal("SS"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit slowSpeed")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("SlowSpeed")))); + value = Component.literal("(" + pkt.getEntityInfo().slowSpeed + ") "); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); option.getSiblings().add(value); text.getSiblings().add(option); - option = Component.literal("DecD"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionDefend")))); - value = Component.literal("(" + pkt.getEntityInfo().decisionDefend + "%) "); - value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - option.getSiblings().add(value); - text.getSiblings().add(option); + if (pkt.getEntityInfo().playerName.isEmpty()) { + option = Component.literal("C"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Category")))); + value = Component.literal("(" + pkt.getEntityInfo().category + ") "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); - option = Component.literal("DecF"); - option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionFlee")))); - value = Component.literal("(" + pkt.getEntityInfo().decisionFlee + "%) "); - value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - option.getSiblings().add(value); - text.getSiblings().add(option); + option = Component.literal("DecA"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionAttack")))); + value = Component.literal("(" + pkt.getEntityInfo().decisionAttack + "%) "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); + + option = Component.literal("DecD"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionDefend")))); + value = Component.literal("(" + pkt.getEntityInfo().decisionDefend + "%) "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); + + option = Component.literal("DecF"); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionFlee")))); + value = Component.literal("(" + pkt.getEntityInfo().decisionFlee + "%) "); + value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); + option.getSiblings().add(value); + text.getSiblings().add(option); + } option = Component.literal("Finished Editing"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish"))); @@ -1303,6 +1328,44 @@ public class ClientProxy extends CommonProxy { TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } + case EDIT_HASTE_SPEED: { + MutableComponent text = Component.literal("haste speed: "); + text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); + + for (int i = 0; i <= 100; i += 10) { + MutableComponent option = Component.literal(Integer.toString(i)); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit hasteSpeed " + Integer.toString(i)))); + text.getSiblings().add(option); + if (i < 100) { + text.getSiblings().add(Component.literal(", ")); + } + } + + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit hasteSpeed \")")); + + parentComponent.getSiblings().add(text); + TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); + break; + } + case EDIT_SLOW_SPEED: { + MutableComponent text = Component.literal("slow speed: "); + text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); + + for (int i = 0; i <= 100; i += 10) { + MutableComponent option = Component.literal(Integer.toString(i)); + option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit slowSpeed " + Integer.toString(i)))); + text.getSiblings().add(option); + if (i < 100) { + text.getSiblings().add(Component.literal(", ")); + } + } + + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit slowSpeed \")")); + + parentComponent.getSiblings().add(text); + TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); + break; + } case EDIT_CATEGORY: { MutableComponent text = Component.literal("category: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); @@ -1473,6 +1536,10 @@ public class ClientProxy extends CommonProxy { TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } + case PICK_PLAYER: { + TurnBasedMinecraftMod.proxy.displayString("Use \"/tbm-edit player \""); + break; + } default: break; } diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java index 0425c8b..e934c70 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java @@ -292,6 +292,30 @@ public class TurnBasedMinecraftMod { } return 1; })) + .then(Commands.literal("player") + .executes(c -> { + ServerPlayer player = c.getSource().getPlayerOrException(); + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_PLAYER), PacketDistributor.PLAYER.with(player)); + return 1; + }) + .then(Commands.argument("playerName", StringArgumentType.greedyString()).executes(c -> { + String name = StringArgumentType.getString(c, "playerName"); + ServerPlayer player = c.getSource().getPlayerOrException(); + getHandler().send(new PacketGeneralMessage("Editing player \"" + name + "\""), PacketDistributor.PLAYER.with(player)); + TurnBasedMinecraftMod.logger.info("Begin editing player \"" + name + "\""); + proxy.setEditingPlayer(player); + EditingInfo editInfo = proxy.getEditingInfo(player.getId()); + editInfo.isEditingPlayer = true; + editInfo.entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getPlayerInfo(name); + if (editInfo.entityInfo == null) { + editInfo.entityInfo = new EntityInfo(); + } + editInfo.entityInfo.playerName = name; + editInfo.isPendingEntitySelection = false; + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editInfo.entityInfo), PacketDistributor.PLAYER.with(player)); + return 1; + })) + ) .then(Commands.literal("edit") .executes(c -> { ServerPlayer player = c.getSource().getPlayerOrException(); @@ -615,11 +639,45 @@ public class TurnBasedMinecraftMod { })) ) .then(Commands.literal("speed") + .executes(c -> { + ServerPlayer player = c.getSource().getPlayerOrException(); + EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); + if (editingInfo != null && !editingInfo.isPendingEntitySelection) { + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED), PacketDistributor.PLAYER.with(player)); + } else if (editingInfo != null) { + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player)); + } else { + Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); + throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage); + } + return 1; + }) + .then(Commands.argument("speed", IntegerArgumentType.integer()) + .executes(c -> { + ServerPlayer player = c.getSource().getPlayerOrException(); + EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); + int speed = IntegerArgumentType.getInteger(c, "speed"); + if (speed < 0) { + speed = 0; + } + if (editingInfo != null && !editingInfo.isPendingEntitySelection) { + editingInfo.entityInfo.speed = speed; + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player)); + } else if (editingInfo != null) { + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player)); + } else { + Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); + throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage); + } + return 1; + })) + ) + .then(Commands.literal("hasteSpeed") .executes(c -> { ServerPlayer player = c.getSource().getPlayerOrException(); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); if (editingInfo != null && !editingInfo.isPendingEntitySelection) { - getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED), PacketDistributor.PLAYER.with(player)); + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_HASTE_SPEED), PacketDistributor.PLAYER.with(player)); } else if (editingInfo != null) { getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player)); } else { @@ -628,16 +686,16 @@ public class TurnBasedMinecraftMod { } return 1; }) - .then(Commands.argument("speed", IntegerArgumentType.integer()) + .then(Commands.argument("hasteSpeed", IntegerArgumentType.integer()) .executes(c -> { ServerPlayer player = c.getSource().getPlayerOrException(); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); - int speed = IntegerArgumentType.getInteger(c, "speed"); - if (speed < 0) { - speed = 0; + int hasteSpeed = IntegerArgumentType.getInteger(c, "hasteSpeed"); + if (hasteSpeed < 0) { + hasteSpeed = 0; } if (editingInfo != null && !editingInfo.isPendingEntitySelection) { - editingInfo.entityInfo.speed = speed; + editingInfo.entityInfo.hasteSpeed = hasteSpeed; getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player)); } else if (editingInfo != null) { getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player)); @@ -648,6 +706,40 @@ public class TurnBasedMinecraftMod { return 1; })) ) + .then(Commands.literal("slowSpeed") + .executes(c -> { + ServerPlayer player = c.getSource().getPlayerOrException(); + EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); + if (editingInfo != null && !editingInfo.isPendingEntitySelection) { + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SLOW_SPEED), PacketDistributor.PLAYER.with(player)); + } else if (editingInfo != null) { + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player)); + } else { + Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); + throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage); + } + return 1; + }) + .then(Commands.argument("slowSpeed", IntegerArgumentType.integer()) + .executes(c -> { + ServerPlayer player = c.getSource().getPlayerOrException(); + EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); + int slowSpeed = IntegerArgumentType.getInteger(c, "slowSpeed"); + if (slowSpeed < 0) { + slowSpeed = 0; + } + if (editingInfo != null && !editingInfo.isPendingEntitySelection) { + editingInfo.entityInfo.slowSpeed = slowSpeed; + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player)); + } else if (editingInfo != null) { + getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player)); + } else { + Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); + throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage); + } + return 1; + })) + ) .then(Commands.literal("category") .executes(c -> { ServerPlayer player = c.getSource().getPlayerOrException();