Skip to content

Commit 12d7224

Browse files
committed
1.19 + migrate to mojmap
1 parent 336e192 commit 12d7224

12 files changed

+209
-201
lines changed

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import com.modrinth.minotaur.TaskModrinthUpload
22

33
plugins {
4-
id 'fabric-loom' version '0.10-SNAPSHOT'
4+
id 'fabric-loom' version '0.12-SNAPSHOT'
55
id 'maven-publish'
66
id "com.matthewprenger.cursegradle" version "1.4.0"
77
id "com.modrinth.minotaur" version "1.1.0"
@@ -27,7 +27,7 @@ repositories {
2727
dependencies {
2828
// To change the versions see the gradle.properties file
2929
minecraft "com.mojang:minecraft:${project.minecraft_version}"
30-
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
30+
mappings loom.officialMojangMappings()
3131
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
3232

3333
// Fabric API. This is technically optional, but you probably want it anyway.
@@ -108,6 +108,7 @@ curseforge {
108108
releaseType = "release"
109109
addGameVersion "${project.minecraft_version}"
110110
addGameVersion "Fabric"
111+
addGameVersion "Quilt"
111112

112113
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
113114
displayName = "[${project.minecraft_version}] Healthcare ${version}"
@@ -138,4 +139,5 @@ task modrinth(type: TaskModrinthUpload, dependsOn: remapJar) {
138139

139140
addGameVersion("${project.minecraft_version}")
140141
addLoader('fabric')
142+
addLoader('quilt')
141143
}

gradle.properties

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
# Done to increase the memory available to gradle.
22
org.gradle.jvmargs=-Xmx1G
3-
43
# Fabric Properties
5-
minecraft_version=1.18.2
6-
yarn_mappings=1.18.2+build.1
7-
loader_version=0.13.3
8-
4+
minecraft_version=1.19
5+
yarn_mappings=1.19+build.1
6+
loader_version=0.14.6
97
#Fabric api
10-
fabric_version=0.47.8+1.18.2
11-
8+
fabric_version=0.55.2+1.19
129
# Mod Properties
13-
mod_version = 1.0.11
14-
maven_group = org.samo_lego
15-
archives_base_name = healthcare
16-
10+
mod_version=1.1.0
11+
maven_group=org.samo_lego
12+
archives_base_name=healthcare
1713
# Config editing lib
18-
c2b_version = 1.0.2
14+
c2b_version=4c3b0be618

src/main/java/org/samo_lego/healthcare/HealthCare.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.samo_lego.healthcare;
22

33
import net.fabricmc.api.ModInitializer;
4-
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
4+
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
55
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
66
import net.fabricmc.loader.api.FabricLoader;
77
import org.samo_lego.healthcare.command.HealthbarCommand;

src/main/java/org/samo_lego/healthcare/command/HealthbarCommand.java

Lines changed: 80 additions & 77 deletions
Large diffs are not rendered by default.

src/main/java/org/samo_lego/healthcare/command/HealthcareCommand.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,34 @@
33
import com.mojang.brigadier.CommandDispatcher;
44
import com.mojang.brigadier.context.CommandContext;
55
import com.mojang.brigadier.tree.LiteralCommandNode;
6-
import net.minecraft.server.command.ServerCommandSource;
7-
import net.minecraft.text.LiteralText;
8-
import net.minecraft.util.Formatting;
6+
import net.minecraft.ChatFormatting;
7+
import net.minecraft.commands.CommandBuildContext;
8+
import net.minecraft.commands.CommandSourceStack;
9+
import net.minecraft.commands.Commands;
10+
import net.minecraft.network.chat.Component;
911
import org.samo_lego.healthcare.config.HealthConfig;
1012
import org.samo_lego.healthcare.permission.PermissionHelper;
1113

12-
import static net.minecraft.server.command.CommandManager.literal;
13-
import static org.samo_lego.healthcare.HealthCare.*;
14+
import static net.minecraft.commands.Commands.literal;
15+
import static org.samo_lego.healthcare.HealthCare.CONFIG_FILE;
16+
import static org.samo_lego.healthcare.HealthCare.LUCKPERMS_LOADED;
17+
import static org.samo_lego.healthcare.HealthCare.config;
1418

1519
public class HealthcareCommand {
1620

17-
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated) {
18-
LiteralCommandNode<ServerCommandSource> healthcareNode = dispatcher.register(literal("healthcare")
19-
.requires(src -> LUCKPERMS_LOADED ? PermissionHelper.checkPermission(src, config.perms.healthcare_config, 4) : src.hasPermissionLevel(4)));
21+
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context, Commands.CommandSelection selection) {
22+
LiteralCommandNode<CommandSourceStack> healthcareNode = dispatcher.register(literal("healthcare")
23+
.requires(src -> LUCKPERMS_LOADED ? PermissionHelper.checkPermission(src, config.perms.healthcare_config, 4) : src.hasPermission(4)));
2024

21-
LiteralCommandNode<ServerCommandSource> configNode = literal("config")
25+
LiteralCommandNode<CommandSourceStack> configNode = literal("config")
2226
.then(literal("reload")
23-
.requires(src -> LUCKPERMS_LOADED ? PermissionHelper.checkPermission(src, config.perms.healthcare_config_reload, 4) : src.hasPermissionLevel(4))
27+
.requires(src -> LUCKPERMS_LOADED ? PermissionHelper.checkPermission(src, config.perms.healthcare_config_reload, 4) : src.hasPermission(4))
2428
.executes(HealthcareCommand::reloadConfig)
2529
)
2630
.build();
2731

28-
LiteralCommandNode<ServerCommandSource> editNode = literal("edit")
29-
.requires(src -> LUCKPERMS_LOADED ? PermissionHelper.checkPermission(src, config.perms.healthcare_config_edit, 4) : src.hasPermissionLevel(4))
32+
LiteralCommandNode<CommandSourceStack> editNode = literal("edit")
33+
.requires(src -> LUCKPERMS_LOADED ? PermissionHelper.checkPermission(src, config.perms.healthcare_config_edit, 4) : src.hasPermission(4))
3034
.build();
3135

3236
config.generateCommand(editNode);
@@ -35,12 +39,12 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher, b
3539
healthcareNode.addChild(configNode);
3640
}
3741

38-
private static int reloadConfig(CommandContext<ServerCommandSource> ctx) {
42+
private static int reloadConfig(CommandContext<CommandSourceStack> ctx) {
3943
HealthConfig newConfig = HealthConfig.loadConfigFile(CONFIG_FILE);
4044
config.reload(newConfig);
4145

42-
ctx.getSource().sendFeedback(
43-
new LiteralText(config.lang.configReloaded).formatted(Formatting.GREEN),
46+
ctx.getSource().sendSuccess(
47+
Component.literal(config.lang.configReloaded).withStyle(ChatFormatting.GREEN),
4448
false
4549
);
4650
return 0;

src/main/java/org/samo_lego/healthcare/event/EventHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.samo_lego.healthcare.event;
22

33
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
4-
import net.minecraft.server.network.ServerPlayerEntity;
4+
import net.minecraft.server.level.ServerPlayer;
55
import org.samo_lego.healthcare.healthbar.HealthbarPreferences;
66

77
public class EventHandler implements ServerPlayerEvents.CopyFrom {
@@ -14,7 +14,7 @@ public class EventHandler implements ServerPlayerEvents.CopyFrom {
1414
* @param alive whether the old player is still alive
1515
*/
1616
@Override
17-
public void copyFromPlayer(ServerPlayerEntity oldPlayer, ServerPlayerEntity newPlayer, boolean alive) {
17+
public void copyFromPlayer(ServerPlayer oldPlayer, ServerPlayer newPlayer, boolean alive) {
1818
((HealthbarPreferences) newPlayer).setHealthbarStyle(((HealthbarPreferences) oldPlayer).getHealthbarStyle());
1919
((HealthbarPreferences) newPlayer).setEnabled(((HealthbarPreferences) oldPlayer).isEnabled());
2020
((HealthbarPreferences) newPlayer).setAlwaysVisible(((HealthbarPreferences) oldPlayer).isAlwaysVisible());

src/main/java/org/samo_lego/healthcare/healthbar/HealthbarPreferences.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.samo_lego.healthcare.healthbar;
22

3-
import net.minecraft.text.MutableText;
3+
import net.minecraft.network.chat.MutableComponent;
44

55
public interface HealthbarPreferences {
66
/**
@@ -12,11 +12,12 @@ public interface HealthbarPreferences {
1212

1313
/**
1414
* Gets the health text from current health and max health depending on HealthbarStyle.
15-
* @param health current health
15+
*
16+
* @param health current health
1617
* @param maxHealth max health
1718
* @return formatted mutable text with health info
1819
*/
19-
MutableText getHealthbarText(float health, float maxHealth);
20+
MutableComponent getHealthbarText(float health, float maxHealth);
2021

2122
void setEnabled(boolean enabled);
2223
boolean isEnabled();
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
package org.samo_lego.healthcare.mixin;
22

3-
import net.minecraft.entity.Entity;
4-
import net.minecraft.entity.data.TrackedData;
5-
import net.minecraft.text.Text;
3+
import net.minecraft.network.chat.Component;
4+
import net.minecraft.network.syncher.EntityDataAccessor;
5+
import net.minecraft.world.entity.Entity;
66
import org.spongepowered.asm.mixin.Mixin;
77
import org.spongepowered.asm.mixin.gen.Accessor;
88

99
import java.util.Optional;
1010

1111
@Mixin(Entity.class)
1212
public interface EntityAccessor {
13-
@Accessor("NAME_VISIBLE")
14-
static TrackedData<Boolean> getNAME_VISIBLE() {
13+
@Accessor("DATA_CUSTOM_NAME_VISIBLE")
14+
static EntityDataAccessor<Boolean> getNAME_VISIBLE() {
1515
throw new AssertionError();
1616
}
17-
@Accessor("CUSTOM_NAME")
18-
static TrackedData<Optional<Text>> getCUSTOM_NAME() {
17+
18+
@Accessor("DATA_CUSTOM_NAME")
19+
static EntityDataAccessor<Optional<Component>> getCUSTOM_NAME() {
1920
throw new AssertionError();
2021
}
2122
}

src/main/java/org/samo_lego/healthcare/mixin/EntityTrackerUpdateS2CPacketAccessor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package org.samo_lego.healthcare.mixin;
22

3-
import net.minecraft.entity.data.DataTracker;
4-
import net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket;
3+
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
4+
import net.minecraft.network.syncher.SynchedEntityData;
55
import org.spongepowered.asm.mixin.Mixin;
66
import org.spongepowered.asm.mixin.Mutable;
77
import org.spongepowered.asm.mixin.gen.Accessor;
88

99
import java.util.List;
1010

11-
@Mixin(EntityTrackerUpdateS2CPacket.class)
11+
@Mixin(ClientboundSetEntityDataPacket.class)
1212
public interface EntityTrackerUpdateS2CPacketAccessor {
1313

14-
@Accessor("trackedValues")
15-
List<DataTracker.Entry<?>> getTrackedValues();
14+
@Accessor("packedItems")
15+
List<SynchedEntityData.DataItem<?>> getPackedItems();
1616

1717
@Mutable
18-
@Accessor("trackedValues")
19-
void setTrackedValues(List<DataTracker.Entry<?>> trackedValues);
18+
@Accessor("packedItems")
19+
void setPackedItems(List<SynchedEntityData.DataItem<?>> packedItems);
2020

2121
@Accessor("id")
2222
int getId();

src/main/java/org/samo_lego/healthcare/mixin/PlayerEntityMixinCast_Preferences.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package org.samo_lego.healthcare.mixin;
22

3-
import net.minecraft.entity.player.PlayerEntity;
4-
import net.minecraft.nbt.NbtCompound;
5-
import net.minecraft.text.LiteralText;
6-
import net.minecraft.text.MutableText;
7-
import net.minecraft.util.Formatting;
3+
import net.minecraft.ChatFormatting;
4+
import net.minecraft.nbt.CompoundTag;
5+
import net.minecraft.network.chat.Component;
6+
import net.minecraft.network.chat.MutableComponent;
7+
import net.minecraft.world.entity.player.Player;
88
import org.samo_lego.healthcare.healthbar.HealthbarPreferences;
99
import org.spongepowered.asm.mixin.Mixin;
1010
import org.spongepowered.asm.mixin.injection.At;
@@ -13,7 +13,7 @@
1313

1414
import static org.samo_lego.healthcare.HealthCare.config;
1515

16-
@Mixin(PlayerEntity.class)
16+
@Mixin(Player.class)
1717
public class PlayerEntityMixinCast_Preferences implements HealthbarPreferences {
1818

1919
private HealthbarStyle healthbarStyle = config.defaultStyle;
@@ -36,14 +36,14 @@ public void setHealthbarStyle(HealthbarStyle healthbarStyle) {
3636
}
3737

3838
@Override
39-
public MutableText getHealthbarText(float health, float maxHealth) {
40-
if(health < 0.0F) {
39+
public MutableComponent getHealthbarText(float health, float maxHealth) {
40+
if (health < 0.0F) {
4141
health = 0.0F;
4242
}
43-
if(maxHealth <= 0.0F) {
43+
if (maxHealth <= 0.0F) {
4444
maxHealth = 1.0F;
4545
}
46-
if(health > maxHealth) {
46+
if (health > maxHealth) {
4747
maxHealth = health;
4848
}
4949

@@ -55,14 +55,14 @@ public MutableText getHealthbarText(float health, float maxHealth) {
5555
second = String.valueOf((int) Math.ceil(maxHealth));
5656

5757
// We return it here because of custom formatting
58-
return new LiteralText(first)
59-
.formatted(health > maxHealth / 2 ? Formatting.GREEN : Formatting.YELLOW)
60-
.append(new LiteralText("/")
61-
.formatted(Formatting.WHITE))
62-
.append(new LiteralText(second)
63-
.formatted(Formatting.GREEN))
64-
.append(new LiteralText(String.valueOf((char) 10084)) // ❤
65-
.formatted(Formatting.RED));
58+
return Component.literal(first)
59+
.withStyle(health > maxHealth / 2 ? ChatFormatting.GREEN : ChatFormatting.YELLOW)
60+
.append(Component.literal("/")
61+
.withStyle(ChatFormatting.WHITE))
62+
.append(Component.literal(second)
63+
.withStyle(ChatFormatting.GREEN))
64+
.append(Component.literal(String.valueOf((char) 10084)) // ❤
65+
.withStyle(ChatFormatting.RED));
6666
}
6767
case NUMBER -> {
6868
// Number
@@ -98,9 +98,9 @@ public MutableText getHealthbarText(float health, float maxHealth) {
9898
second = new String(new char[heartCount - fullHearts]).replace('\0', empty);
9999
}
100100
}
101-
return new LiteralText(first)
102-
.formatted(Formatting.RED) /*health > maxHealth / 3 ? (health > maxHealth * 1.5F ? Formatting.YELLOW : Formatting.GOLD) : */
103-
.append(new LiteralText(second).formatted(Formatting.GRAY));
101+
return Component.literal(first)
102+
.withStyle(ChatFormatting.RED) /*health > maxHealth / 3 ? (health > maxHealth * 1.5F ? Formatting.YELLOW : Formatting.GOLD) : */
103+
.append(Component.literal(second).withStyle(ChatFormatting.GRAY));
104104
}
105105

106106
@Override
@@ -155,7 +155,7 @@ public int getCustomFullChar() {
155155

156156
@Override
157157
public void setCustomLength(int length) {
158-
if(length >= 0) // Don't allow negative length
158+
if (length >= 0) // Don't allow negative length
159159
this.customLength = length;
160160
}
161161

@@ -164,31 +164,31 @@ public int getCustomLength() {
164164
return this.customLength;
165165
}
166166

167-
@Inject(method = "writeCustomDataToNbt", at = @At("TAIL"))
168-
private void writeCustomDataToTag(NbtCompound tag, CallbackInfo ci) {
169-
NbtCompound healthbar = new NbtCompound();
167+
@Inject(method = "addAdditionalSaveData", at = @At("TAIL"))
168+
private void writeCustomDataToTag(CompoundTag tag, CallbackInfo ci) {
169+
CompoundTag healthbar = new CompoundTag();
170170
healthbar.putString("Style", this.healthbarStyle.toString());
171171
healthbar.putBoolean("Enabled", this.enabled);
172172
healthbar.putBoolean("ShowType", this.showType);
173173
healthbar.putBoolean("AlwaysVisible", this.alwaysVisible);
174-
if(this.healthbarStyle.equals(HealthbarStyle.CUSTOM)) {
174+
if (this.healthbarStyle.equals(HealthbarStyle.CUSTOM)) {
175175
healthbar.putInt("CustomFullChar", this.customFullChar);
176176
healthbar.putInt("CustomEmptyChar", this.customEmptyChar);
177177
healthbar.putInt("Length", this.customLength);
178178
}
179179
tag.put("Healthbar", healthbar);
180180
}
181181

182-
@Inject(method = "readCustomDataFromNbt", at = @At("TAIL"))
183-
private void readCustomDataFromTag(NbtCompound tag, CallbackInfo ci) {
184-
if(tag.contains("Healthbar")) {
185-
NbtCompound healthbar = tag.getCompound("Healthbar");
182+
@Inject(method = "readAdditionalSaveData", at = @At("TAIL"))
183+
private void readCustomDataFromTag(CompoundTag tag, CallbackInfo ci) {
184+
if (tag.contains("Healthbar")) {
185+
CompoundTag healthbar = tag.getCompound("Healthbar");
186186
this.healthbarStyle = HealthbarStyle.valueOf(healthbar.getString("Style"));
187187
this.enabled = healthbar.getBoolean("Enabled");
188188
this.alwaysVisible = healthbar.getBoolean("AlwaysVisible");
189189
this.showType = healthbar.getBoolean("ShowType");
190190

191-
if(this.healthbarStyle.equals(HealthbarStyle.CUSTOM)) {
191+
if (this.healthbarStyle.equals(HealthbarStyle.CUSTOM)) {
192192
this.customFullChar = healthbar.getInt("CustomFullChar");
193193
this.customEmptyChar = healthbar.getInt("CustomEmptyChar");
194194
this.customLength = healthbar.getInt("Length");

0 commit comments

Comments
 (0)