Allow choosing expected server distance check and fix wrong checks on 1.20.5+ by default
This commit is contained in:
parent
88423eeff9
commit
18dea5499f
@ -12,6 +12,29 @@ public class Config implements ConfigData {
|
|||||||
@ConfigEntry.Gui.Tooltip(count = 2) public boolean disableAsyncPlayback;
|
@ConfigEntry.Gui.Tooltip(count = 2) public boolean disableAsyncPlayback;
|
||||||
@ConfigEntry.Gui.Tooltip(count = 2) public boolean omnidirectionalNoteBlockSounds = true;
|
@ConfigEntry.Gui.Tooltip(count = 2) public boolean omnidirectionalNoteBlockSounds = true;
|
||||||
|
|
||||||
|
public enum ExpectedServerVersion {
|
||||||
|
All,
|
||||||
|
v1_20_4_Or_Earlier,
|
||||||
|
v1_20_5_Or_Later;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
if(this == All) {
|
||||||
|
return "All (universal)";
|
||||||
|
}else if(this == v1_20_4_Or_Earlier) {
|
||||||
|
return "≤1.20.4";
|
||||||
|
}else if (this == v1_20_5_Or_Later) {
|
||||||
|
return "≥1.20.5";
|
||||||
|
}else {
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
|
||||||
|
@ConfigEntry.Gui.Tooltip(count = 4)
|
||||||
|
public ExpectedServerVersion expectedServerVersion = ExpectedServerVersion.All;
|
||||||
|
|
||||||
@ConfigEntry.Gui.Excluded
|
@ConfigEntry.Gui.Excluded
|
||||||
public ArrayList<String> favorites = new ArrayList<>();
|
public ArrayList<String> favorites = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,9 @@ import net.minecraft.util.Formatting;
|
|||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Pair;
|
import net.minecraft.util.Pair;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import net.minecraft.world.GameMode;
|
import net.minecraft.world.GameMode;
|
||||||
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -473,7 +471,20 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
|||||||
|
|
||||||
// The server limits interacts to 6 Blocks from Player Eye to Block Center
|
// The server limits interacts to 6 Blocks from Player Eye to Block Center
|
||||||
private boolean canInteractWith(ClientPlayerEntity player, BlockPos blockPos) {
|
private boolean canInteractWith(ClientPlayerEntity player, BlockPos blockPos) {
|
||||||
return player.getEyePos().squaredDistanceTo(new Vec3d(blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5)) <= 6.0*6.0;
|
final Vec3d eyePos = player.getEyePos();
|
||||||
|
if(Main.config.expectedServerVersion == Config.ExpectedServerVersion.v1_20_4_Or_Earlier) {
|
||||||
|
return eyePos.squaredDistanceTo(blockPos.toCenterPos()) <= 6.0 * 6.0;
|
||||||
|
}else if(Main.config.expectedServerVersion == Config.ExpectedServerVersion.v1_20_5_Or_Later) {
|
||||||
|
double blockInteractRange = player.getBlockInteractionRange() + 1.0;
|
||||||
|
return new Box(blockPos).squaredMagnitude(eyePos) < blockInteractRange * blockInteractRange;
|
||||||
|
}else if(Main.config.expectedServerVersion == Config.ExpectedServerVersion.All) {
|
||||||
|
// Require both checks to succeed (aka use worst distance)
|
||||||
|
double blockInteractRange = player.getBlockInteractionRange() + 1.0;
|
||||||
|
return eyePos.squaredDistanceTo(blockPos.toCenterPos()) <= 6.0 * 6.0
|
||||||
|
&& new Box(blockPos).squaredMagnitude(eyePos) < blockInteractRange * blockInteractRange;
|
||||||
|
}else {
|
||||||
|
throw new NotImplementedException("ExpectedServerVersion Value not implemented: " + Main.config.expectedServerVersion.name());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getSongElapsedSeconds() {
|
public double getSongElapsedSeconds() {
|
||||||
|
@ -44,5 +44,10 @@
|
|||||||
"text.autoconfig.disc_jockey.option.disableAsyncPlayback.@Tooltip[1]": "This can lead to performance loss, especially when you client has low or inconsistent fps but can fix issues when playback does not happen at all.",
|
"text.autoconfig.disc_jockey.option.disableAsyncPlayback.@Tooltip[1]": "This can lead to performance loss, especially when you client has low or inconsistent fps but can fix issues when playback does not happen at all.",
|
||||||
"text.autoconfig.disc_jockey.option.omnidirectionalNoteBlockSounds": "Omnidirectional Note Block Sounds (clientside)",
|
"text.autoconfig.disc_jockey.option.omnidirectionalNoteBlockSounds": "Omnidirectional Note Block Sounds (clientside)",
|
||||||
"text.autoconfig.disc_jockey.option.omnidirectionalNoteBlockSounds.@Tooltip[0]": "Makes all note block sounds when playing a song omnidirectional, creating a more pleasing listening experience",
|
"text.autoconfig.disc_jockey.option.omnidirectionalNoteBlockSounds.@Tooltip[0]": "Makes all note block sounds when playing a song omnidirectional, creating a more pleasing listening experience",
|
||||||
"text.autoconfig.disc_jockey.option.omnidirectionalNoteBlockSounds.@Tooltip[1]": "If you don't know what that means, I recommend you just try it and hear the difference"
|
"text.autoconfig.disc_jockey.option.omnidirectionalNoteBlockSounds.@Tooltip[1]": "If you don't know what that means, I recommend you just try it and hear the difference",
|
||||||
|
"text.autoconfig.disc_jockey.option.expectedServerVersion": "Expected Server Version",
|
||||||
|
"text.autoconfig.disc_jockey.option.expectedServerVersion.@Tooltip[0]": "Select the server version, you expect this mod to be used on.",
|
||||||
|
"text.autoconfig.disc_jockey.option.expectedServerVersion.@Tooltip[1]": "This affects how reachable NoteBlocks are determined.",
|
||||||
|
"text.autoconfig.disc_jockey.option.expectedServerVersion.@Tooltip[2]": "Selecting the wrong version could cause you not to be able to play some distant note blocks which could break/worsen playback",
|
||||||
|
"text.autoconfig.disc_jockey.option.expectedServerVersion.@Tooltip[3]": "If you're unsure, or play on many different server versions and don't mind not reaching every possible note block, select \"All\""
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user