Skip to content

Commit

Permalink
Fixed issue with darkmode resourcepacks
Browse files Browse the repository at this point in the history
*Some darkmode resourcepacks used shaders to change text colour to white. The fix was to not rely on the font renderer to colour the text, but rather the text formatting.
*Incremented version
  • Loading branch information
CleverNucleus committed Jul 24, 2022
1 parent 9174be0 commit 0c60bee
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 40 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ modrinth {
versionNumber = "${project.mod_version}"
versionName = "${project.mod_version}"
uploadFile = remapJar
gameVersions = ["1.18.2"]
gameVersions = ["${project.minecraft_version}"]
loaders = ["fabric"]
dependencies = [
new ModDependency("P7dR8mSH", "required"),
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
loader_version=0.14.6

mod_version = 3.2.1
mod_version = 3.2.2
maven_group = com.github.clevernucleus
archives_base_name = playerex

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {

COMPONENTS.forEach(component -> component.renderText(this.client.player, matrices, this.textRenderer, this.x, this.y, scaleX.get(), scaleY.get()));

this.textRenderer.draw(matrices, (new TranslatableText("playerex.gui.page.attributes.text.vitality")), (this.x + 105) / scaleX.get(), (this.y + 26) / scaleY.get(), 4210752);
this.textRenderer.draw(matrices, (new TranslatableText("playerex.gui.page.attributes.text.resistances")), (this.x + 105) / scaleX.get(), (this.y + 81) / scaleY.get(), 4210752);
this.textRenderer.draw(matrices, (new TranslatableText("playerex.gui.page.attributes.text.vitality")).formatted(Formatting.DARK_GRAY), (this.x + 105) / scaleX.get(), (this.y + 26) / scaleY.get(), 4210752);
this.textRenderer.draw(matrices, (new TranslatableText("playerex.gui.page.attributes.text.resistances")).formatted(Formatting.DARK_GRAY), (this.x + 105) / scaleX.get(), (this.y + 81) / scaleY.get(), 4210752);

matrices.pop();

Expand Down Expand Up @@ -172,7 +172,7 @@ protected void init() {

static {
COMPONENTS.add(RenderComponent.of(ExAPI.LEVEL, value -> {
return new TranslatableText("playerex.gui.page.attributes.text.level", Math.round(value));
return new TranslatableText("playerex.gui.page.attributes.text.level", Math.round(value)).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText("playerex.gui.page.attributes.tooltip.level[0]")).formatted(Formatting.GRAY));
Expand All @@ -183,7 +183,7 @@ protected void init() {
return tooltip;
}, 21, 26));
COMPONENTS.add(RenderComponent.of(entity -> {
return new TranslatableText("playerex.gui.page.attributes.text.skill_points", ExAPI.PLAYER_DATA.get(entity).skillPoints());
return new TranslatableText("playerex.gui.page.attributes.text.skill_points", ExAPI.PLAYER_DATA.get(entity).skillPoints()).formatted(Formatting.DARK_GRAY);
}, entity -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText("playerex.gui.page.attributes.tooltip.skill_points[0]")).formatted(Formatting.GRAY));
Expand All @@ -192,7 +192,7 @@ protected void init() {
return tooltip;
}, 21, 37));
COMPONENTS.add(RenderComponent.of(ExAPI.CONSTITUTION, value -> {
return new TranslatableText("playerex.gui.page.attributes.text.constitution", Math.round(value));
return new TranslatableText("playerex.gui.page.attributes.text.constitution", Math.round(value)).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText(ExAPI.CONSTITUTION.get().getTranslationKey())).formatted(Formatting.GRAY));
Expand All @@ -202,7 +202,7 @@ protected void init() {
return tooltip;
}, 21, 59));
COMPONENTS.add(RenderComponent.of(ExAPI.STRENGTH, value -> {
return new TranslatableText("playerex.gui.page.attributes.text.strength", Math.round(value));
return new TranslatableText("playerex.gui.page.attributes.text.strength", Math.round(value)).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText(ExAPI.STRENGTH.get().getTranslationKey())).formatted(Formatting.GRAY));
Expand All @@ -212,7 +212,7 @@ protected void init() {
return tooltip;
}, 21, 70));
COMPONENTS.add(RenderComponent.of(ExAPI.DEXTERITY, value -> {
return new TranslatableText("playerex.gui.page.attributes.text.dexterity", Math.round(value));
return new TranslatableText("playerex.gui.page.attributes.text.dexterity", Math.round(value)).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText(ExAPI.DEXTERITY.get().getTranslationKey())).formatted(Formatting.GRAY));
Expand All @@ -222,7 +222,7 @@ protected void init() {
return tooltip;
}, 21, 81));
COMPONENTS.add(RenderComponent.of(ExAPI.INTELLIGENCE, value -> {
return new TranslatableText("playerex.gui.page.attributes.text.intelligence", Math.round(value));
return new TranslatableText("playerex.gui.page.attributes.text.intelligence", Math.round(value)).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText(ExAPI.INTELLIGENCE.get().getTranslationKey())).formatted(Formatting.GRAY));
Expand All @@ -232,7 +232,7 @@ protected void init() {
return tooltip;
}, 21, 92));
COMPONENTS.add(RenderComponent.of(ExAPI.LUCKINESS, value -> {
return new TranslatableText("playerex.gui.page.attributes.text.luckiness", Math.round(value));
return new TranslatableText("playerex.gui.page.attributes.text.luckiness", Math.round(value)).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText(ExAPI.LUCKINESS.get().getTranslationKey())).formatted(Formatting.GRAY));
Expand All @@ -242,7 +242,7 @@ protected void init() {
return tooltip;
}, 21, 103));
COMPONENTS.add(RenderComponent.of(entity -> {
return new TranslatableText("playerex.gui.page.attributes.text.movement_speed", ClientUtil.FORMATTING_3.format(entity.getMovementSpeed()));
return new TranslatableText("playerex.gui.page.attributes.text.movement_speed", ClientUtil.FORMATTING_3.format(entity.getMovementSpeed())).formatted(Formatting.DARK_GRAY);
}, entity -> {
List<Text> tooltip = new ArrayList<Text>();
String formatted = ClientUtil.FORMATTING_3.format(20.0D * entity.getMovementSpeed());
Expand All @@ -251,15 +251,15 @@ protected void init() {
return tooltip;
}, 21, 125));
COMPONENTS.add(RenderComponent.of(ExAPI.BREAKING_SPEED, value -> {
return new TranslatableText("playerex.gui.page.attributes.text.breaking_speed", ClientUtil.FORMATTING_3.format(value));
return new TranslatableText("playerex.gui.page.attributes.text.breaking_speed", ClientUtil.FORMATTING_3.format(value)).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText("playerex.gui.page.attributes.tooltip.breaking_speed")).formatted(Formatting.GRAY));

return tooltip;
}, 21, 136));
COMPONENTS.add(RenderComponent.of(ExAPI.REACH_DISTANCE, value -> {
return new TranslatableText("playerex.gui.page.attributes.text.reach_distance", ClientUtil.FORMATTING_2.format(4.5F + value));
return new TranslatableText("playerex.gui.page.attributes.text.reach_distance", ClientUtil.FORMATTING_2.format(4.5F + value)).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText("playerex.gui.page.attributes.tooltip.reach_distance", ClientUtil.FORMATTING_2.format(4.5F + value))).formatted(Formatting.GRAY));
Expand All @@ -270,15 +270,15 @@ protected void init() {
String current = ClientUtil.FORMATTING_2.format(entity.getHealth());
String maximum = ClientUtil.FORMATTING_2.format(entity.getMaxHealth());

return new TranslatableText("playerex.gui.page.attributes.text.health", current, maximum);
return new TranslatableText("playerex.gui.page.attributes.text.health", current, maximum).formatted(Formatting.DARK_GRAY);
}, entity -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText("playerex.gui.page.attributes.tooltip.health")).formatted(Formatting.GRAY));

