diff --git a/build.gradle b/build.gradle index 79fe2a4..44e1efb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ import com.modrinth.minotaur.TaskModrinthUpload plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' + id 'fabric-loom' version '1.0-SNAPSHOT' id 'maven-publish' // Quilt Mappings, for parameters and javadoc. Also hashed mojmap. @@ -11,8 +11,8 @@ plugins { id "com.modrinth.minotaur" version "1.1.0" } -sourceCompatibility = JavaVersion.VERSION_16 -targetCompatibility = JavaVersion.VERSION_16 +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 archivesBaseName = project.archives_base_name version = project.mod_version @@ -21,7 +21,7 @@ group = project.maven_group def ENV = System.getenv() repositories { - maven { url 'https://jitpack.io'} + maven { url 'https://jitpack.io' } maven { url "https://maven.architectury.dev/" } maven { url 'https://maven.nucleoid.xyz' } maven { @@ -34,7 +34,7 @@ dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" mappings loom.layered { - it.addLayer(quiltMappings.mappings("org.quiltmc:quilt-mappings:${rootProject.minecraft_version}+build.${rootProject.quilt_mappings}:v2")) + //it.addLayer(quiltMappings.mappings("org.quiltmc:quilt-mappings:${rootProject.minecraft_version}+build.${rootProject.quilt_mappings}:v2")) // https://lambdaurora.dev/tools/import_quilt.html it.officialMojangMappings { setNameSyntheticMembers(false) diff --git a/gradle.properties b/gradle.properties index 1a5cdf2..7ce7648 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,16 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G # Fabric Properties -minecraft_version=1.19.1 -yarn_mappings=1.19.1+build.1 -loader_version=0.14.8 +minecraft_version=1.19.3 +yarn_mappings=1.19.3+build.3 +loader_version=0.14.11 #Fabric api -fabric_version=0.58.5+1.19.1 +fabric_version=0.69.1+1.19.3 quilt_mappings=1 # Mod Properties -mod_version=1.2.0 +mod_version=1.2.1 maven_group=org.samo_lego archives_base_name=healthcare # Dependencies c2b_version=1.2.1 -translations_version=1.4.16+1.19 +translations_version=1.4.19+1.19.3 diff --git a/src/main/java/org/samo_lego/healthcare/mixin/EntityTrackerUpdateS2CPacketAccessor.java b/src/main/java/org/samo_lego/healthcare/mixin/EntityTrackerUpdateS2CPacketAccessor.java deleted file mode 100644 index 4542b5c..0000000 --- a/src/main/java/org/samo_lego/healthcare/mixin/EntityTrackerUpdateS2CPacketAccessor.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.samo_lego.healthcare.mixin; - -import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; -import net.minecraft.network.syncher.SynchedEntityData; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.List; - -@Mixin(ClientboundSetEntityDataPacket.class) -public interface EntityTrackerUpdateS2CPacketAccessor { - - @Accessor("packedItems") - List> getPackedItems(); - - @Mutable - @Accessor("packedItems") - void setPackedItems(List> packedItems); - - @Accessor("id") - int getId(); - - @Mutable - @Accessor("id") - void setId(int id); -} 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 4995326..68cae7e 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 @@ -1,6 +1,6 @@ package org.samo_lego.healthcare.mixin; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.PacketSendListener; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; @@ -65,33 +65,33 @@ public abstract class ServerPlayNetworkHandlerMixin_HealthTag { ), cancellable = true ) - private void onPacketSend(Packet packet, PacketSendListener listener, CallbackInfo ci) { - if (packet instanceof ClientboundSetEntityDataPacket && !this.hc_skipCheck) { - int id = ((EntityTrackerUpdateS2CPacketAccessor) packet).getId(); + 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); final var hb = ((HealthbarPreferences) this.player).healthcarePrefs(); if (entity instanceof LivingEntity living && hb.enabled && !(entity instanceof Player) && - !config.blacklistedEntities.contains(Registry.ENTITY_TYPE.getKey(entity.getType()).toString()) && + !config.blacklistedEntities.contains(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString()) && !entity.isInvisibleTo(player)) { - var trackedValues = new ArrayList<>(((EntityTrackerUpdateS2CPacketAccessor) packet).getPackedItems()); + var trackedValues = new ArrayList<>(packet.packedItems()); // Removing current custom name - var customName = trackedValues.stream().filter(value -> value.getAccessor().getId() == 2).findFirst(); + var customName = trackedValues.stream().filter(value -> value.id() == 2).findFirst(); // Ensure name is visible only if mob is not too far away boolean visible = (entity.distanceTo(player) < config.activationRange || entity.isCustomNameVisible()) && hb.alwaysVisible; - var visibleTag = new SynchedEntityData.DataItem<>(EntityAccessor.getNAME_VISIBLE(), visible); + var visibleTag = SynchedEntityData.DataValue.create(EntityAccessor.getNAME_VISIBLE(), visible); float health = living.getHealth(); float maxHealth = living.getMaxHealth(); MutableComponent name = Component.empty(); - if (customName.isPresent() && ((Optional) customName.get().getValue()).isPresent()) { - name = ((Optional) customName.get().getValue()).get().copy().append(" "); + if (customName.isPresent() && ((Optional) customName.get().value()).isPresent()) { + name = ((Optional) customName.get().value()).get().copy().append(" "); } else if (entity.hasCustomName()) { // @SpaceClouds42 saved me here, `.copy()` after getting custom name is essential! name = entity.getCustomName().copy().append(" "); @@ -100,17 +100,13 @@ private void onPacketSend(Packet packet, PacketSendListener listener, Callbac } var healthbar = ((HealthbarPreferences) this.player).createHealthbarText(health, maxHealth); - var healthTag = new SynchedEntityData.DataItem<>(EntityAccessor.getCUSTOM_NAME(), Optional.of(name.append(healthbar))); + var healthTag = SynchedEntityData.DataValue.create(EntityAccessor.getCUSTOM_NAME(), Optional.of(name.append(healthbar))); Collections.addAll(trackedValues, visibleTag, healthTag); // Create a new packet in order to not mess with other network handlers // since same packet object is sent to every player - var trackerUpdatePacket = new ClientboundSetEntityDataPacket(id, this.hc_dummyTracker, false); - var accessor = (EntityTrackerUpdateS2CPacketAccessor) trackerUpdatePacket; - - accessor.setId(id); - accessor.setPackedItems(trackedValues); + var trackerUpdatePacket = new ClientboundSetEntityDataPacket(id, trackedValues); this.hc_skipCheck = true; this.send(trackerUpdatePacket, listener); diff --git a/src/main/resources/healthcare.mixins.json b/src/main/resources/healthcare.mixins.json index dfbec20..ee47811 100644 --- a/src/main/resources/healthcare.mixins.json +++ b/src/main/resources/healthcare.mixins.json @@ -5,7 +5,6 @@ "compatibilityLevel": "JAVA_8", "mixins": [ "EntityAccessor", - "EntityTrackerUpdateS2CPacketAccessor", "PlayerEntityMixinCast_Preferences", "ServerPlayNetworkHandlerMixin_HealthTag" ],