From 6e75026681902ec507f4a03853820790c001a655 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Sun, 19 May 2024 09:27:22 +0200 Subject: [PATCH] Add config option to suppress emulation warnings (#751) --- .../com/viaversion/viabackwards/ViaBackwardsConfig.java | 7 +++++++ .../viaversion/viabackwards/api/ViaBackwardsConfig.java | 7 +++++++ .../rewriter/EntityPacketRewriter1_16_2.java | 2 +- .../v1_17to1_16_4/rewriter/EntityPacketRewriter1_17.java | 2 +- common/src/main/resources/assets/viabackwards/config.yml | 5 ++++- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java b/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java index 5bd6b83e..09164f90 100644 --- a/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java +++ b/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java @@ -34,6 +34,7 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback private boolean alwaysShowOriginalMobName; private boolean fix1_13FormattedInventoryTitles; private boolean handlePingsAsInvAcknowledgements; + private boolean suppressEmulationWarnings; public ViaBackwardsConfig(File configFile, Logger logger) { super(configFile, logger); @@ -52,6 +53,7 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback fix1_13FormattedInventoryTitles = getBoolean("fix-formatted-inventory-titles", true); alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true); handlePingsAsInvAcknowledgements = getBoolean("handle-pings-as-inv-acknowledgements", false); + suppressEmulationWarnings = getBoolean("suppress-emulation-warnings", false); } @Override @@ -84,6 +86,11 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback return handlePingsAsInvAcknowledgements || Boolean.getBoolean("com.viaversion.handlePingsAsInvAcknowledgements"); } + @Override + public boolean suppressEmulationWarnings() { + return suppressEmulationWarnings; + } + @Override public URL getDefaultConfigURL() { return getClass().getClassLoader().getResource("assets/viabackwards/config.yml"); diff --git a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsConfig.java b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsConfig.java index b14fc9ce..c06cb555 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsConfig.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsConfig.java @@ -63,4 +63,11 @@ public interface ViaBackwardsConfig extends Config { * @return true if enabled */ boolean handlePingsAsInvAcknowledgements(); + + /** + * Suppresses warnings of missing emulations for certain features that are not supported (e.g. world height in 1.17+). + * + * @return true if enabled + */ + boolean suppressEmulationWarnings(); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/EntityPacketRewriter1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/EntityPacketRewriter1_16_2.java index 0110cab1..c35fd8b4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/EntityPacketRewriter1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/EntityPacketRewriter1_16_2.java @@ -83,7 +83,7 @@ public class EntityPacketRewriter1_16_2 extends EntityRewriter 256 || logicalHeight.asInt() > 256) { - if (warn && !warned) { + if (warn && !warned && !ViaBackwards.getConfig().suppressEmulationWarnings()) { protocol.getLogger().warning("Increased world height is NOT SUPPORTED for 1.16 players and below. They will see a void below y 0 and above 256"); warned = true; } diff --git a/common/src/main/resources/assets/viabackwards/config.yml b/common/src/main/resources/assets/viabackwards/config.yml index b9ce0f60..ccd3f80e 100644 --- a/common/src/main/resources/assets/viabackwards/config.yml +++ b/common/src/main/resources/assets/viabackwards/config.yml @@ -19,4 +19,7 @@ fix-formatted-inventory-titles: true # # Sends inventory acknowledgement packets to act as a replacement for ping packets for sub 1.17 clients. # This only takes effect for ids in the short range. Useful for anticheat compatibility. -handle-pings-as-inv-acknowledgements: false \ No newline at end of file +handle-pings-as-inv-acknowledgements: false +# +# Suppresses warnings of missing emulations for certain features that are not supported (e.g. world height in 1.17+). +suppress-emulation-warnings: false \ No newline at end of file