Skip to content

Commit

Permalink
Merge branch 'meow' into feature/rust-in-the-java
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixaurora authored Sep 3, 2024
2 parents 2037920 + 8fa3ffc commit 8bb1943
Show file tree
Hide file tree
Showing 247 changed files with 3,345 additions and 876 deletions.
4 changes: 4 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ dependencies {
implementation(libs.quilt.loom)

implementation(libs.gson)

// Enable using version catalog in local plugins
// https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}

kotlin {
Expand Down
4 changes: 3 additions & 1 deletion build-logic/src/main/kotlin/kit_tunes.module.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.gradle.accessors.dm.LibrariesForLibs
import net.pixaurora.kit_tunes.build_logic.ProjectMetadata

plugins {
Expand All @@ -6,6 +7,7 @@ plugins {
id("org.quiltmc.loom")
}

val libs = the<LibrariesForLibs>()
val metadata = extra.get("metadata") as ProjectMetadata

loom {
Expand All @@ -15,7 +17,7 @@ loom {
}

dependencies {
modImplementation("org.quiltmc:quilt-loader:0.26.0")
modImplementation(libs.quilt.loader)

mappings(loom.officialMojangMappings())
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
Expand Down
6 changes: 3 additions & 3 deletions build-logic/src/main/kotlin/kit_tunes.submodule.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
id("kit_tunes.module")
}

val minecraft_version_min = project.property("minecraft_version_min") as String
val minecraft_version_max = project.property("minecraft_version_max") as String
val minecraftVersionMin = project.property("minecraft_version_min") as String
val minecraftVersionMax = project.property("minecraft_version_max") as String

configure<ModResourcesExtension>{
metadata {
Expand All @@ -14,6 +14,6 @@ configure<ModResourcesExtension>{
}

dependencies {
required("minecraft").version(minecraft_version_min, minecraft_version_max)
required("minecraft").version(minecraftVersionMin, minecraftVersionMax)
}
}
8 changes: 6 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ dependencies {
include(project(":projects:kitten-thoughts"))

include(project(":projects:kitten-sounds:r1.17.0"))
include(project(":projects:kitten-sounds:r1.20.4"))
include(project(":projects:kitten-sounds:r1.20.3"))

include(project(":projects:kitten-square:r1.17.0"))
include(project(":projects:kitten-square:r1.20.4"))
include(project(":projects:kitten-square:r1.19.0"))
include(project(":projects:kitten-square:r1.19.3"))
include(project(":projects:kitten-square:r1.19.4"))
include(project(":projects:kitten-square:r1.20.0"))
include(project(":projects:kitten-square:r1.20.3"))
include(project(":projects:kitten-square:r1.21.0"))
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.caching = true
org.gradle.parallel = true

# Mod Properties
mod_version = 0.1.0
mod_version = 0.3.0
update_title = axolotl
description = Helps you appreciate this game's music a bit more!

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
minecraft = "1.20.4"
quilt_mappings = "1.20.4+build.3"

quilt_loom = "1.7.3"
quilt_loader = "0.26.0"
quilt_loom = "1.7.4"
quilt_loader = "0.26.3"

qsl = "8.0.0-alpha.11+1.20.4"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-rc-1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import net.pixaurora.kit_tunes.api.resource.ResourcePath;

public interface Album {
public ResourcePath path();

public String name();

public Optional<ResourcePath> albumArtPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@

import java.util.List;
import java.util.Optional;
import java.util.Random;

import net.pixaurora.kit_tunes.api.resource.ResourcePath;

public interface Track {
public ResourcePath path();

public List<String> matches();

public String name();

public Artist artist();

public Optional<Album> album();
public default Optional<Album> album() {
if (this.albums().size() > 0) {
return Optional.of(this.albums().get(new Random().nextInt(this.albums().size())));
} else {
return Optional.empty();
}
}

public List<Album> albums();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ public static Point of(int x, int y) {
return new PointImpl(x, y);
}

public default Point midPointBetween(Vec2Int other) {
return Point.of((this.x() + other.x()) / 2, (this.y() + other.y()) / 2);
}

// Functions in common with Size

public default Point offset(Vec2Int by) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ public int x() {
public int y() {
return this.y;
}

@Override
public String toString() {
return "Point(x = " + this.x + ", y = " + this.y + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public default Point centerOnVertical(Point targetMidpoint) {
return targetMidpoint.offset(this.divideBy(-2).x(), 0);
}

public default Size overlay(Size other) {
return Size.of(Math.max(this.x(), other.x()), Math.max(this.y(), other.y()));
}

// Functions in common with Point

public default Size offset(Vec2Int by) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ public int x() {
public int y() {
return this.height;
}

@Override
public String toString() {
return "Size(width = " + this.width + ", height = " + this.height + ")";
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.pixaurora.kitten_cube.impl.text;

import net.pixaurora.kitten_cube.impl.MinecraftClient;
import net.pixaurora.kitten_cube.impl.math.Size;
import net.pixaurora.kitten_heart.impl.KitTunes;

public interface Component {
Expand All @@ -16,4 +18,8 @@ public static Component translatableWithFallback(String key, String fallbackText
}

public Component concat(Component other);

public default Size size() {
return MinecraftClient.textSize(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.time.Duration;
import java.util.List;

import net.pixaurora.kitten_cube.impl.MinecraftClient;
import net.pixaurora.kitten_cube.impl.math.Point;
import net.pixaurora.kitten_cube.impl.math.Size;
import net.pixaurora.kitten_cube.impl.text.Component;
import net.pixaurora.kitten_cube.impl.ui.display.GuiDisplay;
import net.pixaurora.kitten_cube.impl.ui.texture.Texture;
import net.pixaurora.kitten_cube.impl.ui.tile.PositionedInnerTile;
Expand All @@ -30,14 +30,24 @@ public DrawableToast(ToastData data) {
this.icon = data.icon();
this.iconPos = background.iconPos();

this.title = new PositionedText(data.title(), data.titleColor(), background.titlePos());
this.body = TextBox.of(data.messageLines(), data.messageColor(), background.maxLineLength(),
background.bodyTextStartPos());
Size totalBodySize = this.body.size().offset(background.bodyTextStartPos());

Size textSize = this.body.size();
textSize.withX(Math.max(textSize.x(), MinecraftClient.textWidth(this.title.text())));
Component title = data.title();

Pair<List<PositionedInnerTile>, Size> tilesAndSize = background.tilesAndSize(textSize);
Point titlePos = background.titlePos();
if (background.isTitleCentered()) {
Point centerOfText = titlePos.midPointBetween(totalBodySize.withYOf(titlePos));
titlePos = title.size().centerOnVertical(centerOfText);
}

this.title = new PositionedText(title, data.titleColor(), titlePos);
Size totalTitleSize = title.size().offset(titlePos);

Size minimumSize = totalBodySize.overlay(totalTitleSize).offset(background.padding());

Pair<List<PositionedInnerTile>, Size> tilesAndSize = background.tilesAndSize(minimumSize);

this.tiles = tilesAndSize.first();
this.size = tilesAndSize.second();
Expand All @@ -54,7 +64,7 @@ public void draw(GuiDisplay gui) {

gui.draw(icon, iconPos);

gui.drawText(this.title.text(), this.title.color(), this.title.pos());
gui.drawText(this.title.text(), this.title.color(), this.title.pos(), false);
gui.drawTextBox(this.body);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,31 @@ public class ToastBackground {
private final Point iconPos;

private final Point titlePos;
private final boolean isTitleCentered;

private final Point linesStartPos;
private final int maxLineLength;

private final int rightPadding;
private final int bottomPadding;

public ToastBackground(ToastBackgroundAppearance appearance, Point iconPos, Point titlePos, Point linesStartPos,
int maxLineLength, int rightPadding, int bottomPadding) {
public ToastBackground(ToastBackgroundAppearance appearance, Point iconPos, Point titlePos, boolean isTitleCentered,
Point linesStartPos, int maxLineLength, int rightPadding, int bottomPadding) {
this.appearance = appearance;
this.iconPos = iconPos;
this.titlePos = titlePos;
this.isTitleCentered = isTitleCentered;
this.linesStartPos = linesStartPos;
this.maxLineLength = maxLineLength;
this.rightPadding = rightPadding;
this.bottomPadding = bottomPadding;
}

public Pair<List<PositionedInnerTile>, Size> tilesAndSize(Size textSize) {
Size minimumSize = textSize.offset(bodyTextStartPos()).offset(rightPadding, bottomPadding);
public Size padding() {
return Size.of(rightPadding, bottomPadding);
}

public Pair<List<PositionedInnerTile>, Size> tilesAndSize(Size minimumSize) {
Size corners = this.appearance.topLeftSize().offset(this.appearance.bottomRightSize());
Size centerSegmentCounts = Size.of(
(int) Math.ceil(
Expand All @@ -62,7 +66,7 @@ public Pair<List<PositionedInnerTile>, Size> tilesAndSize(Size textSize) {
pos = pos.offset(0, topTile.size().height());

InnerTile middleTile = column.get(1);
for (int middlePart = 0; middlePart <= centerSegmentCounts.y(); middlePart++) {
for (int middlePart = 0; middlePart < centerSegmentCounts.y(); middlePart++) {
arrangedTiles.add(middleTile.atPos(pos));
pos = pos.offset(0, middleTile.size().height());
}
Expand Down Expand Up @@ -93,6 +97,10 @@ public Point titlePos() {
return this.titlePos;
}

public boolean isTitleCentered() {
return this.isTitleCentered;
}

public Point bodyTextStartPos() {
return this.linesStartPos;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public static void init() {
// Mostly just init the class to make sure all static fields are set, etc.
// It's not a problem in modern versions, but in older Java versions not
// doing this can sometimes cause issues.
MusicMetadata.init(MusicMetadataLoader.albumFiles(), MusicMetadataLoader.artistFiles());
MusicMetadata.init(MusicMetadataLoader.albumFiles(), MusicMetadataLoader.artistFiles(),
MusicMetadataLoader.trackFiles());

KittenThoughts.init();

String helloMessage = ScrobblerSetup.hello("CoolCat");
Expand Down
Loading

0 comments on commit 8bb1943

Please sign in to comment.