From 74b968125342b1397791eb28f7b6a9882f1fba8b Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Wed, 3 Aug 2022 14:46:33 +0900 Subject: [PATCH] Update for forge-1.19-41.1.0, mod ver. 1.19 --- README.md | 2 +- build.gradle | 6 +- .../TurnBasedMinecraft/client/BattleGui.java | 24 +- .../client/ClientProxy.java | 718 +++++++++--------- .../client/EntitySelectionButton.java | 3 +- .../client/ItemSelectionButton.java | 4 +- .../common/PlayerJoinEventHandler.java | 6 +- .../common/TurnBasedMinecraftMod.java | 365 ++++----- .../TurnBasedMinecraft/common/Utility.java | 2 +- .../networking/PacketBattleRequestInfo.java | 1 - src/main/resources/META-INF/mods.toml | 4 +- .../TBM_Config.toml | 47 +- src/main/resources/mcmod.info | 2 +- 13 files changed, 610 insertions(+), 574 deletions(-) diff --git a/README.md b/README.md index fcc58a9..b0eadb9 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ configured for them.) # Building Simply invoke `./gradlew build` in the mod directory and after some time the -finished jar will be saved at "build/libs/TurnBasedMinecraft-1.18.7.jar" +finished jar will be saved at "build/libs/TurnBasedMinecraft-1.19.0.jar" # Other notes diff --git a/build.gradle b/build.gradle index 614b3fd..ca8a094 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ apply plugin: 'net.minecraftforge.gradle' //apply plugin: 'eclipse' //apply plugin: 'maven-publish' -version = "1.18.7" +version = "1.19.0" group = "com.burnedkirby.TurnBasedMinecraft" archivesBaseName = "TurnBasedMinecraft" @@ -27,7 +27,7 @@ minecraft { // stable_# Stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'official', version: '1.18.2' + mappings channel: 'official', version: '1.19' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') @@ -151,7 +151,7 @@ dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.18.2-40.1.0' + minecraft 'net.minecraftforge:forge:1.19-41.1.0' // Real mod deobf dependency examples - these get remapped to your current mappings // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleGui.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleGui.java index 39a7644..deb8a6c 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleGui.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleGui.java @@ -9,7 +9,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import java.util.ConcurrentModificationException; import java.util.HashMap; @@ -82,7 +82,7 @@ public class BattleGui extends Screen { } public BattleGui() { - super(new TextComponent("Battle Gui")); + super(Component.literal("Battle Gui")); timeRemaining = new AtomicInteger((int) (Config.BATTLE_DECISION_DURATION_NANO_DEFAULT / 1000000000L)); timerMax = timeRemaining.get(); lastInstant = System.nanoTime(); @@ -127,16 +127,16 @@ public class BattleGui extends Screen { switch (state) { case MAIN_MENU: info = "What will you do?"; - addRenderableWidget(new Button(width * 3 / 7 - 25, 40, 50, 20, new TextComponent("Attack"), (button) -> { + addRenderableWidget(new Button(width * 3 / 7 - 25, 40, 50, 20, Component.literal("Attack"), (button) -> { buttonActionEvent(button, ButtonAction.ATTACK); })); - addRenderableWidget(new Button(width * 4 / 7 - 25, 40, 50, 20, new TextComponent("Defend"), (button) -> { + addRenderableWidget(new Button(width * 4 / 7 - 25, 40, 50, 20, Component.literal("Defend"), (button) -> { buttonActionEvent(button, ButtonAction.DEFEND); })); - addRenderableWidget(new Button(width * 3 / 7 - 25, 60, 50, 20, new TextComponent("Item"), (button) -> { + addRenderableWidget(new Button(width * 3 / 7 - 25, 60, 50, 20, Component.literal("Item"), (button) -> { buttonActionEvent(button, ButtonAction.ITEM); })); - addRenderableWidget(new Button(width * 4 / 7 - 25, 60, 50, 20, new TextComponent("Flee"), (button) -> { + addRenderableWidget(new Button(width * 4 / 7 - 25, 60, 50, 20, Component.literal("Flee"), (button) -> { buttonActionEvent(button, ButtonAction.FLEE); })); break; @@ -178,19 +178,19 @@ public class BattleGui extends Screen { } catch (ConcurrentModificationException e) { // ignored } - addRenderableWidget(new Button(width / 2 - 30, height - 120, 60, 20, new TextComponent("Cancel"), (button) -> { + addRenderableWidget(new Button(width / 2 - 30, height - 120, 60, 20, Component.literal("Cancel"), (button) -> { buttonActionEvent(button, ButtonAction.CANCEL); })); break; case ITEM_ACTION: info = "What will you do with an item?"; - addRenderableWidget(new Button(width * 1 / 4 - 40, height - 120, 80, 20, new TextComponent("Switch Held"), (button) -> { + addRenderableWidget(new Button(width * 1 / 4 - 40, height - 120, 80, 20, Component.literal("Switch Held"), (button) -> { buttonActionEvent(button, ButtonAction.SWITCH_HELD_ITEM); })); - addRenderableWidget(new Button(width * 2 / 4 - 40, height - 120, 80, 20, new TextComponent("Use"), (button) -> { + addRenderableWidget(new Button(width * 2 / 4 - 40, height - 120, 80, 20, Component.literal("Use"), (button) -> { buttonActionEvent(button, ButtonAction.DECIDE_USE_ITEM); })); - addRenderableWidget(new Button(width * 3 / 4 - 40, height - 120, 80, 20, new TextComponent("Cancel"), (button) -> { + addRenderableWidget(new Button(width * 3 / 4 - 40, height - 120, 80, 20, Component.literal("Cancel"), (button) -> { buttonActionEvent(button, ButtonAction.CANCEL); })); break; @@ -204,7 +204,7 @@ public class BattleGui extends Screen { buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH); })); } - addRenderableWidget(new Button(width / 2 - 40, height - 120, 80, 20, new TextComponent("Cancel"), (button) -> { + addRenderableWidget(new Button(width / 2 - 40, height - 120, 80, 20, Component.literal("Cancel"), (button) -> { buttonActionEvent(button, ButtonAction.CANCEL); })); break; @@ -215,7 +215,7 @@ public class BattleGui extends Screen { buttonActionEvent(button, ButtonAction.DO_USE_ITEM); })); } - addRenderableWidget(new Button(width / 2 - 40, height - 120, 80, 20, new TextComponent("Cancel"), (button) -> { + addRenderableWidget(new Button(width / 2 - 40, height - 120, 80, 20, Component.literal("Cancel"), (button) -> { buttonActionEvent(button, ButtonAction.CANCEL); })); break; diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java index 7f073eb..f0ba408 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java @@ -147,30 +147,30 @@ public class ClientProxy extends CommonProxy { @Override public void displayString(String message) { - Component parentComponent = new TextComponent(""); + MutableComponent parentComponent = Component.empty(); - TextComponent prefix = new TextComponent("TBM: "); - prefix.withStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true)); - TextComponent text = new TextComponent(message); - text.withStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); + MutableComponent prefix = Component.literal("TBM: "); + prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true)); + MutableComponent text = Component.literal(message); + text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); parentComponent.getSiblings().add(prefix); parentComponent.getSiblings().add(text); // UUID is required by sendMessage, but appears to be unused, so just give dummy UUID - Minecraft.getInstance().player.sendMessage(parentComponent, new UUID(0, 0)); + Minecraft.getInstance().player.sendSystemMessage(parentComponent); } @Override public void displayComponent(Component text) { - Component parentComponent = new TextComponent(""); + MutableComponent parentComponent = Component.empty(); - TextComponent prefix = new TextComponent("TBM: "); - prefix.withStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true)); + MutableComponent prefix = Component.literal("TBM: "); + prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true)); parentComponent.getSiblings().add(prefix); parentComponent.getSiblings().add(text); // UUID is required by sendMessage, but appears to be unused, so just give dummy UUID - Minecraft.getInstance().player.sendMessage(parentComponent, new UUID(0, 0)); + Minecraft.getInstance().player.sendSystemMessage(parentComponent); } private void checkBattleTypes(boolean entityLeft) { @@ -229,7 +229,7 @@ public class ClientProxy extends CommonProxy { if (msg.getClass() == PacketBattleMessage.class) { PacketBattleMessage pkt = (PacketBattleMessage) msg; Entity fromEntity = getEntity(pkt.getEntityIDFrom(), pkt.getDimension()); - Component from = new TextComponent("Unknown"); + Component from = Component.literal("Unknown"); if (fromEntity != null) { from = fromEntity.getDisplayName(); } else if (TurnBasedMinecraftMod.proxy.getLocalBattle() != null) { @@ -239,7 +239,7 @@ public class ClientProxy extends CommonProxy { } } Entity toEntity = TurnBasedMinecraftMod.proxy.getEntity(pkt.getEntityIDTo(), pkt.getDimension()); - Component to = new TextComponent("Unknown"); + Component to = Component.literal("Unknown"); if (toEntity != null) { to = toEntity.getDisplayName(); } else if (TurnBasedMinecraftMod.proxy.getLocalBattle() != null) { @@ -249,11 +249,11 @@ public class ClientProxy extends CommonProxy { } } - Component parentComponent = new TextComponent(""); + MutableComponent parentComponent = Component.empty(); switch (pkt.getMessageType()) { case ENTERED: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" entered battle!")); + parentComponent.getSiblings().add(Component.literal(" entered battle!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null || TurnBasedMinecraftMod.proxy.getLocalBattle().getId() != pkt.getAmount()) { TurnBasedMinecraftMod.proxy.createLocalBattle(pkt.getAmount()); @@ -264,18 +264,18 @@ public class ClientProxy extends CommonProxy { case FLEE: if (pkt.getAmount() != 0) { parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" fled battle!")); + parentComponent.getSiblings().add(Component.literal(" fled battle!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); TurnBasedMinecraftMod.proxy.typeLeftBattle(pkt.getCustom()); } else { parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" tried to flee battle but failed!")); + parentComponent.getSiblings().add(Component.literal(" tried to flee battle but failed!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); } break; case DIED: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" died in battle!")); + parentComponent.getSiblings().add(Component.literal(" died in battle!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); TurnBasedMinecraftMod.proxy.typeLeftBattle(pkt.getCustom()); break; @@ -285,74 +285,74 @@ public class ClientProxy extends CommonProxy { break; case ATTACK: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" attacked ")); + parentComponent.getSiblings().add(Component.literal(" attacked ")); parentComponent.getSiblings().add(to); - parentComponent.getSiblings().add(new TextComponent(" and dealt ")); - parentComponent.getSiblings().add(new TextComponent(Integer.valueOf(pkt.getAmount()).toString())); - parentComponent.getSiblings().add(new TextComponent(" damage!")); + parentComponent.getSiblings().add(Component.literal(" and dealt ")); + parentComponent.getSiblings().add(Component.literal(Integer.valueOf(pkt.getAmount()).toString())); + parentComponent.getSiblings().add(Component.literal(" damage!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case DEFEND: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" blocked ")); + parentComponent.getSiblings().add(Component.literal(" blocked ")); parentComponent.getSiblings().add(to); - parentComponent.getSiblings().add(new TextComponent("'s attack!")); + parentComponent.getSiblings().add(Component.literal("'s attack!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case DEFENSE_DAMAGE: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" retaliated from ")); + parentComponent.getSiblings().add(Component.literal(" retaliated from ")); parentComponent.getSiblings().add(to); - parentComponent.getSiblings().add(new TextComponent("'s attack and dealt ")); - parentComponent.getSiblings().add(new TextComponent(Integer.valueOf(pkt.getAmount()).toString())); - parentComponent.getSiblings().add(new TextComponent(" damage!")); + parentComponent.getSiblings().add(Component.literal("'s attack and dealt ")); + parentComponent.getSiblings().add(Component.literal(Integer.valueOf(pkt.getAmount()).toString())); + parentComponent.getSiblings().add(Component.literal(" damage!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case MISS: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" attacked ")); + parentComponent.getSiblings().add(Component.literal(" attacked ")); parentComponent.getSiblings().add(to); - parentComponent.getSiblings().add(new TextComponent(" but missed!")); + parentComponent.getSiblings().add(Component.literal(" but missed!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case DEFENDING: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" is defending!")); + parentComponent.getSiblings().add(Component.literal(" is defending!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case DID_NOTHING: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" did nothing!")); + parentComponent.getSiblings().add(Component.literal(" did nothing!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case USED_ITEM: parentComponent.getSiblings().add(from); switch (PacketBattleMessage.UsedItemAction.valueOf(pkt.getAmount())) { case USED_NOTHING: - parentComponent.getSiblings().add(new TextComponent(" tried to use nothing!")); + parentComponent.getSiblings().add(Component.literal(" tried to use nothing!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case USED_INVALID: if (pkt.getCustom().length() > 0) { - parentComponent.getSiblings().add(new TextComponent(" tried to consume ")); - parentComponent.getSiblings().add(new TextComponent(pkt.getCustom())); - parentComponent.getSiblings().add(new TextComponent(" and failed!")); + parentComponent.getSiblings().add(Component.literal(" tried to consume ")); + parentComponent.getSiblings().add(Component.literal(pkt.getCustom())); + parentComponent.getSiblings().add(Component.literal(" and failed!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); } else { - parentComponent.getSiblings().add(new TextComponent(" tried to consume an invalid item and failed!")); + parentComponent.getSiblings().add(Component.literal(" tried to consume an invalid item and failed!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); } break; case USED_FOOD: - parentComponent.getSiblings().add(new TextComponent(" ate a ")); - parentComponent.getSiblings().add(new TextComponent(pkt.getCustom())); - parentComponent.getSiblings().add(new TextComponent("!")); + parentComponent.getSiblings().add(Component.literal(" ate a ")); + parentComponent.getSiblings().add(Component.literal(pkt.getCustom())); + parentComponent.getSiblings().add(Component.literal("!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case USED_POTION: - parentComponent.getSiblings().add(new TextComponent(" drank a ")); - parentComponent.getSiblings().add(new TextComponent(pkt.getCustom())); - parentComponent.getSiblings().add(new TextComponent("!")); + parentComponent.getSiblings().add(Component.literal(" drank a ")); + parentComponent.getSiblings().add(Component.literal(pkt.getCustom())); + parentComponent.getSiblings().add(Component.literal("!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } @@ -374,48 +374,48 @@ public class ClientProxy extends CommonProxy { case SWITCHED_ITEM: if (pkt.getAmount() != 0) { parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" switched to a different item!")); + parentComponent.getSiblings().add(Component.literal(" switched to a different item!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); } else { parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" switched to a different item but failed because it was invalid!")); + parentComponent.getSiblings().add(Component.literal(" switched to a different item but failed because it was invalid!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); } break; case WAS_AFFECTED: parentComponent.getSiblings().add(to); - parentComponent.getSiblings().add(new TextComponent(" was " + pkt.getCustom() + " by ")); + parentComponent.getSiblings().add(Component.literal(" was " + pkt.getCustom() + " by ")); parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent("!")); + parentComponent.getSiblings().add(Component.literal("!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case BECAME_CREATIVE: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" entered creative mode and left battle!")); + parentComponent.getSiblings().add(Component.literal(" entered creative mode and left battle!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case FIRED_ARROW: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" let loose an arrow towards ")); + parentComponent.getSiblings().add(Component.literal(" let loose an arrow towards ")); parentComponent.getSiblings().add(to); - parentComponent.getSiblings().add(new TextComponent("!")); + parentComponent.getSiblings().add(Component.literal("!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case ARROW_HIT: parentComponent.getSiblings().add(to); - parentComponent.getSiblings().add(new TextComponent(" was hit by ")); + parentComponent.getSiblings().add(Component.literal(" was hit by ")); parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent("'s arrow!")); + parentComponent.getSiblings().add(Component.literal("'s arrow!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case BOW_NO_AMMO: parentComponent.getSiblings().add(from); - parentComponent.getSiblings().add(new TextComponent(" tried to use their bow but ran out of ammo!")); + parentComponent.getSiblings().add(Component.literal(" tried to use their bow but ran out of ammo!")); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; case CREEPER_WAIT: { parentComponent.getSiblings().add(from); - TextComponent message = new TextComponent(" is charging up!"); + MutableComponent message = Component.literal(" is charging up!"); message.setStyle(message.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00))); parentComponent.getSiblings().add(message); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); @@ -423,7 +423,7 @@ public class ClientProxy extends CommonProxy { break; case CREEPER_WAIT_FINAL: { parentComponent.getSiblings().add(from); - TextComponent message = new TextComponent(" is about to explode!"); + MutableComponent message = Component.literal(" is about to explode!"); message.setStyle(message.getStyle().withColor(TextColor.fromRgb(0xFFFF5050))); parentComponent.getSiblings().add(message); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); @@ -431,7 +431,7 @@ public class ClientProxy extends CommonProxy { break; case CREEPER_EXPLODE: { parentComponent.getSiblings().add(from); - TextComponent message = new TextComponent(" exploded!"); + MutableComponent message = Component.literal(" exploded!"); message.setStyle(message.getStyle().withColor(TextColor.fromRgb(0xFFFF0000))); parentComponent.getSiblings().add(message); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); @@ -443,13 +443,13 @@ public class ClientProxy extends CommonProxy { displayString(pkt.getMessage()); } else if (msg.getClass() == PacketEditingMessage.class) { PacketEditingMessage pkt = (PacketEditingMessage) msg; - Component parentComponent = new TextComponent(""); + MutableComponent parentComponent = Component.empty(); switch (pkt.getType()) { case ATTACK_ENTITY: { - TextComponent text = new TextComponent("Attack the entity you want to edit for TurnBasedMinecraftMod. "); + MutableComponent text = Component.literal("Attack the entity you want to edit for TurnBasedMinecraftMod. "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); - TextComponent cancel = new TextComponent("Cancel"); + MutableComponent cancel = Component.literal("Cancel"); cancel.setStyle(cancel.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel"))); parentComponent.getSiblings().add(text); @@ -458,128 +458,128 @@ public class ClientProxy extends CommonProxy { break; } case PICK_EDIT: { - TextComponent text = new TextComponent("Edit what value? "); + MutableComponent text = Component.literal("Edit what value? "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); - TextComponent option = new TextComponent("IgB"); + 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, new TextComponent("IgnoreBattle")))); - TextComponent value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("AP"); + 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, new TextComponent("AttackPower")))); - value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("APr"); + option = Component.literal("APr"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("AttackProbability")))); - value = new TextComponent("(" + pkt.getEntityInfo().attackProbability + "%) "); + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackProbability")))); + value = Component.literal("(" + pkt.getEntityInfo().attackProbability + "%) "); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); option.getSiblings().add(value); text.getSiblings().add(option); - option = new TextComponent("AV"); + 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, new TextComponent("AttackVariance")))); - value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("AE"); + 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, new TextComponent("AttackEffect")))); - value = new TextComponent("(" + pkt.getEntityInfo().attackEffect.toString() + ") "); + .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 = new TextComponent("AEPr"); + 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, new TextComponent("AttackEffectProbability")))); - value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("DD"); + 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, new TextComponent("DefenseDamage")))); - value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("DDPr"); + 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, new TextComponent("DefenseDamageProbability")))); - value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("E"); + option = Component.literal("E"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Evasion")))); - value = new TextComponent("(" + pkt.getEntityInfo().evasion + "%) "); + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Evasion")))); + value = Component.literal("(" + pkt.getEntityInfo().evasion + "%) "); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); option.getSiblings().add(value); text.getSiblings().add(option); - option = new TextComponent("S"); + option = Component.literal("S"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Speed")))); - value = new TextComponent("(" + pkt.getEntityInfo().speed + ") "); + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Speed")))); + value = Component.literal("(" + pkt.getEntityInfo().speed + ") "); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); option.getSiblings().add(value); text.getSiblings().add(option); - option = new TextComponent("C"); + 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, new TextComponent("Category")))); - value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("DecA"); + 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, new TextComponent("DecisionAttack")))); - value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("DecD"); + 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, new TextComponent("DecisionDefend")))); - value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("DecF"); + 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, new TextComponent("DecisionFlee")))); - value = new TextComponent("(" + pkt.getEntityInfo().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 = new TextComponent("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"))); text.getSiblings().add(option); - text.getSiblings().add(new TextComponent(" ")); + text.getSiblings().add(Component.literal(" ")); - option = new TextComponent("Cancel"); + option = Component.literal("Cancel"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel"))); text.getSiblings().add(option); @@ -588,156 +588,148 @@ public class ClientProxy extends CommonProxy { break; } case SERVER_EDIT: { - TextComponent parent = new TextComponent("Edit what server value? "); + MutableComponent parent = Component.literal("Edit what server value? "); parent.setStyle(parent.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); - TextComponent sub = new TextComponent("leave_battle_cooldown "); + MutableComponent sub = Component.literal("leave_battle_cooldown "); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW).withBold(true)); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 1; i <= 10; ++i) { - sub = new TextComponent(String.valueOf(i) + ' '); - sub.setStyle( - sub.getStyle() - .withColor(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - "/tbm-server-edit leave_battle_cooldown " + i))); - parent.append(sub); + sub = Component.literal(String.valueOf(i) + ' '); + sub.setStyle(sub.getStyle() + .withColor(ChatFormatting.GREEN) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + "/tbm-server-edit leave_battle_cooldown " + i))); + parent.getSiblings().add(sub); } - sub = new TextComponent("aggro_start_battle_max_distance "); + sub = Component.literal("aggro_start_battle_max_distance "); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW).withBold(true)); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("5 "); - sub.setStyle( - sub.getStyle() - .withColor(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - "/tbm-server-edit aggro_start_battle_max_distance 5"))); - parent.append(sub); + sub = Component.literal("5 "); + sub.setStyle(sub.getStyle() + .withColor(ChatFormatting.GREEN) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + "/tbm-server-edit aggro_start_battle_max_distance 5"))); + parent.getSiblings().add(sub); - sub = new TextComponent("8 "); - sub.setStyle( - sub.getStyle() - .withColor(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - "/tbm-server-edit aggro_start_battle_max_distance 8"))); - parent.append(sub); + sub = Component.literal("8 "); + sub.setStyle(sub.getStyle() + .withColor(ChatFormatting.GREEN) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + "/tbm-server-edit aggro_start_battle_max_distance 8"))); + parent.getSiblings().add(sub); for (int i = 10; i <= 50; i += 5) { - sub = new TextComponent(String.valueOf(i) + ' '); - sub.setStyle( - sub.getStyle() - .withColor(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - "/tbm-server-edit aggro_start_battle_max_distance " + String.valueOf(i)))); - parent.append(sub); + sub = Component.literal(String.valueOf(i) + ' '); + sub.setStyle(sub.getStyle() + .withColor(ChatFormatting.GREEN) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + "/tbm-server-edit aggro_start_battle_max_distance " + String.valueOf(i)))); + parent.getSiblings().add(sub); } - sub = new TextComponent("old_battle_behavior "); + sub = Component.literal("old_battle_behavior "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("If enabled, battles only start on a hit, not including mobs targeting players"))) + Component.literal("If enabled, battles only start on a hit, not including mobs targeting players"))) .withBold(true)); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("true "); - sub.setStyle( - sub.getStyle() - .withColor(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - "/tbm-server-edit old_battle_behavior true"))); - parent.append(sub); + sub = Component.literal("true "); + sub.setStyle(sub.getStyle() + .withColor(ChatFormatting.GREEN) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + "/tbm-server-edit old_battle_behavior true"))); + parent.getSiblings().add(sub); - sub = new TextComponent("false "); - sub.setStyle( - sub.getStyle() - .withColor(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - "/tbm-server-edit old_battle_behavior false"))); - parent.append(sub); + sub = Component.literal("false "); + sub.setStyle(sub.getStyle() + .withColor(ChatFormatting.GREEN) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + "/tbm-server-edit old_battle_behavior false"))); + parent.getSiblings().add(sub); - sub = new TextComponent("anyone_can_disable_tbm_for_self "); + sub = Component.literal("anyone_can_disable_tbm_for_self "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Allows use for /tbm-disable and /tbm-enable for all"))) + Component.literal("Allows use for /tbm-disable and /tbm-enable for all"))) .withBold(true)); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("true "); - sub.setStyle( - sub.getStyle() - .withColor(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - "/tbm-server-edit anyone_can_disable_tbm_for_self true"))); - parent.append(sub); + sub = Component.literal("true "); + sub.setStyle(sub.getStyle() + .withColor(ChatFormatting.GREEN) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + "/tbm-server-edit anyone_can_disable_tbm_for_self true"))); + parent.getSiblings().add(sub); - sub = new TextComponent("false "); - sub.setStyle( - sub.getStyle() - .withColor(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - "/tbm-server-edit anyone_can_disable_tbm_for_self false"))); - parent.append(sub); + sub = Component.literal("false "); + sub.setStyle(sub.getStyle() + .withColor(ChatFormatting.GREEN) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + "/tbm-server-edit anyone_can_disable_tbm_for_self false"))); + parent.getSiblings().add(sub); - sub = new TextComponent("max_in_battle "); + sub = Component.literal("max_in_battle "); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW).withBold(true)); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("2 "); + sub = Component.literal("2 "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit max_in_battle 2"))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 5; i < 30; i += 5) { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit max_in_battle " + String.valueOf(i)))); - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("freeze_battle_combatants "); + sub = Component.literal("freeze_battle_combatants "); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW).withBold(true)); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("true "); + sub = Component.literal("true "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit freeze_battle_combatants true" ))); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("false "); + sub = Component.literal("false "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit freeze_battle_combatants false" ))); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("ignore_battle_types "); + sub = Component.literal("ignore_battle_types "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.DARK_GREEN) .withClickEvent(new ClickEvent( @@ -745,333 +737,333 @@ public class ClientProxy extends CommonProxy { "/tbm-server-edit ignore_battle_types")) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Click to show current ignored categories, or use /tbm-server-edit ignore_battle_types add/remove ") + Component.literal("Click to show current ignored categories, or use /tbm-server-edit ignore_battle_types add/remove ") )) .withBold(true)); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("player_speed "); + sub = Component.literal("player_speed "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Player default speed")))); - parent.append(sub); + Component.literal("Player default speed")))); + parent.getSiblings().add(sub); for (int i = 0; i <= 100; i += 5) { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit player_speed " + i))); - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("player_haste_speed "); + sub = Component.literal("player_haste_speed "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Player speed when under the effects of \"Speed\"") + Component.literal("Player speed when under the effects of \"Speed\"") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 0; i <= 100; i += 5) { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit player_haste_speed " + i))); - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("player_slow_speed "); + sub = Component.literal("player_slow_speed "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Player speed when under the effects of \"Slow\"") + Component.literal("Player speed when under the effects of \"Slow\"") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 0; i <= 100; i += 5) { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit player_slow_speed " + i))); - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("player_attack_probability "); + sub = Component.literal("player_attack_probability "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Base Player attack probability in percentage") + Component.literal("Base Player attack probability in percentage") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 0; i <= 100; i += 5) { if (i == 0) { - sub = new TextComponent("1 "); + sub = Component.literal("1 "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit player_attack_probability 1"))); } else { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit player_attack_probability " + i))); } - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("player_evasion "); + sub = Component.literal("player_evasion "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Base Player evasion rate in percentage") + Component.literal("Base Player evasion rate in percentage") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 0; i <= 100; i += 5) { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit player_evasion " + i))); - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("defense_duration "); + sub = Component.literal("defense_duration "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Number of attacks that a \"Defend\" move blocks (lasts until next action)") + Component.literal("Number of attacks that a \"Defend\" move blocks (lasts until next action)") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 0; i <= 5; ++i) { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit defense_duration " + i))); - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("flee_good_probability "); + sub = Component.literal("flee_good_probability "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Probability of flee success when Player's speed is higher than the fastest opposing Entity") + Component.literal("Probability of flee success when Player's speed is higher than the fastest opposing Entity") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 0; i <= 100; i += 5) { if (i == 0) { - sub = new TextComponent("1 "); + sub = Component.literal("1 "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit flee_good_probability 1"))); } else { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit flee_good_probability " + i))); } - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("flee_bad_probability "); + sub = Component.literal("flee_bad_probability "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Probability of flee success when Player's speed is lower than the fastest opposing Entity") + Component.literal("Probability of flee success when Player's speed is lower than the fastest opposing Entity") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 0; i <= 100; i += 5) { if (i == 0) { - sub = new TextComponent("1 "); + sub = Component.literal("1 "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit flee_bad_probability 1"))); } else { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit flee_bad_probability " + i))); } - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("minimum_hit_percentage "); + sub = Component.literal("minimum_hit_percentage "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("The minimum percentage possible when calculating hit percentage for any attacker") + Component.literal("The minimum percentage possible when calculating hit percentage for any attacker") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 0; i <= 100; i += 5) { if (i == 0) { - sub = new TextComponent("1 "); + sub = Component.literal("1 "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit minimum_hit_percentage 1"))); } else { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit minimum_hit_percentage " + i))); } - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("battle_turn_wait_forever "); + sub = Component.literal("battle_turn_wait_forever "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Disables the turn timer (recommended to leave this to false)")) + Component.literal("Disables the turn timer (recommended to leave this to false)")) )); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("true "); + sub = Component.literal("true "); sub.setStyle(sub.getStyle().withColor(ChatFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit battle_turn_wait_forever true"))); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("false "); + sub = Component.literal("false "); sub.setStyle(sub.getStyle().withColor(ChatFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit battle_turn_wait_forever false"))); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("battle_turn_time_seconds "); + sub = Component.literal("battle_turn_time_seconds "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("The time in seconds to wait for all Players to choose their move") + Component.literal("The time in seconds to wait for all Players to choose their move") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 5; i <= 60; i += 5) { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit battle_turn_time_seconds " + i))); - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("creeper_explode_turn "); + sub = Component.literal("creeper_explode_turn "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("The number of turns it takes for a creeper to explode") + Component.literal("The number of turns it takes for a creeper to explode") ))); - parent.append(sub); + parent.getSiblings().add(sub); for (int i = 1; i <= 10; ++i) { - sub = new TextComponent(String.valueOf(i) + ' '); + sub = Component.literal(String.valueOf(i) + ' '); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit creeper_explode_turn " + i))); - parent.append(sub); + parent.getSiblings().add(sub); } - sub = new TextComponent("creeper_stop_explode_on_leave_battle "); + sub = Component.literal("creeper_stop_explode_on_leave_battle "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Stops creepers from exploding when they leave battle (during leave battle cooldown)") + Component.literal("Stops creepers from exploding when they leave battle (during leave battle cooldown)") ))); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("true "); + sub = Component.literal("true "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit creeper_stop_explode_on_leave_battle true"))); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("false "); + sub = Component.literal("false "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit creeper_stop_explode_on_leave_battle false"))); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("creeper_always_allow_damage "); + sub = Component.literal("creeper_always_allow_damage "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.YELLOW) .withBold(true) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Allows creepers to damage anyone who just left battle (in cooldown)") + Component.literal("Allows creepers to damage anyone who just left battle (in cooldown)") ))); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("true "); + sub = Component.literal("true "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit creeper_always_allow_damage true"))); - parent.append(sub); + parent.getSiblings().add(sub); - sub = new TextComponent("false "); + sub = Component.literal("false "); sub.setStyle(sub.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-server-edit creeper_always_allow_damage false"))); - parent.append(sub); + parent.getSiblings().add(sub); TurnBasedMinecraftMod.proxy.displayComponent(parent); break; } case EDIT_IGNORE_BATTLE: { - TextComponent text = new TextComponent("ignoreBattle: "); + MutableComponent text = Component.literal("ignoreBattle: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); - TextComponent option = new TextComponent("true"); + MutableComponent option = Component.literal("true"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle true"))); text.getSiblings().add(option); - text.getSiblings().add(new TextComponent(" ")); + text.getSiblings().add(Component.literal(" ")); - option = new TextComponent("false"); + option = Component.literal("false"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle false"))); text.getSiblings().add(option); @@ -1080,73 +1072,73 @@ public class ClientProxy extends CommonProxy { break; } case EDIT_ATTACK_POWER: { - TextComponent text = new TextComponent("attackPower: "); + MutableComponent text = Component.literal("attackPower: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 15; ++i) { - TextComponent option = new TextComponent(Integer.toString(i)); + 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 attackPower " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 15) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } - text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit attackPower \")")); + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit attackPower \")")); parentComponent.getSiblings().add(text); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } case EDIT_ATTACK_PROBABILITY: { - TextComponent text = new TextComponent("attackProbability: "); + MutableComponent text = Component.literal("attackProbability: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 10; i <= 100; i += 10) { - TextComponent option = new TextComponent(Integer.toString(i) + "%"); + 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 attackProbability " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 100) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } - text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit attackProbability \")")); + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit attackProbability \")")); parentComponent.getSiblings().add(text); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } case EDIT_ATTACK_VARIANCE: { - TextComponent text = new TextComponent("attackVariance: "); + MutableComponent text = Component.literal("attackVariance: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 10; ++i) { - TextComponent option = new TextComponent(Integer.toString(i)); + 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 attackVariance " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 10) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } - text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit attackVariance \")")); + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit attackVariance \")")); parentComponent.getSiblings().add(text); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } case EDIT_ATTACK_EFFECT: { - TextComponent text = new TextComponent("attackEffect: "); + MutableComponent text = Component.literal("attackEffect: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (EntityInfo.Effect e : EntityInfo.Effect.values()) { - TextComponent option = new TextComponent(e.toString()); + MutableComponent option = Component.literal(e.toString()); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect " + e.toString()))); text.getSiblings().add(option); if (e != EntityInfo.Effect.UNKNOWN) { // TODO find a better way to handle printing comma for items before last - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } @@ -1155,229 +1147,229 @@ public class ClientProxy extends CommonProxy { break; } case EDIT_ATTACK_EFFECT_PROBABILITY: { - TextComponent text = new TextComponent("attackEffectProbability: "); + MutableComponent text = Component.literal("attackEffectProbability: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 100; i += 10) { - TextComponent option = new TextComponent(Integer.toString(i) + "%"); + 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 attackEffectProbability " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 100) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } - text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit attackEffectProbability \")")); + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit attackEffectProbability \")")); parentComponent.getSiblings().add(text); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } case EDIT_DEFENSE_DAMAGE: { - TextComponent text = new TextComponent("defenseDamage: "); + MutableComponent text = Component.literal("defenseDamage: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 15; ++i) { - TextComponent option = new TextComponent(Integer.toString(i)); + 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 defenseDamage " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 15) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } - text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit defenseDamage \")")); + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit defenseDamage \")")); parentComponent.getSiblings().add(text); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } case EDIT_DEFENSE_DAMAGE_PROBABILITY: { - TextComponent text = new TextComponent("defenseDamageProbability: "); + MutableComponent text = Component.literal("defenseDamageProbability: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 100; i += 10) { - TextComponent option = new TextComponent(Integer.toString(i) + "%"); + 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 defenseDamageProbability " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 100) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } - text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit defenseDamageProbability \")")); + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit defenseDamageProbability \")")); parentComponent.getSiblings().add(text); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } case EDIT_EVASION: { - TextComponent text = new TextComponent("evasion: "); + MutableComponent text = Component.literal("evasion: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 100; i += 10) { - TextComponent option = new TextComponent(Integer.toString(i) + "%"); + 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 evasion " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 100) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } - text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit evasion \")")); + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit evasion \")")); parentComponent.getSiblings().add(text); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } case EDIT_SPEED: { - TextComponent text = new TextComponent("speed: "); + MutableComponent text = Component.literal("speed: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 100; i += 10) { - TextComponent option = new TextComponent(Integer.toString(i)); + 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 speed " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 100) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } - text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit speed \")")); + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit speed \")")); parentComponent.getSiblings().add(text); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } case EDIT_CATEGORY: { - TextComponent text = new TextComponent("category: "); + MutableComponent text = Component.literal("category: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); - TextComponent option = new TextComponent("monster"); + MutableComponent option = Component.literal("monster"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category monster"))); if (TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("monster")) { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("disabled"); + MutableComponent optionInfoBool = Component.literal("disabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } else { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("enabled"); + MutableComponent optionInfoBool = Component.literal("enabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } text.getSiblings().add(option); - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); - option = new TextComponent("animal"); + option = Component.literal("animal"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category animal"))); if (TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("animal")) { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("disabled"); + MutableComponent optionInfoBool = Component.literal("disabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } else { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("enabled"); + MutableComponent optionInfoBool = Component.literal("enabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } text.getSiblings().add(option); - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); - option = new TextComponent("passive"); + option = Component.literal("passive"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category passive"))); if (TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("passive")) { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("disabled"); + MutableComponent optionInfoBool = Component.literal("disabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } else { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("enabled"); + MutableComponent optionInfoBool = Component.literal("enabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } text.getSiblings().add(option); - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); - option = new TextComponent("boss"); + option = Component.literal("boss"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category boss"))); if (TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("boss")) { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("disabled"); + MutableComponent optionInfoBool = Component.literal("disabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } else { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("enabled"); + MutableComponent optionInfoBool = Component.literal("enabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } text.getSiblings().add(option); - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); - option = new TextComponent("player"); + option = Component.literal("player"); option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category player"))); if (TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("player")) { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("disabled"); + MutableComponent optionInfoBool = Component.literal("disabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } else { - TextComponent optionInfo = new TextComponent("(battle-"); + MutableComponent optionInfo = Component.literal("(battle-"); optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); - TextComponent optionInfoBool = new TextComponent("enabled"); + MutableComponent optionInfoBool = Component.literal("enabled"); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00))); optionInfo.getSiblings().add(optionInfoBool); - optionInfo.getSiblings().add(new TextComponent(")")); + optionInfo.getSiblings().add(Component.literal(")")); option.getSiblings().add(optionInfo); } text.getSiblings().add(option); - text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit category \")")); + text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit category \")")); parentComponent.getSiblings().add(text); TurnBasedMinecraftMod.proxy.displayComponent(parentComponent); break; } case EDIT_DECISION_ATTACK: { - TextComponent text = new TextComponent("decisionAttack: "); + MutableComponent text = Component.literal("decisionAttack: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 100; i += 10) { - TextComponent option = new TextComponent(Integer.toString(i) + "%"); + 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 decisionAttack " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 100) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } @@ -1386,15 +1378,15 @@ public class ClientProxy extends CommonProxy { break; } case EDIT_DECISION_DEFEND: { - TextComponent text = new TextComponent("decisionDefend: "); + MutableComponent text = Component.literal("decisionDefend: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 100; i += 10) { - TextComponent option = new TextComponent(Integer.toString(i) + "%"); + 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 decisionDefend " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 100) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } @@ -1403,15 +1395,15 @@ public class ClientProxy extends CommonProxy { break; } case EDIT_DECISION_FLEE: { - TextComponent text = new TextComponent("decisionFlee: "); + MutableComponent text = Component.literal("decisionFlee: "); text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false)); for (int i = 0; i <= 100; i += 10) { - TextComponent option = new TextComponent(Integer.toString(i) + "%"); + 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 decisionFlee " + Integer.toString(i)))); text.getSiblings().add(option); if (i < 100) { - text.getSiblings().add(new TextComponent(", ")); + text.getSiblings().add(Component.literal(", ")); } } diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/EntitySelectionButton.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/EntitySelectionButton.java index bb424a5..d350916 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/EntitySelectionButton.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/EntitySelectionButton.java @@ -6,14 +6,13 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.network.chat.TextComponent; public class EntitySelectionButton extends Button { private int entityID; private boolean isSideA; public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, Button.OnPress onPress) { - super(x, y, widthIn, heightIn, new TextComponent(buttonText), onPress); + super(x, y, widthIn, heightIn, Component.literal(buttonText), onPress); this.entityID = entityID; this.isSideA = isSideA; } diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ItemSelectionButton.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ItemSelectionButton.java index 1e3bd62..d9b17e1 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ItemSelectionButton.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ItemSelectionButton.java @@ -2,13 +2,13 @@ package com.burnedkirby.TurnBasedMinecraft.client; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.Button; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; public class ItemSelectionButton extends Button { private int itemStackID; public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, Button.OnPress onPress) { - super(x, y, widthIn, heightIn, new TextComponent(buttonText), onPress); + super(x, y, widthIn, heightIn, Component.literal(buttonText), onPress); this.itemStackID = itemStackID; } diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/PlayerJoinEventHandler.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/PlayerJoinEventHandler.java index b115629..d7104d0 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/PlayerJoinEventHandler.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/PlayerJoinEventHandler.java @@ -1,15 +1,15 @@ package com.burnedkirby.TurnBasedMinecraft.common; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.EntityJoinLevelEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class PlayerJoinEventHandler { @SubscribeEvent - public void entityJoinHandler(EntityJoinWorldEvent event) + public void entityJoinHandler(EntityJoinLevelEvent event) { - if(event.getWorld().isClientSide) + if(event.getLevel().isClientSide) { return; } diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java index b8eb937..ba4e6d0 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java @@ -14,7 +14,8 @@ import net.minecraft.commands.Commands; import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.HoverEvent; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.common.MinecraftForge; @@ -38,7 +39,7 @@ import org.apache.logging.log4j.Logger; public class TurnBasedMinecraftMod { public static final String MODID = "com_burnedkirby_turnbasedminecraft"; public static final String NAME = "Turn Based Minecraft Mod"; - public static final String VERSION = "1.18.7"; + public static final String VERSION = "1.19.0"; public static final String CONFIG_FILENAME = "TBM_Config.toml"; public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml"; public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/"; @@ -157,7 +158,7 @@ public class TurnBasedMinecraftMod { }) .executes(c -> { proxy.getConfig().addBattleIgnoringPlayer(c.getSource().getPlayerOrException().getId()); - c.getSource().sendSuccess(new TextComponent("Disabled turn-based-combat for current player"), true); + c.getSource().sendSuccess(Component.literal("Disabled turn-based-combat for current player"), true); return 1; })); // tbm-disable-all @@ -180,7 +181,7 @@ public class TurnBasedMinecraftMod { .requires(c -> !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermission(2)) .executes(c -> { proxy.getConfig().removeBattleIgnoringPlayer(c.getSource().getPlayerOrException().getId()); - c.getSource().sendSuccess(new TextComponent("Enabled turn-based-combat for current player"), true); + c.getSource().sendSuccess(Component.literal("Enabled turn-based-combat for current player"), true); return 1; })); // tbm-enable-all @@ -203,7 +204,7 @@ public class TurnBasedMinecraftMod { for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) { proxy.getConfig().addBattleIgnoringPlayer(player.getId()); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for you")); - c.getSource().sendSuccess(new TextComponent("Enabled turn-based-combat for " + player.getDisplayName().getString()), true); + c.getSource().sendSuccess(Component.literal("Enabled turn-based-combat for " + player.getDisplayName().getString()), true); } return 1; }))); @@ -215,7 +216,7 @@ public class TurnBasedMinecraftMod { for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) { proxy.getConfig().removeBattleIgnoringPlayer(player.getId()); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for you")); - c.getSource().sendSuccess(new TextComponent("Disabled turn-based-combat for " + player.getDisplayName().getString()), true); + c.getSource().sendSuccess(Component.literal("Disabled turn-based-combat for " + player.getDisplayName().getString()), true); } return 1; }))); @@ -786,12 +787,12 @@ public class TurnBasedMinecraftMod { return 1; }) .then(Commands.literal("leave_battle_cooldown").executes(c -> { - TextComponent response = new TextComponent("leave_battle_cooldown requires an integer argument. "); - TextComponent subResponse = new TextComponent("leave_battle_cooldown is currently: "); - response.append(subResponse); - subResponse = new TextComponent(String.valueOf(TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownSeconds())); + MutableComponent response = Component.literal("leave_battle_cooldown requires an integer argument. "); + MutableComponent subResponse = Component.literal("leave_battle_cooldown is currently: "); + response.getSiblings().add(subResponse); + subResponse = Component.literal(String.valueOf(TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownSeconds())); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, false); return 1; }) @@ -806,27 +807,27 @@ public class TurnBasedMinecraftMod { cooldown)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.leave_battle_cooldown\" in config file!"); - c.getSource().sendFailure(new TextComponent("" + + c.getSource().sendFailure(Component.literal("" + "Failed to set leave_battle_cooldown to \"" + cooldown + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set leave_battle_cooldown to: "); - TextComponent subResponse = new TextComponent(String.valueOf(cooldown)); + MutableComponent response = Component.literal("Successfully set leave_battle_cooldown to: "); + MutableComponent subResponse = Component.literal(String.valueOf(cooldown)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("aggro_start_battle_max_distance").executes(c -> { - TextComponent response = new TextComponent("aggro_start_battle_max_distance requires an integer argument. "); - TextComponent subResponse = new TextComponent("aggro_start_battle_max_distance is currently: "); - response.append(subResponse); - subResponse = new TextComponent(String.valueOf( + MutableComponent response = Component.literal("aggro_start_battle_max_distance requires an integer argument. "); + MutableComponent subResponse = Component.literal("aggro_start_battle_max_distance is currently: "); + response.getSiblings().add(subResponse); + subResponse = Component.literal(String.valueOf( TurnBasedMinecraftMod.proxy.getConfig().getAggroStartBattleDistance())); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, false); return 1; }) @@ -841,27 +842,27 @@ public class TurnBasedMinecraftMod { distance)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.aggro_start_battle_max_distance\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set aggro_start_battle_max_distance to \"" + distance + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set aggro_start_battle_max_distance to: "); - TextComponent subResponse = new TextComponent(String.valueOf(distance)); + MutableComponent response = Component.literal("Successfully set aggro_start_battle_max_distance to: "); + MutableComponent subResponse = Component.literal(String.valueOf(distance)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("old_battle_behavior").executes(c -> { - TextComponent response = new TextComponent("old_battle_behavior requires a boolean argument. "); - TextComponent subResponse = new TextComponent("old_battle_behavior is currently: "); - response.append(subResponse); - subResponse = new TextComponent(String.valueOf( + MutableComponent response = Component.literal("old_battle_behavior requires a boolean argument. "); + MutableComponent subResponse = Component.literal("old_battle_behavior is currently: "); + response.getSiblings().add(subResponse); + subResponse = Component.literal(String.valueOf( TurnBasedMinecraftMod.proxy.getConfig().isOldBattleBehaviorEnabled())); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, false); return 1; }) @@ -874,27 +875,27 @@ public class TurnBasedMinecraftMod { enabled)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.old_battle_behavior\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set old_battle_behavior to \"" + enabled + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set old_battle_behavior to: "); - TextComponent subResponse = new TextComponent(String.valueOf(enabled)); + MutableComponent response = Component.literal("Successfully set old_battle_behavior to: "); + MutableComponent subResponse = Component.literal(String.valueOf(enabled)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("anyone_can_disable_tbm_for_self").executes(c -> { - TextComponent response = new TextComponent("anyone_can_disable_tbm_for_self requires a boolean argument. "); - TextComponent subResponse = new TextComponent("anyone_can_disable_tbm_for_self is currently: "); - response.append(subResponse); - subResponse = new TextComponent(String.valueOf( + MutableComponent response = Component.literal("anyone_can_disable_tbm_for_self requires a boolean argument. "); + MutableComponent subResponse = Component.literal("anyone_can_disable_tbm_for_self is currently: "); + response.getSiblings().add(subResponse); + subResponse = Component.literal(String.valueOf( !TurnBasedMinecraftMod.proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf())); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, false); return 1; }) @@ -908,27 +909,27 @@ public class TurnBasedMinecraftMod { )) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.anyone_can_disable_tbm_for_self\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set anyone_can_disable_tbm_for_self to \"" + enabled_for_all + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set anyone_can_disable_tbm_for_self to: "); - TextComponent subResponse = new TextComponent(String.valueOf(enabled_for_all)); + MutableComponent response = Component.literal("Successfully set anyone_can_disable_tbm_for_self to: "); + MutableComponent subResponse = Component.literal(String.valueOf(enabled_for_all)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("max_in_battle").executes(c -> { - TextComponent response = new TextComponent("max_in_battle requires an integer argument. "); - TextComponent subResponse = new TextComponent("max_in_battle is currently: "); - response.append(subResponse); - subResponse = new TextComponent(String.valueOf( + MutableComponent response = Component.literal("max_in_battle requires an integer argument. "); + MutableComponent subResponse = Component.literal("max_in_battle is currently: "); + response.getSiblings().add(subResponse); + subResponse = Component.literal(String.valueOf( TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle())); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, false); return 1; }) @@ -943,27 +944,27 @@ public class TurnBasedMinecraftMod { max_amount)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.max_in_battle\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set max_in_battle to \"" + max_amount + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set max_in_battle to: "); - TextComponent subResponse = new TextComponent(String.valueOf(max_amount)); + MutableComponent response = Component.literal("Successfully set max_in_battle to: "); + MutableComponent subResponse = Component.literal(String.valueOf(max_amount)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("freeze_battle_combatants").executes(c -> { - TextComponent response = new TextComponent("freeze_battle_combatants requires a boolean argument. "); - TextComponent subResponse = new TextComponent("freeze_battle_combatants is currently: "); - response.append(subResponse); - subResponse = new TextComponent(String.valueOf( + MutableComponent response = Component.literal("freeze_battle_combatants requires a boolean argument. "); + MutableComponent subResponse = Component.literal("freeze_battle_combatants is currently: "); + response.getSiblings().add(subResponse); + subResponse = Component.literal(String.valueOf( !TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, false); return 1; }) @@ -974,34 +975,34 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.freeze_battle_combatants", enabled)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.freeze_battle_combatants\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set freeze_battle_combatants to \"" + enabled + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set freeze_battle_combatants to: "); - TextComponent subResponse = new TextComponent(String.valueOf(enabled)); + MutableComponent response = Component.literal("Successfully set freeze_battle_combatants to: "); + MutableComponent subResponse = Component.literal(String.valueOf(enabled)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("ignore_battle_types").executes(c -> { - TextComponent response = new TextComponent("Use "); - TextComponent subResponse = new TextComponent("/tbm-server-edit ignore_battle_types add/remove "); + MutableComponent response = Component.literal("Use "); + MutableComponent subResponse = Component.literal("/tbm-server-edit ignore_battle_types add/remove "); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.YELLOW)); - response.append(subResponse); + response.getSiblings().add(subResponse); - subResponse = new TextComponent("ignore_battle_types is currently: ["); - response.append(subResponse); + subResponse = Component.literal("ignore_battle_types is currently: ["); + response.getSiblings().add(subResponse); boolean isFirst = true; for (String category : TurnBasedMinecraftMod.proxy.getConfig().getIgnoreBattleTypes()) { if (!isFirst) { - response.append(new TextComponent(", ")); + response.getSiblings().add(Component.literal(", ")); } - subResponse = new TextComponent(category); + subResponse = Component.literal(category); subResponse.setStyle(subResponse.getStyle() .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent( @@ -1009,69 +1010,69 @@ public class TurnBasedMinecraftMod { "/tbm-server-edit ignore_battle_types remove " + category)) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new TextComponent("Click to remove category")))); - response.append(subResponse); + Component.literal("Click to remove category")))); + response.getSiblings().add(subResponse); isFirst = false; } - response.append(new TextComponent("] ")); + response.getSiblings().add(Component.literal("] ")); c.getSource().sendSuccess(response, false); return 1; }) .then(Commands.literal("add").executes(c -> { - c.getSource().sendFailure(new TextComponent("/tbm-server-edit ignore_battle_types add ")); + c.getSource().sendFailure(Component.literal("/tbm-server-edit ignore_battle_types add ")); return 1; }) .then(Commands.argument("category", StringArgumentType.greedyString()).executes(c -> { String category = StringArgumentType.getString(c, "category"); if (TurnBasedMinecraftMod.proxy.getConfig().addIgnoreBattleType(category) && TurnBasedMinecraftMod.proxy.getConfig().updateConfigAppendToStringArray("server_config.ignore_battle_types", category)) { - TextComponent response = new TextComponent("Successfully appended category \""); + MutableComponent response = Component.literal("Successfully appended category \""); - TextComponent sub = new TextComponent(category); + MutableComponent sub = Component.literal(category); sub.setStyle(sub.getStyle().withColor(ChatFormatting.GREEN)); - response.append(sub); + response.getSiblings().add(sub); - sub = new TextComponent("\" to ignore_battle_types"); - response.append(sub); + sub = Component.literal("\" to ignore_battle_types"); + response.getSiblings().add(sub); c.getSource().sendSuccess(response, true); return 1; } - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to append category \"" + category + "\" to ignore_battle_types")); return 1; }))) .then(Commands.literal("remove").executes(c -> { - c.getSource().sendFailure(new TextComponent("/tbm-server-edit ignore_battle_types remove ")); + c.getSource().sendFailure(Component.literal("/tbm-server-edit ignore_battle_types remove ")); return 1; }) .then(Commands.argument("category", StringArgumentType.greedyString()).executes(c -> { String category = StringArgumentType.getString(c, "category"); if (TurnBasedMinecraftMod.proxy.getConfig().removeIgnoreBattleType(category) && TurnBasedMinecraftMod.proxy.getConfig().updateConfigRemoveFromStringArray("server_config.ignore_battle_types", category)) { - TextComponent response = new TextComponent("Successfully removed category \""); + MutableComponent response = Component.literal("Successfully removed category \""); - TextComponent sub = new TextComponent(category); + MutableComponent sub = Component.literal(category); sub.setStyle(sub.getStyle().withColor(ChatFormatting.GREEN)); - response.append(sub); + response.getSiblings().add(sub); - sub = new TextComponent("\" from ignore_battle_types"); - response.append(sub); + sub = Component.literal("\" from ignore_battle_types"); + response.getSiblings().add(sub); c.getSource().sendSuccess(response, true); return 1; } - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to remove category \"" + category + "\" to ignore_battle_types")); return 1; })))) .then(Commands.literal("player_speed").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit player_speed <0-100>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit player_speed <0-100>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1084,24 +1085,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.player_speed", speed)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.player_speed\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set player_speed to \"" + speed + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set player_speed to: "); - TextComponent subResponse = new TextComponent(String.valueOf(speed)); + MutableComponent response = Component.literal("Successfully set player_speed to: "); + MutableComponent subResponse = Component.literal(String.valueOf(speed)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("player_haste_speed").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit player_haste_speed <0-100>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit player_haste_speed <0-100>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1114,24 +1115,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.player_haste_speed", haste_speed)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.player_haste_speed\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set player_haste_speed to \"" + haste_speed + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set player_haste_speed to: "); - TextComponent subResponse = new TextComponent(String.valueOf(haste_speed)); + MutableComponent response = Component.literal("Successfully set player_haste_speed to: "); + MutableComponent subResponse = Component.literal(String.valueOf(haste_speed)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("player_slow_speed").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit player_slow_speed <0-100>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit player_slow_speed <0-100>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1144,24 +1145,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.player_slow_speed", slow_speed)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.player_slow_speed\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set player_slow_speed to \"" + slow_speed + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set player_slow_speed to: "); - TextComponent subResponse = new TextComponent(String.valueOf(slow_speed)); + MutableComponent response = Component.literal("Successfully set player_slow_speed to: "); + MutableComponent subResponse = Component.literal(String.valueOf(slow_speed)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("player_attack_probability").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit player_attack_probability <1-100>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit player_attack_probability <1-100>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1174,24 +1175,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.player_attack_probability", probability)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.player_attack_probability\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set player_attack_probability to \"" + probability + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set player_attack_probability to: "); - TextComponent subResponse = new TextComponent(String.valueOf(probability)); + MutableComponent response = Component.literal("Successfully set player_attack_probability to: "); + MutableComponent subResponse = Component.literal(String.valueOf(probability)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("player_evasion").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit player_evasion <0-100>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit player_evasion <0-100>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1204,24 +1205,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.player_evasion", evasion)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.player_evasion\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set player_evasion to \"" + evasion + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set player_evasion to: "); - TextComponent subResponse = new TextComponent(String.valueOf(evasion)); + MutableComponent response = Component.literal("Successfully set player_evasion to: "); + MutableComponent subResponse = Component.literal(String.valueOf(evasion)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("defense_duration").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit defense_duration <0-5>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit defense_duration <0-5>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1234,24 +1235,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.defense_duration", defends)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.defense_duration\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set defense_druation to \"" + defends + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set defense_duration to: "); - TextComponent subResponse = new TextComponent(String.valueOf(defends)); + MutableComponent response = Component.literal("Successfully set defense_duration to: "); + MutableComponent subResponse = Component.literal(String.valueOf(defends)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("flee_good_probability").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit flee_good_probability <1-100>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit flee_good_probability <1-100>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1264,24 +1265,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.flee_good_probability", probability)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.flee_good_probability\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set flee_good_probability to \"" + probability + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set flee_good_probability to: "); - TextComponent subResponse = new TextComponent(String.valueOf(probability)); + MutableComponent response = Component.literal("Successfully set flee_good_probability to: "); + MutableComponent subResponse = Component.literal(String.valueOf(probability)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("flee_bad_probability").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit flee_bad_probability <1-100>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit flee_bad_probability <1-100>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1294,24 +1295,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.flee_bad_probability", probability)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.flee_bad_probability\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set flee_bad_probability to \"" + probability + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set flee_bad_probability to: "); - TextComponent subResponse = new TextComponent(String.valueOf(probability)); + MutableComponent response = Component.literal("Successfully set flee_bad_probability to: "); + MutableComponent subResponse = Component.literal(String.valueOf(probability)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("minimum_hit_percentage").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit minimum_hit_percentage <1-100>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit minimum_hit_percentage <1-100>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1324,24 +1325,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.minimum_hit_percentage", percentage)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.minimum_hit_percentage\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set minimum_hit_percentage to \"" + percentage + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set minimum_hit_percentage to: "); - TextComponent subResponse = new TextComponent(String.valueOf(percentage)); + MutableComponent response = Component.literal("Successfully set minimum_hit_percentage to: "); + MutableComponent subResponse = Component.literal(String.valueOf(percentage)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("battle_turn_wait_forever").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit battle_turn_wait_forever "); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit battle_turn_wait_forever "); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1353,21 +1354,21 @@ public class TurnBasedMinecraftMod { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.battle_turn_wait_forever\" in config file!" ); - c.getSource().sendFailure(new TextComponent("Failed to set battle_turn_wait_forever to \"" + (enabled ? "true" : "false") + "\" in config file!")); + c.getSource().sendFailure(Component.literal("Failed to set battle_turn_wait_forever to \"" + (enabled ? "true" : "false") + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set battle_turn_wait_forever to: "); - TextComponent subResponse = new TextComponent((enabled ? "true" : "false")); + MutableComponent response = Component.literal("Successfully set battle_turn_wait_forever to: "); + MutableComponent subResponse = Component.literal((enabled ? "true" : "false")); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("battle_turn_time_seconds").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit battle_turn_time_seconds <5-60>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit battle_turn_time_seconds <5-60>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1380,24 +1381,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.battle_turn_time_seconds", seconds)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.battle_turn_time_seconds\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set battle_turn_time_seconds to \"" + seconds + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set battle_turn_time_seconds to: "); - TextComponent subResponse = new TextComponent(String.valueOf(seconds)); + MutableComponent response = Component.literal("Successfully set battle_turn_time_seconds to: "); + MutableComponent subResponse = Component.literal(String.valueOf(seconds)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("creeper_explode_turn").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit creeper_explode_turn <1-10>"); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit creeper_explode_turn <1-10>"); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1410,24 +1411,24 @@ public class TurnBasedMinecraftMod { if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.creeper_explode_turn", turns)) { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.creeper_explode_turn\" in config file!"); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set creeper_explode_turn to \"" + turns + "\" in config file!")); } else { - TextComponent response = new TextComponent("Successfully set creeper_explode_turn to: "); - TextComponent subResponse = new TextComponent(String.valueOf(turns)); + MutableComponent response = Component.literal("Successfully set creeper_explode_turn to: "); + MutableComponent subResponse = Component.literal(String.valueOf(turns)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("creeper_stop_explode_on_leave_battle").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit creeper_stop_explode_on_leave_battle "); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit creeper_stop_explode_on_leave_battle "); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1439,25 +1440,25 @@ public class TurnBasedMinecraftMod { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.creeper_stop_explode_on_leave_battle\" in config file!" ); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set creeper_stop_explode_on_leave_battle to \"" + stop_explode_on_leave + "\" in config file!" )); } else { - TextComponent response = new TextComponent("Successfully set creeper_stop_explode_on_leave_battle to: "); - TextComponent subResponse = new TextComponent(String.valueOf(stop_explode_on_leave)); + MutableComponent response = Component.literal("Successfully set creeper_stop_explode_on_leave_battle to: "); + MutableComponent subResponse = Component.literal(String.valueOf(stop_explode_on_leave)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; }))) .then(Commands.literal("creeper_always_allow_damage").executes(c -> { - TextComponent parent = new TextComponent("Use "); - TextComponent sub = new TextComponent("/tbm-server-edit creeper_always_allow_damage "); + MutableComponent parent = Component.literal("Use "); + MutableComponent sub = Component.literal("/tbm-server-edit creeper_always_allow_damage "); sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW)); - parent.append(sub); + parent.getSiblings().add(sub); c.getSource().sendSuccess(parent, false); return 1; @@ -1469,16 +1470,16 @@ public class TurnBasedMinecraftMod { TurnBasedMinecraftMod.logger.warn( "Failed to set \"server_config.creeper_always_allow_damage\" in config file!" ); - c.getSource().sendFailure(new TextComponent( + c.getSource().sendFailure(Component.literal( "Failed to set creeper_always_allow_damage to \"" + allow_damage + "\" in config file!" )); } else { - TextComponent response = new TextComponent("Successfully set creeper_always_allow_damage to: "); - TextComponent subResponse = new TextComponent(String.valueOf(allow_damage)); + MutableComponent response = Component.literal("Successfully set creeper_always_allow_damage to: "); + MutableComponent subResponse = Component.literal(String.valueOf(allow_damage)); subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN)); - response.append(subResponse); + response.getSiblings().add(subResponse); c.getSource().sendSuccess(response, true); } return 1; diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Utility.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Utility.java index 2a783f3..4e83557 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Utility.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Utility.java @@ -55,7 +55,7 @@ public class Utility } public static String serializeDimension(ResourceKey dimObject) { - return dimObject.getRegistryName().toString(); + return dimObject.registry().toString(); } public static ResourceKey deserializeDimension(String dimString) { diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java index c12620e..604c2fa 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java @@ -5,7 +5,6 @@ import java.util.function.Supplier; import com.burnedkirby.TurnBasedMinecraft.common.Battle; import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod; -import io.netty.buffer.Unpooled; import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.network.NetworkEvent; diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a601b02..cfe9f5d 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -15,7 +15,7 @@ license="MIT" # The modid of the mod modId="com_burnedkirby_turnbasedminecraft" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -version="1.18.7" #mandatory +version="1.19.0" #mandatory # A display name for the mod displayName="TurnBasedMinecraftMod" #mandatory # A URL to query for updates for this mod. See the JSON update specification @@ -48,6 +48,6 @@ Implements turn-based-battle in Minecraft. [[dependencies.com_burnedkirby_turnbasedminecraft]] modId="minecraft" mandatory=true - versionRange="[1.18.2,1.19)" + versionRange="[1.19,1.20)" ordering="NONE" side="BOTH" diff --git a/src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml b/src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml index da39a8b..180671a 100644 --- a/src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml +++ b/src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml @@ -1,6 +1,6 @@ # Please do not change this option, the mod uses this to keep track of what new # changes to add to the config. -version = 7 +version = 8 do_not_overwrite = false [client_config] @@ -446,6 +446,18 @@ decision_attack_probability = 100 decision_defend_probability = 0 decision_flee_probability = 0 +[[server_config.entity]] +name = "net.minecraft.world.entity.monster.warden.Warden" +attack_power = 28 +attack_probability = 65 +attack_variance = 10 +evasion = 7 +category = "monster" +speed = 50 +decision_attack_probability = 95 +decision_defend_probability = 0 +decision_flee_probability = 0 + [[server_config.entity]] name = "net.minecraft.world.entity.monster.Witch" attack_power = 5 @@ -516,6 +528,17 @@ decision_attack_probability = 100 decision_defend_probability = 0 decision_flee_probability = 0 +[[server_config.entity]] +name = "net.minecraft.world.entity.animal.allay.Allay" +attack_power = 0 +attack_probability = 50 +evasion = 40 +category = "passive" +speed = 50 +decision_attack_probability = 0 +decision_defend_probability = 0 +decision_flee_probability = 100 + [[server_config.entity]] name = "net.minecraft.world.entity.animal.axolotl.Axolotl" attack_power = 2 @@ -608,6 +631,28 @@ decision_attack_probability = 70 decision_defend_probability = 0 decision_flee_probability = 25 +[[server_config.entity]] +name = "net.minecraft.world.entity.animal.frog.Frog" +attack_power = 2 +attack_probability = 50 +evasion = 60 +category = "animal" +speed = 70 +decision_attack_probability = 0 +decision_defend_probability = 0 +decision_flee_probability = 100 + +[[server_config.entity]] +name = "net.minecraft.world.entity.animal.frog.Tadpole" +attack_power = 0 +attack_probability = 0 +evasion = 45 +category = "animal" +speed = 50 +decision_attack_probability = 0 +decision_defend_probability = 0 +decision_flee_probability = 100 + [[server_config.entity]] name = "net.minecraft.world.entity.animal.horse.Donkey" attack_power = 0 diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 5f6a17f..e43f6c0 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "com_burnedkirby_turnbasedminecraft", "name": "Turn Based Minecraft", "description": "Changes battles to be turn-based.", - "version": "1.18.7", + "version": "1.19.0", "mcversion": "1.18.2", "url": "", "updateUrl": "",