Initial Via 4.8.1 update (non working)

This commit is contained in:
RaphiMC 2023-10-05 23:33:11 +02:00
parent 51ada93885
commit 1fb3df2e12
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
5 changed files with 27 additions and 8 deletions

View File

@ -22,7 +22,7 @@ repositories {
} }
dependencies { dependencies {
compileOnly "com.viaversion:viaversion:4.8.0" compileOnly "com.viaversion:viaversion:4.8.1"
compileOnly "org.yaml:snakeyaml:2.2" compileOnly "org.yaml:snakeyaml:2.2"
compileOnly "com.google.guava:guava:32.1.2-jre" compileOnly "com.google.guava:guava:32.1.2-jre"
compileOnly "io.netty:netty-handler:4.1.99.Final" compileOnly "io.netty:netty-handler:4.1.99.Final"

View File

@ -50,6 +50,12 @@ public class Protocolb1_5_0_2tob1_4_0_1 extends AbstractProtocol<ClientboundPack
map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // server hash map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // server hash
} }
}); });
this.registerClientbound(ClientboundPacketsb1_4.HANDSHAKE, ClientboundPacketsb1_5.HANDSHAKE, new PacketHandlers() {
@Override
public void register() {
map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // server hash
}
});
this.registerClientbound(State.LOGIN, ClientboundPacketsb1_4.DISCONNECT.getId(), ClientboundPacketsb1_5.DISCONNECT.getId(), new PacketHandlers() { this.registerClientbound(State.LOGIN, ClientboundPacketsb1_4.DISCONNECT.getId(), ClientboundPacketsb1_5.DISCONNECT.getId(), new PacketHandlers() {
@Override @Override
public void register() { public void register() {

View File

@ -848,10 +848,10 @@ public class Protocol1_3_1_2to1_2_4_5 extends AbstractProtocol<ClientboundPacket
login.write(Type.BYTE, (byte) 0); // world height login.write(Type.BYTE, (byte) 0); // world height
login.write(Type.BYTE, (byte) 0); // max players login.write(Type.BYTE, (byte) 0); // max players
final State oldState = info.getState(); final State oldState = info.getClientState();
info.setState(State.LOGIN); info.setState(State.LOGIN);
login.sendToServer(Protocol1_3_1_2to1_2_4_5.class); login.sendToServer(Protocol1_3_1_2to1_2_4_5.class);
info.setState(oldState); info.setClientState(oldState);
} }
@Override @Override

View File

@ -33,6 +33,7 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap; import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
@ -124,9 +125,13 @@ public class Protocol1_7_2_5to1_6_4 extends AbstractProtocol<ClientboundPackets1
if (!protocolMetadata.skipEncryption) { if (!protocolMetadata.skipEncryption) {
Via.getManager().getProviders().get(EncryptionProvider.class).enableDecryption(wrapper.user()); Via.getManager().getProviders().get(EncryptionProvider.class).enableDecryption(wrapper.user());
} }
// Parts of BaseProtocol1_7 GAME_PROFILE handler
if (info.getProtocolVersion() < ProtocolVersion.v1_20_2.getVersion()) {
info.setState(State.PLAY); info.setState(State.PLAY);
}
Via.getManager().getConnectionManager().onLoginSuccess(wrapper.user()); Via.getManager().getConnectionManager().onLoginSuccess(wrapper.user());
if (info.getPipeline().pipes().stream().allMatch(Via.getManager().getProtocolManager()::isBaseProtocol)) { if (!info.getPipeline().hasNonBaseProtocols()) {
wrapper.user().setActive(false); wrapper.user().setActive(false);
} }
if (Via.getManager().isDebug()) { if (Via.getManager().isDebug()) {
@ -481,8 +486,8 @@ public class Protocol1_7_2_5to1_6_4 extends AbstractProtocol<ClientboundPackets1
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
wrapper.write(Type.STRING, wrapper.read(Types1_6_4.STRING)); // id wrapper.write(Type.STRING, wrapper.read(Types1_6_4.STRING)); // id
wrapper.passthrough(Type.DOUBLE); // baseValue wrapper.passthrough(Type.DOUBLE); // baseValue
final int modifierlength = wrapper.passthrough(Type.SHORT); // modifier count final int modifierCount = wrapper.passthrough(Type.SHORT); // modifier count
for (int x = 0; x < modifierlength; x++) { for (int x = 0; x < modifierCount; x++) {
wrapper.passthrough(Type.UUID); // modifier uuid wrapper.passthrough(Type.UUID); // modifier uuid
wrapper.passthrough(Type.DOUBLE); // modifier amount wrapper.passthrough(Type.DOUBLE); // modifier amount
wrapper.passthrough(Type.BYTE); // modifier operation wrapper.passthrough(Type.BYTE); // modifier operation
@ -1190,7 +1195,7 @@ public class Protocol1_7_2_5to1_6_4 extends AbstractProtocol<ClientboundPackets1
userConnection.getChannel().pipeline().addFirst(new ChannelOutboundHandlerAdapter() { userConnection.getChannel().pipeline().addFirst(new ChannelOutboundHandlerAdapter() {
@Override @Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
if (userConnection.getProtocolInfo().getState().equals(State.PLAY) && ctx.channel().isWritable() && userConnection.get(PlayerInfoStorage.class).entityId != -1) { if (ctx.channel().isWritable() && userConnection.getProtocolInfo().getClientState().equals(State.PLAY) && userConnection.get(PlayerInfoStorage.class).entityId != -1) {
final PacketWrapper disconnect = PacketWrapper.create(ServerboundPackets1_6_4.DISCONNECT, userConnection); final PacketWrapper disconnect = PacketWrapper.create(ServerboundPackets1_6_4.DISCONNECT, userConnection);
disconnect.write(Types1_6_4.STRING, "Quitting"); // reason disconnect.write(Types1_6_4.STRING, "Quitting"); // reason
disconnect.sendToServer(Protocol1_7_2_5to1_6_4.class); disconnect.sendToServer(Protocol1_7_2_5to1_6_4.class);

View File

@ -17,12 +17,14 @@
*/ */
package net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.baseprotocols; package net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.baseprotocols;
import com.viaversion.viaversion.api.connection.ProtocolInfo;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol; import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.base.ServerboundHandshakePackets; import com.viaversion.viaversion.protocols.base.ServerboundHandshakePackets;
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.HandshakeStorage; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.HandshakeStorage;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
@ -48,6 +50,12 @@ public class PreNettyBaseProtocol extends AbstractSimpleProtocol {
}); });
} }
}); });
// Copied from BaseProtocol1_7
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.LOGIN_ACKNOWLEDGED.getId(), ServerboundLoginPackets.LOGIN_ACKNOWLEDGED.getId(), wrapper -> {
final ProtocolInfo info = wrapper.user().getProtocolInfo();
info.setState(State.CONFIGURATION);
});
} }
@Override @Override