Skip to content
Merged
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
37 changes: 13 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,21 @@ on: [ pull_request, push ]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
21, # Current Java LTS & minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ ubuntu-20.04, windows-2022 ]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v2
- name: Upload Build Artifact
uses: actions/[email protected]
with:
name: Artifacts
name: artifact
path: build/libs/

143 changes: 46 additions & 97 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,101 +1,54 @@
plugins {
id "fabric-loom" version "1.8.9" apply false
id "fabric-loom" version "1.10-SNAPSHOT"
id "maven-publish"
id "org.ajoberstar.grgit" version "5.2.2"
id "org.jetbrains.kotlin.jvm" version "2.0.0"
}

allprojects {
apply plugin: "fabric-loom"
apply plugin: "maven-publish"

repositories {
mavenCentral()
maven { url = "https://maven.fabricmc.net/" }
maven { url = "https://oss.sonatype.org/content/repositories/snapshots" }
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
maven { url "https://maven.shedaniel.me" }
if (project.archices_preview_version.empty) {
version = project.mod_version + "+" + grgit.branch.current().name // usually branch name is the mc version
} else {
version = project.mod_version + "-" + project.archices_preview_version + "+" + grgit.branch.current().name + "-" + grgit.head().id.substring(0, 8)
}
group = project.maven_group

repositories {
mavenCentral()
maven { url = "https://maven.fabricmc.net/" }
maven { url = "https://oss.sonatype.org/content/repositories/snapshots" }
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
maven { url "https://maven.shedaniel.me" }

// maven {
// name = "Reden"
// url = ("https://maven.starlight.cool/artifactory/reden")
// }
}

base {
archivesName = project.archives_base_name
}

processResources {
inputs.property "version", rootProject.version

filesMatching("fabric.mod.json") {
expand "version": rootProject.version
}
}

dependencies {
// Minecraft
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings "net.fabricmc:yarn:${rootProject.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}"
// Fabric API
modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}"
// Kotlin support
modImplementation("net.fabricmc:fabric-language-kotlin:1.11.0+kotlin.2.0.0")
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}

kotlin {
compilerOptions {
freeCompilerArgs.add("-Xjvm-default=all")
}
jvmToolchain(21)
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}

base {
archivesName = project.archives_base_name
}

if (project.archices_preview_version.empty) {
version = project.mod_version + "+" + grgit.branch.current().name // usually branch name is the mc version
} else {
version = project.mod_version + "-" + project.archices_preview_version + "+" + grgit.branch.current().name + "-" + grgit.head().id.substring(0, 8)
}
group = project.maven_group

processResources {
inputs.property "version", project.version

subprojects {
dependencies {
// exclude group: "net.fabricmc", module: "fabric-loader"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

loom {
accessWidenerPath = file("src/main/resources/enclosure.accesswidener")
}

dependencies {
// todo
// modRuntimeOnly "maven.modrinth:luckperms:v5.4.113-fabric"
// include(implementation("com.redenmc:brigadier-kotlin-dsl:1.0-SNAPSHOT"))
// Minecraft
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Kotlin support
modImplementation("net.fabricmc:fabric-language-kotlin:1.11.0+kotlin.2.0.0")

// SnakeYAML. To convert the old config
include(modImplementation("org.yaml:snakeyaml:1.33"))
Expand All @@ -104,24 +57,28 @@ dependencies {
include(modImplementation('me.lucko:fabric-permissions-api:0.2-SNAPSHOT'))
// REI. To avoid the REI GUI overlap with the Enclosure GUI
modCompileOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}"
}

println("Loading subprojects...")
subprojects.each {
it.dependencies {
implementation project(':')
}
implementation project(path: ":${it.name}", configuration: "namedElements")
include project("${it.name}:")
clean.dependsOn("${it.name}:clean")
println("Loaded " + it.name)
tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}

kotlin {
compilerOptions {
freeCompilerArgs.add("-Xjvm-default=all")
}
jvmToolchain(21)
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

loom {
accessWidenerPath = file("src/main/resources/enclosure.accesswidener")
}

jar {
Expand All @@ -137,12 +94,4 @@ publishing {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
org.gradle.jvmargs=-Xmx5G
org.gradle.parallel=true
# Mod Properties
mod_version=0.4.6
mod_version=0.4.7
archices_preview_version=

maven_group=com.github.zly2006
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.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
56 changes: 48 additions & 8 deletions src/main/java/com/github/zly2006/enclosure/gui/AboutScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.RotationAxis;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -16,6 +19,16 @@ public class AboutScreen extends Screen {
public static final String WIKI_ZH = "https://enclosure.fandom.com/zh/wiki/Enclosure_Wiki";
public static final String WIKI_EN = "https://enclosure.fandom.com";

public static final Identifier MOD_ICON_TEXTURE = Identifier.of("enclosure", "icon.png");
public static final int MOD_ICON_TEXTURE_WIDTH = 80;
public static final int MOD_ICON_TEXTURE_HEIGHT = 80;

private boolean isHovering = false;
private long animationStartTime = 0;
private float lastAngle = 0;
private float startAngle = 0;
private float targetAngle = 0;

public AboutScreen(Screen parent) {
super(Text.of("About"));
this.parent = parent;
Expand All @@ -36,25 +49,52 @@ protected void init() {
button -> ConfirmLinkScreen.open(this, "https://www.starlight.cool/"), 5, 5, width - 20));
textWidgets.add(new ClickableTextWidget(client, parent, Text.translatable("enclosure.about.copyright"), null,
button -> {}, 5, 5, width - 20));
textWidgets.add(new ClickableTextWidget(client, parent, Text.translatable("点击查看中文wiki页面").formatted(Formatting.UNDERLINE), Text.translatable("enclosure.about.click_to_open"),
textWidgets.add(new ClickableTextWidget(client, parent, Text.literal("点击查看中文wiki页面").formatted(Formatting.UNDERLINE), Text.translatable("enclosure.about.click_to_open"),
button -> ConfirmLinkScreen.open(this, WIKI_ZH), 5, 5, width - 20));
textWidgets.add(new ClickableTextWidget(client, parent, Text.translatable("Click to open English wiki page").formatted(Formatting.UNDERLINE), Text.translatable("enclosure.about.click_to_open"),
textWidgets.add(new ClickableTextWidget(client, parent, Text.literal("Click to open English wiki page").formatted(Formatting.UNDERLINE), Text.translatable("enclosure.about.click_to_open"),
button -> ConfirmLinkScreen.open(this, WIKI_EN), 5, 5, width - 20));
}

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
int centerHeight = height / 2;
int centerWidth = width / 2;
int renderStart = Math.max(50, centerHeight - 80);
context.drawCenteredTextWithShadow(textRenderer, Text.of("Enclosure"), centerWidth, renderStart, 0xffffff);
renderStart += 10;
renderInGameBackground(context);

int renderStart;
MatrixStack matrices = context.getMatrices();
matrices.push();
try {
int renderIconX = (width - MOD_ICON_TEXTURE_WIDTH) / 2;
int renderIconY = 5;

boolean mouseHoverIcon = mouseX > renderIconX && mouseX < renderIconX + MOD_ICON_TEXTURE_WIDTH && mouseY > renderIconY && mouseY < renderIconY + MOD_ICON_TEXTURE_HEIGHT;


if (mouseHoverIcon != isHovering) {
isHovering = mouseHoverIcon;
animationStartTime = System.currentTimeMillis();
startAngle = lastAngle;
targetAngle = isHovering ? 360 : 0;
}

float progress = Math.min((System.currentTimeMillis() - animationStartTime) / 500f, 1.0f);
float smoothProgress = (float) (1 - Math.cos(progress * Math.PI)) / 2f;
lastAngle = startAngle + (targetAngle - startAngle) * smoothProgress;

matrices.translate(renderIconX + MOD_ICON_TEXTURE_WIDTH / 2D, renderIconY + MOD_ICON_TEXTURE_HEIGHT / 2D, 0);
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(lastAngle));

context.drawTexture(MOD_ICON_TEXTURE, -MOD_ICON_TEXTURE_WIDTH / 2, -MOD_ICON_TEXTURE_HEIGHT / 2, MOD_ICON_TEXTURE_WIDTH, MOD_ICON_TEXTURE_HEIGHT, 0, 0, 640, 640, 640, 640);

renderStart = renderIconY + MOD_ICON_TEXTURE_HEIGHT + 20;
} finally {
matrices.pop();
}

for (ClickableTextWidget textWidget : textWidgets) {
textWidget.x = 10;
textWidget.y = renderStart;
textWidget.render(context, mouseX, mouseY, delta);
renderStart += textWidget.getHeight() + 10;
renderStart += textWidget.getHeight() + 5;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,33 +128,42 @@ public SetButtonWidget(int x, int y, int width, int height, Text message, PressA
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
assert client.player != null;
if (!visible || !active) {
if (!visible || !active || !hovered) {
return false;
}
else if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {

if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
Boolean value = getValue();
if (value == null) setValue(true);
else setValue(null);
if (value == null) {
setValue(true);
} else {
setValue(null);
}

client.player.networkHandler.sendChatCommand("enclosure set " + fullName + " uuid " +
uuid.toString() + " " +
permission.getName() + " " +
Optional.ofNullable(getValue()).map(String::valueOf).orElse("none"));
buttonWidget.setMessage(value());
playDownSound(MinecraftClient.getInstance().getSoundManager());
return true;
}
else if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) {
if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) {
Boolean value = getValue();
if (value == null) setValue(false);
else setValue(null);
if (value == null) {
setValue(false);
} else {
setValue(null);
}
client.player.networkHandler.sendChatCommand("enclosure set " + fullName + " uuid " +
uuid.toString() + " " +
permission.getName() + " " +
Optional.ofNullable(getValue()).map(String::valueOf).orElse("none"));
buttonWidget.setMessage(value());
playDownSound(MinecraftClient.getInstance().getSoundManager());
return true;
}
return super.mouseClicked(mouseX, mouseY, button);
return false;
}
}
}
Expand Down