Skip to content

Commit

Permalink
1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Dec 15, 2022
1 parent 353d526 commit 4e3bc7c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 55 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Component>) customName.get().getValue()).isPresent()) {
name = ((Optional<Component>) customName.get().getValue()).get().copy().append(" ");
if (customName.isPresent() && ((Optional<Component>) customName.get().value()).isPresent()) {
name = ((Optional<Component>) 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(" ");
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/healthcare.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"EntityAccessor",
"EntityTrackerUpdateS2CPacketAccessor",
"PlayerEntityMixinCast_Preferences",
"ServerPlayNetworkHandlerMixin_HealthTag"
],
Expand Down

0 comments on commit 4e3bc7c

Please sign in to comment.