diff --git a/build.gradle b/build.gradle index 5402b8b..8f7cd4f 100644 --- a/build.gradle +++ b/build.gradle @@ -67,7 +67,7 @@ tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" // Minecraft 1.17 (21w19a) upwards uses Java 16. - it.options.release = 16 + it.options.release = 17 } diff --git a/gradle.properties b/gradle.properties index 339b886..38370bf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,15 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G # Fabric Properties -minecraft_version=1.19.3 -yarn_mappings=1.19.3+build.3 -loader_version=0.14.11 +minecraft_version=1.20 +yarn_mappings=1.20+build.1 +loader_version=0.14.21 #Fabric api -fabric_version=0.69.1+1.19.3 -quilt_mappings=1 +fabric_version=0.83.0+1.20 # Mod Properties -mod_version=1.3.0 +mod_version=1.3.1 maven_group=org.samo_lego archives_base_name=healthcare # Dependencies -c2b_version=1.2.3 +c2b_version=1.2.5 translations_version=2.0.0-beta.2+1.19.4-pre2 diff --git a/src/main/java/org/samo_lego/healthcare/command/HealthbarCommand.java b/src/main/java/org/samo_lego/healthcare/command/HealthbarCommand.java index e792f0a..db9e73c 100644 --- a/src/main/java/org/samo_lego/healthcare/command/HealthbarCommand.java +++ b/src/main/java/org/samo_lego/healthcare/command/HealthbarCommand.java @@ -92,11 +92,11 @@ private static int toggleEntityType(CommandContext context) preferences.healthcarePrefs().showType = allowEntityType; - context.getSource().sendSuccess( - Component.translatable("healthcare.healthbar.toggledType", allowEntityType) - .withStyle(ChatFormatting.GREEN) - .append("\n") - .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), + context.getSource().sendSuccess(() -> + Component.translatable("healthcare.healthbar.toggledType", allowEntityType) + .withStyle(ChatFormatting.GREEN) + .append("\n") + .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), false ); return 1; @@ -107,16 +107,16 @@ private static int editHealthbarLength(CommandContext contex int length = IntegerArgumentType.getInteger(context, "length"); preferences.healthcarePrefs().customLength = length; - context.getSource().sendSuccess( - Component.translatable("healthcare.healthbar.customLengthSet", length) - .withStyle(ChatFormatting.GREEN) - .append("\n") - .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), + context.getSource().sendSuccess(() -> + Component.translatable("healthcare.healthbar.customLengthSet", length) + .withStyle(ChatFormatting.GREEN) + .append("\n") + .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), false ); if (preferences.healthcarePrefs().healthbarStyle != HealthbarStyle.CUSTOM) { - context.getSource().sendSuccess( - Component.translatable("healthcare.healthbar.useCustomStyle").withStyle(ChatFormatting.GOLD), + context.getSource().sendSuccess(() -> + Component.translatable("healthcare.healthbar.useCustomStyle").withStyle(ChatFormatting.GOLD), false ); } @@ -134,16 +134,16 @@ private static int setSymbol(CommandContext context, boolean preferences.healthcarePrefs().customEmptyChar = symbol; } - context.getSource().sendSuccess( - Component.translatable("healthcare.healthbar.customSymbolSet", full ? "Full" : "Empty", symbol) - .withStyle(ChatFormatting.GREEN) - .append("\n") - .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), + context.getSource().sendSuccess(() -> + Component.translatable("healthcare.healthbar.customSymbolSet", full ? "Full" : "Empty", symbol) + .withStyle(ChatFormatting.GREEN) + .append("\n") + .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), false ); if (preferences.healthcarePrefs().healthbarStyle != HealthbarStyle.CUSTOM) { - context.getSource().sendSuccess( - Component.translatable("healthcare.healthbar.useCustomStyle").withStyle(ChatFormatting.GOLD), + context.getSource().sendSuccess(() -> + Component.translatable("healthcare.healthbar.useCustomStyle").withStyle(ChatFormatting.GOLD), false ); } @@ -157,11 +157,11 @@ private static int changeVisibility(CommandContext context) preferences.healthcarePrefs().alwaysVisible = alwaysVisible; - context.getSource().sendSuccess( - Component.translatable("healthcare.healthbar.visibilitySet", alwaysVisible) - .withStyle(ChatFormatting.GREEN) - .append("\n") - .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), + context.getSource().sendSuccess(() -> + Component.translatable("healthcare.healthbar.visibilitySet", alwaysVisible) + .withStyle(ChatFormatting.GREEN) + .append("\n") + .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), false ); return 1; @@ -173,11 +173,11 @@ private static int editHealthbarStyle(CommandContext context preferences.healthcarePrefs().healthbarStyle = style; - context.getSource().sendSuccess( - Component.translatable("healthcare.healthbar.styleSet", style) - .withStyle(ChatFormatting.GREEN) - .append("\n") - .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), + context.getSource().sendSuccess(() -> + Component.translatable("healthcare.healthbar.styleSet", style) + .withStyle(ChatFormatting.GREEN) + .append("\n") + .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), false ); return 1; @@ -188,11 +188,11 @@ private static int toggleHealthBar(CommandContext context) t boolean enabled = !preferences.healthcarePrefs().enabled; preferences.healthcarePrefs().enabled = enabled; - context.getSource().sendSuccess( - Component.translatable(enabled ? "healthcare.healthbar.healthbarEnabled" : "healthcare.healthbar.healthbarDisabled") - .withStyle(ChatFormatting.GREEN) - .append("\n") - .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), + context.getSource().sendSuccess(() -> + Component.translatable(enabled ? "healthcare.healthbar.healthbarEnabled" : "healthcare.healthbar.healthbarDisabled") + .withStyle(ChatFormatting.GREEN) + .append("\n") + .append(Component.translatable("healthcare.healthbar.reloadRequired").withStyle(ChatFormatting.GOLD)), false ); diff --git a/src/main/java/org/samo_lego/healthcare/command/HealthcareCommand.java b/src/main/java/org/samo_lego/healthcare/command/HealthcareCommand.java index ff71664..50479a0 100644 --- a/src/main/java/org/samo_lego/healthcare/command/HealthcareCommand.java +++ b/src/main/java/org/samo_lego/healthcare/command/HealthcareCommand.java @@ -42,8 +42,8 @@ private static int reloadConfig(CommandContext ctx) { HealthConfig newConfig = HealthConfig.loadConfigFile(CONFIG_FILE); config.reload(newConfig); - ctx.getSource().sendSuccess( - Component.translatable("healthcare.config_reload_success").withStyle(ChatFormatting.GREEN), + ctx.getSource().sendSuccess(() -> + Component.translatable("healthcare.config_reload_success").withStyle(ChatFormatting.GREEN), false ); return 1; diff --git a/src/main/java/org/samo_lego/healthcare/config/HealthConfig.java b/src/main/java/org/samo_lego/healthcare/config/HealthConfig.java index 98aeb6a..9e7addf 100644 --- a/src/main/java/org/samo_lego/healthcare/config/HealthConfig.java +++ b/src/main/java/org/samo_lego/healthcare/config/HealthConfig.java @@ -7,14 +7,7 @@ import org.samo_lego.config2brigadier.annotation.BrigadierDescription; import org.samo_lego.healthcare.healthbar.HealthbarStyle; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Writer; +import java.io.*; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; @@ -55,7 +48,7 @@ public class HealthConfig implements IBrigadierConfigurator { @SerializedName("// The default style of healthbar. The following are available") public final String _comment_defaultStyle1 = Arrays.toString(HealthbarStyle.values()); @BrigadierDescription(defaultOption = "PERCENTAGE") - public HealthbarStyle defaultStyle = HealthbarStyle.PERCENTAGE; + public HealthbarStyle defaultStyle = HealthbarStyle.SKYBLOCK; @SerializedName("// Whether healthbar is enabled by default.") public final String _comment_enabled = ""; diff --git a/src/main/java/org/samo_lego/healthcare/mixin/ServerPlayNetworkHandlerMixin_HealthTag.java b/src/main/java/org/samo_lego/healthcare/mixin/ServerPlayNetworkHandlerMixin_HealthTag.java index 68cae7e..6da5fc3 100644 --- a/src/main/java/org/samo_lego/healthcare/mixin/ServerPlayNetworkHandlerMixin_HealthTag.java +++ b/src/main/java/org/samo_lego/healthcare/mixin/ServerPlayNetworkHandlerMixin_HealthTag.java @@ -53,7 +53,7 @@ public abstract class ServerPlayNetworkHandlerMixin_HealthTag { * it accordingly to player's preferences if it is * an {@link ClientboundSetEntityDataPacket}. * - * @param packet packet being sent + * @param sendPacket packet being sent * @param listener * @param ci */ @@ -68,7 +68,7 @@ public abstract class ServerPlayNetworkHandlerMixin_HealthTag { private void onPacketSend(Packet sendPacket, PacketSendListener listener, CallbackInfo ci) { if (sendPacket instanceof ClientboundSetEntityDataPacket packet && !this.hc_skipCheck) { int id = packet.id(); - Entity entity = this.player.getLevel().getEntity(id); + Entity entity = this.player.level().getEntity(id); final var hb = ((HealthbarPreferences) this.player).healthcarePrefs(); if (entity instanceof LivingEntity living &&