Implement Ascend Compat, Irons spellbooks compat, And rehauled most things.
This commit is contained in:
@@ -5,4 +5,8 @@ public class ClientData {
|
||||
public static float INSANITY = 0f;
|
||||
public static int TEMPO = 0;
|
||||
public static int VENT_COOLDOWN = 0;
|
||||
}
|
||||
|
||||
// NEW: synced from server
|
||||
public static float MAX_SANITY = 80f;
|
||||
public static int MAX_TEMPO = 120;
|
||||
}
|
||||
@@ -19,27 +19,21 @@ public class SanityTempoOverlay {
|
||||
public static void onRenderOverlay(RenderGuiOverlayEvent.Post event) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc.player == null || mc.options.hideGui) return;
|
||||
|
||||
GuiGraphics gui = event.getGuiGraphics();
|
||||
int width = event.getWindow().getGuiScaledWidth();
|
||||
int height = event.getWindow().getGuiScaledHeight();
|
||||
|
||||
int y = height - 48;
|
||||
int xTempo = 8;
|
||||
int xSanity = width - BAR_WIDTH - 8;
|
||||
|
||||
float sanity = ClientData.SANITY;
|
||||
float insanity = ClientData.INSANITY;
|
||||
float tempo = ClientData.TEMPO;
|
||||
|
||||
float sanityPercent = sanity / 80f;
|
||||
float insanityPercent = insanity / 80f; // same max as sanity (80)
|
||||
float tempoPercent = tempo / 120f;
|
||||
|
||||
float sanityPercent = sanity / ClientData.MAX_SANITY;
|
||||
float insanityPercent = insanity / ClientData.MAX_SANITY;
|
||||
float tempoPercent = (float) tempo / (float) ClientData.MAX_TEMPO;
|
||||
int sanityFill = (int) (BAR_WIDTH * sanityPercent);
|
||||
int tempoFill = (int) (BAR_WIDTH * tempoPercent);
|
||||
int insanityFill = (int) (BAR_WIDTH * insanityPercent);
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
drawRoundedBar(gui, xTempo, y, BAR_WIDTH, BAR_HEIGHT, 0xFF33AFFF, tempoFill);
|
||||
gui.drawString(mc.font, Component.literal("Tempo"), xTempo, y - 10, 0x66CCFF, false);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.fretux.mindmotion.client.effects;
|
||||
|
||||
import io.redspace.ironsspellbooks.api.registry.AttributeRegistry;
|
||||
import net.fretux.mindmotion.player.PlayerCapabilityProvider;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class IronsSpellbooksCompatMM {
|
||||
public static final double TEMPO_PER_PERCENT = 3;
|
||||
private static final UUID TEMPO_MANA_REGEN_UUID =
|
||||
UUID.fromString("de4f16ad-73b3-4b99-bf77-44c9878222aa");
|
||||
|
||||
private IronsSpellbooksCompatMM() {}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return ModList.get().isLoaded("irons_spellbooks");
|
||||
}
|
||||
public static void applyTempo(Player player) {
|
||||
if (!isLoaded()) return;
|
||||
player.getCapability(PlayerCapabilityProvider.TEMPO).ifPresent(tempoCap -> {
|
||||
int tempo = tempoCap.getTempo();
|
||||
applyTempoToManaRegen(player, tempo);
|
||||
});
|
||||
}
|
||||
|
||||
public static void applyTempoToManaRegen(Player player, int tempo) {
|
||||
Attribute manaRegenAttr = (Attribute) AttributeRegistry.MANA_REGEN.get();
|
||||
if (manaRegenAttr == null) return;
|
||||
AttributeInstance inst = player.getAttribute(manaRegenAttr);
|
||||
if (inst == null) return;
|
||||
inst.removeModifier(TEMPO_MANA_REGEN_UUID);
|
||||
if (tempo <= 0) {
|
||||
return;
|
||||
}
|
||||
double bonusPercent = (double) tempo / TEMPO_PER_PERCENT;
|
||||
double multiplier = bonusPercent / 100.0;
|
||||
inst.addTransientModifier(new AttributeModifier(
|
||||
TEMPO_MANA_REGEN_UUID,
|
||||
"MindMotion Tempo mana regen",
|
||||
multiplier,
|
||||
AttributeModifier.Operation.MULTIPLY_BASE
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -38,22 +38,17 @@ public class SanityShaderHandler {
|
||||
@SubscribeEvent
|
||||
public static void onRenderWorld(RenderLevelStageEvent event) {
|
||||
if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_LEVEL) return;
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc.player == null || mc.level == null) return;
|
||||
|
||||
float sanity = ClientData.SANITY;
|
||||
float insanity = ClientData.INSANITY;
|
||||
float maxSanity = 80f;
|
||||
|
||||
float maxSanity = ClientData.MAX_SANITY;
|
||||
float sanityPct = sanity / maxSanity;
|
||||
float insanityPct = insanity / maxSanity;
|
||||
|
||||
float baseDesat = 0f;
|
||||
if (sanityPct < 0.70f) {
|
||||
baseDesat = 1f - (sanityPct / 0.70f);
|
||||
}
|
||||
|
||||
float insanityBoost = 0.75f * insanityPct;
|
||||
float target = Math.max(baseDesat, insanityBoost);
|
||||
if (sanity <= 0f) target = 1f;
|
||||
@@ -73,7 +68,6 @@ public class SanityShaderHandler {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PostChain chain = mc.gameRenderer.currentEffect();
|
||||
if (chain == null) return;
|
||||
try {
|
||||
@@ -107,13 +101,10 @@ public class SanityShaderHandler {
|
||||
blur = Math.min(blur, 1f);
|
||||
vig = Math.min(vig, 1f);
|
||||
fog = Math.min(fog, 1f);
|
||||
|
||||
var uBlur = effect.getUniform("BlurAmount");
|
||||
if (uBlur != null) uBlur.set(blur);
|
||||
|
||||
var uVig = effect.getUniform("Vignette");
|
||||
if (uVig != null) uVig.set(vig);
|
||||
|
||||
var uFog = effect.getUniform("FogStrength");
|
||||
if (uFog != null) uFog.set(fog);
|
||||
float shake = 0f;
|
||||
@@ -151,10 +142,8 @@ public class SanityShaderHandler {
|
||||
@SubscribeEvent
|
||||
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
|
||||
if (!event.getEntity().level().isClientSide()) return;
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
currentStrength = 0f;
|
||||
|
||||
mc.execute(() -> {
|
||||
if (mc.gameRenderer.currentEffect() != null) {
|
||||
mc.gameRenderer.shutdownEffect();
|
||||
|
||||
Reference in New Issue
Block a user