Update VV API usage

This commit is contained in:
FlorianMichael 2024-09-15 22:46:10 +02:00
parent 9de9345c4b
commit 92c7f29926
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
6 changed files with 8 additions and 83 deletions

View File

@ -27,8 +27,6 @@ import net.minecraft.client.network.ServerInfo;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.listener.ClientQueryPacketListener;
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

View File

@ -21,9 +21,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.protocols.v1_16_4to1_17.storage.InventoryAcknowledgements;
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
import de.florianmichael.viafabricplus.util.DataCustomPayload;
@ -109,24 +107,14 @@ public abstract class MixinClientCommonNetworkHandler {
}
@Inject(method = "onPing", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER), cancellable = true)
private void onPing(CommonPingS2CPacket packet, CallbackInfo ci) {
private void addMissingConditions(CommonPingS2CPacket packet, CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
final InventoryAcknowledgements acks = ((IClientConnection) this.connection).viaFabricPlus$getUserConnection().get(InventoryAcknowledgements.class);
if (acks.removeId(packet.getParameter())) {
final short inventoryId = (short) ((packet.getParameter() >> 16) & 0xFF);
ScreenHandler handler = null;
if (inventoryId == 0) handler = client.player.playerScreenHandler;
else if (inventoryId == client.player.currentScreenHandler.syncId) handler = client.player.currentScreenHandler;
if (handler != null) {
acks.addId(packet.getParameter());
} else {
if (inventoryId != 0 && inventoryId != client.player.currentScreenHandler.syncId) {
ci.cancel();
}
}
}
}
@Inject(method = "onCustomPayload(Lnet/minecraft/network/packet/s2c/common/CustomPayloadS2CPacket;)V", at = @At("HEAD"), cancellable = true)
private void handleSyncTask(CustomPayloadS2CPacket packet, CallbackInfo ci) {

View File

@ -24,8 +24,8 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(targets = "com.viaversion.viaversion.protocols.v1_11_1to1_12.Protocol1_11_1To1_12$1", remap = false)
public abstract class MixinProtocol1_11_1To1_12 {
@Mixin(targets = "com.viaversion.viaversion.protocols.v1_11_1to1_12.rewriter.EntityPacketRewriter1_12$1", remap = false)
public abstract class MixinEntityPacketRewriter1_12 {
@Redirect(method = "lambda$register$1", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;newerThanOrEqualTo(Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;)Z"))
private static boolean dontClearRecipes(ProtocolVersion instance, ProtocolVersion other) {

View File

@ -1,60 +0,0 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
* Copyright (C) 2023-2024 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.fastutil.ints.IntList;
import com.viaversion.viaversion.protocols.v1_16_4to1_17.storage.InventoryAcknowledgements;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntLists;
import org.spongepowered.asm.mixin.*;
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;
@Mixin(value = InventoryAcknowledgements.class, remap = false)
public abstract class MixinInventoryAcknowledgements {
@Mutable
@Shadow
@Final
private IntList ids;
@Unique
private it.unimi.dsi.fastutil.ints.IntList viaFabricPlus$ids;
@Inject(method = "<init>", at = @At("RETURN"))
private void makeConcurrent(CallbackInfo ci) {
this.ids = null;
this.viaFabricPlus$ids = IntLists.synchronize(new IntArrayList());
}
@Inject(method = "addId", at = @At("HEAD"), cancellable = true)
private void forwardAdd(int id, CallbackInfo ci) {
viaFabricPlus$ids.add(id);
ci.cancel();
}
@Inject(method = "removeId", at = @At("HEAD"), cancellable = true)
private void forwardRemove(int id, CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(viaFabricPlus$ids.rem(id));
}
}

View File

@ -24,7 +24,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(targets = "com.viaversion.viaversion.protocols.v1_10to1_11.Protocol1_10To1_11$8", remap = false)
@Mixin(targets = "com.viaversion.viaversion.protocols.v1_10to1_11.Protocol1_10To1_11$6", remap = false)
public abstract class MixinProtocol1_10To1_11 {
@ModifyConstant(method = "lambda$register$0", constant = @Constant(intValue = 100))

View File

@ -192,7 +192,6 @@
"fixes.viaversion.MixinEntityPacketRewriter1_20_5",
"fixes.viaversion.MixinEntityPacketRewriter1_9",
"fixes.viaversion.MixinEntityTracker1_9",
"fixes.viaversion.MixinInventoryAcknowledgements",
"fixes.viaversion.MixinInventoryTracker1_16",
"fixes.viaversion.MixinItemPacketRewriter1_14",
"fixes.viaversion.MixinItemPacketRewriter1_17",
@ -202,7 +201,7 @@
"fixes.viaversion.MixinParticleIdMappings1_13",
"fixes.viaversion.MixinParticleMappings",
"fixes.viaversion.MixinProtocol1_10To1_11",
"fixes.viaversion.MixinProtocol1_11_1To1_12",
"fixes.viaversion.MixinEntityPacketRewriter1_12",
"fixes.viaversion.MixinProtocol1_20_3To1_20_5",
"fixes.viaversion.MixinProtocol1_20To1_20_2",
"fixes.viaversion.MixinTagType",