Skip to content

Commit

Permalink
Merge pull request #7 from Pixaurora/feature/rust-in-the-java
Browse files Browse the repository at this point in the history
Add Rust to the mod
  • Loading branch information
Pixaurora authored Sep 3, 2024
2 parents 8fa3ffc + 8bb1943 commit 417fbda
Show file tree
Hide file tree
Showing 23 changed files with 710 additions and 44 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,20 @@ jobs:
with:
cache-read-only: ${{ github.ref != 'refs/heads/meow' }}
- name: build
run: ./gradlew build --warning-mode=all
- name: capture build artifacts
run: ./gradlew build buildDevNatives --warning-mode=all
- name: capture Java artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Upload artifacts from one job, ignore the rest
uses: actions/upload-artifact@v4
with:
name: kit-tunes-artifacts
path: build/libs
if-no-files-found: error
- name: capture Rust artifacts
uses: actions/upload-artifact@v4
with:
name: libkittenthoughts-${{ runner.os }}-artifacts
path: |
projects/kitten-thoughts/target/debug/*.so
projects/kitten-thoughts/target/debug/*.dylib
projects/kitten-thoughts/target/debug/*.dll
if-no-files-found: error
34 changes: 9 additions & 25 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,23 @@
icon.png
quilt.mod.json

# Cargo
target/

# Gradle
.gradle/
build/
out/
classes/

# Quilt Loom
remappedSrc/
run/

# Eclipse
*.launch

# IntelliJ Idea
.idea/
*.iml
*.ipr
*.iws

# Fleet
.fleet/
# macOS
*.DS_Store
/.apt_generated/

# Quilt Loom
run/

# Visual Studio Code
.settings/
.vscode/
bin/
.classpath
.project

# Eclipse JDT LS
.factorypath
workspace/

# macOS
*.DS_Store
/.apt_generated/
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
public enum ModIcon {
KIT_TUNES(),
KIT_TUNES_API(),
KITTEN_SQUARE(),
KITTEN_HEART(),
KITTEN_THOUGHTS(),
KITTEN_SQUARE(),
KITTEN_SOUNDS();

private final String modId;
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod {
dependencies {
include(project(":projects:kit-tunes-api"))
include(project(":projects:kitten-heart"))
include(project(":projects:kitten-thoughts"))

include(project(":projects:kitten-sounds:r1.17.0"))
include(project(":projects:kitten-sounds:r1.20.3"))
Expand Down
3 changes: 2 additions & 1 deletion projects/kitten-heart/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ mod {
dependencies {
required("quilt_loader").versionAbove(libs.versions.quilt.loader.get())


required("kit_tunes_api")
required("kitten_square")
required("kitten_sounds")
required("kitten_thoughts")
}
}

dependencies {
implementation(project(":projects:kit-tunes-api"))
implementation(project(":projects:kitten-thoughts"))

implementation(libs.annotations)
implementation(libs.quilt.loader)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import net.pixaurora.kitten_heart.impl.resource.ResourcePathImpl;
import net.pixaurora.kitten_heart.impl.service.MinecraftUICompat;
import net.pixaurora.kitten_heart.impl.service.ServiceLoading;
import net.pixaurora.kitten_thoughts.impl.KittenThoughts;
import net.pixaurora.kitten_thoughts.impl.scrobbler.ScrobblerSetup;

public class KitTunes {
public static final Logger LOGGER = LoggerFactory.getLogger(Constants.MOD_ID);
Expand All @@ -41,6 +43,11 @@ public static void init() {
// doing this can sometimes cause issues.
MusicMetadata.init(MusicMetadataLoader.albumFiles(), MusicMetadataLoader.artistFiles(),
MusicMetadataLoader.trackFiles());

KittenThoughts.init();

String helloMessage = ScrobblerSetup.hello("CoolCat");
KitTunes.LOGGER.info(helloMessage);
}

public static void tick() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package net.pixaurora.kitten_heart.impl.network;

import net.pixaurora.kitten_thoughts.impl.util.CryptoUtil;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Encryption {
public static String signMd5(String input) {
return bytesToHex(getMd5Digest(input));
return CryptoUtil.toHex(getMd5Digest(input));
}

public static byte[] getMd5Digest(String input) {
Expand All @@ -21,18 +23,4 @@ public static byte[] getMd5Digest(String input) {

return digester.digest();
}

public static String bytesToHex(byte[] bytes) {
StringBuilder hexString = new StringBuilder(bytes.length * 2);

for (byte rawByte : bytes) {
int processedByte = Byte.toUnsignedInt(rawByte);

// Example byte: 11 01 10 00
hexString.append(Integer.toHexString(processedByte >> 0b100)); // Grabs the part that is 11 01
hexString.append(Integer.toHexString(processedByte & 0b1111)); // Grabs the part that is 10 00
}

return hexString.toString();
}
}
Loading

0 comments on commit 417fbda

Please sign in to comment.