|
1 | 1 | package dev.sterner.mixin;
|
2 | 2 |
|
3 | 3 | import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
4 |
| -import com.sammy.malum.MalumMod; |
| 4 | +import com.mojang.blaze3d.platform.Window; |
| 5 | +import com.mojang.blaze3d.systems.RenderSystem; |
| 6 | +import com.mojang.blaze3d.vertex.PoseStack; |
| 7 | +import com.sammy.malum.common.components.MalumComponents; |
| 8 | +import com.sammy.malum.common.components.MalumPlayerDataComponent; |
5 | 9 | import com.sammy.malum.core.handlers.SoulWardHandler;
|
6 | 10 | import dev.sterner.VoidBound;
|
7 | 11 | import dev.sterner.registry.VoidBoundItemRegistry;
|
8 | 12 | import net.minecraft.client.Minecraft;
|
| 13 | +import net.minecraft.client.gui.GuiGraphics; |
| 14 | +import net.minecraft.client.player.LocalPlayer; |
| 15 | +import net.minecraft.client.renderer.GameRenderer; |
9 | 16 | import net.minecraft.resources.ResourceLocation;
|
| 17 | +import net.minecraft.util.Mth; |
10 | 18 | import net.minecraft.world.entity.EquipmentSlot;
|
| 19 | +import net.minecraft.world.entity.ai.attributes.Attributes; |
| 20 | +import org.joml.Vector4f; |
11 | 21 | import org.spongepowered.asm.mixin.Mixin;
|
12 | 22 | import org.spongepowered.asm.mixin.injection.At;
|
| 23 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 24 | +import org.spongepowered.asm.mixin.injection.Redirect; |
| 25 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 26 | +import team.lodestar.lodestone.registry.client.LodestoneShaderRegistry; |
| 27 | +import team.lodestar.lodestone.systems.rendering.VFXBuilders; |
| 28 | +import team.lodestar.lodestone.systems.rendering.shader.ExtendedShaderInstance; |
| 29 | + |
| 30 | +import java.util.function.Supplier; |
| 31 | + |
| 32 | +import static com.sammy.malum.core.handlers.SoulWardHandler.ClientOnly.getSoulWardTexture; |
13 | 33 |
|
14 | 34 | @Mixin(SoulWardHandler.ClientOnly.class)
|
15 | 35 | public class SoulWardHandlerMixin {
|
16 | 36 |
|
17 | 37 | @ModifyReturnValue(method = "getSoulWardTexture", at = @At("RETURN"))
|
18 | 38 | private static ResourceLocation voidbound$modSoulWardTexture(ResourceLocation original){
|
19 | 39 | if (Minecraft.getInstance().player != null) {
|
20 |
| - boolean bl = Minecraft.getInstance().player.getItemBySlot(EquipmentSlot.HEAD).is(VoidBoundItemRegistry.INSTANCE.getICHORIUM_CROWN().get()); |
| 40 | + boolean bl = Minecraft.getInstance().player.getItemBySlot(EquipmentSlot.HEAD).is(VoidBoundItemRegistry.INSTANCE.getICHORIUM_CIRCLET().get()); |
21 | 41 | if (bl) {
|
22 | 42 | return VoidBound.INSTANCE.id("textures/gui/soul_ward/ichorium.png");
|
23 | 43 | }
|
24 | 44 | }
|
25 | 45 | return original;
|
26 | 46 | }
|
| 47 | +/* |
| 48 | + @Inject(method = "renderSoulWard", at = @At("HEAD"), cancellable = true) |
| 49 | + private static void v(GuiGraphics guiGraphics, Window window, CallbackInfo ci){ |
| 50 | + Minecraft minecraft = Minecraft.getInstance(); |
| 51 | + PoseStack poseStack = guiGraphics.pose(); |
| 52 | + if (!minecraft.options.hideGui) { |
| 53 | + LocalPlayer player = minecraft.player; |
| 54 | + if (!player.isCreative() && !player.isSpectator()) { |
| 55 | + SoulWardHandler soulWardHandler = ((MalumPlayerDataComponent) MalumComponents.MALUM_PLAYER_COMPONENT.get(player)).soulWardHandler; |
| 56 | + float soulWard = soulWardHandler.soulWard; |
| 57 | + if (soulWard > 0.0F) { |
| 58 | + float absorb = (float) Mth.ceil(player.getAbsorptionAmount()); |
| 59 | + float maxHealth = (float)player.getAttribute(Attributes.MAX_HEALTH).getValue(); |
| 60 | + float armor = (float)player.getAttribute(Attributes.ARMOR).getValue(); |
| 61 | + int left = window.getGuiScaledWidth() / 2 - 91; |
| 62 | + int top = window.getGuiScaledHeight() - 59; |
| 63 | + if (armor == 0.0F) { |
| 64 | + top += 4; |
| 65 | + } |
| 66 | +
|
| 67 | + int healthRows = Mth.ceil((maxHealth + absorb) / 2.0F / 10.0F); |
| 68 | + int rowHeight = Math.max(10 - (healthRows - 2), 3); |
| 69 | + poseStack.pushPose(); |
| 70 | + RenderSystem.setShaderTexture(0, getSoulWardTexture()); |
| 71 | + RenderSystem.depthMask(true); |
| 72 | + RenderSystem.enableBlend(); |
| 73 | + RenderSystem.defaultBlendFunc(); |
| 74 | + //ExtendedShaderInstance shaderInstance = (ExtendedShaderInstance) LodestoneShaderRegistry.DISTORTED_TEXTURE.getInstance().get(); |
| 75 | + //shaderInstance.safeGetUniform("YFrequency").set(15.0F); |
| 76 | + //shaderInstance.safeGetUniform("XFrequency").set(15.0F); |
| 77 | + //shaderInstance.safeGetUniform("Speed").set(550.0F); |
| 78 | + //shaderInstance.safeGetUniform("Intensity").set(120.0F); |
| 79 | + VFXBuilders.ScreenVFXBuilder builder = VFXBuilders.createScreen().setPosColorTexDefaultFormat().setShader(() -> { |
| 80 | + return GameRenderer.getPositionColorTexShader(); |
| 81 | + }); |
| 82 | + int size = 13; |
| 83 | + boolean forceDisplay = soulWard <= 1.0F; |
| 84 | + double soulWardAmount = forceDisplay ? 1.0 : Math.ceil(Math.floor((double)soulWard) / 3.0); |
| 85 | +
|
| 86 | + for(int i = 0; (double)i < soulWardAmount; ++i) { |
| 87 | + int row = (int)((float)i / 10.0F); |
| 88 | + int x = left + i % 10 * 8; |
| 89 | + int y = top - row * 4 + rowHeight * 2 - 15; |
| 90 | + int progress = Math.min(3, (int)soulWard - i * 3); |
| 91 | + int xTextureOffset = forceDisplay ? 31 : 1 + (3 - progress) * 15; |
| 92 | + //shaderInstance.safeGetUniform("UVCoordinates").set(new Vector4f((float)xTextureOffset / 45.0F, (float)(xTextureOffset + size) / 45.0F, 0.0F, 0.33333334F)); |
| 93 | + //shaderInstance.safeGetUniform("TimeOffset").set((float)i * 150.0F); |
| 94 | + builder.setPositionWithWidth((float)(x - 2), (float)(y - 2), (float)size, (float)size).setUVWithWidth((float)xTextureOffset, 0.0F, (float)size, (float)size, 45.0F).draw(poseStack); |
| 95 | + } |
| 96 | +
|
| 97 | + //shaderInstance.setUniformDefaults(); |
| 98 | + RenderSystem.depthMask(true); |
| 99 | + RenderSystem.disableBlend(); |
| 100 | + poseStack.popPose(); |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + ci.cancel(); |
| 105 | + } |
| 106 | +
|
| 107 | + */ |
| 108 | + |
| 109 | +/* |
| 110 | +
|
| 111 | + @Redirect(method = "renderSoulWard", at = @At(value = "INVOKE", target = "Lteam/lodestar/lodestone/systems/rendering/VFXBuilders;createScreen()Lteam/lodestar/lodestone/systems/rendering/VFXBuilders$ScreenVFXBuilder;")) |
| 112 | + private static VFXBuilders.ScreenVFXBuilder voidbound$modSoulWardScreen(){ |
| 113 | +
|
| 114 | + return VFXBuilders.createScreen().setPosColorTexDefaultFormat().setShader(() -> { |
| 115 | +
|
| 116 | + return GameRenderer.getPositionTexShader(); |
| 117 | + }); |
| 118 | + } |
| 119 | +
|
| 120 | + */ |
27 | 121 | }
|
0 commit comments