diff --git a/src/main/java/dev/tr7zw/exordium/access/VanillaBufferAccess.java b/src/main/java/dev/tr7zw/exordium/access/VanillaBufferAccess.java index 152014b..c9ab037 100644 --- a/src/main/java/dev/tr7zw/exordium/access/VanillaBufferAccess.java +++ b/src/main/java/dev/tr7zw/exordium/access/VanillaBufferAccess.java @@ -10,11 +10,6 @@ interface PlayerListOverlayAccess extends VanillaBufferAccess { LegacyBuffer getPlayerListOverlayBuffer(); } - interface ScoreBoardOverlayAccess extends VanillaBufferAccess { - - LegacyBuffer getScoreBoardOverlayBuffer(); - } - interface BossHealthOverlayAccess extends VanillaBufferAccess { LegacyBuffer getHotbarOverlayBuffer(); } diff --git a/src/main/java/dev/tr7zw/exordium/components/BufferManager.java b/src/main/java/dev/tr7zw/exordium/components/BufferManager.java index 6addc1d..8d71ceb 100644 --- a/src/main/java/dev/tr7zw/exordium/components/BufferManager.java +++ b/src/main/java/dev/tr7zw/exordium/components/BufferManager.java @@ -10,6 +10,7 @@ import dev.tr7zw.exordium.components.vanilla.DebugOverlayComponent; import dev.tr7zw.exordium.components.vanilla.ExperienceComponent; import dev.tr7zw.exordium.components.vanilla.HotbarComponent; +import dev.tr7zw.exordium.components.vanilla.ScoreboardComponent; import dev.tr7zw.exordium.components.vanilla.VignetteComponent; import dev.tr7zw.exordium.versionless.config.Config; import lombok.NoArgsConstructor; @@ -29,10 +30,7 @@ public void initialize() { registerBuffer(CrosshairComponent.getId(), new CrosshairComponent(), () -> inst.config.crosshairSettings); registerBuffer(VignetteComponent.getId(), new VignetteComponent(), () -> inst.config.vignetteSettings); registerBuffer(ExperienceComponent.getId(), new ExperienceComponent(), () -> inst.config.experienceSettings); - -// vanillaBuffers.put(new ResourceLocation("scoreboard"), -// gui -> ((ScoreBoardOverlayAccess) gui).getScoreBoardOverlayBuffer()); - + registerBuffer(ScoreboardComponent.getId(), new ScoreboardComponent(), () -> inst.config.scoreboardSettings); registerBuffer(HotbarComponent.getId(), new HotbarComponent(), () -> inst.config.hotbarSettings); registerBuffer(ChatComponent.getId(), new ChatComponent(), () -> inst.config.chatSettings); diff --git a/src/main/java/dev/tr7zw/exordium/components/vanilla/ScoreboardComponent.java b/src/main/java/dev/tr7zw/exordium/components/vanilla/ScoreboardComponent.java new file mode 100644 index 0000000..5882183 --- /dev/null +++ b/src/main/java/dev/tr7zw/exordium/components/vanilla/ScoreboardComponent.java @@ -0,0 +1,32 @@ +package dev.tr7zw.exordium.components.vanilla; + +import java.util.Objects; + +import dev.tr7zw.exordium.components.BufferComponent; +import dev.tr7zw.exordium.util.ScoreboardHelper; +import dev.tr7zw.exordium.util.ScoreboardHelper.ScoreboardState; +import dev.tr7zw.util.NMSHelper; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.resources.ResourceLocation; + +public class ScoreboardComponent implements BufferComponent { + + private static final Minecraft minecraft = Minecraft.getInstance(); + @Getter + private static final ResourceLocation id = NMSHelper.getResourceLocation("minecraft", "scoreboard"); + + private String scoreboardState = null; + + @Override + public void captureState(Void context) { + scoreboardState = "" + ScoreboardHelper.getScoreboardData(); + } + + @Override + public boolean hasChanged(int tickCount, Void context) { + ScoreboardState cur = ScoreboardHelper.getScoreboardData(); + return !Objects.equals(scoreboardState, "" + cur); // dirty workaround + } + +} diff --git a/src/main/java/dev/tr7zw/exordium/mixin/ScoreboardMixin.java b/src/main/java/dev/tr7zw/exordium/mixin/ScoreboardMixin.java index 352ff30..a8d001d 100644 --- a/src/main/java/dev/tr7zw/exordium/mixin/ScoreboardMixin.java +++ b/src/main/java/dev/tr7zw/exordium/mixin/ScoreboardMixin.java @@ -1,60 +1,31 @@ package dev.tr7zw.exordium.mixin; -import java.util.Objects; - import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import dev.tr7zw.exordium.ExordiumModBase; -import dev.tr7zw.exordium.access.VanillaBufferAccess.ScoreBoardOverlayAccess; -import dev.tr7zw.exordium.render.BufferedComponent; -import dev.tr7zw.exordium.render.LegacyBuffer; -import dev.tr7zw.exordium.util.ScoreboardHelper; -import dev.tr7zw.exordium.util.ScoreboardHelper.ScoreboardState; -import net.minecraft.client.Minecraft; +import dev.tr7zw.exordium.components.BufferInstance; +import dev.tr7zw.exordium.components.vanilla.ScoreboardComponent; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.world.scores.Objective; @Mixin(Gui.class) -public class ScoreboardMixin implements ScoreBoardOverlayAccess { - - @Shadow - private Minecraft minecraft; - private String scoreboardState = null; - - private LegacyBuffer scoreboardBuffer = new LegacyBuffer(true, - () -> ExordiumModBase.instance.config.scoreboardSettings) { - - @Override - public boolean shouldRenderNextCappedFrame() { - ScoreboardState cur = ScoreboardHelper.getScoreboardData(); - return !Objects.equals(scoreboardState, "" + cur); // dirty workaround - } - - @Override - public void captureState() { - scoreboardState = "" + ScoreboardHelper.getScoreboardData(); - } - }; +public class ScoreboardMixin { @WrapOperation(method = "renderScoreboardSidebar", at = { @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;displayScoreboardSidebar(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/scores/Objective;)V"), }) private void displayScoreboardSidebarWrapper(Gui gui, GuiGraphics guiGraphics, Objective objective, final Operation operation) { - if (!scoreboardBuffer.render()) { + BufferInstance buffer = ExordiumModBase.instance.getBufferManager() + .getBufferInstance(ScoreboardComponent.getId(), Void.class); + if (!buffer.renderBuffer(0, null)) { operation.call(gui, guiGraphics, objective); } - scoreboardBuffer.renderEnd(); - } - - @Override - public LegacyBuffer getScoreBoardOverlayBuffer() { - return scoreboardBuffer; + buffer.postRender(null); } }