mirror of
https://github.com/TeamMidnightDust/PictureSign.git
synced 2025-12-11 12:05:09 +01:00
Fix some issues related to multimedia
This commit is contained in:
@@ -14,7 +14,7 @@ public class PictureSignConfig extends MidnightConfig {
|
||||
|
||||
@Entry(category = general) public static boolean enabled = true;
|
||||
@Entry(category = general) public static boolean enableVideoSigns = true;
|
||||
@Entry(min = 1, max = 1000, isSlider = true, category = general) public static int audioDistanceMultiplier = 10;
|
||||
@Entry(min = 0, max = 1000, isSlider = true, category = general) public static int audioDistanceMultiplier = 30;
|
||||
@Entry(category = general) public static boolean translucency = false;
|
||||
@Entry(category = general) public static boolean fullBrightPicture = false;
|
||||
@Entry(category = general) public static boolean helperUi = true;
|
||||
|
||||
@@ -12,10 +12,7 @@ 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.gui.widget.*;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
|
||||
@@ -29,6 +26,7 @@ import net.minecraft.util.Identifier;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
@@ -47,6 +45,7 @@ public class PictureSignHelperScreen extends Screen {
|
||||
private final boolean isHanging;
|
||||
protected final WoodType signType;
|
||||
private static boolean switchScreen = false;
|
||||
private List<ClickableWidget> pictureWidgets = new ArrayList<>();
|
||||
private PictureSignType type = PictureSignType.PICTURE;
|
||||
|
||||
public PictureSignHelperScreen(SignBlockEntity sign, boolean front, boolean filtered) {
|
||||
@@ -153,6 +152,12 @@ public class PictureSignHelperScreen extends Screen {
|
||||
this.addDrawableChild(posXWidget);
|
||||
this.addDrawableChild(posYWidget);
|
||||
this.addDrawableChild(posZWidget);
|
||||
|
||||
pictureWidgets.add(widthWidget);
|
||||
pictureWidgets.add(heightWidget);
|
||||
pictureWidgets.add(posXWidget);
|
||||
pictureWidgets.add(posYWidget);
|
||||
pictureWidgets.add(posZWidget);
|
||||
if (text[2].matches("(.*\\d:.*\\d:.*\\d)")) addRotationWidgets();
|
||||
this.model = SignBlockEntityRenderer.createSignModel(this.client.getEntityModelLoader(), AbstractSignBlock.getWoodType(sign.getCachedState().getBlock()));
|
||||
}
|
||||
@@ -183,6 +188,10 @@ public class PictureSignHelperScreen extends Screen {
|
||||
this.addDrawableChild(rotXWidget);
|
||||
this.addDrawableChild(rotYWidget);
|
||||
this.addDrawableChild(rotZWidget);
|
||||
|
||||
pictureWidgets.add(rotXWidget);
|
||||
pictureWidgets.add(rotYWidget);
|
||||
pictureWidgets.add(rotZWidget);
|
||||
}
|
||||
public void applyRotation(int rotation, int index) {
|
||||
String[] dimensions = new String[3];
|
||||
@@ -279,6 +288,8 @@ public class PictureSignHelperScreen extends Screen {
|
||||
else if (type.isVideo) enabledWebsites = " (youtube.com/youtu.be/vimeo.com)";
|
||||
else if (type.isAudio) enabledWebsites = " (youtube.com/youtu.be/vimeo.com/freesound.org)";
|
||||
}
|
||||
if (type.isAudio) pictureWidgets.forEach(widget -> widget.active = false);
|
||||
else pictureWidgets.forEach(widget -> widget.active = true);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("Link" + enabledWebsites),
|
||||
this.width / 2 - 175, this.height / 5 + 3, -8816268);
|
||||
context.drawTextWithShadow(textRenderer, Text.of("Width"),this.width / 2 - 175, this.height / 5 + 60, -8816268);
|
||||
|
||||
@@ -49,8 +49,6 @@ public class GIFHandler {
|
||||
}
|
||||
|
||||
public void play(String url) throws MalformedURLException {
|
||||
System.out.println(url);
|
||||
System.out.println(UrlAPI.fixURL(url).assumeVideo);
|
||||
this.player = ImageAPI.getCache(url, MinecraftClient.getInstance());
|
||||
player.load();
|
||||
this.playbackStarted = true;
|
||||
|
||||
@@ -4,17 +4,13 @@ import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||
import me.srrapero720.watermedia.api.player.SyncBasePlayer;
|
||||
import me.srrapero720.watermedia.api.player.SyncMusicPlayer;
|
||||
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 net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -40,19 +36,26 @@ public class MediaHandler {
|
||||
else return new MediaHandler(id, pos);
|
||||
}
|
||||
public void setVolumeBasedOnDistance() {
|
||||
if (client.player == null) return;
|
||||
if (player == null || client.player == null) return;
|
||||
|
||||
Vec3d playerPos = client.player.getPos();
|
||||
if (PictureSignConfig.audioDistanceMultiplier == 0) {
|
||||
setVolume(0);
|
||||
return;
|
||||
}
|
||||
double distance = this.pos.getSquaredDistance(playerPos) / PictureSignConfig.audioDistanceMultiplier;
|
||||
this.setVolume((int) Math.clamp(100-distance, 0, 100));
|
||||
setVolume((int) Math.clamp(100-distance, 0, 100));
|
||||
}
|
||||
private void setVolume(int volume) {
|
||||
player.setVolume(volume);
|
||||
}
|
||||
|
||||
public void closePlayer() {
|
||||
if (player != null) player.release();
|
||||
mediaPlayers.remove(id);
|
||||
if (player != null) {
|
||||
player.stop();
|
||||
player.release();
|
||||
}
|
||||
//mediaPlayers.remove(id);
|
||||
player = null;
|
||||
}
|
||||
public static void closePlayer(Identifier videoId) {
|
||||
@@ -80,12 +83,10 @@ public class MediaHandler {
|
||||
}
|
||||
|
||||
public void play(String url, boolean isVideo) throws MalformedURLException {
|
||||
URL fixedUrl = UrlAPI.fixURL(url).url;
|
||||
System.out.println("Fixed URL: " + fixedUrl);
|
||||
this.player = isVideo ? new SyncVideoPlayer(MinecraftClient.getInstance()) : new SyncMusicPlayer();
|
||||
mediaPlayers.put(id, this);
|
||||
if (player.isBroken()) return;
|
||||
player.start(fixedUrl.toString());
|
||||
player.start(url);
|
||||
this.playbackStarted = true;
|
||||
}
|
||||
public boolean hasMedia() {
|
||||
@@ -105,7 +106,7 @@ public class MediaHandler {
|
||||
return -1;
|
||||
}
|
||||
public boolean isWorking() {
|
||||
return mediaPlayers.containsKey(id) && !mediaPlayers.get(id).player.isBroken();
|
||||
return mediaPlayers.containsKey(id) && mediaPlayers.get(id).player != null && !mediaPlayers.get(id).player.isBroken();
|
||||
}
|
||||
public static Identifier getMissingTexture() {
|
||||
if (PictureSignConfig.missingImageMode.equals(PictureSignConfig.MissingImageMode.TRANSPARENT)) return null;
|
||||
|
||||
@@ -15,7 +15,7 @@ midnightlib_version=1.5.7
|
||||
watermedia_version=2.0.63
|
||||
|
||||
iris_version=1.6.17+1.20.4
|
||||
LATEST_IRIS_VERSION_CAUSES_BUILD_FAILURE=ThisIsFine
|
||||
# The latest Iris version causes the build to fail, but we don't need that anyway
|
||||
|
||||
fabric_loader_version=0.15.11
|
||||
fabric_api_version=0.100.1+1.21
|
||||
|
||||
Reference in New Issue
Block a user