Skip to content

Commit 5ccf574

Browse files
committed
render brain damage hearts
1 parent 423cc13 commit 5ccf574

22 files changed

+54
-13
lines changed

src/main/java/galena/oreganized/client/render/gui/OGui.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
import net.minecraft.resources.ResourceLocation;
1212
import net.minecraftforge.client.gui.overlay.ForgeGui;
1313

14-
import java.util.HashMap;
15-
import java.util.stream.IntStream;
16-
1714
public class OGui extends ForgeGui {
1815

1916
protected static final ResourceLocation STUNNING_VIGNETTE_LOCATION = Oreganized.modLoc( "textures/misc/stunning_overlay.png");
17+
protected static final ResourceLocation STUNNED_HEARTS = Oreganized.modLoc( "textures/misc/hearts/brain_damaged_full.png");
2018

2119
private static final IntObjectHashMap<ResourceLocation> STUNNING_OVERLAY_LOCATIONS = new IntObjectHashMap<>();
2220

@@ -46,4 +44,8 @@ public void render(GuiGraphics guiGraphics, float partialTick) {
4644
if (this.minecraft.player.isEyeInFluidType(OFluids.MOLTEN_LEAD_TYPE.get()))
4745
this.renderTextureOverlay(guiGraphics, STUNNING_VIGNETTE_LOCATION, 1F);
4846
}
47+
48+
public static void renderStunnedHeart(GuiGraphics graphics, int x, int y, int v) {
49+
graphics.blit(STUNNED_HEARTS, x, y, 0, v, 9, 9);
50+
}
4951
}

src/main/java/galena/oreganized/content/effect/StunningEffect.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package galena.oreganized.content.effect;
22

33
import galena.oreganized.Oreganized;
4-
import galena.oreganized.index.OEffects;
4+
import net.minecraft.sounds.SoundEvents;
55
import net.minecraft.world.effect.MobEffect;
66
import net.minecraft.world.effect.MobEffectCategory;
77
import net.minecraft.world.effect.MobEffectInstance;
@@ -23,13 +23,6 @@ public StunningEffect() {
2323
addAttributeModifier(Attributes.MOVEMENT_SPEED, SLOWNESS_UUID, -0.075, AttributeModifier.Operation.MULTIPLY_TOTAL);
2424
}
2525

26-
public static double getTurnModifier(LivingEntity entity) {
27-
var effect = entity.getEffect(OEffects.STUNNING.get());
28-
if (effect == null) return 1.0;
29-
30-
return 0.95 - effect.getAmplifier() * 0.05;
31-
}
32-
3326
@Override
3427
public void applyEffectTick(@NotNull LivingEntity entity, int amplifier) {
3528
if (entity.level().getGameTime() % 5 != 0L) return;
@@ -45,6 +38,7 @@ public void applyEffectTick(@NotNull LivingEntity entity, int amplifier) {
4538

4639
if (instance.update(new MobEffectInstance(this, instance.getDuration() + 1, amplifier + step, instance.isAmbient(), instance.isVisible(), instance.showIcon()))) {
4740
addAttributeModifiers(entity, entity.getAttributes(), instance.getAmplifier());
41+
entity.playSound(SoundEvents.SCULK_BLOCK_SPREAD, instance.getAmplifier() * 0.8F / MAX_AMPLIFIER + 0.2F, entity.getRandom().nextFloat() * 0.2F + 0.8F);
4842
}
4943
}
5044

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package galena.oreganized.mixin.client;
2+
3+
import net.minecraft.client.gui.Gui;
4+
import net.minecraft.client.gui.GuiGraphics;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Invoker;
7+
8+
@Mixin(Gui.class)
9+
public interface GuiAccessor {
10+
11+
@Invoker
12+
void callRenderHeart(GuiGraphics p_283024_, Gui.HeartType p_281393_, int p_283636_, int p_283279_, int p_283188_, boolean p_283440_, boolean p_282496_);
13+
14+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package galena.oreganized.mixin.client;
2+
3+
import com.llamalad7.mixinextras.sugar.Local;
4+
import galena.oreganized.client.render.gui.OGui;
5+
import galena.oreganized.index.OEffects;
6+
import net.minecraft.client.gui.Gui;
7+
import net.minecraft.client.gui.GuiGraphics;
8+
import net.minecraft.world.entity.player.Player;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Redirect;
12+
13+
@Mixin(Gui.class)
14+
public class GuiMixin {
15+
16+
@Redirect(
17+
method = "renderHearts(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/entity/player/Player;IIIIFIIIZ)V",
18+
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderHeart(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/gui/Gui$HeartType;IIIZZ)V")
19+
)
20+
private void renderStunnedHeart(Gui instance, GuiGraphics graphics, Gui.HeartType type, int x, int y, int v, boolean flag1, boolean flag2, @Local Player player) {
21+
var accessor = (GuiAccessor) instance;
22+
23+
if (player.hasEffect(OEffects.STUNNING.get())) {
24+
OGui.renderStunnedHeart(graphics, x, y, v);
25+
} else {
26+
accessor.callRenderHeart(graphics, type, x, y, v, flag1, flag2);
27+
}
28+
}
29+
30+
}

src/main/resources/META-INF/accesstransformer.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ public net.minecraft.world.level.block.FireBlock m_53444_(Lnet/minecraft/world/l
1111
public net.minecraft.world.entity.monster.ZombieVillager m_34383_(Ljava/util/UUID;I)V #startConverting
1212
public net.minecraft.world.damagesource.DamageSources *()
1313
public net.minecraft.client.particle.SingleQuadParticle f_107663_ # quadSize # quadSize
14-
public net.minecraft.world.entity.LivingEntity m_6125_()Z # shouldDropLoot
14+
public net.minecraft.world.entity.LivingEntity m_6125_()Z # shouldDropLoot
15+
public net.minecraft.client.gui.Gui$HeartType
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)