2/2 Player-specific TBMM battle config

Add support for custom stats per-player by player username.
This commit is contained in:
Stephen Seo 2024-10-31 14:35:34 +09:00
parent d33686aaf9
commit ae6af86e7b
2 changed files with 237 additions and 78 deletions

View file

@ -481,22 +481,27 @@ public class ClientProxy extends CommonProxy {
MutableComponent text = Component.literal("Edit what value? "); MutableComponent text = Component.literal("Edit what value? ");
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
MutableComponent option = Component.literal("IgB"); MutableComponent option;
// HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT MutableComponent value;
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);
option = Component.literal("AP"); if (pkt.getEntityInfo().playerName.isEmpty()) {
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower")) option = Component.literal("IgB");
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackPower")))); // HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT
value = Component.literal("(" + pkt.getEntityInfo().attackPower + ") "); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle"))
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("IgnoreBattle"))));
option.getSiblings().add(value); value = Component.literal("(" + pkt.getEntityInfo().ignoreBattle + ") ");
text.getSiblings().add(option); 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 = Component.literal("APr");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability")) option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability"))
@ -506,45 +511,47 @@ public class ClientProxy extends CommonProxy {
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = Component.literal("AV"); if (pkt.getEntityInfo().playerName.isEmpty()) {
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance")) option = Component.literal("AV");
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackVariance")))); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance"))
value = Component.literal("(" + pkt.getEntityInfo().attackVariance + ") "); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackVariance"))));
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value = Component.literal("(" + pkt.getEntityInfo().attackVariance + ") ");
option.getSiblings().add(value); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
text.getSiblings().add(option); option.getSiblings().add(value);
text.getSiblings().add(option);
option = Component.literal("AE"); option = Component.literal("AE");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect")) 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")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackEffect"))));
value = Component.literal("(" + pkt.getEntityInfo().attackEffect.toString() + ") "); value = Component.literal("(" + pkt.getEntityInfo().attackEffect.toString() + ") ");
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = Component.literal("AEPr"); option = Component.literal("AEPr");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability")) 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")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackEffectProbability"))));
value = Component.literal("(" + pkt.getEntityInfo().attackEffectProbability + "%) "); value = Component.literal("(" + pkt.getEntityInfo().attackEffectProbability + "%) ");
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = Component.literal("DD"); option = Component.literal("DD");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage")) 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")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamage"))));
value = Component.literal("(" + pkt.getEntityInfo().defenseDamage + ") "); value = Component.literal("(" + pkt.getEntityInfo().defenseDamage + ") ");
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = Component.literal("DDPr"); option = Component.literal("DDPr");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability")) 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")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamageProbability"))));
value = Component.literal("(" + pkt.getEntityInfo().defenseDamageProbability + "%) "); value = Component.literal("(" + pkt.getEntityInfo().defenseDamageProbability + "%) ");
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
}
option = Component.literal("E"); option = Component.literal("E");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion")) option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion"))
@ -562,37 +569,55 @@ public class ClientProxy extends CommonProxy {
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = Component.literal("C"); option = Component.literal("HS");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category")) 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("Category")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("HasteSpeed"))));
value = Component.literal("(" + pkt.getEntityInfo().category + ") "); value = Component.literal("(" + pkt.getEntityInfo().hasteSpeed + ") ");
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = Component.literal("DecA"); option = Component.literal("SS");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack")) 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("DecisionAttack")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("SlowSpeed"))));
value = Component.literal("(" + pkt.getEntityInfo().decisionAttack + "%) "); value = Component.literal("(" + pkt.getEntityInfo().slowSpeed + ") ");
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = Component.literal("DecD"); if (pkt.getEntityInfo().playerName.isEmpty()) {
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend")) option = Component.literal("C");
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionDefend")))); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category"))
value = Component.literal("(" + pkt.getEntityInfo().decisionDefend + "%) "); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Category"))));
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value = Component.literal("(" + pkt.getEntityInfo().category + ") ");
option.getSiblings().add(value); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
text.getSiblings().add(option); option.getSiblings().add(value);
text.getSiblings().add(option);
option = Component.literal("DecF"); option = Component.literal("DecA");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee")) 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("DecisionFlee")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionAttack"))));
value = Component.literal("(" + pkt.getEntityInfo().decisionFlee + "%) "); value = Component.literal("(" + pkt.getEntityInfo().decisionAttack + "%) ");
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); 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 = Component.literal("Finished Editing");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish"))); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish")));
@ -1302,6 +1327,44 @@ public class ClientProxy extends CommonProxy {
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
break; 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 <integer>\")"));
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 <integer>\")"));
parentComponent.getSiblings().add(text);
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
break;
}
case EDIT_CATEGORY: { case EDIT_CATEGORY: {
MutableComponent text = Component.literal("category: "); MutableComponent text = Component.literal("category: ");
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
@ -1472,6 +1535,10 @@ public class ClientProxy extends CommonProxy {
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
break; break;
} }
case PICK_PLAYER: {
TurnBasedMinecraftMod.proxy.displayString("Use \"/tbm-edit player <player_name>\"");
break;
}
default: default:
break; break;
} }

View file

@ -267,6 +267,30 @@ public class TurnBasedMinecraftMod {
} }
return 1; return 1;
})) }))
.then(Commands.literal("player")
.executes(c -> {
ServerPlayer player = c.getSource().getPlayerOrException();
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_PLAYER));
return 1;
})
.then(Commands.argument("playerName", StringArgumentType.greedyString()).executes(c -> {
String name = StringArgumentType.getString(c, "playerName");
ServerPlayer player = c.getSource().getPlayerOrException();
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("Editing player \"" + name + "\""));
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;
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editInfo.entityInfo));
return 1;
}))
)
.then(Commands.literal("edit") .then(Commands.literal("edit")
.executes(c -> { .executes(c -> {
ServerPlayer player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
@ -590,11 +614,45 @@ public class TurnBasedMinecraftMod {
})) }))
) )
.then(Commands.literal("speed") .then(Commands.literal("speed")
.executes(c -> {
ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
} else if (editingInfo != null) {
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} 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;
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if (editingInfo != null) {
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} 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 -> { .executes(c -> {
ServerPlayer player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if (editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED)); PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_HASTE_SPEED));
} else if (editingInfo != null) { } else if (editingInfo != null) {
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
@ -603,16 +661,16 @@ public class TurnBasedMinecraftMod {
} }
return 1; return 1;
}) })
.then(Commands.argument("speed", IntegerArgumentType.integer()) .then(Commands.argument("hasteSpeed", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayer player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int speed = IntegerArgumentType.getInteger(c, "speed"); int hasteSpeed = IntegerArgumentType.getInteger(c, "hasteSpeed");
if (speed < 0) { if (hasteSpeed < 0) {
speed = 0; hasteSpeed = 0;
} }
if (editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.speed = speed; editingInfo.entityInfo.hasteSpeed = hasteSpeed;
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if (editingInfo != null) { } else if (editingInfo != null) {
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
@ -623,6 +681,40 @@ public class TurnBasedMinecraftMod {
return 1; 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) {
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SLOW_SPEED));
} else if (editingInfo != null) {
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} 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;
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if (editingInfo != null) {
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} 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") .then(Commands.literal("category")
.executes(c -> { .executes(c -> {
ServerPlayer player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();