Skip to content

Commit

Permalink
stop music when moving to credits
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed Nov 30, 2024
1 parent 252eec0 commit 163d718
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ authors=ModFest
contributors=Prospector, Sisby folk, acikek
license=MIT
# Mod Version
baseVersion=0.5.1
baseVersion=0.5.2
# Branch Metadata
branch=1.21
tagBranch=1.21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ private static Widget replaceReportBugs(GridWidget.Adder instance, Widget widget
@WrapOperation(method = "initWidgets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget$Adder;add(Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;", ordinal = 6))
private Widget replacePlayerReporting(GridWidget.Adder instance, Widget widget, Operation<Widget> original) {
if (!BallotBox.CONFIG.replace_reporting_credits.value()) return original.call(instance, widget);
return instance.add(ButtonWidget.builder(Text.of(BallotBox.CONFIG.credits_text.value()), b -> MinecraftClient.getInstance().setScreen(new CreditsScreen(false, () -> MinecraftClient.getInstance().setScreen((GameMenuScreen) (Object) this)))).width(98).build());
return instance.add(ButtonWidget.builder(Text.of(BallotBox.CONFIG.credits_text.value()), b -> {
MinecraftClient.getInstance().getMusicTracker().stop();
MinecraftClient.getInstance().setScreen(new CreditsScreen(false, () -> MinecraftClient.getInstance().setScreen((GameMenuScreen) (Object) this)));
}).width(98).build());
}

@Inject(method = "render", at = @At("TAIL"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ protected TitleScreenMixin(Text title) {
@WrapOperation(method = "initWidgetsNormal", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;addDrawableChild(Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element;", ordinal = 2))
private Element replaceRealms(TitleScreen instance, Element element, Operation<Element> original, int y, int spacingY) {
if (!BallotBox.CONFIG.replace_realms_credits.value()) return original.call(instance, element);
return addDrawableChild(ButtonWidget.builder(Text.of(BallotBox.CONFIG.credits_text.value()), b -> MinecraftClient.getInstance().setScreen(new CreditsScreen(false, () -> MinecraftClient.getInstance().setScreen((TitleScreen) (Object) this))))
return addDrawableChild(ButtonWidget.builder(Text.of(BallotBox.CONFIG.credits_text.value()), b -> {
MinecraftClient.getInstance().getMusicTracker().stop();
MinecraftClient.getInstance().setScreen(new CreditsScreen(false, () -> MinecraftClient.getInstance().setScreen((TitleScreen) (Object) this)));
})
.dimensions(this.width / 2 - 100, y + spacingY * 2, 200, 20)
.build()
);
Expand Down

0 comments on commit 163d718

Please sign in to comment.