mirror of
https://github.com/TeamMidnightDust/PictureSign.git
synced 2025-12-13 12:55:09 +01:00
Huge code cleanup, Architectury & Watermedia
- A huge cleanup of the codebase - Make use of the Architectury build system - Replaced VideoLib with WATERMeDIA (More features, better stability, multiplatform support)
This commit is contained in:
106
fabric/build.gradle
Normal file
106
fabric/build.gradle
Normal file
@@ -0,0 +1,106 @@
|
||||
plugins {
|
||||
id 'com.github.johnrengelman.shadow'
|
||||
id "me.shedaniel.unified-publishing"
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
fabric()
|
||||
}
|
||||
|
||||
loom {
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentFabric.extendsFrom common
|
||||
archivesBaseName = rootProject.archives_base_name + "-fabric"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric")
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "architectury.common.json"
|
||||
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
archiveClassifier = "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
input.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
unifiedPublishing {
|
||||
project {
|
||||
displayName = "PictureSign $project.version - Fabric $project.minecraft_version"
|
||||
releaseType = "$project.release_type"
|
||||
changelog = releaseChangelog()
|
||||
gameVersions = []
|
||||
gameLoaders = ["fabric","quilt"]
|
||||
mainPublication remapJar
|
||||
relations {
|
||||
depends {
|
||||
curseforge = "fabric-api"
|
||||
modrinth = "fabric-api"
|
||||
}
|
||||
depends {
|
||||
curseforge = "watermedia"
|
||||
modrinth = "watermedia"
|
||||
}
|
||||
includes {
|
||||
curseforge = "midnightlib"
|
||||
modrinth = "midnightlib"
|
||||
}
|
||||
}
|
||||
|
||||
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
||||
if (CURSEFORGE_TOKEN != null) {
|
||||
curseforge {
|
||||
token = CURSEFORGE_TOKEN
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 21", project.minecraft_version
|
||||
}
|
||||
}
|
||||
|
||||
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
||||
if (MODRINTH_TOKEN != null) {
|
||||
modrinth {
|
||||
token = MODRINTH_TOKEN
|
||||
id = rootProject.modrinth_id
|
||||
version = "$project.version-$project.name"
|
||||
gameVersions.addAll project.minecraft_version
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package eu.midnightdust.picturesign.fabric;
|
||||
|
||||
import eu.midnightdust.picturesign.PictureSignClient;
|
||||
import eu.midnightdust.picturesign.util.VideoHandler;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientBlockEntityEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import static eu.midnightdust.picturesign.PictureSignClient.*;
|
||||
|
||||
public class PictureSignClientFabric implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
PictureSignClient.init();
|
||||
|
||||
KeyBindingHelper.registerKeyBinding(BINDING_COPY_SIGN);
|
||||
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> {
|
||||
if (hasWaterMedia) VideoHandler.closeAll();
|
||||
});
|
||||
ClientBlockEntityEvents.BLOCK_ENTITY_UNLOAD.register((blockEntity, world) -> {
|
||||
if (hasWaterMedia) {
|
||||
BlockPos pos = blockEntity.getPos();
|
||||
Identifier videoId = id(pos.getX() + "_" + pos.getY() + "_" + pos.getZ()+"_f");
|
||||
VideoHandler.closePlayer(videoId);
|
||||
Identifier videoId2 = id(pos.getX() + "_" + pos.getY() + "_" + pos.getZ()+"_b");
|
||||
VideoHandler.closePlayer(videoId2);
|
||||
}
|
||||
});
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
if (!BINDING_COPY_SIGN.isPressed()) return;
|
||||
BINDING_COPY_SIGN.setPressed(false);
|
||||
if (client.player == null || client.world == null || client.crosshairTarget == null || client.crosshairTarget.getType() != HitResult.Type.BLOCK) return;
|
||||
if (client.crosshairTarget.getType() == HitResult.Type.BLOCK && client.world.getBlockState(BlockPos.ofFloored(client.crosshairTarget.getPos())).hasBlockEntity()) {
|
||||
if (client.world.getBlockEntity(BlockPos.ofFloored(client.crosshairTarget.getPos())) instanceof SignBlockEntity sign) {
|
||||
boolean front = sign.isPlayerFacingFront(client.player);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
clipboard[i] = sign.getText(front).getMessage(i, false).getString();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
35
fabric/src/main/resources/fabric.mod.json
Executable file
35
fabric/src/main/resources/fabric.mod.json
Executable file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "picturesign",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "PictureSign",
|
||||
"description": "Use signs to display custom images and videos completely client-side!",
|
||||
"authors": [
|
||||
"Motschen",
|
||||
"TeamMidnightDust"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://www.midnightdust.eu/",
|
||||
"sources": "https://github.com/TeamMidnightDust/PictureSign",
|
||||
"issues": "https://github.com/TeamMidnightDust/PictureSign/issues"
|
||||
},
|
||||
|
||||
"license": "MIT",
|
||||
"icon": "assets/picturesign/icon.png",
|
||||
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"eu.midnightdust.picturesign.fabric.PictureSignClientFabric"
|
||||
]
|
||||
},
|
||||
|
||||
"depends": {
|
||||
"midnightlib": "*",
|
||||
"watermedia": "*"
|
||||
},
|
||||
"mixins": [
|
||||
"picturesign.mixins.json"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user