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:
25
common/build.gradle
Normal file
25
common/build.gradle
Normal file
@@ -0,0 +1,25 @@
|
||||
architectury {
|
||||
common(rootProject.enabled_platforms.split(","))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
modCompileOnlyApi "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric"
|
||||
//modCompileOnly "maven.modrinth:iris:${project.iris_version}"
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenCommon(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name
|
||||
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.
|
||||
}
|
||||
}
|
||||
26
common/src/main/java/eu/midnightdust/picturesign/PictureSignClient.java
Executable file
26
common/src/main/java/eu/midnightdust/picturesign/PictureSignClient.java
Executable file
@@ -0,0 +1,26 @@
|
||||
package eu.midnightdust.picturesign;
|
||||
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class PictureSignClient {
|
||||
public static Logger LOGGER = LogManager.getLogger("PictureSign");
|
||||
public static String MOD_ID = "picturesign";
|
||||
public static final boolean hasWaterMedia = PlatformFunctions.isModLoaded("watermedia");
|
||||
public static String[] clipboard = new String[4];
|
||||
public static final KeyBinding BINDING_COPY_SIGN = new KeyBinding("key."+MOD_ID+".copy_sign",
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_U, "key.categories."+MOD_ID);
|
||||
|
||||
public static void init() {
|
||||
PictureSignConfig.init(MOD_ID, PictureSignConfig.class);
|
||||
}
|
||||
public static Identifier id(String path) {
|
||||
return Identifier.of(MOD_ID, path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package eu.midnightdust.picturesign.config;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import net.minecraft.client.gl.ShaderProgram;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PictureSignConfig extends MidnightConfig {
|
||||
private static final String general = "1general";
|
||||
private static final String advanced = "advanced";
|
||||
|
||||
@Entry(category = general) public static boolean enabled = true;
|
||||
@Entry(category = general) public static boolean enableVideoSigns = true;
|
||||
@Entry(category = general) public static boolean translucency = false;
|
||||
@Entry(category = general) public static boolean fullBrightPicture = false;
|
||||
@Entry(category = general) public static boolean helperUi = true;
|
||||
@Entry(category = general) public static boolean exceedVanillaLineLength = true;
|
||||
@Entry(category = advanced) public static boolean debug = false;
|
||||
@Entry(min = 1, max = 10, isSlider = true, category = advanced) public static int maxThreads = 4;
|
||||
@Entry(min = 0, max = 2048, isSlider = true, category = general) public static int signRenderDistance = 64;
|
||||
@Entry(category = general) public static boolean safeMode = true;
|
||||
@Entry(category = general) public static List<String> safeProviders = Lists.newArrayList("https://i.imgur.com/", "https://i.ibb.co/", "https://pictshare.net/", "https://iili.io/", "https://vimeo.com/", "https://yewtu.be/");
|
||||
@Entry(category = general) public static String invidiousInstance = "yt.oelrichsgarcia.de";
|
||||
@Comment(category = general) public static Comment ebeWarning;
|
||||
@Entry(category = advanced) public static MissingImageMode missingImageMode = MissingImageMode.BLACK;
|
||||
@Entry(category = advanced) public static PictureShader pictureShader = PictureShader.PosColTexLight;
|
||||
|
||||
public enum MissingImageMode {
|
||||
BLACK, MISSING_TEXTURE, TRANSPARENT
|
||||
}
|
||||
public enum PictureShader {
|
||||
PosColTexLight(GameRenderer::getPositionColorTexLightmapProgram),
|
||||
RenderTypeCutout(GameRenderer::getRenderTypeCutoutProgram),
|
||||
PosTex(GameRenderer::getPositionTexProgram),
|
||||
PosTexCol(GameRenderer::getPositionTexColorProgram);
|
||||
|
||||
PictureShader(Supplier<ShaderProgram> program) {
|
||||
this.program = program;
|
||||
}
|
||||
public final Supplier<ShaderProgram> program;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package eu.midnightdust.picturesign.mixin;
|
||||
|
||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import eu.midnightdust.picturesign.render.PictureSignRenderer;
|
||||
import eu.midnightdust.picturesign.util.PictureSignType;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.block.entity.HangingSignBlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(HangingSignBlockEntityRenderer.class)
|
||||
public abstract class MixinHangingSignBlockEntityRenderer implements BlockEntityRenderer<SignBlockEntity> {
|
||||
@Unique private static final MinecraftClient client = MinecraftClient.getInstance();
|
||||
@Unique PictureSignRenderer psRenderer = new PictureSignRenderer();
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "render")
|
||||
public void ps$onRender(SignBlockEntity sign, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, int overlay, CallbackInfo ci) {
|
||||
if (PictureSignConfig.enabled) {
|
||||
if (PictureSignType.isNotOfType(sign, PictureSignType.NONE, true)) psRenderer.render(sign, matrixStack, light, overlay, true);
|
||||
if (PictureSignType.isNotOfType(sign, PictureSignType.NONE, false)) psRenderer.render(sign, matrixStack, light, overlay, false);
|
||||
}
|
||||
}
|
||||
@Unique
|
||||
@Override
|
||||
public int getRenderDistance() {
|
||||
return PictureSignConfig.signRenderDistance;
|
||||
}
|
||||
@Unique
|
||||
@Override
|
||||
public boolean rendersOutsideBoundingBox(SignBlockEntity sign) {
|
||||
return PictureSignConfig.enabled && PictureSignType.hasPicture(sign);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package eu.midnightdust.picturesign.mixin;
|
||||
|
||||
import eu.midnightdust.picturesign.util.VideoHandler;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import static eu.midnightdust.picturesign.PictureSignClient.MOD_ID;
|
||||
import static eu.midnightdust.picturesign.PictureSignClient.id;
|
||||
|
||||
@Mixin(value = SignBlockEntity.class, priority = 1100)
|
||||
public abstract class MixinSignBlockEntity extends BlockEntity {
|
||||
public MixinSignBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Unique
|
||||
public void markRemoved() {
|
||||
Identifier videoId = id(pos.getX() + "_" + pos.getY() + "_" + pos.getZ() + "_f");
|
||||
Identifier videoId2 = id(pos.getX() + "_" + pos.getY() + "_" + pos.getZ() + "_b");
|
||||
VideoHandler.closePlayer(videoId);
|
||||
VideoHandler.closePlayer(videoId2);
|
||||
super.markRemoved();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package eu.midnightdust.picturesign.mixin;
|
||||
|
||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import eu.midnightdust.picturesign.render.PictureSignRenderer;
|
||||
import eu.midnightdust.picturesign.util.PictureSignType;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(SignBlockEntityRenderer.class)
|
||||
public abstract class MixinSignBlockEntityRenderer implements BlockEntityRenderer<SignBlockEntity> {
|
||||
@Unique private static final MinecraftClient client = MinecraftClient.getInstance();
|
||||
@Unique PictureSignRenderer psRenderer = new PictureSignRenderer();
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "render")
|
||||
public void ps$onRender(SignBlockEntity sign, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, int overlay, CallbackInfo ci) {
|
||||
if (PictureSignConfig.enabled) {
|
||||
if (PictureSignType.isNotOfType(sign, PictureSignType.NONE, true)) psRenderer.render(sign, matrixStack, light, overlay, true);
|
||||
if (PictureSignType.isNotOfType(sign, PictureSignType.NONE, false)) psRenderer.render(sign, matrixStack, light, overlay, false);
|
||||
}
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "shouldRender", cancellable = true)
|
||||
private static void shouldRender(BlockPos pos, int signColor, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (PictureSignConfig.enabled && client.world != null && PictureSignType.hasPicture((SignBlockEntity) client.world.getBlockEntity(pos))) cir.setReturnValue(true);
|
||||
}
|
||||
@Unique
|
||||
@Override
|
||||
public int getRenderDistance() {
|
||||
return PictureSignConfig.signRenderDistance;
|
||||
}
|
||||
@Unique
|
||||
@Override
|
||||
public boolean rendersOutsideBoundingBox(SignBlockEntity sign) {
|
||||
return PictureSignConfig.enabled && PictureSignType.hasPicture(sign);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package eu.midnightdust.picturesign.mixin;
|
||||
|
||||
import eu.midnightdust.picturesign.PictureSignClient;
|
||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import eu.midnightdust.picturesign.screen.PictureSignHelperScreen;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen;
|
||||
import net.minecraft.client.gui.widget.TextIconButtonWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static eu.midnightdust.picturesign.PictureSignClient.MOD_ID;
|
||||
import static eu.midnightdust.picturesign.PictureSignClient.id;
|
||||
|
||||
@Mixin(AbstractSignEditScreen.class)
|
||||
public abstract class MixinSignEditScreen extends Screen {
|
||||
@Shadow @Final private SignBlockEntity blockEntity;
|
||||
@Shadow @Final private String[] messages;
|
||||
@Shadow @Final private boolean front;
|
||||
|
||||
@Unique private static final Identifier PICTURESIGN_ICON_TEXTURE = id("icon/picturesign");
|
||||
@Unique private static final Identifier CLIPBOARD_ICON_TEXTURE = id("icon/clipboard");
|
||||
@Unique private static final Identifier TRASHBIN_ICON_TEXTURE = id("icon/trashbin");
|
||||
@Unique private static boolean switchScreen = false;
|
||||
|
||||
protected MixinSignEditScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"),method = "init")
|
||||
private void picturesign$init(CallbackInfo ci) {
|
||||
if (PictureSignClient.clipboard != null && PictureSignClient.clipboard[0] != null) {
|
||||
TextIconButtonWidget clipboardBuilder = TextIconButtonWidget.builder(Text.empty(), (buttonWidget) -> {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
messages[i] = PictureSignClient.clipboard[i];
|
||||
int finalI = i;
|
||||
blockEntity.changeText(changer -> changer.withMessage(finalI, Text.of(messages[finalI])), front);
|
||||
}
|
||||
}, true).texture(CLIPBOARD_ICON_TEXTURE, 16, 16).dimension(20, 20).build();
|
||||
clipboardBuilder.setPosition(this.width - 84, this.height - 40);
|
||||
this.addDrawableChild(clipboardBuilder);
|
||||
}
|
||||
if (PictureSignConfig.helperUi) {
|
||||
TextIconButtonWidget trashbinBuilder = TextIconButtonWidget.builder(Text.empty(), (buttonWidget) -> {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
messages[i] = "";
|
||||
int finalI = i;
|
||||
blockEntity.changeText(changer -> changer.withMessage(finalI, Text.empty()), front);
|
||||
}
|
||||
}, true).texture(TRASHBIN_ICON_TEXTURE, 16, 16).dimension(20, 20).build();
|
||||
trashbinBuilder.setPosition(this.width - 62, this.height - 40);
|
||||
this.addDrawableChild(trashbinBuilder);
|
||||
|
||||
TextIconButtonWidget picturesignBuilder = TextIconButtonWidget.builder(Text.empty(), (buttonWidget) -> {
|
||||
switchScreen = true;
|
||||
Objects.requireNonNull(client).setScreen(new PictureSignHelperScreen(this.blockEntity, front, false));
|
||||
}, true).texture(PICTURESIGN_ICON_TEXTURE, 16, 16).dimension(20, 20).build();
|
||||
picturesignBuilder.setPosition(this.width - 40, this.height - 40);
|
||||
this.addDrawableChild(picturesignBuilder);
|
||||
}
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "removed", cancellable = true)
|
||||
private void picturesign$removed(CallbackInfo ci) {
|
||||
if (switchScreen) {
|
||||
switchScreen = false;
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
226
common/src/main/java/eu/midnightdust/picturesign/render/PictureSignRenderer.java
Executable file
226
common/src/main/java/eu/midnightdust/picturesign/render/PictureSignRenderer.java
Executable file
@@ -0,0 +1,226 @@
|
||||
package eu.midnightdust.picturesign.render;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import eu.midnightdust.picturesign.util.*;
|
||||
import eu.midnightdust.picturesign.PictureSignClient;
|
||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.world.World;
|
||||
import org.joml.*;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import static eu.midnightdust.picturesign.PictureSignClient.id;
|
||||
|
||||
public class PictureSignRenderer {
|
||||
private boolean isSafeUrl;
|
||||
private boolean isDeactivated = false;
|
||||
private boolean playbackStarted = false;
|
||||
private Identifier videoId;
|
||||
private VideoHandler videoHandler;
|
||||
|
||||
public void render(SignBlockEntity signBlockEntity, MatrixStack matrixStack, int light, int overlay, boolean front) {
|
||||
PictureSignType type = PictureSignType.getType(signBlockEntity, front);
|
||||
String url = PictureURLUtils.getLink(signBlockEntity, front);
|
||||
PictureInfo info = null;
|
||||
if (!url.contains("://")) {
|
||||
url = "https://" + url;
|
||||
}
|
||||
if (url.endsWith(".json")) {
|
||||
info = PictureURLUtils.infoFromJson(url);
|
||||
if (info == null) return;
|
||||
url = info.url();
|
||||
}
|
||||
if (!url.contains("://")) {
|
||||
url = "https://" + url;
|
||||
}
|
||||
if (type == PictureSignType.PICTURE && !url.contains(".png") && !url.contains(".jpg") && !url.contains(".jpeg")) return;
|
||||
if (PictureSignConfig.safeMode) {
|
||||
isSafeUrl = false;
|
||||
String finalUrl = url;
|
||||
PictureSignConfig.safeProviders.forEach(safe -> {
|
||||
if (!isSafeUrl) isSafeUrl = finalUrl.startsWith(safe);
|
||||
});
|
||||
if (!isSafeUrl && !url.startsWith("https://youtu.be/") && !url.startsWith("https://youtube.com/") && !url.startsWith("https://www.youtube.com/")) return;
|
||||
}
|
||||
if ((!PictureSignConfig.enableVideoSigns || !PictureSignClient.hasWaterMedia) && type != PictureSignType.PICTURE) return;
|
||||
if (url.startsWith("https://youtube.com/") || url.startsWith("https://www.youtube.com/watch?v=") || url.startsWith("https://youtu.be/")) {
|
||||
url = url.replace("https://www.", "https://");
|
||||
//url = url.replace("youtube.com/watch?v=", PictureSignConfig.invidiousInstance.replace("https://", "").replace("/", "")+"/latest_version?id=");
|
||||
//url = url.replace("youtu.be/", PictureSignConfig.invidiousInstance.replace("https://", "").replace("/", "")+"/latest_version?id=");
|
||||
}
|
||||
World world = signBlockEntity.getWorld();
|
||||
BlockPos pos = signBlockEntity.getPos();
|
||||
String videoSuffix = front ? "_f" : "_b";
|
||||
if (videoId == null) videoId = id(pos.getX() + "_" + pos.getY() + "_" + pos.getZ()+videoSuffix);
|
||||
if (videoHandler == null) videoHandler = new VideoHandler(videoId);
|
||||
|
||||
if (world != null && ((world.getBlockState(pos.down()).getBlock().equals(Blocks.REDSTONE_TORCH) || world.getBlockState(pos.down()).getBlock().equals(Blocks.REDSTONE_WALL_TORCH))
|
||||
&& world.getBlockState(pos.down()).get(Properties.LIT).equals(false)
|
||||
|| (world.getBlockState(pos.up()).getBlock().equals(Blocks.REDSTONE_TORCH) || world.getBlockState(pos.up()).getBlock().equals(Blocks.REDSTONE_WALL_TORCH))
|
||||
&& world.getBlockState(pos.up()).get(Properties.LIT).equals(false)))
|
||||
{
|
||||
if (PictureSignClient.hasWaterMedia && videoHandler.isWorking() && !videoHandler.isStopped()) {
|
||||
videoHandler.stop();
|
||||
}
|
||||
isDeactivated = true;
|
||||
PictureURLUtils.cachedJsonData.remove(url);
|
||||
return;
|
||||
}
|
||||
else if (isDeactivated) {
|
||||
if (PictureSignClient.hasWaterMedia && videoHandler.isWorking() && videoHandler.isStopped())
|
||||
videoHandler.restart();
|
||||
isDeactivated = false;
|
||||
}
|
||||
|
||||
String lastLine = signBlockEntity.getText(front).getMessage(3, false).getString();
|
||||
|
||||
if (!lastLine.matches("(.*\\d:.*\\d:.*\\d:.*\\d:.*\\d)")) return;
|
||||
|
||||
String[] scale = lastLine.split(":");
|
||||
float width = 0;
|
||||
float height = 0;
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
try {
|
||||
width = Float.parseFloat(scale[0]);
|
||||
height = Float.parseFloat(scale[1]);
|
||||
x = Float.parseFloat(scale[2]);
|
||||
y = Float.parseFloat(scale[3]);
|
||||
z = Float.parseFloat(scale[4]);
|
||||
}
|
||||
catch (NumberFormatException ignored) {}
|
||||
|
||||
String thirdLine = signBlockEntity.getText(front).getMessage(2, false).getString();
|
||||
boolean hasRotation = thirdLine.matches("(.*\\d:.*\\d:.*\\d)");
|
||||
float xRot = 0;
|
||||
float yRot = 0;
|
||||
float zRot = 0;
|
||||
|
||||
if (hasRotation) {
|
||||
String[] rotation = thirdLine.split(":");
|
||||
try {
|
||||
xRot = Float.parseFloat(rotation[0]);
|
||||
yRot = Float.parseFloat(rotation[1]);
|
||||
zRot = Float.parseFloat(rotation[2]);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
// Download the picture data
|
||||
PictureDownloader.PictureData data = null;
|
||||
if (type == PictureSignType.PICTURE) {
|
||||
data = PictureDownloader.getInstance().getPicture(url);
|
||||
if (data == null || data.identifier == null) return;
|
||||
}
|
||||
else if (type.isVideo) {
|
||||
try {
|
||||
if (type.isLooped && !videoHandler.hasMedia() && !playbackStarted) {
|
||||
videoHandler.play(url);
|
||||
videoHandler.setRepeat(true);
|
||||
}
|
||||
else if (!videoHandler.hasMedia() && !playbackStarted) {
|
||||
videoHandler.play(url);
|
||||
}
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
PictureSignClient.LOGGER.error(e);
|
||||
return;
|
||||
}
|
||||
if (info != null && info.start() > 0 && videoHandler.getTime() < info.start()) videoHandler.setTime(info.start());
|
||||
if (info != null && info.end() > 0 && videoHandler.getTime() >= info.end() && !playbackStarted) videoHandler.stop();
|
||||
}
|
||||
else return;
|
||||
|
||||
if (videoId != null && !playbackStarted) playbackStarted = true;
|
||||
|
||||
float xOffset = 0.0F;
|
||||
float zOffset = 0.0F;
|
||||
|
||||
float yRotation = 0;
|
||||
|
||||
if (signBlockEntity.getCachedState().contains(Properties.HORIZONTAL_FACING)) {
|
||||
Direction direction = signBlockEntity.getCachedState().get(Properties.HORIZONTAL_FACING);
|
||||
switch (direction) {
|
||||
case NORTH -> {
|
||||
zOffset = 1.01F;
|
||||
xOffset = 1.0F;
|
||||
yRotation = 180;
|
||||
}
|
||||
case SOUTH -> zOffset = 0.010F;
|
||||
case EAST -> {
|
||||
zOffset = 1.01F;
|
||||
yRotation = 90;
|
||||
}
|
||||
case WEST -> {
|
||||
yRotation = -90;
|
||||
xOffset = 1.01F;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (signBlockEntity.getCachedState().contains(Properties.ROTATION)) {
|
||||
yRotation = signBlockEntity.getCachedState().get(Properties.ROTATION) * -22.5f;
|
||||
}
|
||||
else return;
|
||||
if (!front) yRotation -= 180f;
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
|
||||
int l = PictureSignConfig.fullBrightPicture ? 15728880 : light;
|
||||
if (PlatformFunctions.isModLoaded("iris") && IrisCompat.isShaderPackInUse()) {
|
||||
RenderSystem.setShader(PictureSignConfig.pictureShader.program);
|
||||
}
|
||||
else RenderSystem.setShader(GameRenderer::getPositionColorTexLightmapProgram);
|
||||
|
||||
Identifier texture = null;
|
||||
if (type == PictureSignType.PICTURE) {
|
||||
texture = data.identifier;
|
||||
}
|
||||
else if (type.isVideo)
|
||||
if (videoHandler.isWorking()) RenderSystem.setShaderTexture(0, videoHandler.getTexture());
|
||||
else {
|
||||
var id = VideoHandler.getMissingTexture();
|
||||
if (id == null) return;
|
||||
texture = id;
|
||||
}
|
||||
else return;
|
||||
if (texture != null) RenderSystem.setShaderTexture(0, texture);
|
||||
|
||||
if (PictureSignConfig.translucency) RenderSystem.enableBlend();
|
||||
else RenderSystem.disableBlend();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.depthMask(true);
|
||||
|
||||
matrixStack.push();
|
||||
matrixStack.translate(xOffset + x, y, zOffset + z);
|
||||
matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(yRotation + yRot));
|
||||
matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(xRot));
|
||||
matrixStack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(zRot));
|
||||
|
||||
Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
|
||||
BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE_LIGHT);
|
||||
|
||||
buffer.vertex(matrix4f, width, 0.0F, 1.0F).color(255, 255, 255, 255).texture(1.0F, 1.0F).light(l).overlay(overlay);
|
||||
|
||||
buffer.vertex(matrix4f, width, height, 1.0F).color(255, 255, 255, 255).texture(1.0F, 0.0F).light(l).overlay(overlay);
|
||||
|
||||
buffer.vertex(matrix4f, 0.0F, height, 1.0F).color(255, 255, 255, 255).texture(0.0F, 0.0F).light(l).overlay(overlay);
|
||||
|
||||
buffer.vertex(matrix4f, 0.0F, 0.0F, 1.0F).color(255, 255, 255, 255).texture(0.0F, 1.0F).light(l).overlay(overlay);
|
||||
|
||||
BufferRenderer.drawWithGlobalProgram(buffer.end());
|
||||
|
||||
matrixStack.pop();
|
||||
RenderSystem.disableBlend();
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,374 @@
|
||||
package eu.midnightdust.picturesign.screen;
|
||||
|
||||
import eu.midnightdust.picturesign.PictureSignClient;
|
||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import eu.midnightdust.picturesign.util.PictureSignType;
|
||||
import eu.midnightdust.picturesign.util.PictureURLUtils;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.HangingSignEditScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.SliderWidget;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.TextIconButtonWidget;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.OrderedText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static eu.midnightdust.picturesign.PictureSignClient.id;
|
||||
|
||||
public class PictureSignHelperScreen extends Screen {
|
||||
private static final Identifier TEXTSIGN_ICON_TEXTURE = id("icon/textsign");
|
||||
private static final Identifier CLIPBOARD_ICON_TEXTURE = id("icon/clipboard");
|
||||
private static final Identifier TRASHBIN_ICON_TEXTURE = id("icon/trashbin");
|
||||
private final SignBlockEntity sign;
|
||||
private SignBlockEntityRenderer.SignModel model;
|
||||
protected String[] text;
|
||||
private final boolean front;
|
||||
private final boolean isHanging;
|
||||
protected final WoodType signType;
|
||||
private static boolean switchScreen = false;
|
||||
private PictureSignType type = PictureSignType.PICTURE;
|
||||
|
||||
public PictureSignHelperScreen(SignBlockEntity sign, boolean front, boolean filtered) {
|
||||
super((sign.getCachedState().getBlock() instanceof HangingSignBlock || sign.getCachedState().getBlock() instanceof WallHangingSignBlock) ? Text.translatable("hanging_sign.edit") : Text.translatable("sign.edit"));
|
||||
this.text = IntStream.range(0, 4).mapToObj((row) ->
|
||||
sign.getText(front).getMessage(row, filtered)).map(Text::getString).toArray(String[]::new);
|
||||
this.sign = sign;
|
||||
this.signType = AbstractSignBlock.getWoodType(sign.getCachedState().getBlock());
|
||||
this.isHanging = sign.getCachedState().getBlock() instanceof HangingSignBlock || sign.getCachedState().getBlock() instanceof WallHangingSignBlock;
|
||||
|
||||
this.front = front;
|
||||
}
|
||||
protected void init() {
|
||||
super.init();
|
||||
if (this.client == null) return;
|
||||
text = IntStream.range(0, 4).mapToObj((row) ->
|
||||
sign.getText(front).getMessage(row, false)).map(Text::getString).toArray(String[]::new);
|
||||
if (!text[3].matches("(.*\\d:.*\\d:.*\\d:.*\\d:.*\\d)")) text[3] = "1:1:0:0:0";
|
||||
if (!text[0].startsWith("!")) text[0] = PictureSignType.PICTURE.format+text[0];
|
||||
if (text[2].isBlank() && PictureSignConfig.exceedVanillaLineLength) text[2] = "0:0:0";
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int finalI = i;
|
||||
sign.changeText(changer -> changer.withMessage(finalI, Text.of(text[finalI])), front);
|
||||
}
|
||||
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> this.finishEditing()).dimensions(this.width / 2 - 100, this.height / 4 + 120, 200, 20).build());
|
||||
|
||||
if (PictureSignClient.clipboard != null && PictureSignClient.clipboard[0] != null) {
|
||||
TextIconButtonWidget clipboardBuilder = TextIconButtonWidget.builder(Text.empty(), (buttonWidget) -> {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
text[i] = PictureSignClient.clipboard[i];
|
||||
int finalI = i;
|
||||
sign.changeText(changer -> changer.withMessage(finalI, Text.of(text[finalI])), front);
|
||||
}
|
||||
assert client != null;
|
||||
client.setScreen(this);
|
||||
}, true).texture(CLIPBOARD_ICON_TEXTURE, 16, 16).dimension(20, 20).build();
|
||||
clipboardBuilder.setPosition(this.width - 84, this.height - 40);
|
||||
this.addDrawableChild(clipboardBuilder);
|
||||
}
|
||||
if (PictureSignConfig.helperUi) {
|
||||
TextIconButtonWidget trashbinBuilder = TextIconButtonWidget.builder(Text.empty(), (buttonWidget) -> {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
text[i] = "";
|
||||
int finalI = i;
|
||||
sign.changeText(changer -> changer.withMessage(finalI, Text.empty()), front);
|
||||
}
|
||||
assert client != null;
|
||||
client.setScreen(this);
|
||||
}, true).texture(TRASHBIN_ICON_TEXTURE, 16, 16).dimension(20, 20).build();
|
||||
trashbinBuilder.setPosition(this.width - 62, this.height - 40);
|
||||
this.addDrawableChild(trashbinBuilder);
|
||||
|
||||
TextIconButtonWidget textsignBuilder = TextIconButtonWidget.builder(Text.empty(), (buttonWidget) -> {
|
||||
switchScreen = true;
|
||||
Objects.requireNonNull(client).setScreen(isHanging ? new HangingSignEditScreen(this.sign, false, front) : new SignEditScreen(this.sign, front, false));
|
||||
}, true).texture(TEXTSIGN_ICON_TEXTURE, 16, 16).dimension(20, 20).build();
|
||||
textsignBuilder.setPosition(this.width - 40, this.height - 40);
|
||||
this.addDrawableChild(textsignBuilder);
|
||||
}
|
||||
type = PictureSignType.getType(text[0]);
|
||||
this.addDrawableChild(ButtonWidget.builder(type.name, (buttonWidget) -> {
|
||||
text[0] = text[0].replace(type.format, "");
|
||||
type = type.next();
|
||||
text[0] = type.format + text[0];
|
||||
// if (text[0].startsWith("!PS:")) text[0] = "!VS:" + text[0].replace("!PS:","").replace("!VS:", "").replace("!LS:", "");
|
||||
// else if (text[0].startsWith("!VS:")) text[0] = "!LS:" + text[0].replace("!PS:","").replace("!VS:", "").replace("!LS:", "");
|
||||
// else if (text[0].startsWith("!LS:")) text[0] = "!PS:" + text[0].replace("!PS:","").replace("!VS:", "").replace("!LS:", "");
|
||||
// else text[0] = "!PS:" + text[0].replace("!PS:","").replace("!VS:", "").replace("!LS:", "");
|
||||
// type = PictureSignType.getType(text[0]);
|
||||
buttonWidget.setMessage(type.name);
|
||||
|
||||
sign.changeText(changer -> changer.withMessage(0, Text.of(text[0])), front);
|
||||
}).dimensions(this.width / 2,this.height / 5 + 70,40,20).build());
|
||||
TextFieldWidget linkWidget = new TextFieldWidget(textRenderer,this.width / 2 - 175,this.height / 5 + 13,215,40, Text.of("url"));
|
||||
linkWidget.setMaxLength(900);
|
||||
linkWidget.setText(PictureURLUtils.getLink(sign, front));
|
||||
linkWidget.setChangedListener(s -> {
|
||||
String[] lines = breakLink(type.format, PictureURLUtils.shortenLink(s));
|
||||
for (int i = 0; i < (PictureSignConfig.exceedVanillaLineLength ? 2 : 3); i++) {
|
||||
text[i] = lines[i];
|
||||
int finalI = i;
|
||||
sign.changeText(changer -> changer.withMessage(finalI, Text.of(text[finalI])), front);
|
||||
}
|
||||
});
|
||||
this.addDrawableChild(linkWidget);
|
||||
String[] initialDimensions = text[3].split(":");
|
||||
TextFieldWidget widthWidget = new TextFieldWidget(textRenderer,this.width / 2 - 175,this.height / 5 + 70,30,20, Text.of("width"));
|
||||
TextFieldWidget heightWidget = new TextFieldWidget(textRenderer,this.width / 2 - 140,this.height / 5 + 70,30,20, Text.of("height"));
|
||||
TextFieldWidget posXWidget = new TextFieldWidget(textRenderer,this.width / 2 - 105,this.height / 5 + 70,30,20, Text.of("posX"));
|
||||
TextFieldWidget posYWidget = new TextFieldWidget(textRenderer,this.width / 2 - 70,this.height / 5 + 70,30,20, Text.of("posY"));
|
||||
TextFieldWidget posZWidget = new TextFieldWidget(textRenderer,this.width / 2 - 35,this.height / 5 + 70,30,20, Text.of("posZ"));
|
||||
widthWidget.setText(initialDimensions[0]);
|
||||
heightWidget.setText(initialDimensions[1]);
|
||||
posXWidget.setText(initialDimensions[2]);
|
||||
posYWidget.setText(initialDimensions[3]);
|
||||
posZWidget.setText(initialDimensions[4]);
|
||||
widthWidget.setChangedListener(s -> applyPosition(s, 0));
|
||||
heightWidget.setChangedListener(s -> applyPosition(s, 1));
|
||||
posXWidget.setChangedListener(s -> applyPosition(s, 2));
|
||||
posYWidget.setChangedListener(s -> applyPosition(s, 3));
|
||||
posZWidget.setChangedListener(s -> applyPosition(s, 4));
|
||||
this.addDrawableChild(widthWidget);
|
||||
this.addDrawableChild(heightWidget);
|
||||
this.addDrawableChild(posXWidget);
|
||||
this.addDrawableChild(posYWidget);
|
||||
this.addDrawableChild(posZWidget);
|
||||
if (text[2].matches("(.*\\d:.*\\d:.*\\d)")) addRotationWidgets();
|
||||
this.model = SignBlockEntityRenderer.createSignModel(this.client.getEntityModelLoader(), AbstractSignBlock.getWoodType(sign.getCachedState().getBlock()));
|
||||
}
|
||||
public void applyPosition(String position, int index) {
|
||||
String[] dimensions = new String[5];
|
||||
for (int i = 0; i < dimensions.length; ++i){
|
||||
if (text[3].split(":").length > i)
|
||||
dimensions[i] = text[3].split(":")[i];
|
||||
}
|
||||
dimensions[index] = position;
|
||||
StringBuilder mergedDimensions = new StringBuilder();
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (dimensions[i] == null) dimensions[i] = "";
|
||||
mergedDimensions.append(dimensions[i]);
|
||||
if (i < 4)mergedDimensions.append(":");
|
||||
}
|
||||
text[3] = String.valueOf(mergedDimensions);
|
||||
sign.changeText(changer -> changer.withMessage(3, Text.of(text[3])), front);
|
||||
}
|
||||
public void addRotationWidgets() {
|
||||
String[] initialRotation = text[2].split(":");
|
||||
RotationSliderWidget rotXWidget = new RotationSliderWidget(this.width / 2 - 176,this.height / 5 + 100,70,20, Integer.parseInt(initialRotation[0]));
|
||||
RotationSliderWidget rotYWidget = new RotationSliderWidget(this.width / 2 - 103,this.height / 5 + 100,70,20, Integer.parseInt(initialRotation[1]));
|
||||
RotationSliderWidget rotZWidget = new RotationSliderWidget(this.width / 2 - 30,this.height / 5 + 100,70,20, Integer.parseInt(initialRotation[2]));
|
||||
rotXWidget.setChangedListener(s -> applyRotation(s, 0));
|
||||
rotYWidget.setChangedListener(s -> applyRotation(s, 1));
|
||||
rotZWidget.setChangedListener(s -> applyRotation(s, 2));
|
||||
this.addDrawableChild(rotXWidget);
|
||||
this.addDrawableChild(rotYWidget);
|
||||
this.addDrawableChild(rotZWidget);
|
||||
}
|
||||
public void applyRotation(int rotation, int index) {
|
||||
String[] dimensions = new String[3];
|
||||
for (int i = 0; i < dimensions.length; ++i){
|
||||
if (text[2].split(":").length > i)
|
||||
dimensions[i] = text[2].split(":")[i];
|
||||
}
|
||||
dimensions[index] = String.valueOf(rotation);
|
||||
StringBuilder mergedDimensions = new StringBuilder();
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (dimensions[i] == null) dimensions[i] = "";
|
||||
mergedDimensions.append(dimensions[i]);
|
||||
if (i < 2)mergedDimensions.append(":");
|
||||
}
|
||||
text[2] = String.valueOf(mergedDimensions);
|
||||
sign.changeText(changer -> changer.withMessage(2, Text.of(text[2])), front);
|
||||
}
|
||||
public static class RotationSliderWidget extends SliderWidget {
|
||||
private Consumer<Integer> changedListener;
|
||||
|
||||
public RotationSliderWidget(int x, int y, int width, int height, int rot) {
|
||||
super(x, y, width, height, Text.of(String.valueOf(rot)), rot / (360d));
|
||||
}
|
||||
|
||||
protected void updateMessage() {
|
||||
this.setMessage(Text.of(String.valueOf(getValue())));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyValue() {
|
||||
changedListener.accept(getValue());
|
||||
}
|
||||
|
||||
protected int getValue() {
|
||||
return Double.valueOf(this.value * (360)).intValue();
|
||||
}
|
||||
public void setChangedListener(Consumer<Integer> changedListener) {
|
||||
this.changedListener = changedListener;
|
||||
}
|
||||
}
|
||||
private void finishEditing() {
|
||||
assert this.client != null;
|
||||
switchScreen = false;
|
||||
this.client.setScreen(null);
|
||||
}
|
||||
public void removed() {
|
||||
if (this.client == null || switchScreen) return;
|
||||
ClientPlayNetworkHandler clientPlayNetworkHandler = this.client.getNetworkHandler();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int finalI = i;
|
||||
sign.changeText(changer -> changer.withMessage(finalI, Text.of(text[finalI])), front);
|
||||
}
|
||||
if (clientPlayNetworkHandler != null) {
|
||||
clientPlayNetworkHandler.sendPacket(new UpdateSignC2SPacket(this.sign.getPos(), front, this.text[0], this.text[1], this.text[2], this.text[3]));
|
||||
}
|
||||
}
|
||||
|
||||
private String[] breakLink(String prefix, String link) {
|
||||
Text linkText = Text.of(prefix+link);
|
||||
String[] brokenLink = new String[3];
|
||||
assert client != null;
|
||||
List<OrderedText> text = client.textRenderer.wrapLines(linkText, 90);
|
||||
for (int i = 0; i < text.size(); i++) {
|
||||
String textLine = orderedToString(text.get(i));
|
||||
if (i < (PictureSignConfig.exceedVanillaLineLength ? 2 : 3))
|
||||
brokenLink[i] = textLine;
|
||||
else if (PictureSignConfig.exceedVanillaLineLength) brokenLink[1] += textLine;
|
||||
}
|
||||
|
||||
return brokenLink;
|
||||
}
|
||||
private String orderedToString(OrderedText ordered) {
|
||||
StringBuilder string = new StringBuilder();
|
||||
ordered.accept((i, style, codePoint) -> {
|
||||
string.append(Character.toString(codePoint));
|
||||
return true;
|
||||
}); return string.toString();
|
||||
}
|
||||
@Override
|
||||
public boolean shouldPause() {
|
||||
return false;
|
||||
}
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (!this.sign.getType().supports(this.sign.getCachedState())) {
|
||||
this.finishEditing();
|
||||
}
|
||||
}
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
if (this.client == null) return;
|
||||
DiffuseLighting.disableGuiDepthLighting();
|
||||
context.drawTextWithShadow(textRenderer, Text.of("Link" +
|
||||
(PictureSignConfig.safeMode ? (type.equals(PictureSignType.PICTURE) ? " (imgur.com/imgbb.com/iili.io/pictshare.net)" : " (youtube.com/youtu.be/vimeo.com)") : "")),
|
||||
this.width / 2 - 175, this.height / 5 + 3, -8816268);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("Width"),this.width / 2 - 175, this.height / 5 + 60, -8816268);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("Height"),this.width / 2 - 140, this.height / 5 + 60, -8816268);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("PosX"),this.width / 2 - 105, this.height / 5 + 60, -8816268);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("PosY"),this.width / 2 - 70, this.height / 5 + 60, -8816268);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("PosZ"),this.width / 2 - 35, this.height / 5 + 60, -8816268);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("Mode"),this.width / 2, this.height / 5 + 60, -8816268);
|
||||
if (text[2].matches("(.*\\d:.*\\d:.*\\d)")) {
|
||||
context.drawTextWithShadow(textRenderer, Text.of("RotX"),this.width / 2 - 175, this.height / 5 + 92, -8816268);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("RotY"),this.width / 2 - 103, this.height / 5 + 92, -8816268);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("RotZ"),this.width / 2 - 30, this.height / 5 + 92, -8816268);
|
||||
}
|
||||
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 40, 16777215);
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
matrices.push();
|
||||
VertexConsumerProvider.Immediate immediate = this.client.getBufferBuilders().getEntityVertexConsumers();
|
||||
translateForRender(context, sign.getCachedState());
|
||||
renderSignBackground(context, sign.getCachedState());
|
||||
|
||||
int i = this.sign.getText(front).getColor().getSignColor();
|
||||
matrices.pop();
|
||||
matrices.push();
|
||||
|
||||
context.getMatrices().translate((float)this.width / 2.0F + 100, this.height / 5f + 47.5f, 400.0F);
|
||||
if (sign.getCachedState().getBlock() instanceof SignBlock) context.getMatrices().translate(0,-15f,0);
|
||||
else if (isHanging) context.getMatrices().translate(0,17f,0);
|
||||
Vector3f vector3f = this.getTextScale();
|
||||
context.getMatrices().scale(vector3f.x(), vector3f.y(), vector3f.z());
|
||||
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
|
||||
|
||||
int m;
|
||||
String string;
|
||||
for(m = 0; m < this.text.length; ++m) {
|
||||
string = this.text[m];
|
||||
if (string != null) {
|
||||
if (this.textRenderer.isRightToLeft()) {
|
||||
string = this.textRenderer.mirror(string);
|
||||
}
|
||||
|
||||
float n = (float)(-this.client.textRenderer.getWidth(string) / 2);
|
||||
this.client.textRenderer.draw(string, n, (float)(m * 10 - this.text.length * 5), i, false, matrix4f, immediate, TextRenderer.TextLayerType.NORMAL, 0, 15728880, false);
|
||||
}
|
||||
}
|
||||
|
||||
immediate.draw();
|
||||
|
||||
matrices.pop();
|
||||
DiffuseLighting.enableGuiDepthLighting();
|
||||
}
|
||||
protected void translateForRender(DrawContext context, BlockState state) {
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
if (isHanging) {
|
||||
matrices.translate((float)this.width / 2.0F + 100, this.height / 5f + 50, 50.0F);
|
||||
}
|
||||
else {
|
||||
matrices.push();
|
||||
matrices.translate(this.width / 2f + 100, this.height / 5f - 60, 50.0);
|
||||
matrices.scale(93.75F, -93.75F, 93.75F);
|
||||
matrices.translate(0.0, -1.3125, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderSignBackground(DrawContext context, BlockState state) {
|
||||
if (!isHanging) {
|
||||
VertexConsumerProvider.Immediate immediate = this.client.getBufferBuilders().getEntityVertexConsumers();
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
|
||||
BlockState blockState = this.sign.getCachedState();
|
||||
boolean bl = blockState.getBlock() instanceof SignBlock;
|
||||
if (!bl) {
|
||||
matrices.translate(0.0, -0.15625, 0.0);
|
||||
}
|
||||
matrices.push();
|
||||
matrices.scale(0.6666667F, -0.6666667F, -0.6666667F);
|
||||
|
||||
SpriteIdentifier spriteIdentifier = TexturedRenderLayers.getSignTextureId(AbstractSignBlock.getWoodType(sign.getCachedState().getBlock()));
|
||||
SignBlockEntityRenderer.SignModel var10002 = this.model;
|
||||
Objects.requireNonNull(var10002);
|
||||
VertexConsumer vertexConsumer = spriteIdentifier.getVertexConsumer(immediate, var10002::getLayer);
|
||||
this.model.stick.visible = bl;
|
||||
this.model.root.render(matrices, vertexConsumer, 15728880, OverlayTexture.DEFAULT_UV);
|
||||
matrices.pop();
|
||||
matrices.translate(0.0, 0.3333333432674408, 0.046666666865348816);
|
||||
matrices.scale(0.010416667F, -0.010416667F, 0.010416667F);
|
||||
}
|
||||
else {
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
matrices.scale(4.5F, 4.5F, 1.0F);
|
||||
context.drawTexture(Identifier.ofVanilla("textures/gui/hanging_signs/" + this.signType.name() + ".png"), -8, -8, 0.0F, 0.0F, 16, 16, 16, 16);
|
||||
}
|
||||
}
|
||||
|
||||
protected Vector3f getTextScale() {
|
||||
return isHanging ? new Vector3f(1.0F, 1.0F, 1.0F) : new Vector3f(0.9765628F, 0.9765628F, 0.9765628F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package eu.midnightdust.picturesign.util;
|
||||
|
||||
//import net.irisshaders.iris.api.v0.IrisApi;
|
||||
|
||||
public class IrisCompat {
|
||||
public static boolean isShaderPackInUse() {
|
||||
return false;//IrisApi.getInstance().isShaderPackInUse();
|
||||
}
|
||||
}
|
||||
111
common/src/main/java/eu/midnightdust/picturesign/util/PictureDownloader.java
Executable file
111
common/src/main/java/eu/midnightdust/picturesign/util/PictureDownloader.java
Executable file
@@ -0,0 +1,111 @@
|
||||
package eu.midnightdust.picturesign.util;
|
||||
|
||||
import eu.midnightdust.picturesign.PictureSignClient;
|
||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.texture.NativeImage;
|
||||
import net.minecraft.client.texture.NativeImageBackedTexture;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.Hashtable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import static eu.midnightdust.picturesign.PictureSignClient.MOD_ID;
|
||||
import static java.util.concurrent.Executors.newFixedThreadPool;
|
||||
|
||||
public class PictureDownloader {
|
||||
|
||||
public static class PictureData {
|
||||
public String url;
|
||||
public Identifier identifier;
|
||||
|
||||
public PictureData(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
static PictureDownloader downloader = new PictureDownloader();
|
||||
|
||||
public static PictureDownloader getInstance() {
|
||||
return downloader;
|
||||
}
|
||||
|
||||
// Create a service for downloading the picture
|
||||
private final ExecutorService service = newFixedThreadPool(PictureSignConfig.maxThreads);
|
||||
|
||||
private final Hashtable<String, PictureData> cache = new Hashtable<>();
|
||||
|
||||
private final Object mutex = new Object();
|
||||
|
||||
// Downloads the picture, or returns the cached picture
|
||||
public PictureData getPicture(String url) {
|
||||
synchronized (mutex) {
|
||||
// Try to get the picture from cache
|
||||
PictureData data = this.cache.get(url);
|
||||
if (data == null) {
|
||||
// Download the picture if not in cache
|
||||
this.downloadPicture(url);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.identifier == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
// Download the image and save it in cache
|
||||
private void downloadPicture(String url) {
|
||||
if (PictureSignConfig.debug) PictureSignClient.LOGGER.info("Started downloading picture: " + url);
|
||||
this.cache.put(url, new PictureData(url));
|
||||
|
||||
service.submit(() -> {
|
||||
try {
|
||||
BufferedInputStream in = new BufferedInputStream(new URL(url).openStream());
|
||||
File file = File.createTempFile("."+MOD_ID, "temp");
|
||||
file.deleteOnExit();
|
||||
|
||||
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
|
||||
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
out.write(dataBuffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
out.close();
|
||||
|
||||
// Convert to png
|
||||
BufferedImage bufferedImage = ImageIO.read(file);
|
||||
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
ImageIO.write(bufferedImage, "png", byteArrayOutputStream);
|
||||
|
||||
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
||||
|
||||
NativeImage nativeImage = NativeImage.read(inputStream);
|
||||
NativeImageBackedTexture nativeImageBackedTexture = new NativeImageBackedTexture(nativeImage);
|
||||
|
||||
Identifier texture = MinecraftClient.getInstance().getTextureManager().registerDynamicTexture(MOD_ID+"/image",
|
||||
nativeImageBackedTexture);
|
||||
|
||||
// Cache the downloaded picture
|
||||
synchronized (mutex) {
|
||||
PictureData data = this.cache.get(url);
|
||||
data.identifier = texture;
|
||||
}
|
||||
|
||||
if (PictureSignConfig.debug) PictureSignClient.LOGGER.info("Finished downloading picture: " + url);
|
||||
|
||||
} catch (IOException error) {
|
||||
PictureSignClient.LOGGER.error("Error downloading picture: " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package eu.midnightdust.picturesign.util;
|
||||
|
||||
public record PictureInfo(String url, long start, long end, int volume) {
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package eu.midnightdust.picturesign.util;
|
||||
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public enum PictureSignType {
|
||||
NONE(Text.empty(), ""),
|
||||
PICTURE(Text.of("Image"), "!PS:"),
|
||||
VIDEO(Text.of("Video"), "!VS:", false, true, false),
|
||||
LOOPED_VIDEO(Text.of("Video Loop"), "!LS:", true, true, false),
|
||||
AUDIO(Text.of("Audio"), "!AS:", false, false, true),
|
||||
LOOPED_AUDIO(Text.of("Audio Loop"), "!LAS:", true, false, true);
|
||||
|
||||
public final Text name;
|
||||
public final String format;
|
||||
public final boolean isLooped;
|
||||
public final boolean isVideo;
|
||||
public final boolean isAudio;
|
||||
PictureSignType(Text name, String format) {
|
||||
this(name, format, false, false, false);
|
||||
}
|
||||
|
||||
PictureSignType(Text name, String format, boolean isLooped, boolean isVideo, boolean isAudio) {
|
||||
this.name = name;
|
||||
this.format = format;
|
||||
this.isLooped = isLooped;
|
||||
this.isVideo = isVideo;
|
||||
this.isAudio = isAudio;
|
||||
}
|
||||
|
||||
public static PictureSignType getType(SignBlockEntity signBlockEntity, boolean front) {
|
||||
return getType(signBlockEntity.getText(front).getMessage(0,false).getString());
|
||||
}
|
||||
public static PictureSignType getType(String lineOne) {
|
||||
if (lineOne.startsWith("!PS:")) return PICTURE;
|
||||
else if (lineOne.startsWith("!VS:")) return VIDEO;
|
||||
else if (lineOne.startsWith("!LS:")) return LOOPED_VIDEO;
|
||||
else if (lineOne.startsWith("!AS:")) return AUDIO;
|
||||
else if (lineOne.startsWith("!LAS:")) return LOOPED_AUDIO;
|
||||
else return NONE;
|
||||
}
|
||||
public PictureSignType next() {
|
||||
return switch (this) {
|
||||
case PICTURE -> VIDEO;
|
||||
case VIDEO -> LOOPED_VIDEO;
|
||||
case LOOPED_VIDEO -> AUDIO;
|
||||
case AUDIO -> LOOPED_AUDIO;
|
||||
case LOOPED_AUDIO -> PICTURE;
|
||||
default -> NONE;
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean isNotOfType(SignBlockEntity signBlockEntity, PictureSignType type, boolean front) {
|
||||
return getType(signBlockEntity, front) != type;
|
||||
}
|
||||
public static boolean hasPicture(SignBlockEntity signBlockEntity) {
|
||||
return isNotOfType(signBlockEntity, NONE, true) || isNotOfType(signBlockEntity, NONE, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package eu.midnightdust.picturesign.util;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import eu.midnightdust.picturesign.PictureSignClient;
|
||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PictureURLUtils {
|
||||
public static final Type STRING_TYPE = new TypeToken<Map<String, String>>(){}.getType();
|
||||
public static final Map<String, PictureInfo> cachedJsonData = new HashMap<>();
|
||||
private static final Gson GSON = new GsonBuilder().create();
|
||||
|
||||
public static PictureInfo infoFromJson(String pathToJson) {
|
||||
if (cachedJsonData.containsKey(pathToJson)) return cachedJsonData.get(pathToJson);
|
||||
PictureInfo result = null;
|
||||
URL json = toURL(pathToJson);
|
||||
Map<String, String> jsonData = null;
|
||||
|
||||
try (Reader reader = new InputStreamReader(json.openStream())) {
|
||||
jsonData = GSON.fromJson(reader, STRING_TYPE);
|
||||
} catch (MalformedURLException error) {
|
||||
PictureSignClient.LOGGER.error("Unable to load url from JSON because of connection problems: " + error.getMessage());
|
||||
} catch (IOException error) {
|
||||
PictureSignClient.LOGGER.error("Unable to load url from JSON because of an I/O Exception: " + error.getMessage());
|
||||
}
|
||||
if (PictureSignConfig.debug) PictureSignClient.LOGGER.info("JsonData: "+jsonData);
|
||||
if (jsonData != null && !jsonData.isEmpty() && jsonData.containsKey("url")) {
|
||||
result = new PictureInfo(jsonData.get("url"), getDurationMillis(jsonData.getOrDefault("start_at", "")),
|
||||
getDurationMillis(jsonData.getOrDefault("end_at", "")), Integer.parseInt(jsonData.getOrDefault("volume", "-1")));
|
||||
PictureSignClient.LOGGER.info("URL successfully loaded from JSON!");
|
||||
} else {
|
||||
PictureSignClient.LOGGER.warn("Unable to load url from JSON");
|
||||
}
|
||||
if (PictureSignConfig.debug) PictureSignClient.LOGGER.info("Result: "+result);
|
||||
cachedJsonData.put(pathToJson, result);
|
||||
return result;
|
||||
}
|
||||
private static long getDurationMillis(String duration) {
|
||||
if (duration.isEmpty()) return -1;
|
||||
String[] splitDuration = duration.split(":");
|
||||
if (splitDuration.length != 4) return -1;
|
||||
return TimeUnit.MILLISECONDS.convert(Duration.parse("PT" + splitDuration[0]+"H" + splitDuration[1]+"M" + splitDuration[2]+"S")) + Long.parseLong(splitDuration[3]);
|
||||
}
|
||||
public static URL toURL(String string) {
|
||||
URL result = null;
|
||||
try { result = URI.create(string).toURL(); }
|
||||
catch (MalformedURLException e) {PictureSignClient.LOGGER.warn("Malformed URL: " + e);}
|
||||
return result;
|
||||
}
|
||||
public static String getLink(SignBlockEntity signBlockEntity, boolean front) {
|
||||
String text = signBlockEntity.getText(front).getMessage(0, false).getString() +
|
||||
signBlockEntity.getText(front).getMessage(1, false).getString();
|
||||
if (!signBlockEntity.getText(front).getMessage(2, false).getString().matches("(.*\\d:.*\\d:.*\\d)")) text += signBlockEntity.getText(front).getMessage(2, false).getString();
|
||||
String url = text.replaceAll("!PS:", "").replaceAll("!VS:", "").replaceAll("!LS:", "").replaceAll(" ","");
|
||||
if (url.startsWith("ps:")) url = url.replace("ps:", "https://pictshare.net/");
|
||||
if (url.startsWith("imgur:")) url = url.replace("imgur:", "https://i.imgur.com/");
|
||||
if (url.startsWith("imgbb:")) url = url.replace("imgbb:", "https://i.ibb.co/");
|
||||
if (url.startsWith("iili:")) url = url.replace("iili:", "https://iili.io/");
|
||||
if (url.startsWith("yt:")) url = url.replace("yt:", "https://youtu.be/");
|
||||
return url;
|
||||
}
|
||||
public static String shortenLink(String url) {
|
||||
if (url.contains("pictshare.net/")) url = url.replace("pictshare.net/", "ps:");
|
||||
if (url.contains("i.imgur.com/")) url = url.replace("i.imgur.com/", "imgur:");
|
||||
if (url.contains("i.ibb.co/:")) url = url.replace("i.ibb.co/", "imgbb:");
|
||||
if (url.contains("iili.io/")) url = url.replace("iili.io/", "iili:");
|
||||
if (url.contains("www.youtube.com/")) url = url.replace("www.youtube.com/", "yt:");
|
||||
if (url.contains("youtu.be/")) url = url.replace("youtu.be/", "yt:");
|
||||
if (url.startsWith("https://")) {
|
||||
url = url.replace("https://", "");
|
||||
}
|
||||
if (url.contains("watch?v=")) url = url.replace("watch?v=", "");
|
||||
if (url.contains("&pp=")) url = url.split("&pp=")[0];
|
||||
return url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package eu.midnightdust.picturesign.util;
|
||||
|
||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import me.srrapero720.watermedia.api.player.SyncVideoPlayer;
|
||||
import me.srrapero720.watermedia.api.url.UrlAPI;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static eu.midnightdust.picturesign.PictureSignClient.id;
|
||||
|
||||
public class VideoHandler {
|
||||
public static Map<Identifier, SyncVideoPlayer> videoPlayers = new HashMap<>();
|
||||
|
||||
private final Identifier id;
|
||||
private SyncVideoPlayer player;
|
||||
|
||||
public VideoHandler(Identifier id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void closePlayer() {
|
||||
if (videoPlayers.containsKey(id)) videoPlayers.get(id).release();
|
||||
videoPlayers.remove(id);
|
||||
player = null;
|
||||
}
|
||||
public static void closePlayer(Identifier videoId) {
|
||||
if (videoPlayers.containsKey(videoId)) videoPlayers.get(videoId).release();
|
||||
videoPlayers.remove(videoId);
|
||||
}
|
||||
public static void closeAll() {
|
||||
videoPlayers.forEach(((id, player) -> player.release()));
|
||||
videoPlayers.clear();
|
||||
}
|
||||
public void stop() {
|
||||
player.stop();
|
||||
}
|
||||
public boolean isStopped() {
|
||||
return player.isStopped();
|
||||
}
|
||||
public boolean isPaused() {
|
||||
return player.isPaused();
|
||||
}
|
||||
public void pause() {
|
||||
player.pause();
|
||||
}
|
||||
public void restart() {
|
||||
player.play();
|
||||
}
|
||||
|
||||
public void play(String url) throws MalformedURLException {
|
||||
URL fixedUrl = UrlAPI.fixURL(url).url;
|
||||
System.out.println("Fixed URL: " + fixedUrl);
|
||||
this.player = new SyncVideoPlayer(MinecraftClient.getInstance());
|
||||
videoPlayers.put(id, player);
|
||||
if (player.isBroken()) return;
|
||||
player.start(fixedUrl.toString());
|
||||
}
|
||||
public boolean hasMedia() {
|
||||
return player != null && player.isPlaying();
|
||||
}
|
||||
public void setRepeat(boolean value) {
|
||||
player.setRepeatMode(true);
|
||||
}
|
||||
public long getTime() {
|
||||
return player.getTime();
|
||||
}
|
||||
public void setTime(long value) {
|
||||
player.seekTo(value);
|
||||
}
|
||||
public int getTexture() {
|
||||
return player.getGlTexture();
|
||||
}
|
||||
public boolean isWorking() {
|
||||
return videoPlayers.containsKey(id) && !videoPlayers.get(id).isBroken();
|
||||
}
|
||||
public static Identifier getMissingTexture() {
|
||||
if (PictureSignConfig.missingImageMode.equals(PictureSignConfig.MissingImageMode.TRANSPARENT)) return null;
|
||||
return PictureSignConfig.missingImageMode.equals(PictureSignConfig.MissingImageMode.BLACK) ?
|
||||
(id("textures/black.png")) : (TextureManager.MISSING_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
BIN
common/src/main/resources/assets/picturesign/icon.png
Executable file
BIN
common/src/main/resources/assets/picturesign/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
32
common/src/main/resources/assets/picturesign/lang/de_de.json
Executable file
32
common/src/main/resources/assets/picturesign/lang/de_de.json
Executable file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"picturesign.midnightconfig.title":"PictureSign Konfiguration",
|
||||
|
||||
"picturesign.midnightconfig.enabled":"Aktiviere Bilder",
|
||||
"picturesign.midnightconfig.translucency":"Aktiviere Lichtdurchlässigkeit",
|
||||
"picturesign.midnightconfig.translucency.tooltip":"Lichtdurchlässigkeit funktioniert teilweise nicht richtig\nbei Block-Entities (und dementsprechend Schildern)",
|
||||
"picturesign.midnightconfig.helperUi":"Aktiviere Hilfsoberfäche",
|
||||
"picturesign.midnightconfig.exceedVanillaLineLength":"Überschreite die Vanilla Zeilenlänge",
|
||||
"picturesign.midnightconfig.debug":"Debug-Modus",
|
||||
"picturesign.midnightconfig.maxThreads":"Maximale Download-Threads",
|
||||
"picturesign.midnightconfig.signRenderDistance":"Schildsichtweite",
|
||||
"picturesign.midnightconfig.safeMode":"Sicherer Modus",
|
||||
"picturesign.midnightconfig.safeMode.tooltip":"Lädt nur Bilder von vertrauten Seiten",
|
||||
"picturesign.midnightconfig.ebeWarning":"§cWenn du die Mod 'Enhanced Block Entities' benutzt, stelle sicher, dass du alles in Relation zu Schildern in der EBE Config deaktiviert hast!",
|
||||
"picturesign.midnightconfig.safeProviders":"Sichere Anbieter",
|
||||
"picturesign.midnightconfig.missingImageMode":"Darstellung fehlender Texturen",
|
||||
"picturesign.midnightconfig.enum.MissingImageMode.BLACK":"Schwarz",
|
||||
"picturesign.midnightconfig.enum.MissingImageMode.MISSING_TEXTURE":"Schwarz & Lila",
|
||||
"picturesign.midnightconfig.enum.MissingImageMode.TRANSPARENT":"Transparent",
|
||||
"key.picturesign.copy_sign": "Text eines Schildes kopieren",
|
||||
"key.picturesign.edit_sign":"Schild bearbeiten",
|
||||
|
||||
"picturesign.midnightconfig.category.1general": "Generell",
|
||||
"picturesign.midnightconfig.category.advanced": "Fortgeschritten",
|
||||
"picturesign.midnightconfig.enableVideoSigns": "Aktiviere Videos",
|
||||
"picturesign.midnightconfig.fullBrightPicture": "Höchste Helligkeit",
|
||||
"picturesign.midnightconfig.fullBrightPicture.tooltip": "Sorgt dafür, dass Bilder immer vollkommen beleuchtet dargestellt werden",
|
||||
"picturesign.midnightconfig.invidiousInstance": "Invidious-Instanz",
|
||||
"picturesign.midnightconfig.invidiousInstance.tooltip": "Wähle die Invidious-Instanz aus, die zur Wiedergabe von YouTube-Videos verwendet wird. \nEine Liste dieser ist zu finden unter\ndocs.invidious.io/instances/",
|
||||
"picturesign.midnightconfig.pictureShader": "Render-Programm",
|
||||
"picturesign.midnightconfig.pictureShader.tooltip": "Wähle das Shader-Programm, mit dem die Bilder dargestellt werden, was nützlich ist, wenn diese mit Shaderpacks nicht richtig dargestellt werden"
|
||||
}
|
||||
37
common/src/main/resources/assets/picturesign/lang/en_us.json
Executable file
37
common/src/main/resources/assets/picturesign/lang/en_us.json
Executable file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"picturesign.midnightconfig.title":"PictureSign Config",
|
||||
"picturesign.midnightconfig.category.1general":"General",
|
||||
"picturesign.midnightconfig.category.advanced":"Advanced",
|
||||
|
||||
"picturesign.midnightconfig.enabled":"Enable Pictures",
|
||||
"picturesign.midnightconfig.enableVideoSigns":"Enable Videos",
|
||||
"picturesign.midnightconfig.translucency":"Enable Translucency",
|
||||
"picturesign.midnightconfig.translucency.tooltip":"Translucency doesn't work too great on block entities\n(and therefore signs)",
|
||||
"picturesign.midnightconfig.fullBrightPicture":"Full-bright Pictures",
|
||||
"picturesign.midnightconfig.fullBrightPicture.tooltip":"Makes pictures always appear fully lit",
|
||||
"picturesign.midnightconfig.helperUi":"Enable Helper UI",
|
||||
"picturesign.midnightconfig.exceedVanillaLineLength":"Exceed vanilla line length",
|
||||
"picturesign.midnightconfig.debug":"Debug mode",
|
||||
"picturesign.midnightconfig.maxThreads":"Max download threads",
|
||||
"picturesign.midnightconfig.signRenderDistance":"Sign render distance",
|
||||
"picturesign.midnightconfig.safeMode":"Safe mode",
|
||||
"picturesign.midnightconfig.safeMode.tooltip":"Only load images from trusted providers",
|
||||
"picturesign.midnightconfig.ebeWarning":"§cIf you are using the mod 'Enhanced Block Entities' make sure to disable anything sign-related in it's config!",
|
||||
"picturesign.midnightconfig.safeProviders":"Safe providers",
|
||||
"picturesign.midnightconfig.invidiousInstance":"Invidious Instance",
|
||||
"picturesign.midnightconfig.invidiousInstance.tooltip":"Select the Invidious instance that is being used to play YouTube videos. \nYou can find a list of them at\ndocs.invidious.io/instances/",
|
||||
"picturesign.midnightconfig.missingImageMode":"Missing image mode",
|
||||
"picturesign.midnightconfig.enum.MissingImageMode.BLACK":"Black",
|
||||
"picturesign.midnightconfig.enum.MissingImageMode.MISSING_TEXTURE":"Black & Purple",
|
||||
"picturesign.midnightconfig.enum.MissingImageMode.TRANSPARENT":"Transparent",
|
||||
"picturesign.midnightconfig.pictureShader":"Render Program",
|
||||
"picturesign.midnightconfig.pictureShader.tooltip":"Select the shader program to draw pictures with when using shaderpacks where they appear black/buggy",
|
||||
"picturesign.midnightconfig.enum.PictureShader.PosColTexLight":"PosColTexLight",
|
||||
"picturesign.midnightconfig.enum.PictureShader.RenderTypeCutout":"RenderTypeCutout",
|
||||
"picturesign.midnightconfig.enum.PictureShader.PosTex":"PosTex",
|
||||
"picturesign.midnightconfig.enum.PictureShader.PosColTex":"PosColTex",
|
||||
"picturesign.midnightconfig.enum.PictureShader.PosTexCol":"PosTexCol",
|
||||
"key.picturesign.copy_sign":"Copy Text from Sign",
|
||||
"key.picturesign.edit_sign":"Edit Sign",
|
||||
"key.categories.picturesign":"PictureSign"
|
||||
}
|
||||
BIN
common/src/main/resources/assets/picturesign/textures/black.png
Normal file
BIN
common/src/main/resources/assets/picturesign/textures/black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 104 B |
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
14
common/src/main/resources/picturesign.mixins.json
Executable file
14
common/src/main/resources/picturesign.mixins.json
Executable file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "eu.midnightdust.picturesign.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"MixinSignBlockEntityRenderer",
|
||||
"MixinHangingSignBlockEntityRenderer",
|
||||
"MixinSignEditScreen",
|
||||
"MixinSignBlockEntity"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user