Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: capture build artifacts
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
15 changes: 3 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ on:
type: string

permissions:
# packages: write
packages: write
contents: write

jobs:
publish:
strategy:
matrix:
# Use these Java versions
java: [21]
# and run on both Linux and Windows
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -51,14 +49,11 @@ jobs:
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew

# get new tag in the form vX.Y.Z, saved to new_tag=vX.Y.Z
- name: Pull Mod Version
id: pull-new-version
run: |
grep 'module_version=' gradle.properties | sed 's/module_version=/new_tag=v/g' >> $GITHUB_OUTPUT

# previous tag parsing
# we use an env variable here because it's easier than joining two step outputs I think
- name: Set previous tag from override
if: ${{ inputs.lastTagOverride != null }}
run: |
Expand All @@ -80,8 +75,6 @@ jobs:
echo "PREVIOUS_TAG=NONE" >> "$GITHUB_ENV"
fi

# new tag parsing and concat
# vX.Y.Z -> vX.Y.Z+1.20.4
- id: new-tag-generator
name: Format new tag from input and branch
run: |
Expand Down Expand Up @@ -122,18 +115,16 @@ jobs:
- name: build & run tests
run: ./gradlew check build

- name: Publish to JackFred Maven and GitHub Release
- name: Publish to GitHub Packages and GitHub Release
run: ./gradlew publish githubRelease -PchangelogHeaderAddon="${{ inputs.changelogHeader }}"
env:
RELEASE: true
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JACKFRED_MAVEN_USER: ${{ secrets.JACKFRED_MAVEN_USER }}
JACKFRED_MAVEN_PASS: ${{ secrets.JACKFRED_MAVEN_PASS }}

- name: Capture build artifacts
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: |
Expand Down
38 changes: 21 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import red.jackf.GenerateChangelogTask
import red.jackf.UpdateDependenciesTask

plugins {
id("fabric-loom") version "1.9-SNAPSHOT" apply false
id("fabric-loom") version "1.11-SNAPSHOT" apply false
id("com.github.breadmoirai.github-release") version "2.4.1" apply false
id("org.ajoberstar.grgit") version "5.0.+"
id("org.ajoberstar.grgit") version "5.2.1"
id("maven-publish")
}

