From d02a2d4a3703cdb5f126cdfb1c21a79304f785af Mon Sep 17 00:00:00 2001 From: Emafire003 <29462910+Emafire003@users.noreply.github.com> Date: Mon, 27 May 2024 16:08:57 +0200 Subject: [PATCH] Fixed a weird NPE (hopefully) --- TODO.txt | 10 ++++++---- gradle.properties | 2 +- .../dev/coloredglowlib/mixin/EntityColorMixin.java | 9 +++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/TODO.txt b/TODO.txt index 27cac11..38985f6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,6 +1,8 @@ -Probably recode everything from scratch. Use just the hex string and store values with Cardinal Components, then -use architectury to multiplatform +Coloredglowlib: Visible by aggiungere un nuovo component che contiene sia il color che il target che può essere un player specifico, un team, o un party e simili. +Per le entity type e global probabilmente devo fare un'altro component dentro al component che ha il corrsipettivo target, emitter e colore. +Also fare un sistema di chace per non leggere sempre dall'nbt? Forse? -Add DataDriven animation and maybe triggers, like names or team or whatever. Like a sequence of blue red white that with white staing on for 3 seconds and the other ones for 1 etc. -They would work like "rainbow" and "random" \ No newline at end of file +Also splittare in vari moduli magari tipo solo la API e la API extension +per questa roba qua forse? Oddio un po' complesso siccome sarebbe un mixin +del mixin \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 8c75ca8..7146da6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ loader_version=0.15.11 # Mod Properties - mod_version = 3.1.0+fabric_1.20.6 + mod_version = 3.1.1+fabric_1.20.6 maven_group = me.emafire003.dev archives_base_name = coloredglowlib diff --git a/src/main/java/me/emafire003/dev/coloredglowlib/mixin/EntityColorMixin.java b/src/main/java/me/emafire003/dev/coloredglowlib/mixin/EntityColorMixin.java index db06772..dceb9de 100644 --- a/src/main/java/me/emafire003/dev/coloredglowlib/mixin/EntityColorMixin.java +++ b/src/main/java/me/emafire003/dev/coloredglowlib/mixin/EntityColorMixin.java @@ -19,8 +19,6 @@ @Environment(EnvType.CLIENT) @Mixin(Entity.class) public abstract class EntityColorMixin { - @Unique - private final Entity entity = ((Entity)(Object)this); /*public int nameSpecificColor(Entity entity){ Maybe i'll add it maybe not @@ -85,6 +83,7 @@ private int getRainbowColor(){ @Unique private int randomColor(){ + Entity entity = ((Entity)(Object)this); Random r = entity.getWorld().getRandom(); if(random_delay_counter == 10){ random_delay_counter = 0; @@ -97,6 +96,7 @@ private int randomColor(){ @Inject(method = "getTeamColorValue", at = @At("RETURN"), cancellable = true) public void injectChangeColorValue(CallbackInfoReturnable cir){ + Entity entity = ((Entity)(Object)this); ColoredGlowLibAPI cgl = ColoredGlowLibMod.getAPI(); if(cgl == null){ @@ -104,6 +104,11 @@ public void injectChangeColorValue(CallbackInfoReturnable cir){ return; } + if(entity == null){ + LOGGER.warn("The entity is null! Can't display the custom color!"); + return; + } + if(entity.getScoreboardTeam() == null || cgl.getOverrideTeamColors()) { /**Checks if it's april 1st for jokes*/