-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix not calling forge events after cancel, fix compat with old skyhan…
…ni, add skyhanni custom scoreboard support
- Loading branch information
Showing
11 changed files
with
222 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package at.hannibal2.skyhanni.config; | ||
|
||
import at.hannibal2.skyhanni.config.features.gui.GUIConfig; | ||
import at.hannibal2.skyhanni.config.features.misc.MiscConfig; | ||
|
||
public class Features { | ||
public GUIConfig gui = new GUIConfig(); | ||
public MiscConfig misc = new MiscConfig(); | ||
} |
2 changes: 2 additions & 0 deletions
2
src/dummy/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package at.hannibal2.skyhanni.config.features.gui; | ||
|
||
import at.hannibal2.skyhanni.config.features.gui.customscoreboard.CustomScoreboardConfig; | ||
import at.hannibal2.skyhanni.config.features.misc.compacttablist.CompactTabListConfig; | ||
|
||
public class GUIConfig { | ||
public CompactTabListConfig compactTabList = new CompactTabListConfig(); | ||
public CustomScoreboardConfig customScoreboard = new CustomScoreboardConfig(); | ||
} |
7 changes: 7 additions & 0 deletions
7
...va/at/hannibal2/skyhanni/config/features/gui/customscoreboard/CustomScoreboardConfig.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,7 @@ | ||
package at.hannibal2.skyhanni.config.features.gui.customscoreboard; | ||
|
||
import at.hannibal2.skyhanni.deps.moulconfig.observer.Property; | ||
|
||
public class CustomScoreboardConfig { | ||
public Property<Boolean> enabled = Property.of(false); // todo | ||
} |
7 changes: 7 additions & 0 deletions
7
src/dummy/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.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,7 @@ | ||
package at.hannibal2.skyhanni.config.features.misc; | ||
|
||
import at.hannibal2.skyhanni.config.features.misc.compacttablist.CompactTabListConfig; | ||
|
||
public class MiscConfig { | ||
public CompactTabListConfig compactTabList = new CompactTabListConfig(); | ||
} |
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
41 changes: 33 additions & 8 deletions
41
src/main/java/org/polyfrost/vanillahud/mixin/GuiIngameForgeMixin_CancelLow.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 |
---|---|---|
@@ -1,46 +1,71 @@ | ||
package org.polyfrost.vanillahud.mixin; | ||
|
||
import net.minecraftforge.client.GuiIngameForge; | ||
import net.minecraftforge.client.event.RenderGameOverlayEvent; | ||
import org.polyfrost.vanillahud.hud.*; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(value = GuiIngameForge.class, priority = 999) | ||
public class GuiIngameForgeMixin_CancelLow { | ||
public abstract class GuiIngameForgeMixin_CancelLow { | ||
@Shadow protected abstract void post(RenderGameOverlayEvent.ElementType type); | ||
|
||
@Inject(method = "renderJumpBar", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glColor4f(FFFF)V", ordinal = 0), cancellable = true, remap = false) | ||
private void cancelHorsePower(CallbackInfo ci) { | ||
if (!Experience.hud.shouldRender()) ci.cancel(); | ||
if (!Experience.hud.shouldRender()) { | ||
post(RenderGameOverlayEvent.ElementType.JUMPBAR); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "renderHealthMount", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V"), cancellable = true) | ||
private void cancelHorseHealth(CallbackInfo ci) { | ||
if (!Hunger.getMountHud().shouldRender()) ci.cancel(); | ||
if (!Hunger.getMountHud().shouldRender()) { | ||
post(RenderGameOverlayEvent.ElementType.HEALTHMOUNT); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "renderExperience", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V", ordinal = 0), cancellable = true) | ||
private void cancelExpBar(CallbackInfo ci) { | ||
if (!Experience.hud.shouldRender()) ci.cancel(); | ||
if (!Experience.hud.shouldRender()) { | ||
post(RenderGameOverlayEvent.ElementType.EXPERIENCE); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "renderHealth", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/Profiler;startSection(Ljava/lang/String;)V"), cancellable = true) | ||
private void cancelHealth(CallbackInfo ci) { | ||
if (!Health.hud.shouldRender()) ci.cancel(); | ||
if (!Health.hud.shouldRender()) { | ||
post(RenderGameOverlayEvent.ElementType.HEALTH); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "renderFood", at = @At(value = "HEAD"), cancellable = true, remap = false) | ||
private void cancelHunger(CallbackInfo ci) { | ||
if (!Hunger.hud.shouldRender()) ci.cancel(); | ||
if (!Hunger.hud.shouldRender()) { | ||
post(RenderGameOverlayEvent.ElementType.FOOD); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "renderArmor", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/Profiler;startSection(Ljava/lang/String;)V"), cancellable = true) | ||
private void cancelArmor(CallbackInfo ci) { | ||
if (!Armor.hud.shouldRender()) ci.cancel(); | ||
if (!Armor.hud.shouldRender()) { | ||
post(RenderGameOverlayEvent.ElementType.ARMOR); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "renderAir", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/Profiler;startSection(Ljava/lang/String;)V"), cancellable = true) | ||
private void cancelAir(CallbackInfo ci) { | ||
if (!Air.hud.shouldRender()) ci.cancel(); | ||
if (!Air.hud.shouldRender()) { | ||
post(RenderGameOverlayEvent.ElementType.AIR); | ||
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
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,53 @@ | ||
package org.polyfrost.vanillahud.utils; | ||
|
||
import cc.polyfrost.oneconfig.events.event.Stage; | ||
import cc.polyfrost.oneconfig.events.event.TickEvent; | ||
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; | ||
import cc.polyfrost.oneconfig.libs.universal.UMinecraft; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.scoreboard.ScoreObjective; | ||
import net.minecraft.util.StringUtils; | ||
|
||
public class Utils { | ||
|
||
public static boolean inSkyblock = false; | ||
private int tickAmount = 0; | ||
|
||
@Subscribe | ||
private void onTick(TickEvent event) { | ||
if (event.stage == Stage.START) { | ||
tickAmount++; | ||
if (tickAmount % 20 == 0) { | ||
if (UMinecraft.getPlayer() != null) { | ||
Minecraft mc = UMinecraft.getMinecraft(); | ||
if (mc.theWorld != null && !mc.isSingleplayer()) { | ||
ScoreObjective scoreboardObj = mc.theWorld.getScoreboard().getObjectiveInDisplaySlot(1); | ||
if (scoreboardObj != null) { | ||
String scObjName = cleanSB(scoreboardObj.getDisplayName()); | ||
if (scObjName.contains("SKYBLOCK")) { | ||
inSkyblock = true; | ||
return; | ||
} | ||
} | ||
} | ||
inSkyblock = false; | ||
} | ||
|
||
tickAmount = 0; | ||
} | ||
} | ||
} | ||
|
||
private static String cleanSB(String scoreboard) { | ||
char[] nvString = StringUtils.stripControlCodes(scoreboard).toCharArray(); | ||
StringBuilder cleaned = new StringBuilder(); | ||
|
||
for (char c : nvString) { | ||
if ((int) c > 20 && (int) c < 127) { | ||
cleaned.append(c); | ||
} | ||
} | ||
|
||
return cleaned.toString(); | ||
} | ||
} |
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
53fc72c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty for doing this <3