Skip to content

Commit

Permalink
Update to mc1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Jan 18, 2025
1 parent 132facd commit 52e247c
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 36 deletions.
17 changes: 17 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,24 @@ plugins {
id("net.neoforged.moddev")
}

// Vanilla depends on ASM 9.3, MDG makes that a 'strict' version constraint,
// but Mixin and MixinExtras needs newer ASM so we override that here.
configurations.configureEach {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == "org.ow2.asm") {
details.useVersion(asm_version)
details.because("Mixin requires new ASM")
}
}
}

dependencies {
compileOnly "org.ow2.asm:asm:${asm_version}"
compileOnly "org.ow2.asm:asm-analysis:${asm_version}"
compileOnly "org.ow2.asm:asm-commons:${asm_version}"
compileOnly "org.ow2.asm:asm-tree:${asm_version}"
compileOnly "org.ow2.asm:asm-util:${asm_version}"

compileOnly("org.spongepowered:mixin:${mixin_version}")
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static void display(Component name, Supplier<ResourceLocation> spriteSup

switch(style) {
case Toast -> {
mc.getToasts().addToast(new NowPlayingToast(name, spriteSupplier.get(),
mc.getToastManager().addToast(new NowPlayingToast(name, spriteSupplier.get(),
options().toastTime * 1000L, options().toastScale, options().darkToast));
if (options().narrate) mc.getNarrator().sayNow(message);
}
Expand All @@ -111,7 +111,7 @@ private static void display(Component name, Supplier<ResourceLocation> spriteSup
mc.gui.setOverlayMessage(message, true);
((GuiAccessor)mc.gui).setOverlayMessageTime(options().hotbarTime * 20);
} else if (options().fallbackToast) {
mc.getToasts().addToast(new NowPlayingToast(name, spriteSupplier.get(),
mc.getToastManager().addToast(new NowPlayingToast(name, spriteSupplier.get(),
options().toastTime * 1000L, options().toastScale, options().darkToast));
}
if (options().narrate) mc.getNarrator().sayNow(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@

import com.github.scotsguy.nowplaying.config.Config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.toasts.Toast;
import net.minecraft.client.gui.components.toasts.ToastComponent;
import net.minecraft.client.gui.components.toasts.ToastManager;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
Expand All @@ -51,6 +53,8 @@ public class NowPlayingToast implements Toast {
private final ResourceLocation sprite;
private final int nowPlayingColor;
private final int titleColor;
private Toast.Visibility wantedVisibility;
private long startTime;

private static final int TEXT_LEFT_MARGIN = 30;
private static final int TEXT_RIGHT_MARGIN = 7;
Expand All @@ -72,7 +76,18 @@ public NowPlayingToast(Component description, ResourceLocation discSprite, long
}

@Override
public @NotNull Visibility render(@NotNull GuiGraphics graphics, @NotNull ToastComponent toast, long startTime) {
public @NotNull Visibility getWantedVisibility() {
return wantedVisibility;
}

@Override
public void update(@NotNull ToastManager toastManager, long l) {
this.wantedVisibility = startTime >= this.displayTime ? Visibility.HIDE : Visibility.SHOW;
}

@Override
public void render(@NotNull GuiGraphics graphics, @NotNull Font font, long startTime) {
this.startTime = startTime;
if (scale != 1.0F) {
graphics.pose().pushPose();
graphics.pose().translate(160 * (1 - scale), 0.0F, 0.0F);
Expand All @@ -86,7 +101,7 @@ public NowPlayingToast(Component description, ResourceLocation discSprite, long

if (width == 160 && textLines.size() <= 1) {
// Text fits, draw the whole toast from the texture
graphics.blitSprite(sprite, 0, 0, width, height);
graphics.blitSprite(RenderType::guiTextured, sprite, 0, 0, width, height);
} else {
// Stretch toast by drawing the sprite multiple times
height = height + Math.max(0, textLines.size() - (Config.options().simpleToast ? 2 : 1)) * 12;
Expand Down Expand Up @@ -120,22 +135,21 @@ public NowPlayingToast(Component description, ResourceLocation discSprite, long
}

// Draw icon
graphics.blit(discSprite, 9, (height / 2) - (16 / 2), 0, 0, 16, 16, 16, 16);
graphics.blit(RenderType::guiTextured, discSprite, 9, (height / 2) - (16 / 2), 0, 0, 16, 16, 16, 16);

if (scale != 1.0F) graphics.pose().popPose();
return startTime >= this.displayTime ? Visibility.HIDE : Visibility.SHOW;
}

private void renderBackgroundRow(GuiGraphics graphics, int i, int vOffset, int y, int vHeight) {
int uWidth = vOffset == 0 ? 20 : 5;
int n = Math.min(60, i - uWidth);

graphics.blitSprite(sprite, 160, 32, 0, vOffset, 0, y, uWidth, vHeight);
graphics.blitSprite(RenderType::guiTextured, sprite, 160, 32, 0, vOffset, 0, y, uWidth, vHeight);

for (int o = uWidth; o < i - n; o += 64) {
graphics.blitSprite(sprite, 160, 32, 32, vOffset, o, y, Math.min(64, i - o - n), vHeight);
graphics.blitSprite(RenderType::guiTextured, sprite, 160, 32, 32, vOffset, o, y, Math.min(64, i - o - n), vHeight);
}

graphics.blitSprite(sprite, 160, 32, 160 - n, vOffset, i - n, y, n, vHeight);
graphics.blitSprite(RenderType::guiTextured, sprite, 160, 32, 160 - n, vOffset, i - n, y, n, vHeight);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LevelEventHandler;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.item.JukeboxSong;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(LevelRenderer.class)
public class MixinLevelRenderer {
@Mixin(LevelEventHandler.class)
public class MixinLevelEventHandler {
@WrapOperation(
method = "playJukeboxSong",
at = @At(
Expand All @@ -45,6 +45,6 @@ public class MixinLevelRenderer {
)
private void display(Gui instance, Component text, Operation<Void> original,
@Local JukeboxSong song, @Local SoundEvent sound) {
NowPlaying.displayDisc(song.description(), sound.getLocation());
NowPlaying.displayDisc(song.description(), sound.location());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(targets = "net.minecraft.client.gui.components.toasts.ToastComponent$ToastInstance")
public class MixinToastInstance<T extends Toast> {
@Final
@Mixin(targets = "net.minecraft.client.gui.components.toasts.ToastManager$ToastInstance")
public class MixinToastInstance {
@Shadow
private T toast;
private @Final Toast toast;

@WrapOperation(
method = "render",
method = "update",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/components/toasts/Toast$Visibility;playSound(Lnet/minecraft/client/sounds/SoundManager;)V"
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/resources/now-playing.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"mixins": [
],
"client": [
"MixinLevelRenderer",
"MixinLevelEventHandler",
"MixinMinecraft",
"MixinToastInstance",
"accessor.GuiAccessor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.profiling.ProfilerFiller;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -65,7 +64,7 @@ public ResourceLocation getFabricId() {
}

@Override
public @NotNull CompletableFuture<Void> reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) {
public @NotNull CompletableFuture<Void> reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, Executor backgroundExecutor, Executor gameExecutor) {
NowPlaying.onResourceReload();
return CompletableFuture.allOf(CompletableFuture.runAsync(() -> {}))
.thenCompose(preparationBarrier::wait)
Expand Down
30 changes: 16 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ java_versions_fabric=>=21
java_versions_neoforge=[21,)

# Minecraft
minecraft_version=1.21
minecraft_versions_fabric=>1.20.6 <1.22
minecraft_versions_neoforge=(1.20.6, 1.22)
minecraft_version=1.21.3
minecraft_versions_fabric=>1.21.1 <1.22
minecraft_versions_neoforge=(1.21.1, 1.22)

# Parchment https://parchmentmc.org/docs/getting-started#choose-a-version
parchment_minecraft_version=1.21
Expand All @@ -37,24 +37,24 @@ parchment_version=2024.11.10
# Fabric https://fabricmc.net/develop
fabric_loader_version=0.16.9
fabric_loader_versions=>=0.15.0
fabric_api_version=0.102.0+1.21
fabric_api_version=0.110.0+1.21.3
fabric_api_versions=*

# NeoForge https://projects.neoforged.net/neoforged/neoforge
neoforge_loader_versions=[1,)
neoforge_version=21.0.167
neoforge_versions=[21.0.143, 22)
neoforge_version=21.3.57
neoforge_versions=[21.2.0, 22)
# NeoForm https://projects.neoforged.net/neoforged/neoform
neoform_version=1.21-20240613.152323
neoform_version=1.21.3-20241023.131943

# Cloth Config https://modrinth.com/mod/9s6osm5g/versions
clothconfig_version=15.0.140
clothconfig_versions_fabric=>=15
clothconfig_versions_neoforge=[15,)
clothconfig_version=16.0.141
clothconfig_versions_fabric=>=16
clothconfig_versions_neoforge=[16,)

# ModMenu https://modrinth.com/mod/mOgUt4GM/versions
modmenu_version=11.0.3
modmenu_versions_fabric=>=11.0.0-beta.1
modmenu_version=12.0.0
modmenu_versions_fabric=>=12.0.0-beta.1

# GitHub, Modrinth, CurseForge releases
# Plural properties expect CSV lists
Expand All @@ -66,19 +66,21 @@ curseforge_slug=now-playing
release_type=BETA
# Fabric
release_mod_loaders_fabric=fabric,quilt
release_game_versions_fabric=1.21,1.21.1
release_game_versions_fabric=1.21.2,1.21.3
release_required_dep_ids_fabric_mr=P7dR8mSH,mOgUt4GM,9s6osm5g
release_required_dep_ids_fabric_cf=fabric-api,modmenu,cloth-config
# NeoForge
release_mod_loaders_neoforge=neoforge
release_game_versions_neoforge=1.21,1.21.1
release_game_versions_neoforge=1.21.2,1.21.3
release_required_dep_ids_neoforge_mr=9s6osm5g
release_required_dep_ids_neoforge_cf=cloth-config

# Mixin https://mvnrepository.com/artifact/org.spongepowered/mixin
mixin_version=0.8.7
# MixinExtras https://github.com/LlamaLad7/MixinExtras/releases
mixinextras_version=0.4.1
# ASM https://mvnrepository.com/artifact/org.ow2.asm/asm
asm_version=9.7

# Plugins
# Fabric Loom https://mvnrepository.com/artifact/net.fabricmc/fabric-loom
Expand Down

0 comments on commit 52e247c

Please sign in to comment.