mirror of
https://github.com/TeamMidnightDust/PictureSign.git
synced 2025-12-16 06:05:09 +01:00
Allow defining the media volume via JSON
- Also verify JSON hosting website is safe to avoid IP-Grabbers on multiplayer servers
This commit is contained in:
@@ -25,6 +25,7 @@ public class MediaHandler {
|
||||
public boolean playbackStarted = false;
|
||||
public boolean isDeactivated;
|
||||
private SyncBasePlayer player;
|
||||
private int maxVolume = 100;
|
||||
|
||||
private MediaHandler(Identifier id, BlockPos pos) {
|
||||
this.id = id;
|
||||
@@ -44,11 +45,14 @@ public class MediaHandler {
|
||||
return;
|
||||
}
|
||||
double distance = this.pos.getSquaredDistance(playerPos) / PictureSignConfig.audioDistanceMultiplier;
|
||||
setVolume((int) Math.clamp(100-distance, 0, 100));
|
||||
setVolume((int) Math.clamp(maxVolume-distance, 0, 100));
|
||||
}
|
||||
private void setVolume(int volume) {
|
||||
player.setVolume(volume);
|
||||
}
|
||||
public void setMaxVolume(int volume) {
|
||||
maxVolume = volume;
|
||||
}
|
||||
|
||||
public void closePlayer() {
|
||||
if (player != null) {
|
||||
|
||||
Reference in New Issue
Block a user