From 7fbb61076b0feaabf3fd4d0aacc2f637b52e100d Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Tue, 27 Feb 2024 18:47:07 +0100 Subject: [PATCH] Added config option to enable sprinting for <= beta 1.7.3 servers --- src/main/java/net/raphimc/vialegacy/ViaLegacyConfig.java | 7 +++++++ .../net/raphimc/vialegacy/platform/ViaLegacyConfig.java | 2 ++ .../Protocolb1_8_0_1tob1_7_0_3.java | 7 +++++++ src/main/resources/assets/vialegacy/vialegacy.yml | 3 +++ 4 files changed, 19 insertions(+) diff --git a/src/main/java/net/raphimc/vialegacy/ViaLegacyConfig.java b/src/main/java/net/raphimc/vialegacy/ViaLegacyConfig.java index 7f44cb0..515b034 100644 --- a/src/main/java/net/raphimc/vialegacy/ViaLegacyConfig.java +++ b/src/main/java/net/raphimc/vialegacy/ViaLegacyConfig.java @@ -34,6 +34,7 @@ public class ViaLegacyConfig extends Config implements net.raphimc.vialegacy.pla private boolean soundEmulation; private boolean oldBiomes; private boolean remapBasedOnColor; + private boolean enableB1_7_3Sprinting; private int classicChunkRange; private boolean enableClassicFly; @@ -55,6 +56,7 @@ public class ViaLegacyConfig extends Config implements net.raphimc.vialegacy.pla this.soundEmulation = this.getBoolean("sound-emulation", true); this.oldBiomes = this.getBoolean("old-biomes", true); this.remapBasedOnColor = this.getBoolean("remap-based-on-color", true); + this.enableB1_7_3Sprinting = this.getBoolean("enable-b1_7_3-sprinting", false); this.classicChunkRange = this.getInt("classic-chunk-range", 10); this.enableClassicFly = this.getBoolean("enable-classic-fly", false); } @@ -108,6 +110,11 @@ public class ViaLegacyConfig extends Config implements net.raphimc.vialegacy.pla return this.remapBasedOnColor; } + @Override + public boolean enableB1_7_3Sprinting() { + return this.enableB1_7_3Sprinting; + } + @Override public int getClassicChunkRange() { return this.classicChunkRange; diff --git a/src/main/java/net/raphimc/vialegacy/platform/ViaLegacyConfig.java b/src/main/java/net/raphimc/vialegacy/platform/ViaLegacyConfig.java index 4fd8f7e..f1b5f27 100644 --- a/src/main/java/net/raphimc/vialegacy/platform/ViaLegacyConfig.java +++ b/src/main/java/net/raphimc/vialegacy/platform/ViaLegacyConfig.java @@ -35,6 +35,8 @@ public interface ViaLegacyConfig extends Config { boolean isRemapBasedOnColor(); + boolean enableB1_7_3Sprinting(); + int getClassicChunkRange(); boolean enableClassicFly(); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/Protocolb1_8_0_1tob1_7_0_3.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/Protocolb1_8_0_1tob1_7_0_3.java index cd967e7..4d419c1 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/Protocolb1_8_0_1tob1_7_0_3.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_8_0_1tob1_7_0_3/Protocolb1_8_0_1tob1_7_0_3.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import net.raphimc.vialegacy.ViaLegacy; import net.raphimc.vialegacy.api.data.BlockList1_6; import net.raphimc.vialegacy.api.data.ItemList1_6; import net.raphimc.vialegacy.api.protocol.StatelessProtocol; @@ -96,6 +97,12 @@ public class Protocolb1_8_0_1tob1_7_0_3 extends StatelessProtocol wrapper.user().get(PlayerHealthTracker.class).setHealth(wrapper.get(Type.SHORT, 0))); + handler(wrapper -> { + if (ViaLegacy.getConfig().enableB1_7_3Sprinting()) { + wrapper.set(Type.SHORT, 1, (short) 20); // food + wrapper.set(Type.FLOAT, 0, 0F); // saturation + } + }); } }); this.registerClientbound(ClientboundPacketsb1_7.RESPAWN, new PacketHandlers() { diff --git a/src/main/resources/assets/vialegacy/vialegacy.yml b/src/main/resources/assets/vialegacy/vialegacy.yml index c211487..4617337 100644 --- a/src/main/resources/assets/vialegacy/vialegacy.yml +++ b/src/main/resources/assets/vialegacy/vialegacy.yml @@ -21,6 +21,9 @@ old-biomes: true # Remap <= 1.1 biomes based on color remap-based-on-color: true # +# Enables sprinting for versions below beta 1.8. !THIS CAN CAUSE ISSUES WITH ANTI-CHEAT PLUGINS! +enable-b1_7_3-sprinting: false +# # Classic chunk loading range classic-chunk-range: 10 #