diff --git a/src/client/java/symbolics/division/modfest_credits/Modfest_creditsClient.java b/src/client/java/symbolics/division/modfest_credits/Modfest_creditsClient.java index eccf25c..7693da5 100644 --- a/src/client/java/symbolics/division/modfest_credits/Modfest_creditsClient.java +++ b/src/client/java/symbolics/division/modfest_credits/Modfest_creditsClient.java @@ -3,6 +3,7 @@ import com.mojang.datafixers.util.Pair; import net.fabricmc.api.ClientModInitializer; import net.minecraft.client.gui.screen.CreditsScreen; +import net.minecraft.client.gui.screen.GameMenuScreen; import net.minecraft.client.gui.screen.option.CreditsAndAttributionScreen; import java.util.Comparator; @@ -12,6 +13,5 @@ public class Modfest_creditsClient implements ClientModInitializer { @Override public void onInitializeClient() { // This entrypoint is suitable for setting up client-specific logic, such as rendering. - } } \ No newline at end of file diff --git a/src/client/java/symbolics/division/modfest_credits/mixin/CreditsScreenMixin.java b/src/client/java/symbolics/division/modfest_credits/mixin/CreditsScreenMixin.java index 2812b56..9201131 100644 --- a/src/client/java/symbolics/division/modfest_credits/mixin/CreditsScreenMixin.java +++ b/src/client/java/symbolics/division/modfest_credits/mixin/CreditsScreenMixin.java @@ -1,19 +1,19 @@ package symbolics.division.modfest_credits.mixin; +import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import net.minecraft.client.gui.screen.CreditsScreen; -import net.minecraft.util.Identifier; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.sound.MusicSound; import org.spongepowered.asm.mixin.Mixin; +import symbolics.division.modfest_credits.Modfest_credits; @Mixin(CreditsScreen.class) public class CreditsScreenMixin { - private Identifier CREDITS_TEXT_LOCATION; -// @WrapOperation( -// method = "init", -// at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/CreditsScreen;CREDITS_TEXT_LOCATION:Lnet/minecraft/util/Identifier;") -// ) -// public Identifier injectCredits(Operation original) { -// return Identifier.of("mf121", "texts/credits.json"); -// } + @WrapMethod(method = "getMusic") + private MusicSound wrapGetMusic(Operation orig) { + return new MusicSound(new RegistryEntry.Direct<>(Modfest_credits.CREDITS_MUSIC), 20, 600, true); + } } diff --git a/src/client/java/symbolics/division/modfest_credits/mixin/GameMenuScreenMixin.java b/src/client/java/symbolics/division/modfest_credits/mixin/GameMenuScreenMixin.java new file mode 100644 index 0000000..70a4aaf --- /dev/null +++ b/src/client/java/symbolics/division/modfest_credits/mixin/GameMenuScreenMixin.java @@ -0,0 +1,43 @@ +package symbolics.division.modfest_credits.mixin; + +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.CreditsScreen; +import net.minecraft.client.gui.screen.GameMenuScreen; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.TitleScreen; +import net.minecraft.client.gui.screen.option.CreditsAndAttributionScreen; +import net.minecraft.client.gui.screen.option.OptionsScreen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.GridWidget; +import net.minecraft.text.Text; +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; + +import java.util.function.Supplier; + +@Mixin(TitleScreen.class) +public abstract class GameMenuScreenMixin extends Screen { + protected GameMenuScreenMixin(Text title) { + super(title); + } + + + @Inject( + method = "init", + at = @At("HEAD") + ) + private void initWidgets(CallbackInfo ci) { + int l = this.height / 4 + 48; + this.addDrawableChild(ButtonWidget.builder(Text.translatable("credits_and_attribution.button.credits"), (button) -> { + this.client.setScreen( + new CreditsScreen(false, () -> { + MinecraftClient.getInstance().setScreen((TitleScreen)(Object)this); + }) + ); + }).dimensions(this.width / 2 - 100, l + 72 + 12 + 20 + 12, 98 * 2, 20).build()); + } +} diff --git a/src/main/java/symbolics/division/modfest_credits/Modfest_credits.java b/src/main/java/symbolics/division/modfest_credits/Modfest_credits.java index 12be008..7e16247 100644 --- a/src/main/java/symbolics/division/modfest_credits/Modfest_credits.java +++ b/src/main/java/symbolics/division/modfest_credits/Modfest_credits.java @@ -2,6 +2,10 @@ import net.fabricmc.api.ModInitializer; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.sound.SoundEvent; +import net.minecraft.util.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -9,8 +13,12 @@ public class Modfest_credits implements ModInitializer { public static final String MOD_ID = "modfest_credits"; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + + public static Identifier CREDITS_MUSIC_ID = Identifier.of(MOD_ID, "credits_music"); + public static SoundEvent CREDITS_MUSIC = SoundEvent.of(CREDITS_MUSIC_ID); + @Override public void onInitialize() { - + Registry.register(Registries.SOUND_EVENT, CREDITS_MUSIC_ID, CREDITS_MUSIC); } } \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/textures/gui/title/edition.png b/src/main/resources/assets/minecraft/textures/gui/title/edition.png new file mode 100644 index 0000000..153ddba Binary files /dev/null and b/src/main/resources/assets/minecraft/textures/gui/title/edition.png differ diff --git a/src/main/resources/assets/modfest_credits/sounds.json b/src/main/resources/assets/modfest_credits/sounds.json new file mode 100644 index 0000000..9eb0e83 --- /dev/null +++ b/src/main/resources/assets/modfest_credits/sounds.json @@ -0,0 +1,8 @@ +{ + "credits_music": { + "subtitle": "subtitles.mf_credits.credits_music", + "sounds": [ + "modfest_credits:credits_music" + ] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/modfest_credits/sounds/credits_music.ogg b/src/main/resources/assets/modfest_credits/sounds/credits_music.ogg new file mode 100644 index 0000000..05c9133 Binary files /dev/null and b/src/main/resources/assets/modfest_credits/sounds/credits_music.ogg differ