Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Dec 9, 2023
2 parents 8a2e27a + 84c7399 commit 9a7f1a2
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 2 deletions.
13 changes: 12 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ base {

configurations {
jij // jar in jar configuration
modJij // jar in jar configuration for mods

include.extendsFrom modJij
modImplementation.extendsFrom modJij
modCompileOnlyApi.extendsFrom modJij
}

repositories {
Expand Down Expand Up @@ -46,10 +51,16 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

modCompileOnly "com.terraformersmc:modmenu:${project.mod_menu_version}"

// Fabric API
modJij(fabricApi.module("fabric-api-base", project.fabric_api_version))
modJij(fabricApi.module("fabric-resource-loader-v0", project.fabric_api_version))
modJij(fabricApi.module("fabric-networking-api-v1", project.fabric_api_version))
modJij(fabricApi.module("fabric-command-api-v2", project.fabric_api_version))
modJij(fabricApi.module("fabric-lifecycle-events-v1", project.fabric_api_version))

// ViaVersion Libraries
jij "com.viaversion:viaversion-common:${project.viaversion_version}"
jij ("com.viaversion:viabackwards-common:${project.viabackwards_version}") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
* Copyright (C) 2023 RK_01/RaphiMC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;

import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = Protocol1_20_2To1_20.class, remap = false)
public abstract class MixinProtocol1_20_2To1_20 {

@Inject(method = "lambda$queueServerboundPacket$11", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;setPacketType(Lcom/viaversion/viaversion/api/protocol/packet/PacketType;)V", shift = At.Shift.AFTER), cancellable = true)
private static void dontQueueConfigPackets(ServerboundPackets1_20_2 packetType, PacketWrapper wrapper, CallbackInfo ci) {
if (!DebugSettings.global().queueConfigPackets.getValue()) {
ci.cancel();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
* Copyright (C) 2023 RK_01/RaphiMC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;

import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonNull;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2;
import net.lenni0451.mcstructs.text.ATextComponent;
import net.lenni0451.mcstructs.text.serializer.TextComponentCodec;
import net.lenni0451.mcstructs.text.serializer.TextComponentSerializer;
import net.raphimc.vialegacy.api.util.converter.JsonConverter;
import net.raphimc.vialegacy.api.util.converter.NbtConverter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(value = Protocol1_20_3To1_20_2.class, remap = false)
public abstract class MixinProtocol1_20_3To1_20_2 {

/**
* @author RK_01
* @reason Replace code with a proper conversion
*/
@Overwrite
public static JsonElement tagComponentToJson(final Tag tag) {
final ATextComponent textComponent = TextComponentCodec.V1_20_3.deserializeNbtTree(NbtConverter.viaToMcStructs(tag));
if (textComponent == null) return JsonNull.INSTANCE;

return JsonConverter.gsonToVia(TextComponentSerializer.V1_19_4.serializeJson(textComponent));
}

/**
* @author RK_01
* @reason Replace code with a proper conversion
*/
@Overwrite
public static Tag jsonComponentToTag(final JsonElement component) {
final ATextComponent textComponent = TextComponentSerializer.V1_19_4.deserialize(JsonConverter.viaToGson(component));
if (textComponent == null) return null;

return NbtConverter.mcStructsToVia(TextComponentCodec.V1_20_3.serializeNbt(textComponent));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package de.florianmichael.viafabricplus.settings.impl;

import de.florianmichael.viafabricplus.settings.base.BooleanSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.base.VersionedBooleanSetting;
import net.minecraft.text.Text;
Expand All @@ -28,6 +29,8 @@
public class DebugSettings extends SettingGroup {
private static final DebugSettings instance = new DebugSettings();

public final BooleanSetting queueConfigPackets = new BooleanSetting(this, Text.translatable("debug_settings.viafabricplus.queue_config_packets"), true);

// 1.19 -> 1.18.2
public final VersionedBooleanSetting disableSequencing = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.disable_sequencing"), VersionRange.andOlder(VersionEnum.r1_18_2));

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/viafabricplus/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Open prompt GUI to confirm transferring to other servers",
"bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click to set account for Bedrock edition",

"debug_settings.viafabricplus.queue_config_packets": "Queue config packets",
"debug_settings.viafabricplus.disable_sequencing": "Disable sequencing",
"debug_settings.viafabricplus.smooth_out_merchant_screens": "Smooth out merchant screens",
"debug_settings.viafabricplus.execute_inputs_in_sync": "Execute inputs in sync",
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
"accessWidener": "viafabricplus.accesswidener",
"depends": {
"fabricloader": ">=0.15.0",
"fabric-api": ">=0.91.1+1.20.3",
"fabric-resource-loader-v0": ">=0.11.14",
"fabric-networking-api-v1": ">=3.1.1",
"fabric-command-api-v2": ">=2.2.18",
"fabric-lifecycle-events-v1": ">=2.2.28",
"minecraft": ">=1.20.3",
"java": ">=17"
},
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/viafabricplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
"fixes.viaversion.MixinNamedCompoundTagType",
"fixes.viaversion.MixinProtocol1_11To1_10",
"fixes.viaversion.MixinProtocol1_12To1_11_1",
"fixes.viaversion.MixinProtocol1_20_2To1_20",
"fixes.viaversion.MixinProtocol1_20_3To1_20_2",
"fixes.viaversion.MixinTagType",
"fixes.viaversion.MixinUserConnectionImpl",
"fixes.viaversion.MixinWorldPackets1_16_2",
Expand Down

0 comments on commit 9a7f1a2

Please sign in to comment.