Skip to content

Commit 605a71b

Browse files
committed
1.2.0
* Added the ability to hide the album art * Localization files will be downloaded when the mod is launched
1 parent cf946aa commit 605a71b

44 files changed

Lines changed: 49 additions & 1270 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
1-
buildscript {
2-
dependencies {
3-
classpath 'de.guntram.mcmod:crowdin-translate:1.3+1.17'
4-
}
5-
repositories {
6-
maven {
7-
name = 'CrowdinTranslate source'
8-
url = "https://minecraft.guntram.de/maven/"
9-
}
10-
}
11-
}
12-
13-
141
plugins {
152
id 'fabric-loom' version '0.11-SNAPSHOT'
163
id 'maven-publish'
174
id 'com.modrinth.minotaur' version '2.+'
18-
id 'de.guntram.mcmod.crowdin-translate' version '1.4+1.18.2'
195
}
206

21-
22-
apply plugin: 'de.guntram.mcmod.crowdin-translate'
23-
crowdintranslate.crowdinProjectName = 'blockify'
24-
crowdintranslate.minecraftProjectName = 'blockify'
25-
crowdintranslate.verbose = false
26-
277
sourceCompatibility = JavaVersion.VERSION_17
288
targetCompatibility = JavaVersion.VERSION_17
299

@@ -33,15 +13,16 @@ group = project.maven_group
3313

3414
repositories {
3515
maven { url = "https://api.modrinth.com/maven" }
16+
maven { url = "https://minecraft.guntram.de/maven" }
3617
}
3718

