Skip to content

Commit

Permalink
1.2.2 (#13)
Browse files Browse the repository at this point in the history
* Fix #12

* Add more options to change text particle colour.

* Bump version number.
  • Loading branch information
Provismet authored Dec 25, 2023
1 parent 405dacc commit 5f8339a
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.2+build.1
loader_version=0.14.22

# Mod Properties
mod_version=1.2.1+1.20.2
mod_version=1.2.2+1.20.2
maven_group=com.provismet
archives_base_name=provihealth

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,15 @@ public static Screen build (Screen parent) {
.build()
);

particles.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.particleTextColour"), Options.particleTextColour)
particles.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.damageParticleTextColour"), Options.damageParticleTextColour)
.setDefaultValue(0xFFFFFF)
.setSaveConsumer(newValue -> Options.particleTextColour = newValue)
.setSaveConsumer(newValue -> Options.damageParticleTextColour = newValue)
.build()
);

particles.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.healingParticleTextColour"), Options.healingParticleTextColour)
.setDefaultValue(0xFFFFFF)
.setSaveConsumer(newValue -> Options.healingParticleTextColour = newValue)
.build()
);

Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/provismet/provihealth/config/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public class Options {
public static Vector3f unpackedHealing = Vec3d.unpackRgb(healingColour).toVector3f();
public static float particleScale = 0.25f;
public static boolean particleTextShadow = true;
public static int particleTextColour = 0xFFFFFF;
public static int damageParticleTextColour = 0xFFFFFF;
public static int healingParticleTextColour = 0xFFFFFF;
public static DamageParticleType particleType = DamageParticleType.RISING;
public static float maxParticleDistance = 16f;
public static float damageAlpha = 1f;
Expand Down Expand Up @@ -174,7 +175,8 @@ public static void save () {
.append("healingAlpha", healingAlpha).newLine()
.append("particleScale", particleScale).newLine()
.append("particleTextShadow", particleTextShadow).newLine()
.append("particleTextColour", particleTextColour).newLine()
.append("damageParticleTextColour", damageParticleTextColour).newLine()
.append("healingParticleTextColour", healingParticleTextColour).newLine()
.append("particleType", particleType.name()).newLine()
.append("maxParticleDistance", maxParticleDistance).newLine()
.append("topLayerTextType", seeThroughTextType.name()).newLine()
Expand Down Expand Up @@ -366,8 +368,12 @@ public static void load () {
particleTextShadow = parser.nextBoolean();
break;

case "particleTextColour":
particleTextColour = parser.nextInt();
case "damageParticleTextColour":
damageParticleTextColour = parser.nextInt();
break;

case "healingParticleTextColour":
healingParticleTextColour = parser.nextInt();
break;

case "particleType":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import com.provismet.provihealth.config.Options;
import com.provismet.provihealth.hud.TargetHealthBar;
import com.provismet.provihealth.world.EntityHealthBar;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
Expand All @@ -21,4 +23,9 @@ public abstract class EntityRendererMixin {
private void cancelLabel (Entity entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo info) {
if (TargetHealthBar.disabledLabels || (Options.overrideLabels && entity instanceof LivingEntity living && Options.shouldRenderHealthFor(living))) info.cancel();
}

@Inject(method="render", at=@At("HEAD"))
private void addHealthBar (Entity entity, float yaw, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, CallbackInfo info) {
EntityHealthBar.render(entity, tickDelta, matrixStack, vertexConsumerProvider, MinecraftClient.getInstance().getEntityRenderDispatcher().getRotation());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ private void spawnParticles (CallbackInfo info) {
final Entity cameraEntity = MinecraftClient.getInstance().getCameraEntity();
if (cameraEntity != null && (LivingEntity)(Object)this != cameraEntity && this.distanceTo(MinecraftClient.getInstance().getCameraEntity()) <= Options.maxParticleDistance) {
if (this.getHealth() < this.prevHealth && Options.spawnDamageParticles) {
this.getWorld().addParticle(new TextParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, String.format("%d", (int)this.prevHealth - (int)this.getHealth())), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f);
this.getWorld().addParticle(new TextParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, Options.damageParticleTextColour, String.format("%d", (int)this.prevHealth - (int)this.getHealth())), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f);
}
else if (this.getHealth() > this.prevHealth && Options.spawnHealingParticles) {
this.getWorld().addParticle(new TextParticleEffect(Options.unpackedHealing, Options.healingAlpha, Options.particleScale, String.format("%d", (int)this.getHealth() - (int)this.prevHealth)), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f);
this.getWorld().addParticle(new TextParticleEffect(Options.unpackedHealing, Options.healingAlpha, Options.particleScale, Options.healingParticleTextColour, String.format("%d", (int)this.getHealth() - (int)this.prevHealth)), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f);
}
}
this.prevHealth = this.getHealth();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class TextParticle extends SpriteBillboardParticle {
private final String text;
private final float rotationSpeed;
private final float maxScale;
private final int textColour;

protected TextParticle (ClientWorld clientWorld, double x, double y, double z, TextParticleEffect particleEffect) {
super(clientWorld, x, y, z);
Expand All @@ -35,6 +36,7 @@ protected TextParticle (ClientWorld clientWorld, double x, double y, double z, T
this.blue = particleEffect.getColour().z();
this.scale = 0f;
this.alpha = particleEffect.alpha;
this.textColour = particleEffect.textColour;
this.text = particleEffect.text;
this.maxAge = 40;

Expand Down Expand Up @@ -123,7 +125,7 @@ public void buildGeometry (VertexConsumer vertexConsumer, Camera camera, float t
float scaleSize = this.getSize(tickDelta) / 6f;
matrices.scale(-scaleSize, -scaleSize, -scaleSize);

MinecraftClient.getInstance().textRenderer.draw(this.text, 0f, 0f, Options.particleTextColour, Options.particleTextShadow, matrices.peek().getPositionMatrix(), MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(), TextLayerType.POLYGON_OFFSET, 0, this.getBrightness(tickDelta));
MinecraftClient.getInstance().textRenderer.draw(this.text, 0f, 0f, this.textColour, Options.particleTextShadow, matrices.peek().getPositionMatrix(), MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(), TextLayerType.POLYGON_OFFSET, 0, this.getBrightness(tickDelta));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ public class TextParticleEffect implements ParticleEffect {
public final float alpha;
public final float scale;
public final String text;
public final int textColour;

public TextParticleEffect (Vector3f colour, float alpha, float scale, String text) {
public TextParticleEffect (Vector3f colour, float alpha, float scale, int textColour, String text) {
this.colour = colour;
this.alpha = alpha;
this.scale = scale;
this.text = text;
this.textColour = textColour;
}

@SuppressWarnings("deprecation")
Expand All @@ -35,25 +37,28 @@ public TextParticleEffect read (ParticleType<TextParticleEffect> particleType, S
stringReader.expect(' ');
float scale = stringReader.readFloat();
stringReader.expect(' ');
int textColour = stringReader.readInt();
stringReader.expect(' ');
String text = stringReader.getRemaining();
return new TextParticleEffect(colour, alpha, scale, text);
return new TextParticleEffect(colour, alpha, scale, textColour, text);
}

@Override
public TextParticleEffect read (ParticleType<TextParticleEffect> type, PacketByteBuf buffer) {
return new TextParticleEffect(AbstractDustParticleEffect.readColor(buffer), buffer.readFloat(), buffer.readFloat(), buffer.readString());
return new TextParticleEffect(AbstractDustParticleEffect.readColor(buffer), buffer.readFloat(), buffer.readFloat(), buffer.readInt(), buffer.readString());
}
};

@Override
public String asString () {
return String.format("%s %.2 %.2 %.2 %.2 %.2 %s",
return String.format("%s %.2 %.2 %.2 %.2 %.2 %d %s",
Registries.PARTICLE_TYPE.getId(this.getType()),
this.colour.x(),
this.colour.y(),
this.colour.z(),
this.alpha,
this.scale,
this.textColour,
this.text
);
}
Expand All @@ -70,6 +75,7 @@ public void write (PacketByteBuf buffer) {
buffer.writeFloat(this.colour.z());
buffer.writeFloat(this.alpha);
buffer.writeFloat(this.scale);
buffer.writeInt(this.textColour);
buffer.writeString(this.text);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/provihealth/lang/en_gb.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"entry.provihealth.damageColour": "Damage Particle Colour",
"entry.provihealth.healingColour": "Healing Particle Colour",
"entry.provihealth.particleTextColour": "Text Colour",
"entry.provihealth.damageParticleTextColour": "Damage Text Colour",
"entry.provihealth.healingParticleTextColour": "Healing Text Colour",
"entry.provihealth.barStartColour": "Full Health Colour",
"entry.provihealth.barEndColour": "Low Health Colour",

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/provihealth/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"entry.provihealth.healingColour": "Healing Particle Color",
"entry.provihealth.particleScale": "Particle Size",
"entry.provihealth.particleTextShadow": "Text Shadow",
"entry.provihealth.particleTextColour": "Text Color",
"entry.provihealth.damageParticleTextColour": "Damage Text Color",
"entry.provihealth.healingParticleTextColour": "Healing Text Color",
"entry.provihealth.particleType": "Particle Movement",
"entry.provihealth.maxParticleDistance": "Particle Render Distance",
"entry.provihealth.hudOffsetX": "HUD Position",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/provihealth.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"mixins": [
],
"client": [
"LivingEntityRendererMixin",
"LivingEntityMixin",
"EntityRendererMixin"
],
Expand Down

0 comments on commit 5f8339a

Please sign in to comment.