Skip to content

Commit

Permalink
1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Jun 8, 2023
1 parent 2eded7c commit a8ca267
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 55 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ private static int toggleEntityType(CommandContext<CommandSourceStack> 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;
Expand All @@ -107,16 +107,16 @@ private static int editHealthbarLength(CommandContext<CommandSourceStack> 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
);
}
Expand All @@ -134,16 +134,16 @@ private static int setSymbol(CommandContext<CommandSourceStack> 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
);
}
Expand All @@ -157,11 +157,11 @@ private static int changeVisibility(CommandContext<CommandSourceStack> 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;
Expand All @@ -173,11 +173,11 @@ private static int editHealthbarStyle(CommandContext<CommandSourceStack> 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;
Expand All @@ -188,11 +188,11 @@ private static int toggleHealthBar(CommandContext<CommandSourceStack> 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
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ private static int reloadConfig(CommandContext<CommandSourceStack> 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;
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/org/samo_lego/healthcare/config/HealthConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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 &&
Expand Down

0 comments on commit a8ca267

Please sign in to comment.