Expand Down Expand Up @@ -144,19 +144,24 @@ allprojects {
// PACKAGING //
///////////////

tasks.withType<ProcessResources>().configureEach {
inputs.property("module_version", version)
inputs.property("module_name", +properties["module_name"])
inputs.property("module_description", +properties["module_description"])
val moduleName = project.properties["module_name"]?.toString() ?: "jackfredlib"
val moduleDescription = project.properties["module_description"]?.toString() ?: "Library for WhereIsIt"
val rootModuleName = rootProject.properties["module_name"]?.toString() ?: "WhereIsIt"
val rootModuleDescription = rootProject.properties["module_description"]?.toString() ?: "WhereIsIt project"

inputs.property("root_module_name", +rootProject.properties["module_name"])
inputs.property("root_module_description", +rootProject.properties["module_description"])
tasks.withType<ProcessResources>().configureEach {
inputs.property("module_version", project.version)
inputs.property("module_name", moduleName)
inputs.property("module_description", moduleDescription)
inputs.property("root_module_name", rootModuleName)
inputs.property("root_module_description", rootModuleDescription)

filesMatching("fabric.mod.json") {
expand(inputs.properties)
}
}


tasks.named<Jar>("jar") {
from(rootProject.file("LICENSE")) {
rename { "${it}_${this@allprojects.name}" }
Expand Down Expand Up @@ -253,11 +258,11 @@ fun setupRepositories(repos: RepositoryHandler) {

if (canPublish) {
repos.maven {
name = "JackFred-Maven"
url = uri("https://maven.jackf.red/releases")
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ponuing/JackFredLib")
credentials {
username = System.getenv("JACKFRED_MAVEN_USER")
password = System.getenv("JACKFRED_MAVEN_PASS")
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
Expand Down Expand Up @@ -291,19 +296,18 @@ allprojects {
}
developers {
developer {
url = "https://jackf.red"
name = "JackFred2"
url = "https://github.com/ponuing"
name = "ponuing"
}
}
scm {
connection = "scm:git:git://github.com/JackFred2/JackFredLib.git"
developerConnection = "scm:git:git://github.com/JackFred2/JackFredLib.git"
connection = "scm:git:git://github.com/ponuing/JackFredLib.git"
developerConnection = "scm:git:git://github.com/ponuing/JackFredLib.git"
url = +propertiesHandle["github_url"]
}
}
}
}

setupRepositories(repositories)
}
}
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.4-rc3
parchment_version=1.21:2024.07.28
loader_version=0.16.9
minecraft_version=1.21.9
parchment_version=1.21.9:2025.10.05
loader_version=0.17.3

# https://github.com/FabricMC/fabric-loom/issues/869
# seems to randomly work? not reliable enough
Expand All @@ -18,19 +18,19 @@ archives_base_name=jackfredlib

# Dependencies
# JF_AUTO_UPDATE_BLOCK
fabric-api_version=0.110.3+1.21.4
modmenu_version=12.0.0-beta.1
fabric-api_version=0.134.0+1.21.9
modmenu_version=16.0.0-rc.1
# JF_END_AUTO_UPDATE_BLOCK
# mixin_extras_version=0.2.1
jankson_version=1.2.3
commons_io_version=2.17.0
commons_io_version=2.20.0

# Publishing
# lastTag=v0.5.12+1.20.2
# newTag=v0.5.13+1.20.2
changelog_filter=[feat],[fix],[change],[docs]
github_url=https://github.com/JackFred2/JackFredLib
github_owner=JackFred2
github_url=https://github.com/ponuing/JackFredLib
github_owner=ponuing
github_repo=JackFredLib
mod_name=JackFredLib

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 @@
#Sun Aug 18 16:37:48 BST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.util.Mth;
import org.joml.Matrix4f;
import org.joml.Matrix3x2f;
import red.jackf.jackfredlib.api.colour.Colour;
import red.jackf.jackfredlib.api.colour.Gradient;

Expand Down Expand Up @@ -37,18 +36,16 @@ public static void drawHorizontalGradient(GuiGraphics graphics, int x, int y, in
}
final Gradient usedGradient = generateRepeatedGradient(gradient, gradientStart, gradientEnd);

graphics.drawSpecial(buffer -> {
var pose = graphics.pose().last().pose();

float lastKey = usedGradient.getPoints().firstKey();
for (float secondKey : usedGradient.getPoints().navigableKeySet()) {
if (secondKey == lastKey) continue; // don't do last
float x1 = x + (width * lastKey);
float x2 = x + (width * secondKey);
drawHorizontalGradient(buffer.getBuffer(RenderType.gui()), pose, x1, y, x2, y + height, usedGradient.sample(lastKey), usedGradient.sample(secondKey));
lastKey = secondKey;
}
});
float lastKey = usedGradient.getPoints().firstKey();
for (float secondKey : usedGradient.getPoints().navigableKeySet()) {
if (secondKey == lastKey) continue; // don't do last
float x1 = x + (width * lastKey);
float x2 = x + (width * secondKey);
int fromArgb = usedGradient.sample(lastKey).toARGB();
int toArgb = usedGradient.sample(secondKey).toARGB();
graphics.fillGradient((int)Math.floor(x1), y, (int)Math.ceil(x2), y + height, fromArgb, toArgb);
lastKey = secondKey;
}
}

/**
Expand All @@ -74,18 +71,16 @@ public static void drawVerticalGradient(GuiGraphics graphics, int x, int y, int
}
final Gradient usedGradient = generateRepeatedGradient(gradient, gradientStart, gradientEnd);

graphics.drawSpecial(buffer -> {
var pose = graphics.pose().last().pose();

float lastKey = usedGradient.getPoints().firstKey();
for (float secondKey : usedGradient.getPoints().navigableKeySet()) {
if (secondKey == lastKey) continue; // don't do last
float y1 = y + (height * lastKey);
float y2 = y + (height * secondKey);
drawVerticalGradient(buffer.getBuffer(RenderType.gui()), pose, x, y1, x + width, y2, usedGradient.sample(lastKey), usedGradient.sample(secondKey));
lastKey = secondKey;
}
});
float lastKey = usedGradient.getPoints().firstKey();
for (float secondKey : usedGradient.getPoints().navigableKeySet()) {
if (secondKey == lastKey) continue; // don't do last
float y1 = y + (height * lastKey);
float y2 = y + (height * secondKey);
int fromArgb = usedGradient.sample(lastKey).toARGB();
int toArgb = usedGradient.sample(secondKey).toARGB();
graphics.fillGradient(x, (int)Math.floor(y1), x + width, (int)Math.ceil(y2), fromArgb, toArgb);
lastKey = secondKey;
}
}

private static Gradient generateRepeatedGradient(Gradient gradient, float gradientStart, float gradientEnd) {
Expand All @@ -105,9 +100,9 @@ private static Gradient generateRepeatedGradient(Gradient gradient, float gradie
return gradient;
}

private static void drawVerticalGradient(VertexConsumer buffer, Matrix4f pose,
float x1, float y1, float x2, float y2,
Colour from, Colour to) {
private static void drawVerticalGradient(VertexConsumer buffer, Matrix3x2f pose,
float x1, float y1, float x2, float y2,
Colour from, Colour to) {
int r1 = from.r();
int g1 = from.g();
int b1 = from.b();
Expand All @@ -117,13 +112,13 @@ private static void drawVerticalGradient(VertexConsumer buffer, Matrix4f pose,
int b2 = to.b();
int a2 = to.a();

buffer.addVertex(pose, x1, y1, 0).setColor(r1, g1, b1, a1);
buffer.addVertex(pose, x1, y2, 0).setColor(r2, g2, b2, a2);
buffer.addVertex(pose, x2, y2, 0).setColor(r2, g2, b2, a2);
buffer.addVertex(pose, x2, y1, 0).setColor(r1, g1, b1, a1);
buffer.addVertex(x1, y1, 0).setColor(r1, g1, b1, a1);
buffer.addVertex(x1, y2, 0).setColor(r2, g2, b2, a2);
buffer.addVertex(x2, y2, 0).setColor(r2, g2, b2, a2);
buffer.addVertex(x2, y1, 0).setColor(r1, g1, b1, a1);
}

private static void drawHorizontalGradient(VertexConsumer buffer, Matrix4f pose,
private static void drawHorizontalGradient(VertexConsumer buffer, Matrix3x2f pose,
float x1, float y1, float x2, float y2,
Colour from, Colour to) {
int r1 = from.r();
Expand All @@ -135,9 +130,9 @@ private static void drawHorizontalGradient(VertexConsumer buffer, Matrix4f pose,
int b2 = to.b();
int a2 = to.a();

buffer.addVertex(pose, x1, y1, 0).setColor(r1, g1, b1, a1);
buffer.addVertex(pose, x1, y2, 0).setColor(r1, g1, b1, a1);
buffer.addVertex(pose, x2, y2, 0).setColor(r2, g2, b2, a2);
buffer.addVertex(pose, x2, y1, 0).setColor(r2, g2, b2, a2);
buffer.addVertex(x1, y1, 0).setColor(r1, g1, b1, a1);
buffer.addVertex(x1, y2, 0).setColor(r1, g1, b1, a1);
buffer.addVertex(x2, y2, 0).setColor(r2, g2, b2, a2);
buffer.addVertex(x2, y1, 0).setColor(r2, g2, b2, a2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static void setDisplayItem(Display.ItemDisplay display, ItemStack stack)

/**
* <p>Change a display entity's view range multiplier. This is scaled with a client's Entity View Distance modifier.</p>
* <p>The default rangefor a display entity with a modifier of {@code 1.0} and a client Entity View Distance of {@code 100%},
* <p>The default range for a display entity with a modifier of {@code 1.0} and a client Entity View Distance of {@code 100%},
* is 64 blocks.</p>
*
* @param display Display to update
Expand Down Expand Up @@ -161,7 +161,7 @@ public static void setDisplayBrightnessOverride(Display display, Brightness brig
*
* @param display Display to update the brightness for.
* @param block Block light level to use for the display (e.g. from glowstone, torches)
* @param sky Sky light level to use for the display (e.g. from the sun, darkened by storms)
* @param sky Skylight level to use for the display (e.g. from the sun, darkened by storms)
*/
public static void setDisplayBrightnessOverride(Display display, int block, int sky) {
((DisplayAccessor) display).jflib$setBrightnessOverride(new Brightness(block, sky));
Expand Down Expand Up @@ -372,20 +372,51 @@ public static void face(Entity source, Entity target) {
*/
public static void face(Entity source, Vec3 target) {
var vector = target.subtract(source.position());
var yRot = (float) (Mth.atan2(vector.z, vector.x) * 180.0F / (float) Math.PI) + 90.0F;
var yRot = (float) (Mth.atan2(vector.z(), vector.x()) * 180.0F / (float) Math.PI) + 90.0F;
//noinspection SuspiciousNameCombination
var xRot = (float) (Mth.atan2(vector.horizontalDistance(), vector.y) * 180.0F / (float) Math.PI) - 90.0F;
var xRot = (float) (Mth.atan2(vector.horizontalDistance(), vector.y()) * 180.0F / (float) Math.PI) - 90.0F;
//if (source instanceof Display) { // if this wasn't offset the displays would be backwards
yRot += 180.0F % 360.0F;
//}
source.moveTo(source.getX(),
source.getY(),
source.getZ(),
Mth.positiveModulo(yRot, 360f),
Mth.positiveModulo(xRot, 360f));

float yaw = Mth.positiveModulo(yRot, 360f);
float pitch = Mth.positiveModulo(xRot, 360f);

double x = source.getX();
double y = source.getY();
double z = source.getZ();

// Try to call absMoveTo(x,y,z,yaw,pitch) reflectively (present in many mappings).
// If it's not available, fall back to setting position and rotations separately.
try {
source.getClass()
.getMethod("absMoveTo", double.class, double.class, double.class, float.class, float.class)
.invoke(source, x, y, z, yaw, pitch);
} catch (ReflectiveOperationException | LinkageError ignored) {
// fallback: set position then rotation setters (common names)
try {
source.setPos(x, y, z);
} catch (LinkageError ignored2) {
}
try {
source.setYRot(yaw);
} catch (LinkageError ignored2) {
}
try {
source.setXRot(pitch);
} catch (LinkageError ignored2) {
}
}

if (source instanceof LivingEntity living) {
living.setYBodyRot(yRot);
living.setYHeadRot(yRot);
try {
living.setYBodyRot(yaw);
} catch (LinkageError ignored) {
}
try {
living.setYHeadRot(yaw);
} catch (LinkageError ignored) {
}
}
}
}
}
Loading