Added config option to enable sprinting for <= beta 1.7.3 servers

This commit is contained in:
RaphiMC 2024-02-27 18:47:07 +01:00
parent 45a0e1cf24
commit 7fbb61076b
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
4 changed files with 19 additions and 0 deletions

View File

@ -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;

View File

@ -35,6 +35,8 @@ public interface ViaLegacyConfig extends Config {
boolean isRemapBasedOnColor();
boolean enableB1_7_3Sprinting();
int getClassicChunkRange();
boolean enableClassicFly();

View File

@ -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<ClientboundPac
create(Type.SHORT, (short) 6); // food
create(Type.FLOAT, 0F); // saturation
handler(wrapper -> 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() {

View File

@ -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
#