mirror of
https://github.com/TeamMidnightDust/PictureSign.git
synced 2025-12-15 13:45: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:
@@ -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