3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Add option to fix wrong block placement rotation in 1.20.5->1.21 (#4166)

Dieser Commit ist enthalten in:
EnZaXD 2024-10-06 15:19:05 +02:00 committet von GitHub
Ursprung 9df1704357
Commit 9674c617ca
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
4 geänderte Dateien mit 38 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -471,4 +471,11 @@ public interface ViaVersionConfig extends Config {
* @return true if enabled * @return true if enabled
*/ */
boolean hideScoreboardNumbers(); boolean hideScoreboardNumbers();
/**
* Fixes 1.21+ clients on 1.20.5 servers placing water/lava buckets at the wrong location when moving fast.
*
* @return true if enabled
*/
boolean fix1_21PlacementRotation();
} }

Datei anzeigen

@ -25,14 +25,14 @@ import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.protocol.BlockedProtocolVersionsImpl; import com.viaversion.viaversion.protocol.BlockedProtocolVersionsImpl;
import com.viaversion.viaversion.util.Config; import com.viaversion.viaversion.util.Config;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public abstract class AbstractViaConfig extends Config implements ViaVersionConfig { public abstract class AbstractViaConfig extends Config implements ViaVersionConfig {
@ -95,6 +95,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
private boolean handleInvalidItemCount; private boolean handleInvalidItemCount;
private boolean cancelBlockSounds; private boolean cancelBlockSounds;
private boolean hideScoreboardNumbers; private boolean hideScoreboardNumbers;
private boolean fix1_21PlacementRotation;
protected AbstractViaConfig(final File configFile, final Logger logger) { protected AbstractViaConfig(final File configFile, final Logger logger) {
super(configFile, logger); super(configFile, logger);
@ -163,6 +164,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
handleInvalidItemCount = getBoolean("handle-invalid-item-count", false); handleInvalidItemCount = getBoolean("handle-invalid-item-count", false);
cancelBlockSounds = getBoolean("cancel-block-sounds", true); cancelBlockSounds = getBoolean("cancel-block-sounds", true);
hideScoreboardNumbers = getBoolean("hide-scoreboard-numbers", false); hideScoreboardNumbers = getBoolean("hide-scoreboard-numbers", false);
fix1_21PlacementRotation = getBoolean("fix-1_21-placement-rotation", false);
} }
private BlockedProtocolVersions loadBlockedProtocolVersions() { private BlockedProtocolVersions loadBlockedProtocolVersions() {
@ -549,4 +551,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
public boolean hideScoreboardNumbers() { public boolean hideScoreboardNumbers() {
return hideScoreboardNumbers; return hideScoreboardNumbers;
} }
@Override
public boolean fix1_21PlacementRotation() {
return fix1_21PlacementRotation;
}
} }

Datei anzeigen

@ -19,12 +19,14 @@ package com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter;
import com.viaversion.nbt.tag.ByteTag; import com.viaversion.nbt.tag.ByteTag;
import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer; import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5; import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5;
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_21; import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_21;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
@ -105,8 +107,22 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<Cl
protocol.registerServerbound(ServerboundPackets1_20_5.USE_ITEM, wrapper -> { protocol.registerServerbound(ServerboundPackets1_20_5.USE_ITEM, wrapper -> {
wrapper.passthrough(Types.VAR_INT); // Hand wrapper.passthrough(Types.VAR_INT); // Hand
wrapper.passthrough(Types.VAR_INT); // Sequence wrapper.passthrough(Types.VAR_INT); // Sequence
wrapper.read(Types.FLOAT); // Y rotation final float yaw = wrapper.read(Types.FLOAT); // Y rotation
wrapper.read(Types.FLOAT); // X rotation final float pitch = wrapper.read(Types.FLOAT); // X rotation
if (!Via.getConfig().fix1_21PlacementRotation()) {
return;
}
// Not correct but *enough* for vanilla/normal servers to have block placement synchronized
final PacketWrapper playerRotation = wrapper.create(ServerboundPackets1_20_5.MOVE_PLAYER_ROT);
playerRotation.write(Types.FLOAT, yaw);
playerRotation.write(Types.FLOAT, pitch);
playerRotation.write(Types.BOOLEAN, true); // On Ground
playerRotation.sendToServer(Protocol1_20_5To1_21.class);
wrapper.sendToServer(Protocol1_20_5To1_21.class);
wrapper.cancel();
}); });
new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.UPDATE_RECIPES); new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.UPDATE_RECIPES);

Datei anzeigen

@ -167,6 +167,9 @@ handle-invalid-item-count: false
# Hides scoreboard numbers for 1.20.3+ clients on older server versions. # Hides scoreboard numbers for 1.20.3+ clients on older server versions.
hide-scoreboard-numbers: false hide-scoreboard-numbers: false
# #
# Fixes 1.21+ clients on 1.20.5 servers placing water/lava buckets at the wrong location when moving fast, NOTE: This may cause issues with anti-cheat plugins.
fix-1_21-placement-rotation: false
#
#----------------------------------------------------------# #----------------------------------------------------------#
# 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS # # 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #
#----------------------------------------------------------# #----------------------------------------------------------#
@ -211,4 +214,4 @@ chunk-border-fix: false
# Allows 1.9+ left-handedness (main hand) on 1.8 servers # Allows 1.9+ left-handedness (main hand) on 1.8 servers
left-handed-handling: true left-handed-handling: true
# Tries to cancel block break/place sounds sent by 1.8 servers to 1.9+ clients to prevent them from playing twice # Tries to cancel block break/place sounds sent by 1.8 servers to 1.9+ clients to prevent them from playing twice
cancel-block-sounds: true cancel-block-sounds: true