-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
191 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,4 +209,6 @@ public interface ConfigAdapter { | |
boolean hookTFC(); | ||
|
||
boolean hookArsNouveau(); | ||
|
||
boolean hookApoli(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Fabric/src/main/java/com/afoxxvi/asteorbar/mixin/third/OriginPowerHudMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.afoxxvi.asteorbar.mixin.third; | ||
|
||
import com.afoxxvi.asteorbar.AsteorBar; | ||
import io.github.apace100.apoli.screen.PowerHudRenderer; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(PowerHudRenderer.class) | ||
public abstract class OriginPowerHudMixin { | ||
@Inject(method = "render(Lnet/minecraft/client/gui/GuiGraphics;F)V", at = @At("HEAD"), cancellable = true) | ||
void render(GuiGraphics context, float delta, CallbackInfo ci) { | ||
if (AsteorBar.config.enableOverlay() && AsteorBar.compatibility.apoli && AsteorBar.config.hookApoli()) { | ||
ci.cancel(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
Fabric/src/main/java/com/afoxxvi/asteorbar/overlay/parts/OriginsOverlay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package com.afoxxvi.asteorbar.overlay.parts; | ||
|
||
import com.afoxxvi.asteorbar.AsteorBar; | ||
import com.afoxxvi.asteorbar.overlay.RenderGui; | ||
import com.afoxxvi.asteorbar.utils.GuiHelper; | ||
import com.afoxxvi.asteorbar.utils.Utils; | ||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import io.github.apace100.apoli.component.PowerHolderComponent; | ||
import io.github.apace100.apoli.power.HudRendered; | ||
import io.github.apace100.apoli.util.HudRender; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
import java.util.Comparator; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public class OriginsOverlay extends BaseOverlay { | ||
private SimpleBarOverlay subOverlay = null; | ||
private static final int BAR_WIDTH = 71; | ||
private static final int BAR_HEIGHT = 8; | ||
private static final int ICON_SIZE = 8; | ||
|
||
private static final int BAR_INDEX_OFFSET = BAR_HEIGHT + 2; | ||
private static final int ICON_INDEX_OFFSET = ICON_SIZE + 1; | ||
|
||
@Override | ||
public void renderOverlay(RenderGui gui, GuiGraphics guiGraphics, float partialTick, int screenWidth, int screenHeight) { | ||
if (!(AsteorBar.compatibility.apoli && AsteorBar.config.hookApoli())) { | ||
return; | ||
} | ||
final var player = Minecraft.getInstance().player; | ||
if (player == null) { | ||
return; | ||
} | ||
PowerHolderComponent.KEY.get(player).getPowers().stream().filter(HudRendered.class::isInstance).map(p -> (HudRendered) p).filter(HudRendered::shouldRender).map(h -> Map.entry(h, h.getRenderSettings().getChildOrSelf(player))).filter(entry -> entry.getValue().isPresent()).sorted(Map.Entry.comparingByValue(Comparator.comparing(Optional::get))).forEach(entry -> { | ||
HudRendered hudRendered = entry.getKey(); | ||
HudRender hudRender = entry.getValue().get(); | ||
if (subOverlay == null) { | ||
subOverlay = new OriginSimpleBar(); | ||
} | ||
final var originSimpleBar = (OriginSimpleBar) subOverlay; | ||
originSimpleBar.hudRender = hudRender; | ||
originSimpleBar.hudRendered = hudRendered; | ||
subOverlay.render(gui, guiGraphics, partialTick, screenWidth, screenHeight); | ||
}); | ||
} | ||
|
||
private static class OriginSimpleBar extends SimpleBarOverlay { | ||
protected HudRender hudRender; | ||
protected HudRendered hudRendered; | ||
|
||
private static int getFillColor(int index) { | ||
switch (index) { | ||
case 0 -> { | ||
return 0xffc78c79; | ||
} | ||
case 1 -> { | ||
return 0xff385fff; | ||
} | ||
case 2 -> { | ||
return 0xfffaff35; | ||
} | ||
case 3 -> { | ||
return 0xffff33ea; | ||
} | ||
case 4, 5 -> { | ||
return 0xffffffff; | ||
} | ||
case 6 -> { | ||
return 0xff608d6f; | ||
} | ||
case 7 -> { | ||
return 0xffffc650; | ||
} | ||
case 8 -> { | ||
return 0xff339127; | ||
} | ||
default -> { | ||
return 0xffe0e0e0; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected Parameters getParameters(Player player) { | ||
if (hudRendered == null || hudRender == null || hudRendered.getFill() == 0.0) { | ||
return null; | ||
} | ||
Parameters parameters = new Parameters(); | ||
parameters.value = hudRendered.getFill(); | ||
parameters.capacity = 1.0F; | ||
parameters.fillColor = getFillColor(hudRender.getBarIndex()); | ||
parameters.boundColor = Utils.mixColor(0xff000000, parameters.fillColor, 0.5F); | ||
parameters.emptyColor = 0xff202c25; | ||
return parameters; | ||
} | ||
|
||
@Override | ||
protected void drawDecorations(GuiGraphics guiGraphics, int left, int top, int right, int bottom, Parameters parameters, boolean flip) { | ||
int iconU = (BAR_WIDTH + 2) + hudRender.getIconIndex() * ICON_INDEX_OFFSET; | ||
int barV = BAR_HEIGHT + hudRender.getBarIndex() * BAR_INDEX_OFFSET; | ||
RenderSystem.setShaderTexture(0, hudRender.getSpriteLocation()); | ||
GuiHelper.drawTexturedRect(guiGraphics, (right + left) / 2 - ICON_SIZE / 2, (top + bottom) / 2 - ICON_SIZE / 2, iconU, barV, ICON_SIZE, ICON_SIZE); | ||
RenderSystem.setShaderTexture(0, LIGHTMAP_TEXTURE); | ||
} | ||
|
||
@Override | ||
protected boolean shouldRender(Player player) { | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sat Feb 17 16:06:01 GMT+08:00 2024 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |