Updated old ProtocolHack class references to use the new name

This commit is contained in:
FlorianMichael 2024-03-20 22:03:24 +01:00
parent 8f5e4f87e2
commit 5abef51ce9
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 7 additions and 7 deletions

View File

@ -53,24 +53,24 @@ ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> {
## Get and set the current protocol version
```java
final ProtocolVersion version = ProtocolHack.getTargetVersion();
final ProtocolVersion version = ProtocolTranslator.getTargetVersion();
if (version == ProtocolVersion.v1_8) {
ProtocolHack.setTargetVersion(ProtocolVersion.v1_9);
ProtocolTranslator.setTargetVersion(ProtocolVersion.v1_9);
}
```
## Get a Minecraft ClientConnection by channel
```java
final ClientConnection connection = channel.attr(ProtocolHack.CLIENT_CONNECTION_ATTRIBUTE_KEY).get();
final ClientConnection connection = channel.attr(ProtocolTranslator.CLIENT_CONNECTION_ATTRIBUTE_KEY).get();
```
## Interact with UserConnection objects
```java
// If ViaVersion is translating, this field will return the user connection of the client
final UserConnection userConnection = ProtocolHack.getPlayNetworkUserConnection();
final UserConnection userConnection = ProtocolTranslator.getPlayNetworkUserConnection();
// If you need a dummy user connection for testing, you can use this method
final UserConnection cursedDummy = ProtocolHack.createDummyUserConnection(ProtocolHack.NATIVE_VERSION, ProtocolVersion.v1_18_2);
final UserConnection cursedDummy = ProtocolTranslator.createDummyUserConnection(ProtocolTranslator.NATIVE_VERSION, ProtocolVersion.v1_18_2);
// The cursedDummy field now contains all protocols from the native version to 1.18.2
```

View File

@ -38,7 +38,7 @@ ViaFabricPlus uses Gradle, to make sure that it is installed properly you can ch
- `viaversion_version`
- `viabackwards_version`
- `mod_menu_version`
2. Update the `NATIVE_VERSION` field in the ProtocolHack class to the new version
2. Update the `NATIVE_VERSION` field in the ProtocolTranslator class to the new version
3. Check all mixins in the injection package if they still apply correctly, here is a list of some critical ones:
- `MixinClientPlayerEntity#removeBl8Boolean`
- `MixinClientWorld#tickEntity` and `MixinClientWorld#tickPassenger`

View File

@ -42,7 +42,7 @@ public abstract class MixinMinecraftClient {
}
@Inject(method = "startIntegratedServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/lang/String;ILnet/minecraft/network/listener/ClientLoginPacketListener;)V", shift = At.Shift.BEFORE))
private void disableProtocolHack(LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, boolean newWorld, CallbackInfo ci, @Local ClientConnection clientConnection) {
private void disableProtocolTranslator(LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, boolean newWorld, CallbackInfo ci, @Local ClientConnection clientConnection) {
ProtocolTranslator.setTargetVersion(ProtocolTranslator.NATIVE_VERSION, true);
ProtocolTranslator.injectPreviousVersionReset(clientConnection.channel);
}