mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-10 10:11:03 +01:00
Updated to ViaVersion 5
This commit is contained in:
parent
8600180f30
commit
a958c059f2
14
build.gradle
14
build.gradle
@ -54,16 +54,16 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
include "com.viaversion:viaversion-common:4.10.1"
|
||||
include "com.viaversion:viabackwards-common:4.10.1"
|
||||
include "com.viaversion:viarewind-common:3.1.1"
|
||||
include "net.raphimc:ViaLegacy:2.2.23-SNAPSHOT"
|
||||
include "net.raphimc:ViaAprilFools:2.0.13-SNAPSHOT"
|
||||
include("net.raphimc:ViaBedrock:0.0.7-SNAPSHOT") {
|
||||
include "com.viaversion:viaversion-common:5.0.0-20240517.161911-7"
|
||||
include "com.viaversion:viabackwards-common:5.0.0-20240515.152913-2"
|
||||
include "com.viaversion:viarewind-common:4.0.0-20240515.083613-2"
|
||||
include "net.raphimc:ViaLegacy:3.0.0-20240517.153112-1"
|
||||
include "net.raphimc:ViaAprilFools:3.0.0-20240517.172611-2"
|
||||
include("net.raphimc:ViaBedrock:0.0.8-20240517.153009-1") {
|
||||
exclude group: "io.netty"
|
||||
exclude group: "io.jsonwebtoken"
|
||||
}
|
||||
include("net.raphimc:ViaLoader:2.2.14-SNAPSHOT") {
|
||||
include("net.raphimc:ViaLoader:3.0.0-SNAPSHOT") {
|
||||
exclude group: "org.slf4j", module: "slf4j-api"
|
||||
}
|
||||
|
||||
|
@ -4,4 +4,4 @@ org.gradle.configureondemand=true
|
||||
|
||||
maven_group=net.raphimc
|
||||
maven_name=ViaProxy
|
||||
maven_version=3.2.3-SNAPSHOT
|
||||
maven_version=3.3.0-SNAPSHOT
|
||||
|
@ -17,15 +17,15 @@
|
||||
*/
|
||||
package net.raphimc.viaproxy.injection;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.model.ClassicLevel;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicWorldHeightProvider;
|
||||
@ -43,10 +43,10 @@ public class ClassicWorldHeightInjection {
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
for (CompoundTag dimension : wrapper.get(Type.NAMED_COMPOUND_TAG, 0).getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class)) {
|
||||
for (CompoundTag dimension : wrapper.get(Types.NAMED_COMPOUND_TAG, 0).getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class)) {
|
||||
changeDimensionTagHeight(wrapper.user(), dimension.getCompoundTag("element"));
|
||||
}
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 1));
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Types.NAMED_COMPOUND_TAG, 1));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -57,7 +57,7 @@ public class ClassicWorldHeightInjection {
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0));
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Types.NAMED_COMPOUND_TAG, 0));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -101,14 +101,14 @@ public class ClassicWorldHeightInjection {
|
||||
final PacketHandler classicLightHandler = new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // x
|
||||
map(Type.VAR_INT); // y
|
||||
map(Type.BOOLEAN); // trust edges
|
||||
map(Types.VAR_INT); // x
|
||||
map(Types.VAR_INT); // y
|
||||
map(Types.BOOLEAN); // trust edges
|
||||
handler(wrapper -> {
|
||||
wrapper.read(Type.VAR_INT); // sky light mask
|
||||
wrapper.read(Type.VAR_INT); // block light mask
|
||||
final int emptySkyLightMask = wrapper.read(Type.VAR_INT); // empty sky light mask
|
||||
final int emptyBlockLightMask = wrapper.read(Type.VAR_INT); // empty block light mask
|
||||
wrapper.read(Types.VAR_INT); // sky light mask
|
||||
wrapper.read(Types.VAR_INT); // block light mask
|
||||
final int emptySkyLightMask = wrapper.read(Types.VAR_INT); // empty sky light mask
|
||||
final int emptyBlockLightMask = wrapper.read(Types.VAR_INT); // empty block light mask
|
||||
|
||||
final ClassicLevel level = wrapper.user().get(ClassicLevelStorage.class).getClassicLevel();
|
||||
final ClassicWorldHeightProvider heightProvider = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class);
|
||||
@ -120,8 +120,8 @@ public class ClassicWorldHeightInjection {
|
||||
}
|
||||
|
||||
final List<byte[]> lightArrays = new ArrayList<>();
|
||||
while (wrapper.isReadable(Type.BYTE_ARRAY_PRIMITIVE, 0)) {
|
||||
lightArrays.add(wrapper.read(Type.BYTE_ARRAY_PRIMITIVE));
|
||||
while (wrapper.isReadable(Types.BYTE_ARRAY_PRIMITIVE, 0)) {
|
||||
lightArrays.add(wrapper.read(Types.BYTE_ARRAY_PRIMITIVE));
|
||||
}
|
||||
|
||||
int skyLightCount = 16;
|
||||
@ -139,18 +139,18 @@ public class ClassicWorldHeightInjection {
|
||||
skyLightMask.set(0, skyLightCount);
|
||||
blockLightMask.set(0, blockLightCount);
|
||||
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, skyLightMask.toLongArray());
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, blockLightMask.toLongArray());
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[emptySkyLightMask]);
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[emptyBlockLightMask]);
|
||||
wrapper.write(Types.LONG_ARRAY_PRIMITIVE, skyLightMask.toLongArray());
|
||||
wrapper.write(Types.LONG_ARRAY_PRIMITIVE, blockLightMask.toLongArray());
|
||||
wrapper.write(Types.LONG_ARRAY_PRIMITIVE, new long[emptySkyLightMask]);
|
||||
wrapper.write(Types.LONG_ARRAY_PRIMITIVE, new long[emptyBlockLightMask]);
|
||||
|
||||
wrapper.write(Type.VAR_INT, skyLightCount);
|
||||
wrapper.write(Types.VAR_INT, skyLightCount);
|
||||
for (int i = 0; i < skyLightCount; i++) {
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
wrapper.write(Types.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, blockLightCount);
|
||||
wrapper.write(Types.VAR_INT, blockLightCount);
|
||||
for (int i = 0; i < blockLightCount; i++) {
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
wrapper.write(Types.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPacket1_20_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPacket1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.rewriter.BlockItemPacketRewriter1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPacket1_20_3;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.Protocol1_20_3To1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter.BlockItemPacketRewriter1_20_5;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.viaproxy.ViaProxy;
|
||||
@ -52,7 +52,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import java.util.*;
|
||||
|
||||
@Mixin(value = BlockItemPacketRewriter1_20_5.class, remap = false)
|
||||
public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<ClientboundPacket1_20_3, ServerboundPacket1_20_5, Protocol1_20_5To1_20_3> {
|
||||
public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<ClientboundPacket1_20_3, ServerboundPacket1_20_5, Protocol1_20_3To1_20_5> {
|
||||
|
||||
@Unique
|
||||
private final Set<String> foodItems_b1_7_3 = new HashSet<>();
|
||||
@ -71,7 +71,7 @@ public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<Cl
|
||||
}
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void loadItemMappings(Protocol1_20_5To1_20_3 protocol, CallbackInfo ci) {
|
||||
public void loadItemMappings(Protocol1_20_3To1_20_5 protocol, CallbackInfo ci) {
|
||||
this.foodItems_b1_7_3.add("minecraft:apple");
|
||||
this.foodItems_b1_7_3.add("minecraft:mushroom_stew");
|
||||
this.foodItems_b1_7_3.add("minecraft:bread");
|
||||
@ -129,25 +129,25 @@ public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<Cl
|
||||
}
|
||||
|
||||
@Inject(method = "toStructuredItem", at = @At("RETURN"))
|
||||
private void appendItemDataFixComponents(UserConnection connection, Item old, CallbackInfoReturnable<Item> cir) {
|
||||
private void appendItemDataFixComponents(UserConnection user, Item old, CallbackInfoReturnable<Item> cir) {
|
||||
final StructuredDataContainer data = cir.getReturnValue().structuredData();
|
||||
final String identifier = this.protocol.getMappingData().getFullItemMappings().identifier(cir.getReturnValue().identifier());
|
||||
if (connection.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
|
||||
if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
|
||||
if (identifier.equals("minecraft:crossbow")) {
|
||||
data.set(StructuredDataKey.MAX_DAMAGE, 326);
|
||||
}
|
||||
}
|
||||
if (connection.getProtocolInfo().serverProtocolVersion().betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8)) {
|
||||
if (user.getProtocolInfo().serverProtocolVersion().betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8)) {
|
||||
if (this.swordItems1_8.contains(identifier)) {
|
||||
data.set(StructuredDataKey.FOOD, new FoodProperties(0, 0F, true, 3600, new FoodEffect[0]));
|
||||
}
|
||||
}
|
||||
if (connection.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
if (this.armorMaxDamage_b1_8_1.containsKey(identifier)) {
|
||||
data.set(StructuredDataKey.MAX_DAMAGE, this.armorMaxDamage_b1_8_1.get(identifier));
|
||||
}
|
||||
}
|
||||
if (connection.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) {
|
||||
if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) {
|
||||
if (this.foodItems_b1_7_3.contains(identifier)) {
|
||||
data.set(StructuredDataKey.MAX_STACK_SIZE, 1);
|
||||
data.addEmpty(StructuredDataKey.FOOD);
|
||||
@ -155,7 +155,7 @@ public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<Cl
|
||||
}
|
||||
|
||||
for (Map.Entry<ProtocolVersion, Map<String, ToolProperties>> entry : this.toolDataChanges.entrySet()) {
|
||||
if (connection.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(entry.getKey())) {
|
||||
if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(entry.getKey())) {
|
||||
final ToolProperties toolProperties = entry.getValue().get(identifier);
|
||||
if (toolProperties != null) {
|
||||
data.set(StructuredDataKey.TOOL, toolProperties);
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
package net.raphimc.viaproxy.injection.mixins;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CommandBlockProvider;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.provider.CommandBlockProvider;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
@ -20,20 +20,20 @@ package net.raphimc.viaproxy.injection.mixins;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets.EntityPackets;
|
||||
import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.v1_16_4to1_17.Protocol1_16_4To1_17;
|
||||
import com.viaversion.viaversion.protocols.v1_16_4to1_17.rewriter.EntityPacketRewriter1_17;
|
||||
import net.raphimc.viaproxy.injection.ClassicWorldHeightInjection;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(value = EntityPackets.class, remap = false)
|
||||
public abstract class MixinEntityPackets1_17 {
|
||||
@Mixin(value = EntityPacketRewriter1_17.class, remap = false)
|
||||
public abstract class MixinEntityPacketRewriter1_17 {
|
||||
|
||||
@Redirect(method = "registerPackets", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketHandler;)V"))
|
||||
private void handleClassicWorldHeight(Protocol1_17To1_16_4 instance, ClientboundPacketType packetType, PacketHandler packetHandler) {
|
||||
if (packetType == ClientboundPackets1_16_2.JOIN_GAME) packetHandler = ClassicWorldHeightInjection.handleJoinGame(packetHandler);
|
||||
@Redirect(method = "registerPackets", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketHandler;)V"))
|
||||
private void handleClassicWorldHeight(Protocol1_16_4To1_17 instance, ClientboundPacketType packetType, PacketHandler packetHandler) {
|
||||
if (packetType == ClientboundPackets1_16_2.LOGIN) packetHandler = ClassicWorldHeightInjection.handleJoinGame(packetHandler);
|
||||
if (packetType == ClientboundPackets1_16_2.RESPAWN) packetHandler = ClassicWorldHeightInjection.handleRespawn(packetHandler);
|
||||
|
||||
((Protocol) instance).registerClientbound(packetType, packetHandler);
|
@ -21,11 +21,11 @@ package net.raphimc.viaproxy.injection.mixins;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPacket1_20_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.rewriter.EntityPacketRewriter1_20_5;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPacket1_20_3;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.Protocol1_20_3To1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter.EntityPacketRewriter1_20_5;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@ -37,7 +37,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(value = EntityPacketRewriter1_20_5.class, remap = false)
|
||||
public abstract class MixinEntityPacketRewriter1_20_5 extends EntityRewriter<ClientboundPacket1_20_3, Protocol1_20_5To1_20_3> {
|
||||
public abstract class MixinEntityPacketRewriter1_20_5 extends EntityRewriter<ClientboundPacket1_20_3, Protocol1_20_3To1_20_5> {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@ -47,7 +47,7 @@ public abstract class MixinEntityPacketRewriter1_20_5 extends EntityRewriter<Cli
|
||||
@Final
|
||||
private static UUID CREATIVE_ENTITY_INTERACTION_RANGE;
|
||||
|
||||
protected MixinEntityPacketRewriter1_20_5(Protocol1_20_5To1_20_3 protocol) {
|
||||
protected MixinEntityPacketRewriter1_20_5(Protocol1_20_3To1_20_5 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@ -59,14 +59,14 @@ public abstract class MixinEntityPacketRewriter1_20_5 extends EntityRewriter<Cli
|
||||
* @reason Fix interaction range and step height differences
|
||||
*/
|
||||
@Overwrite
|
||||
private void sendRangeAttributes(final UserConnection connection, final boolean creativeMode) throws Exception {
|
||||
final PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_20_5.ENTITY_PROPERTIES, connection);
|
||||
wrapper.write(Type.VAR_INT, this.tracker(connection).clientEntityId());
|
||||
private void sendRangeAttributes(final UserConnection connection, final boolean creativeMode) {
|
||||
final PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES, connection);
|
||||
wrapper.write(Types.VAR_INT, this.tracker(connection).clientEntityId());
|
||||
if (connection.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
|
||||
wrapper.write(Type.VAR_INT, 3); // Number of attributes
|
||||
wrapper.write(Types.VAR_INT, 3); // Number of attributes
|
||||
this.writeAttribute(wrapper, "generic.step_height", 0.5D, null, 0D);
|
||||
} else {
|
||||
wrapper.write(Type.VAR_INT, 2); // Number of attributes
|
||||
wrapper.write(Types.VAR_INT, 2); // Number of attributes
|
||||
}
|
||||
if (connection.getProtocolInfo().serverProtocolVersion().olderThan(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
|
||||
this.writeAttribute(wrapper, "player.block_interaction_range", 4D, creativeMode ? CREATIVE_BLOCK_INTERACTION_RANGE : null, 1D);
|
||||
@ -80,7 +80,7 @@ public abstract class MixinEntityPacketRewriter1_20_5 extends EntityRewriter<Cli
|
||||
} else {
|
||||
this.writeAttribute(wrapper, "player.entity_interaction_range", 3D, creativeMode ? CREATIVE_ENTITY_INTERACTION_RANGE : null, 2D);
|
||||
}
|
||||
wrapper.scheduleSend(Protocol1_20_5To1_20_3.class);
|
||||
wrapper.scheduleSend(Protocol1_20_3To1_20_5.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,8 @@
|
||||
*/
|
||||
package net.raphimc.viaproxy.injection.mixins;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.storage.EntityTracker1_9;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -37,8 +37,8 @@ public abstract class MixinEntityTracker1_9 {
|
||||
return b;
|
||||
}
|
||||
|
||||
@Redirect(method = "handleMetadata", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/minecraft/metadata/Metadata;getValue()Ljava/lang/Object;"), slice = @Slice(from = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/configuration/ViaVersionConfig;isBossbarAntiflicker()Z")))
|
||||
private Object remapNaNToZero(Metadata instance) {
|
||||
@Redirect(method = "handleMetadata", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/minecraft/entitydata/EntityData;getValue()Ljava/lang/Object;"), slice = @Slice(from = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/configuration/ViaVersionConfig;isBossbarAntiflicker()Z")))
|
||||
private Object remapNaNToZero(EntityData instance) {
|
||||
if (instance.getValue() instanceof Float && ((Float) instance.getValue()).isNaN()) {
|
||||
return 0F;
|
||||
}
|
||||
|
@ -18,15 +18,15 @@
|
||||
|
||||
package net.raphimc.viaproxy.injection.mixins;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.ModifierData;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.rewriter.ItemPacketRewriter1_9;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import net.raphimc.viaproxy.protocoltranslator.impl.ViaProxyMappingDataLoader;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -34,28 +34,29 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(value = ItemRewriter.class, remap = false)
|
||||
public abstract class MixinItemRewriter {
|
||||
@Mixin(value = ItemPacketRewriter1_9.class, remap = false)
|
||||
public abstract class MixinItemPacketRewriter1_9 {
|
||||
|
||||
@Unique
|
||||
private static final Int2ObjectMap<String> ITEM_IDENTIFIERS = new Int2ObjectOpenHashMap<>();
|
||||
private final Int2ObjectMap<String> itemIdentifiers = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@Unique
|
||||
private static final Map<String, Map<String, Pair<String, ModifierData>>> ITEM_ATTRIBUTES = new HashMap<>();
|
||||
private final Map<String, Map<String, Pair<String, ModifierData>>> itemAttributes = new HashMap<>();
|
||||
|
||||
@Unique
|
||||
private static final String TAG_NAME = "VV|AttributeFix";
|
||||
private final String attributeFixTagName = "VV|AttributeFix";
|
||||
|
||||
@Inject(method = "<clinit>", at = @At("RETURN"))
|
||||
private static void loadAdditionalData(CallbackInfo ci) {
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void loadAdditionalData(CallbackInfo ci) {
|
||||
final JsonObject itemIdentifiers = ViaProxyMappingDataLoader.INSTANCE.loadData("item-identifiers-1.8.json");
|
||||
for (Map.Entry<String, JsonElement> entry : itemIdentifiers.entrySet()) {
|
||||
ITEM_IDENTIFIERS.put(entry.getValue().getAsInt(), entry.getKey());
|
||||
this.itemIdentifiers.put(entry.getValue().getAsInt(), entry.getKey());
|
||||
}
|
||||
|
||||
final JsonObject itemAttributes = ViaProxyMappingDataLoader.INSTANCE.loadData("item-attributes-1.8.json");
|
||||
@ -69,17 +70,18 @@ public abstract class MixinItemRewriter {
|
||||
final String slot = attributeData.get("slot").getAsString();
|
||||
attributes.put(attribute, new Pair<>(slot, modifierData));
|
||||
}
|
||||
ITEM_ATTRIBUTES.put(itemIdentifier, attributes);
|
||||
this.itemAttributes.put(itemIdentifier, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "toClient", at = @At("RETURN"))
|
||||
private static void addAttributeFixData(Item item, CallbackInfo ci) {
|
||||
@Inject(method = "handleItemToClient", at = @At("RETURN"))
|
||||
private void addAttributeFixData(CallbackInfoReturnable<Item> cir) {
|
||||
final Item item = cir.getReturnValue();
|
||||
if (item == null) return;
|
||||
|
||||
final String identifier = ITEM_IDENTIFIERS.get(item.identifier());
|
||||
if (identifier != null && ITEM_ATTRIBUTES.containsKey(identifier)) {
|
||||
final Map<String, Pair<String, ModifierData>> attributes = ITEM_ATTRIBUTES.get(identifier);
|
||||
final String identifier = this.itemIdentifiers.get(item.identifier());
|
||||
if (identifier != null && this.itemAttributes.containsKey(identifier)) {
|
||||
final Map<String, Pair<String, ModifierData>> attributes = this.itemAttributes.get(identifier);
|
||||
final CompoundTag attributeFixTag = new CompoundTag();
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) {
|
||||
@ -87,7 +89,7 @@ public abstract class MixinItemRewriter {
|
||||
item.setTag(tag);
|
||||
attributeFixTag.putBoolean("RemoveTag", true);
|
||||
}
|
||||
tag.put(TAG_NAME, attributeFixTag);
|
||||
tag.put(this.attributeFixTagName, attributeFixTag);
|
||||
|
||||
ListTag<CompoundTag> attributeModifiers = tag.getListTag("AttributeModifiers", CompoundTag.class);
|
||||
if (attributeModifiers == null) {
|
||||
@ -109,12 +111,13 @@ public abstract class MixinItemRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "toServer", at = @At("RETURN"))
|
||||
private static void removeAttributeFixData(Item item, CallbackInfo ci) {
|
||||
@Inject(method = "handleItemToServer", at = @At("RETURN"))
|
||||
private void removeAttributeFixData(CallbackInfoReturnable<Item> cir) {
|
||||
final Item item = cir.getReturnValue();
|
||||
if (item == null) return;
|
||||
final CompoundTag tag = item.tag();
|
||||
if (tag == null) return;
|
||||
final CompoundTag attributeFixTag = tag.removeUnchecked(TAG_NAME);
|
||||
final CompoundTag attributeFixTag = tag.removeUnchecked(attributeFixTagName);
|
||||
if (attributeFixTag == null) return;
|
||||
|
||||
if (attributeFixTag.contains("RemoveAttributeModifiers")) {
|
@ -20,38 +20,32 @@ package net.raphimc.viaproxy.injection.mixins;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18_2to1_18.Protocol1_18_2To1_18;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ServerboundPackets1_17;
|
||||
import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18;
|
||||
import com.viaversion.viaversion.protocols.v1_18to1_18_2.Protocol1_18To1_18_2;
|
||||
import net.raphimc.viaproxy.protocoltranslator.viaproxy.loading_terrain_fix.SpawnPositionTracker;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
@Mixin(Protocol1_18_2To1_18.class)
|
||||
public abstract class MixinProtocol1_18_2To1_18 extends AbstractProtocol<ClientboundPackets1_18, ClientboundPackets1_18, ServerboundPackets1_17, ServerboundPackets1_17> {
|
||||
@Mixin(Protocol1_18To1_18_2.class)
|
||||
public abstract class MixinProtocol1_18To1_18_2 extends AbstractProtocol<ClientboundPackets1_18, ClientboundPackets1_18, ServerboundPackets1_17, ServerboundPackets1_17> {
|
||||
|
||||
@Inject(method = "registerPackets", at = @At("RETURN"))
|
||||
private void fixDownloadingTerrainScreenNotClosing() {
|
||||
this.registerClientbound(ClientboundPackets1_18.PLAYER_POSITION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
final SpawnPositionTracker tracker = wrapper.user().get(SpawnPositionTracker.class);
|
||||
tracker.sendSpawnPosition();
|
||||
});
|
||||
handler(wrapper -> wrapper.user().get(SpawnPositionTracker.class).sendSpawnPosition());
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_18.SPAWN_POSITION, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_18.SET_DEFAULT_SPAWN_POSITION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION1_14); // position
|
||||
map(Type.FLOAT); // angle
|
||||
handler(wrapper -> {
|
||||
final SpawnPositionTracker tracker = wrapper.user().get(SpawnPositionTracker.class);
|
||||
tracker.setSpawnPosition(wrapper.get(Type.POSITION1_14, 0), wrapper.get(Type.FLOAT, 0));
|
||||
});
|
||||
map(Types.BLOCK_POSITION1_14); // position
|
||||
map(Types.FLOAT); // angle
|
||||
handler(wrapper -> wrapper.user().get(SpawnPositionTracker.class).setSpawnPosition(wrapper.get(Types.BLOCK_POSITION1_14, 0), wrapper.get(Types.FLOAT, 0)));
|
||||
}
|
||||
});
|
||||
}
|
@ -17,15 +17,15 @@
|
||||
*/
|
||||
package net.raphimc.viaproxy.injection.mixins;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets.WorldPackets;
|
||||
import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.rewriter.WorldPacketRewriter1_16_2;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(value = WorldPackets.class, remap = false)
|
||||
public abstract class MixinWorldPackets1_16_2 {
|
||||
@Mixin(value = WorldPacketRewriter1_16_2.class, remap = false)
|
||||
public abstract class MixinWorldPacketRewriter1_16_2 {
|
||||
|
||||
@ModifyConstant(method = "lambda$register$1", constant = @Constant(intValue = 16))
|
||||
@ModifyConstant(method = "lambda$register$0", constant = @Constant(intValue = 16))
|
||||
private static int modifySectionCountToSupportClassicWorldHeight(int constant) {
|
||||
return 64;
|
||||
}
|
@ -20,21 +20,21 @@ package net.raphimc.viaproxy.injection.mixins;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets.WorldPackets;
|
||||
import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.v1_16_4to1_17.Protocol1_16_4To1_17;
|
||||
import com.viaversion.viaversion.protocols.v1_16_4to1_17.rewriter.WorldPacketRewriter1_17;
|
||||
import net.raphimc.viaproxy.injection.ClassicWorldHeightInjection;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(value = WorldPackets.class, remap = false)
|
||||
public abstract class MixinWorldPackets1_17 {
|
||||
@Mixin(value = WorldPacketRewriter1_17.class, remap = false)
|
||||
public abstract class MixinWorldPacketRewriter1_17 {
|
||||
|
||||
@Redirect(method = "register", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketHandler;)V"))
|
||||
private static void handleClassicWorldHeight(Protocol1_17To1_16_4 instance, ClientboundPacketType packetType, PacketHandler packetHandler) {
|
||||
if (packetType == ClientboundPackets1_16_2.CHUNK_DATA) packetHandler = ClassicWorldHeightInjection.handleChunkData(packetHandler);
|
||||
if (packetType == ClientboundPackets1_16_2.UPDATE_LIGHT) packetHandler = ClassicWorldHeightInjection.handleUpdateLight(packetHandler);
|
||||
@Redirect(method = "register", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketHandler;)V"))
|
||||
private static void handleClassicWorldHeight(Protocol1_16_4To1_17 instance, ClientboundPacketType packetType, PacketHandler packetHandler) {
|
||||
if (packetType == ClientboundPackets1_16_2.LEVEL_CHUNK) packetHandler = ClassicWorldHeightInjection.handleChunkData(packetHandler);
|
||||
if (packetType == ClientboundPackets1_16_2.LIGHT_UPDATE) packetHandler = ClassicWorldHeightInjection.handleUpdateLight(packetHandler);
|
||||
|
||||
((Protocol) instance).registerClientbound(packetType, packetHandler);
|
||||
}
|
@ -19,7 +19,7 @@ package net.raphimc.viaproxy.protocoltranslator;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionType;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.Protocol1_20_3To1_20_5;
|
||||
import net.raphimc.vialoader.ViaLoader;
|
||||
import net.raphimc.vialoader.impl.platform.ViaAprilFoolsPlatformImpl;
|
||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
||||
@ -64,7 +64,7 @@ public class ProtocolTranslator {
|
||||
patchConfigs();
|
||||
final Supplier<?>[] platformSuppliers = ViaProxy.EVENT_MANAGER.call(new ProtocolTranslatorInitEvent(ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaProxyViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new)).getPlatformSuppliers().toArray(new Supplier[0]);
|
||||
ViaLoader.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVLLoader(), null, null, platformSuppliers);
|
||||
Protocol1_20_5To1_20_3.strictErrorHandling = false;
|
||||
Protocol1_20_3To1_20_5.strictErrorHandling = false;
|
||||
ProtocolVersion.register(AUTO_DETECT_PROTOCOL);
|
||||
}
|
||||
|
||||
|
@ -17,11 +17,11 @@
|
||||
*/
|
||||
package net.raphimc.viaproxy.protocoltranslator.impl;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.provider.TransferProvider;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.provider.TransferProvider;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.provider.CompressionProvider;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.provider.HandItemProvider;
|
||||
import net.raphimc.viabedrock.protocol.providers.NettyPipelineProvider;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicCustomCommandProvider;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicMPPassProvider;
|
||||
|
@ -18,7 +18,7 @@
|
||||
package net.raphimc.viaproxy.protocoltranslator.providers;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.provider.CompressionProvider;
|
||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||
|
||||
public class ViaProxyCompressionProvider extends CompressionProvider {
|
||||
|
@ -19,7 +19,7 @@ package net.raphimc.viaproxy.protocoltranslator.providers;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.provider.HandItemProvider;
|
||||
|
||||
public class ViaProxyHandItemProvider extends HandItemProvider {
|
||||
|
||||
|
@ -17,8 +17,8 @@
|
||||
*/
|
||||
package net.raphimc.viaproxy.protocoltranslator.providers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.provider.TransferProvider;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.storage.CookieStorage;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.provider.TransferProvider;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.CookieStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import io.netty.channel.Channel;
|
||||
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
|
||||
|
@ -19,7 +19,7 @@ package net.raphimc.viaproxy.protocoltranslator.providers;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
||||
import com.viaversion.viaversion.protocol.version.BaseVersionProvider;
|
||||
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
|
||||
|
||||
public class ViaProxyVersionProvider extends BaseVersionProvider {
|
||||
|
@ -23,6 +23,7 @@ import joptsimple.OptionException;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
import net.raphimc.vialoader.util.JLoggerToSLF4J;
|
||||
import net.raphimc.viaproxy.ViaProxy;
|
||||
import net.raphimc.viaproxy.cli.BetterHelpFormatter;
|
||||
import net.raphimc.viaproxy.cli.HelpRequestedException;
|
||||
@ -33,6 +34,7 @@ import net.raphimc.viaproxy.protocoltranslator.ProtocolTranslator;
|
||||
import net.raphimc.viaproxy.saves.impl.accounts.Account;
|
||||
import net.raphimc.viaproxy.util.AddressUtil;
|
||||
import net.raphimc.viaproxy.util.logging.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -47,7 +49,9 @@ import java.util.Map;
|
||||
|
||||
public class ViaProxyConfig extends Config implements com.viaversion.viaversion.api.configuration.Config {
|
||||
|
||||
private OptionParser optionParser;
|
||||
private static final java.util.logging.Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaProxy"));
|
||||
|
||||
private final OptionParser optionParser;
|
||||
private final OptionSpec<Void> optionHelp;
|
||||
private final OptionSpec<String> optionBindAddress;
|
||||
private final OptionSpec<String> optionTargetAddress;
|
||||
@ -90,7 +94,7 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
|
||||
private boolean simpleVoiceChatSupport = false;
|
||||
|
||||
public ViaProxyConfig(final File configFile) {
|
||||
super(configFile);
|
||||
super(configFile, LOGGER);
|
||||
|
||||
this.optionParser = new OptionParser();
|
||||
this.optionHelp = this.optionParser.accepts("help").forHelp();
|
||||
@ -184,13 +188,13 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
|
||||
ViaProxy.EVENT_MANAGER.call(new PostOptionsParseEvent(options));
|
||||
return;
|
||||
} catch (OptionException e) {
|
||||
Logger.LOGGER.error("Error parsing CLI options: " + e.getMessage());
|
||||
this.logger.severe("Error parsing CLI options: " + e.getMessage());
|
||||
} catch (HelpRequestedException ignored) {
|
||||
}
|
||||
|
||||
this.optionParser.formatHelpWith(new BetterHelpFormatter());
|
||||
this.optionParser.printHelpOn(Logger.SYSOUT);
|
||||
Logger.LOGGER.info("For a more detailed description of the options, please refer to the viaproxy.yml file.");
|
||||
this.logger.info("For a more detailed description of the options, please refer to the viaproxy.yml file.");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
@ -391,12 +395,12 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
|
||||
private void checkTargetVersion() {
|
||||
if (this.targetVersion == null) {
|
||||
this.targetVersion = ProtocolTranslator.AUTO_DETECT_PROTOCOL;
|
||||
Logger.LOGGER.info("Invalid target version: " + this.getString("target-version", "") + ". Defaulting to auto detect.");
|
||||
Logger.LOGGER.info("=== Supported Protocol Versions ===");
|
||||
this.logger.info("Invalid target version: " + this.getString("target-version", "") + ". Defaulting to auto detect.");
|
||||
this.logger.info("=== Supported Protocol Versions ===");
|
||||
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
|
||||
Logger.LOGGER.info(version.getName());
|
||||
this.logger.info(version.getName());
|
||||
}
|
||||
Logger.LOGGER.info("===================================");
|
||||
this.logger.info("===================================");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,9 @@ import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18_2to1_18.Protocol1_18_2To1_18;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18;
|
||||
import com.viaversion.viaversion.protocols.v1_18to1_18_2.Protocol1_18To1_18_2;
|
||||
|
||||
public class SpawnPositionTracker extends StoredObject {
|
||||
|
||||
@ -39,11 +39,11 @@ public class SpawnPositionTracker extends StoredObject {
|
||||
this.angle = angle;
|
||||
}
|
||||
|
||||
public void sendSpawnPosition() throws Exception {
|
||||
final PacketWrapper spawnPosition = PacketWrapper.create(ClientboundPackets1_18.SPAWN_POSITION, this.getUser());
|
||||
spawnPosition.write(Type.POSITION1_14, this.spawnPosition); // position
|
||||
spawnPosition.write(Type.FLOAT, this.angle); // angle
|
||||
spawnPosition.send(Protocol1_18_2To1_18.class);
|
||||
public void sendSpawnPosition() {
|
||||
final PacketWrapper spawnPosition = PacketWrapper.create(ClientboundPackets1_18.SET_DEFAULT_SPAWN_POSITION, this.getUser());
|
||||
spawnPosition.write(Types.BLOCK_POSITION1_14, this.spawnPosition); // position
|
||||
spawnPosition.write(Types.FLOAT, this.angle); // angle
|
||||
spawnPosition.send(Protocol1_18To1_18_2.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
package net.raphimc.viaproxy.proxy.client2proxy;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.storage.CookieStorage;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.CookieStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
|
||||
import com.viaversion.viaversion.api.minecraft.signature.model.MessageMetadata;
|
||||
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_3;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
@ -73,9 +73,9 @@ public class ChatSignaturePacketHandler extends PacketHandler {
|
||||
PacketTypes.writeString(newChatMessage, message); // message
|
||||
newChatMessage.writeLong(timestamp); // timestamp
|
||||
newChatMessage.writeLong(salt); // salt
|
||||
Type.OPTIONAL_SIGNATURE_BYTES.write(newChatMessage, signature); // signature
|
||||
Types.OPTIONAL_SIGNATURE_BYTES.write(newChatMessage, signature); // signature
|
||||
PacketTypes.writeVarInt(newChatMessage, 0); // offset
|
||||
Type.ACKNOWLEDGED_BIT_SET.write(newChatMessage, new BitSet(20)); // acknowledged
|
||||
Types.ACKNOWLEDGED_BIT_SET.write(newChatMessage, new BitSet(20)); // acknowledged
|
||||
this.proxyConnection.getChannel().writeAndFlush(newChatMessage).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
|
||||
return false;
|
||||
@ -97,7 +97,7 @@ public class ChatSignaturePacketHandler extends PacketHandler {
|
||||
final ByteBuf chatSessionUpdate = Unpooled.buffer();
|
||||
PacketTypes.writeVarInt(chatSessionUpdate, this.chatSessionUpdateId);
|
||||
PacketTypes.writeUuid(chatSessionUpdate, chatSession.getSessionId()); // session id
|
||||
Type.PROFILE_KEY.write(chatSessionUpdate, chatSession.getProfileKey()); // profile key
|
||||
Types.PROFILE_KEY.write(chatSessionUpdate, chatSession.getProfileKey()); // profile key
|
||||
this.proxyConnection.getChannel().writeAndFlush(chatSessionUpdate).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}
|
||||
});
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
package net.raphimc.viaproxy.proxy.util;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.storage.CookieStorage;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.CookieStorage;
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
Loading…
Reference in New Issue
Block a user