Skip to content

Commit

Permalink
Fixed bug with side fire and added better third person fire customiza…
Browse files Browse the repository at this point in the history
…tion support
  • Loading branch information
LordEnder-Kitty committed May 18, 2024
1 parent ca48553 commit 0ac24f5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 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.4+build.3
loader_version=0.15.11

# Mod Properties
mod_version=1.0.0-1.20.3-4
mod_version=1.1.0-1.20.3-4
maven_group=net.enderkitty
archives_base_name=firehud

Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/enderkitty/config/FireHudConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class FireHudConfig implements ConfigData {
@ConfigEntry.Gui.PrefixText
@ConfigEntry.Gui.Tooltip
public boolean renderFireInLava = true;
public boolean renderThirdPersonFireInLava = true;
@ConfigEntry.Gui.Tooltip
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public LavaFogOptions renderLavaFog = LavaFogOptions.VANILLA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import net.enderkitty.config.FireHudConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.util.Identifier;
Expand All @@ -32,24 +32,26 @@ public class EntityRendererDispatcherMixin {

@Inject(method = "renderFire", at = @At(value = "HEAD"), cancellable = true)
private void renderThirdPersonFire(MatrixStack matrices, VertexConsumerProvider vertexConsumers, Entity entity, Quaternionf rotation, CallbackInfo ci) {
if ((!config.renderVanillaHud && !config.sideFire && config.fireVignette == FireHudConfig.VignetteOptions.OFF && !config.fireScreenTint && (!config.renderFireInLava && entity.isOnFire()) &&
(!config.renderWithFireResistance && ((LivingEntity) entity).hasStatusEffect(StatusEffects.FIRE_RESISTANCE))) || !config.renderThirdPersonFire) {

ci.cancel();
MinecraftClient client = MinecraftClient.getInstance();

if (client.player != null && client.player.isOnFire()) {
if ((!config.renderThirdPersonFireInLava && client.player.isInLava())) ci.cancel();
if ((!config.renderWithFireResistance && client.player.hasStatusEffect(StatusEffects.FIRE_RESISTANCE))) ci.cancel();
if (!config.renderThirdPersonFire) ci.cancel();
}
}

@Redirect(method = "renderFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;", ordinal = 0))
private Sprite getSprite0(SpriteIdentifier obj, MatrixStack matrices, VertexConsumerProvider vertexConsumers, Entity entity) {
if (config.renderSoulFire && ((SoulFireAccessor)entity).isRenderSoulFire()) {
if (config.renderSoulFire && ((SoulFireAccessor) entity).isRenderSoulFire()) {
return SOUL_FIRE_0.getSprite();
}
return obj.getSprite();
}

@Redirect(method = "renderFire", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SpriteIdentifier;getSprite()Lnet/minecraft/client/texture/Sprite;", ordinal = 1))
private Sprite getSprite1(SpriteIdentifier obj, MatrixStack matrices, VertexConsumerProvider vertexConsumers, Entity entity) {
if (config.renderSoulFire && ((SoulFireAccessor)entity).isRenderSoulFire()) {
if (config.renderSoulFire && ((SoulFireAccessor) entity).isRenderSoulFire()) {
return SOUL_FIRE_1.getSprite();
}
return obj.getSprite();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class InGameOverlayRendererMixin {

@Inject(method = "renderOverlays", at = @At("TAIL"))
private static void renderOverlays(MinecraftClient client, MatrixStack matrices, CallbackInfo ci) {
if (client.player != null && !client.player.isSpectator() && client.player.isOnFire() && config.sideFire) {
if (client.player != null && !client.player.isSpectator() && client.player.isOnFire() && config.sideFire &&
!(!config.renderFireInLava && client.player.isInLava()) && !(!config.renderWithFireResistance && client.player.hasStatusEffect(StatusEffects.FIRE_RESISTANCE))) {
renderSideFireOverlay(client, matrices);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/firehud/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"text.autoconfig.firehud.option.renderWithFireResistance.@PrefixText": "Fire Resistance",
"text.autoconfig.firehud.option.renderWithFireResistance.@Tooltip": "Toggles rendering the hud when under the Fire Resistance status effect",
"text.autoconfig.firehud.option.renderWithFireResistance": "Render With Fire Resistance",
"text.autoconfig.firehud.option.renderThirdPersonFireInLava": "Third Person Fire In Lava",
"text.autoconfig.firehud.option.displayFireResTimer.@Tooltip": "Displays a timer above the hotbar which shows how many seconds remaining on any applied fire resistance effect",
"text.autoconfig.firehud.option.displayFireResTimer": "Display Fire Resistance Timer",
"text.autoconfig.firehud.option.fireResTimerAsTicks.@Tooltip": "Changes Display Fire Resistance Timer to display time in ticks instead of seconds (requires Display Fire Resistance Timer to be enabled)",
Expand Down

0 comments on commit 0ac24f5

Please sign in to comment.