return tooltip;
}, 93, 37));
COMPONENTS.add(RenderComponent.of(ExAPI.HEALTH_REGENERATION, value -> {
return new TranslatableText("playerex.gui.page.attributes.text.health_regeneration", value);
return new TranslatableText("playerex.gui.page.attributes.text.health_regeneration", value).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText("playerex.gui.page.attributes.tooltip.health_regeneration[0]")).formatted(Formatting.GRAY));
Expand All @@ -287,8 +287,8 @@ protected void init() {
return tooltip;
}, 93, 48));
COMPONENTS.add(RenderComponent.of(ExAPI.HEAL_AMPLIFICATION, value -> {
String displ = ClientUtil.FORMATTING_2.format(ClientUtil.displayValue(ExAPI.HEAL_AMPLIFICATION, value));
return new TranslatableText("playerex.gui.page.attributes.text.heal_amplification", displ);
String displ = ClientUtil.FORMATTING_2.format(ClientUtil.displayValue(ExAPI.HEAL_AMPLIFICATION, value)).formatted(Formatting.DARK_GRAY);
return new TranslatableText("playerex.gui.page.attributes.text.heal_amplification", displ).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
tooltip.add((new TranslatableText("playerex.gui.page.attributes.tooltip.heal_amplification[0]")).formatted(Formatting.GRAY));
Expand All @@ -298,7 +298,7 @@ protected void init() {
}, 93, 59));
COMPONENTS.add(RenderComponent.of(ExAPI.FIRE_RESISTANCE, value -> {
String displ = ClientUtil.FORMATTING_2.format(ClientUtil.displayValue(ExAPI.FIRE_RESISTANCE, value));
return new TranslatableText("playerex.gui.page.attributes.text.fire_resistance", displ);
return new TranslatableText("playerex.gui.page.attributes.text.fire_resistance", displ).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
String displ = ClientUtil.FORMATTING_2.format(100.0F * value);
Expand All @@ -308,7 +308,7 @@ protected void init() {
}, 93, 92));
COMPONENTS.add(RenderComponent.of(ExAPI.FREEZE_RESISTANCE, value -> {
String displ = ClientUtil.FORMATTING_2.format(ClientUtil.displayValue(ExAPI.FREEZE_RESISTANCE, value));
return new TranslatableText("playerex.gui.page.attributes.text.freeze_resistance", displ);
return new TranslatableText("playerex.gui.page.attributes.text.freeze_resistance", displ).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
String displ = ClientUtil.FORMATTING_2.format(100.0F * value);
Expand All @@ -318,7 +318,7 @@ protected void init() {
}, 93, 103));
COMPONENTS.add(RenderComponent.of(ExAPI.LIGHTNING_RESISTANCE, value -> {
String displ = ClientUtil.FORMATTING_2.format(ClientUtil.displayValue(ExAPI.LIGHTNING_RESISTANCE, value));
return new TranslatableText("playerex.gui.page.attributes.text.lightning_resistance", displ);
return new TranslatableText("playerex.gui.page.attributes.text.lightning_resistance", displ).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
String displ = ClientUtil.FORMATTING_2.format(100.0F * value);
Expand All @@ -328,7 +328,7 @@ protected void init() {
}, 93, 114));
COMPONENTS.add(RenderComponent.of(ExAPI.POISON_RESISTANCE, value -> {
String displ = ClientUtil.FORMATTING_2.format(ClientUtil.displayValue(ExAPI.POISON_RESISTANCE, value));
return new TranslatableText("playerex.gui.page.attributes.text.poison_resistance", displ);
return new TranslatableText("playerex.gui.page.attributes.text.poison_resistance", displ).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
String displ = ClientUtil.FORMATTING_2.format(100.0F * value);
Expand All @@ -338,7 +338,7 @@ protected void init() {
}, 93, 125));
COMPONENTS.add(RenderComponent.of(ExAPI.WITHER_RESISTANCE, value -> {
String displ = ClientUtil.FORMATTING_2.format(ClientUtil.displayValue(ExAPI.WITHER_RESISTANCE, value));
return new TranslatableText("playerex.gui.page.attributes.text.wither_resistance", displ);
return new TranslatableText("playerex.gui.page.attributes.text.wither_resistance", displ).formatted(Formatting.DARK_GRAY);
}, value -> {
List<Text> tooltip = new ArrayList<Text>();
String displ = ClientUtil.FORMATTING_2.format(100.0F * value);
Expand Down
Loading

0 comments on commit 0c60bee

Please sign in to comment.