3819
dependencies {
39-
// To change the versions see the gradle.properties file
4020
minecraft "com.mojang:minecraft:${project.minecraft_version}"
4121
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
4222
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
4323

44-
// Fabric API. This is technically optional, but you probably want it anyway.
24+
modImplementation "de.guntram.mcmod:crowdin-translate:${project.crowdintranslate_version}"
25+
include "de.guntram.mcmod:crowdin-translate:${project.crowdintranslate_version}"
4526
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
4627
modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"
4728
include "maven.modrinth:midnightlib:${project.midnightlib_version}"
@@ -68,7 +49,6 @@ java {
6849
}
6950

7051
jar {
71-
dependsOn downloadTranslations
7252
from("LICENSE") {
7353
rename { "${it}_${project.archivesBaseName}"}
7454
}

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ org.gradle.jvmargs=-Xmx1G
88
loader_version=0.13.3
99

1010
# Mod Properties
11-
mod_version = 1.1.3
11+
mod_version = 1.2.0
1212
maven_group = one.clownless.blockify
1313
archives_base_name = blockify
1414
modrinth_projectid = X5aijFqA
1515

1616
# Dependencies
1717
fabric_version=0.46.6+1.18
1818
midnightlib_version=0.4.0
19-
crowdintranslate_version=1.4+1.18.2
19+
crowdintranslate_version=1.4+1.18
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package one.clownless.blockify;
2+
3+
import de.guntram.mcmod.crowdintranslate.CrowdinTranslate;
4+
import net.fabricmc.api.ClientModInitializer;
5+
6+
public class BlockifyClient implements ClientModInitializer {
7+
@Override
8+
public void onInitializeClient() {
9+
CrowdinTranslate.downloadTranslations("blockify", "blockify");
10+
}
11+
}

src/main/java/one/clownless/blockify/BlockifyConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class BlockifyConfig extends MidnightConfig {
77
@Entry public static Anchor anchor = Anchor.TOP_LEFT;
88
@Entry public static int posX = 0;
99
@Entry public static int posY = 0;
10+
@Entry public static boolean drawCover = true;
1011
@Entry(min = 1) public static int volumeStep = 10;
1112
@Entry(width = 7, min = 7, isColor = true) public static String titleColor = "#ffffff";
1213
@Entry(width = 7, min = 7, isColor = true) public static String artistColor = "#ffffff";

src/main/java/one/clownless/blockify/BlockifyHUD.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,37 +72,36 @@ public static void draw(MatrixStack matrixStack)
7272
matrixStack.scale((float) BlockifyConfig.scale, (float) BlockifyConfig.scale,1);
7373
scaledWidth = client.getWindow().getScaledWidth();
7474
scaledHeight = client.getWindow().getScaledHeight();
75-
76-
drawRectangle(0, 0, 185, 55, new Color(MidnightColorUtil.hex2Rgb(BlockifyConfig.backgroundColor).getRed(), MidnightColorUtil.hex2Rgb(BlockifyConfig.backgroundColor).getGreen(), MidnightColorUtil.hex2Rgb(BlockifyConfig.backgroundColor).getBlue(), BlockifyConfig.backgroundTransparency)); // background
77-
drawRectangle(60, 48, 180, 50, MidnightColorUtil.hex2Rgb(BlockifyConfig.barColor).darker().darker()); // progressbar
78-
drawRectangle(60, 48, (float) (60 + (120 * percentProgress)), 50, MidnightColorUtil.hex2Rgb(BlockifyConfig.barColor)); // progressbar
79-
80-
if (hudInfo[4] != null && (!prevImage.equals(hudInfo[4]) && !hudInfo[4].equals("")))
75+
int textOffset = 55;
76+
if ((BlockifyConfig.drawCover != false) && hudInfo[4] != null && (!prevImage.equals(hudInfo[4]) && !hudInfo[4].equals("")))
8177
{
8278
LOGGER.info("Drawing new album cover.");
8379
albumImage.setImage(hudInfo[4]);
8480
prevImage = hudInfo[4];
8581
}
8682

87-
88-
drawRectangle(5, 5, 50, 50, new Color(0,0,0,150));
89-
if (hudInfo[4] != null)
83+
if (hudInfo[4] != null && (BlockifyConfig.drawCover != false))
9084
{
85+
drawRectangle(5, 5, 50, 50, new Color(0,0,0,150));
9186
RenderUtil.drawTexture(matrixStack, albumImage, 5, 5, .15F);
87+
textOffset = 0;
9288
}
9389

90+
drawRectangle(0, 0, 185 - textOffset, 55, new Color(MidnightColorUtil.hex2Rgb(BlockifyConfig.backgroundColor).getRed(), MidnightColorUtil.hex2Rgb(BlockifyConfig.backgroundColor).getGreen(), MidnightColorUtil.hex2Rgb(BlockifyConfig.backgroundColor).getBlue(), BlockifyConfig.backgroundTransparency));
91+
drawRectangle(60 - textOffset, 48, 180 - textOffset, 50, MidnightColorUtil.hex2Rgb(BlockifyConfig.barColor).darker().darker());
92+
drawRectangle(60 - textOffset, 48, (float) (60 + (120 * percentProgress)) - textOffset, 50, MidnightColorUtil.hex2Rgb(BlockifyConfig.barColor));
9493

9594
List<OrderedText> nameWrap = fontRenderer.wrapLines(StringVisitable.plain(hudInfo[0]), 125);
9695
int yOffset = 0;
9796
if (nameWrap.size() > 1)
9897
{
99-
fontRenderer.drawWithShadow(matrixStack, nameWrap.get(0), 60, 5, MidnightColorUtil.hex2Rgb(BlockifyConfig.titleColor).getRGB());
100-
fontRenderer.drawWithShadow(matrixStack, nameWrap.get(1), 60, 18, MidnightColorUtil.hex2Rgb(BlockifyConfig.titleColor).getRGB());
98+
fontRenderer.drawWithShadow(matrixStack, nameWrap.get(0), 60 - textOffset, 5, MidnightColorUtil.hex2Rgb(BlockifyConfig.titleColor).getRGB());
99+
fontRenderer.drawWithShadow(matrixStack, nameWrap.get(1), 60 - textOffset, 18, MidnightColorUtil.hex2Rgb(BlockifyConfig.titleColor).getRGB());
101100
yOffset = 15;
102101
}
103102
else
104103
{
105-
fontRenderer.drawWithShadow(matrixStack, nameWrap.get(0), 60, 5, MidnightColorUtil.hex2Rgb(BlockifyConfig.titleColor).getRGB());
104+
fontRenderer.drawWithShadow(matrixStack, nameWrap.get(0), 60 - textOffset, 5, MidnightColorUtil.hex2Rgb(BlockifyConfig.titleColor).getRGB());
106105
yOffset = 0;
107106
}
108107
matrixStack.scale(.5F, .5F, .5F);
@@ -113,20 +112,20 @@ public static void draw(MatrixStack matrixStack)
113112
int artistYOffset = 0;
114113
if (artistWrap.size() > 1)
115114
{
116-
fontRenderer.drawWithShadow(matrixStack, artistWrap.get(0), 120, 44 + yOffset, MidnightColorUtil.hex2Rgb(BlockifyConfig.artistColor).getRGB());
117-
fontRenderer.drawWithShadow(matrixStack, artistWrap.get(1), 120, 57 + yOffset, MidnightColorUtil.hex2Rgb(BlockifyConfig.artistColor).getRGB());
115+
fontRenderer.drawWithShadow(matrixStack, artistWrap.get(0), 120 - (textOffset * 2), 44 + yOffset, MidnightColorUtil.hex2Rgb(BlockifyConfig.artistColor).getRGB());
116+
fontRenderer.drawWithShadow(matrixStack, artistWrap.get(1), 120 - (textOffset * 2), 57 + yOffset, MidnightColorUtil.hex2Rgb(BlockifyConfig.artistColor).getRGB());
118117
artistYOffset = 15;
119118
}
120119
else
121120
{
122-
fontRenderer.drawWithShadow(matrixStack, artistWrap.get(0), 120, 44 + yOffset, MidnightColorUtil.hex2Rgb(BlockifyConfig.artistColor).getRGB());
121+
fontRenderer.drawWithShadow(matrixStack, artistWrap.get(0), 120 - (textOffset * 2), 44 + yOffset, MidnightColorUtil.hex2Rgb(BlockifyConfig.artistColor).getRGB());
123122
artistYOffset = 0;
124123
}
125124
String progressText = (progressMS / (1000 * 60)) + ":" + String.format("%02d", (progressMS / 1000 % 60));
126125
String durationText = (durationMS / (1000 * 60)) + ":" + String.format("%02d ", (durationMS / 1000 % 60)) + I18n.translate("blockify.hud.volume") + ": " + hudInfo[6];
127126

128-
fontRenderer.drawWithShadow(matrixStack, progressText, 120, 85, MidnightColorUtil.hex2Rgb(BlockifyConfig.timeColor).getRGB());
129-
fontRenderer.drawWithShadow(matrixStack, durationText, 360 - (fontRenderer.getWidth(durationText)), 85, MidnightColorUtil.hex2Rgb(BlockifyConfig.timeColor).getRGB());
127+
fontRenderer.drawWithShadow(matrixStack, progressText, 120 - (textOffset * 2), 85, MidnightColorUtil.hex2Rgb(BlockifyConfig.timeColor).getRGB());
128+
fontRenderer.drawWithShadow(matrixStack, durationText, 360 - (fontRenderer.getWidth(durationText)) - (textOffset * 2), 85, MidnightColorUtil.hex2Rgb(BlockifyConfig.timeColor).getRGB());
130129
matrixStack.scale(2F, 2F, 2F);
131130
matrixStack.scale(1,1,1);
132131
matrixStack.pop();

src/main/java/one/clownless/blockify/util/SpotifyUtil.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,17 @@ public static void putRequest(String type)
251251
.PUT(HttpRequest.BodyPublishers.ofString(""))
252252
.header("Authorization", "Bearer " + accessToken).build();
253253
HttpResponse<String> putRes = client.send(putReq, HttpResponse.BodyHandlers.ofString());
254-
LOGGER.info("Put Request (" + type + "): " + putRes.statusCode());
254+
LOGGER.info("PUT Request (" + type + "): " + putRes.statusCode());
255255
if (putRes.statusCode() == 404)
256256
{
257257
refreshActiveSession();
258258
LOGGER.info("Retrying put request...");
259259
putRes = client.send(putReq, HttpResponse.BodyHandlers.ofString());
260-
LOGGER.info("Put Request (" + type + "): " + putRes.statusCode());
260+
LOGGER.info("PUT Request (" + type + "): " + putRes.statusCode());
261+
}
262+
else if (putRes.statusCode() == 403)
263+
{
264+
MinecraftClient.getInstance().inGameHud.addChatMessage(MessageType.SYSTEM, Text.of("Spotify Premium is required for this feature."), UUID.randomUUID());
261265
}
262266
else if (putRes.statusCode() == 401)
263267
{
@@ -294,13 +298,17 @@ public static void postRequest(String type)
294298
.POST(HttpRequest.BodyPublishers.ofString(""))
295299
.header("Authorization", "Bearer " + accessToken).build();
296300
HttpResponse<String> postRes = client.send(postReq, HttpResponse.BodyHandlers.ofString());
297-
LOGGER.info("Post Request (" + type + "): " + postRes.statusCode());
301+
LOGGER.info("POST Request (" + type + "): " + postRes.statusCode());
298302
if (postRes.statusCode() == 404)
299303
{
300304
refreshActiveSession();
301305
LOGGER.info("Retrying post request...");
302306
postRes = client.send(postReq, HttpResponse.BodyHandlers.ofString());
303-
LOGGER.info("Put Request (" + type + "): " + postRes.statusCode());
307+
LOGGER.info("POST Request (" + type + "): " + postRes.statusCode());
308+
}
309+
else if (postRes.statusCode() == 403)
310+
{
311+
MinecraftClient.getInstance().inGameHud.addChatMessage(MessageType.SYSTEM, Text.of("Spotify Premium is required for this feature."), UUID.randomUUID());
304312
}
305313
else if (postRes.statusCode() == 401)
306314
{

src/main/resources/assets/blockify/lang/cs_cz.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/resources/assets/blockify/lang/de_at.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/resources/assets/blockify/lang/de_ch.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/resources/assets/blockify/lang/de_de.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)