Skip to content

Commit

Permalink
Merge pull request #15 from KabanFriends/dev/1.21
Browse files Browse the repository at this point in the history
Update to 1.21
  • Loading branch information
KabanFriends committed Jun 14, 2024
2 parents 9dd37d6 + c7f28ad commit d9ddbd4
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class CraftGR {
public static final Component RECONNECT_ICON;

static {
ResourceLocation iconFont = new ResourceLocation(CraftGR.MOD_ID, "icons");
ResourceLocation iconFont = ResourceLocation.fromNamespaceAndPath(CraftGR.MOD_ID, "icons");
AUDIO_MUTED_ICON = Component.literal("M").withStyle(Style.EMPTY.withFont(iconFont));
RECONNECT_ICON = Component.literal("R").withStyle(Style.EMPTY.withFont(iconFont));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public class RadioOptionContainer extends AbstractContainerWidget {
private static final Component DISABLED_TOOLTIP = Component.translatable("text.craftgr.button.config.disabled");

private static final WidgetSprites CONFIG_BUTTON_SPRITES = new WidgetSprites(
new ResourceLocation(CraftGR.MOD_ID, "config"),
new ResourceLocation(CraftGR.MOD_ID, "config_disabled"),
new ResourceLocation(CraftGR.MOD_ID, "config_highlighted")
ResourceLocation.fromNamespaceAndPath(CraftGR.MOD_ID, "config"),
ResourceLocation.fromNamespaceAndPath(CraftGR.MOD_ID, "config_disabled"),
ResourceLocation.fromNamespaceAndPath(CraftGR.MOD_ID, "config_highlighted")
);

private final RadioVolumeSliderButton volumeSlider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package io.github.kabanfriends.craftgr.mixin;

import net.minecraft.client.gui.screens.OptionsSubScreen;
import net.minecraft.client.gui.components.OptionsList;
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
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(OptionsSubScreen.class)
public class MixinOptionsSubScreen extends Screen {

@Shadow
protected OptionsList list;

public MixinOptionsSubScreen(Component title) {
super(title);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,24 @@
import io.github.kabanfriends.craftgr.util.ThreadLocals;
import net.minecraft.client.OptionInstance;
import net.minecraft.client.gui.components.*;
import net.minecraft.client.gui.screens.SoundOptionsScreen;
import net.minecraft.client.gui.screens.options.SoundOptionsScreen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
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(SoundOptionsScreen.class)
public class MixinSoundOptionsScreen extends MixinOptionsSubScreen {

@Shadow
private OptionsList list;

private AbstractWidget volumeSlider;
private AbstractWidget configButton;

private static final WidgetSprites BUTTON_SPRITES = new WidgetSprites(
new ResourceLocation(CraftGR.MOD_ID, "config"),
new ResourceLocation(CraftGR.MOD_ID, "config_highlighted")
ResourceLocation.fromNamespaceAndPath(CraftGR.MOD_ID, "config"),
ResourceLocation.fromNamespaceAndPath(CraftGR.MOD_ID, "config_highlighted")
);

private static final OptionInstance<Double> PLAYBACK_VOLUME = new OptionInstance<>(
Expand All @@ -53,12 +49,12 @@ public MixinSoundOptionsScreen(Component title) {
super(title);
}

@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall([Lnet/minecraft/client/OptionInstance;)V", shift = At.Shift.BEFORE, ordinal = 0))
@Inject(method = "addOptions", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall([Lnet/minecraft/client/OptionInstance;)V", shift = At.Shift.BEFORE, ordinal = 0))
private void craftgr$startSmallOptions(CallbackInfo ci) {
ThreadLocals.RADIO_OPTION_CONTAINER_ADDED.set(false);
}

@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall([Lnet/minecraft/client/OptionInstance;)V", shift = At.Shift.AFTER, ordinal = 0))
@Inject(method = "addOptions", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall([Lnet/minecraft/client/OptionInstance;)V", shift = At.Shift.AFTER, ordinal = 0))
private void craftgr$endSmallOptions(CallbackInfo ci) {
Boolean added = ThreadLocals.RADIO_OPTION_CONTAINER_ADDED.get();
if (added != null && !added) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ public class SongInfoOverlay extends Overlay {

private static final int ALBUM_ART_FETCH_TRIES = 3;
private static final int ALBUM_ART_FETCH_DELAY_SECONDS = 4;

private static final int COLOR_WHITE = 0xFFFFFF;

private static final ResourceLocation ALBUM_ART_PLACEHOLDER_LOCATION = new ResourceLocation(CraftGR.MOD_ID, "textures/album_placeholder.png");
private static final ResourceLocation ALBUM_ART_LOCATION = new ResourceLocation(CraftGR.MOD_ID, "album");
private static final ResourceLocation ALBUM_ART_PLACEHOLDER_LOCATION = ResourceLocation.fromNamespaceAndPath(CraftGR.MOD_ID, "textures/album_placeholder.png");
private static final ResourceLocation ALBUM_ART_LOCATION = ResourceLocation.fromNamespaceAndPath(CraftGR.MOD_ID, "album");

private static SongInfoOverlay instance;

Expand Down Expand Up @@ -162,7 +164,7 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY) {
muted = true;
updateScrollWidth();
}
graphics.drawString(CraftGR.MC.font, CraftGR.AUDIO_MUTED_ICON, (x + (int) width - MUTED_ICON_RIGHT_PADDING - MUTED_ICON_SIZE) / 2, (y + MUTED_ICON_TOP_PADDING) / 2, Color.WHITE.getRGB());
graphics.drawString(CraftGR.MC.font, CraftGR.AUDIO_MUTED_ICON, (x + (int) width - MUTED_ICON_RIGHT_PADDING - MUTED_ICON_SIZE) / 2, (y + MUTED_ICON_TOP_PADDING) / 2, COLOR_WHITE);
} else if (muted) {
muted = false;
updateScrollWidth();
Expand All @@ -178,10 +180,10 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY) {
long played = System.currentTimeMillis() / 1000L - SongHandler.getInstance().getSongStart();
if (played > duration) played = duration;

graphics.drawString(CraftGR.MC.font, getTimer((int) played), x + ART_LEFT_PADDING, y + ART_TOP_PADDING + ART_SIZE + ART_TIMER_SPACE_HEIGHT, Color.WHITE.getRGB());
graphics.drawString(CraftGR.MC.font, getTimer((int) played), x + ART_LEFT_PADDING, y + ART_TOP_PADDING + ART_SIZE + ART_TIMER_SPACE_HEIGHT, COLOR_WHITE);

int timerWidth = font.width(getTimer((int) duration));
graphics.drawString(CraftGR.MC.font, getTimer((int) duration), x + (int) width - timerWidth - TIMER_RIGHT_PADDING, y + ART_TOP_PADDING + ART_SIZE + ART_TIMER_SPACE_HEIGHT, Color.WHITE.getRGB());
graphics.drawString(CraftGR.MC.font, getTimer((int) duration), x + (int) width - timerWidth - TIMER_RIGHT_PADDING, y + ART_TOP_PADDING + ART_SIZE + ART_TIMER_SPACE_HEIGHT, COLOR_WHITE);

RenderUtil.fill(poseStack, x, y + ART_TOP_PADDING + ART_SIZE + ART_BOTTOM_PADDING, x + (float) played / duration * width, y + height, GRConfig.<Color>getValue("overlayBarColor").getRGB() + 0xFF000000, 0.6f);
RenderUtil.fill(poseStack, x + (float) played / duration * width, y + ART_TOP_PADDING + ART_SIZE + ART_BOTTOM_PADDING, x + width, y + height, GRConfig.<Color>getValue("overlayBgColor").getRGB() + 0xFF000000, 0.6f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,15 @@ public static void fill(PoseStack poseStack, float minX, float minY, float maxX,

a = a * opacity;

BufferBuilder bb = Tesselator.getInstance().getBuilder();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bb.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
bb.vertex(matrix4f, minX, maxY, 0.0F).color(r, g, b, a).endVertex();
bb.vertex(matrix4f, maxX, maxY, 0.0F).color(r, g, b, a).endVertex();
bb.vertex(matrix4f, maxX, minY, 0.0F).color(r, g, b, a).endVertex();
bb.vertex(matrix4f, minX, minY, 0.0F).color(r, g, b, a).endVertex();
BufferUploader.drawWithShader(bb.end());
BufferBuilder bb = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
bb.addVertex(matrix4f, minX, maxY, 0.0F).setColor(r, g, b, a);
bb.addVertex(matrix4f, maxX, maxY, 0.0F).setColor(r, g, b, a);
bb.addVertex(matrix4f, maxX, minY, 0.0F).setColor(r, g, b, a);
bb.addVertex(matrix4f, minX, minY, 0.0F).setColor(r, g, b, a);
BufferUploader.drawWithShader(bb.buildOrThrow());
RenderSystem.disableBlend();
}

Expand Down
7 changes: 5 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@
"craftgr-common.mixins.json"
],
"depends": {
"minecraft": ">=1.20.6-",
"minecraft": ">=1.21-",
"fabricloader": "*",
"fabric-key-binding-api-v1": "*",
"fabric-lifecycle-events-v1": "*",
"fabric-rendering-v1": "*",
"fabric-screen-api-v1": "*"
},
"recommends": {
"yet_another_config_lib_v3": ">=3.4.0"
"yet_another_config_lib_v3": ">=3.5.0"
},
"suggests": {
"modmenu": ">=11.0.0-beta.1"
},
"custom": {
"modmenu:clientsideOnly": true
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ maven_group = io.github.kabanfriends.craftgr
archives_base_name = craftgr

# Mod Properties
minecraft_version = 1.20.6
minecraft_version = 1.21
mod_version = 1.7.1

# Fabric Properties
# See: https://fabricmc.net/develop/
fabric_loader_version = 0.15.11
fabric_api_version = 0.98.0+1.20.6
fabric_api_version = 0.100.0+1.21

# NeoForge Properties
# See: https://neoforged.net/
neoforge_version = 20.6.63-beta
neoforge_version = 21.0.0-beta

# Library Dependencies
jlayer_version = 1.0.3

# Mod Dependencies
mod_menu_version = 10.0.0-beta.1
yacl_version = 3.4.2+1.20.5
mod_menu_version = 11.0.0-beta.1
yacl_version = 3.5.0+1.21
8 changes: 2 additions & 6 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ plugins {
id "com.github.johnrengelman.shadow" version "8.1.1"
}

loom {
neoForge {
accessTransformer { file("src/main/resources/META-INF/accesstransformer.cfg") }
}
}

architectury {
platformSetupLoomIde()
neoForge()
Expand All @@ -30,6 +24,8 @@ dependencies {
shadowCommon "com.github.umjammer:jlayer:${rootProject.jlayer_version}"

implementation "com.github.umjammer:jlayer:${rootProject.jlayer_version}"

modLocalRuntime ("dev.isxander:yet-another-config-lib:${rootProject.yacl_version}-neoforge") { transitive false }
}

processResources {
Expand Down
12 changes: 0 additions & 12 deletions neoforge/src/main/resources/META-INF/accesstransformer.cfg

This file was deleted.

6 changes: 3 additions & 3 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ config = "craftgr-common.mixins.json"
[[dependencies.craftgr]]
modId = "minecraft"
type = "required"
versionRange = "[1.20.6,)"
versionRange = "[1.21,)"
ordering = "NONE"
side = "CLIENT"

[[dependencies.craftgr]]
modId = "neoforge"
type = "required"
versionRange = "[20.6.63-beta,)"
versionRange = "[21.0.0-beta,)"
ordering = "NONE"
side = "CLIENT"

[[dependencies.craftgr]]
modId = "yet_another_config_lib_v3"
type = "optional"
versionRange="[3.4.0,)"
versionRange="[3.5.0,)"
ordering = "NONE"
side = "CLIENT"

0 comments on commit d9ddbd4

Please sign in to comment.