mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-25 12:25:22 +01:00
Updated Via API usage
This commit is contained in:
parent
2537ef5b4a
commit
4d1e1b9a45
@ -19,15 +19,11 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.definition.ClientPlayerInteractionManager1_18_2;
|
||||
import net.minecraft.client.network.SequencedPacketCreator;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.definition.ClientPlayerInteractionManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientPlayerEntity;
|
||||
import de.florianmichael.viafabricplus.injection.access.IScreenHandler;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
@ -37,16 +33,20 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import net.minecraft.client.network.SequencedPacketCreator;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -135,7 +135,7 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
clickSlotPacket.write(Type.BYTE, (byte) clickSlot.getButton());
|
||||
clickSlotPacket.write(Type.SHORT, ((IScreenHandler) client.player.currentScreenHandler).viafabricplus_getAndIncrementLastActionId());
|
||||
clickSlotPacket.write(Type.VAR_INT, clickSlot.getActionType().ordinal());
|
||||
clickSlotPacket.write(Type.FLAT_VAR_INT_ITEM, ItemTranslator.MC_TO_VIA_LATEST_TO_TARGET(slotItemBeforeModification, VersionEnum.r1_16));
|
||||
clickSlotPacket.write(Type.ITEM1_13_2, ItemTranslator.MC_TO_VIA_LATEST_TO_TARGET(slotItemBeforeModification, VersionEnum.r1_16));
|
||||
|
||||
try {
|
||||
clickSlotPacket.sendToServer(Protocol1_17To1_16_4.class);
|
||||
|
@ -34,7 +34,7 @@ public class MixinProtocol1_9_1To1_9 extends AbstractProtocol<ClientboundPackets
|
||||
@Inject(method = "registerPackets", at = @At("RETURN"))
|
||||
public void clearInputBuffer(CallbackInfo ci) {
|
||||
registerClientbound(ClientboundPackets1_9.CHUNK_DATA, wrapper -> {
|
||||
wrapper.passthrough(new ChunkType1_9_1(wrapper.user().get(ClientWorld.class)));
|
||||
wrapper.passthrough(ChunkType1_9_1.forEnvironment(wrapper.user().get(ClientWorld.class).getEnvironment()));
|
||||
wrapper.clearInputBuffer();
|
||||
});
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public abstract class MixinChunkType1_8 {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Redirect(method = "read(Lio/netty/buffer/ByteBuf;Lcom/viaversion/viaversion/api/minecraft/ClientWorld;)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/type/types/chunk/ChunkType1_8;deserialize(IIZZI[B)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;"))
|
||||
@Redirect(method = "read(Lio/netty/buffer/ByteBuf;)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/type/types/chunk/ChunkType1_8;deserialize(IIZZI[B)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;"))
|
||||
private Chunk fixAegis(int chunkX, int chunkZ, boolean fullChunk, boolean skyLight, int bitmask, byte[] data) {
|
||||
try {
|
||||
return deserialize(chunkX, chunkZ, fullChunk, skyLight, bitmask, data);
|
||||
|
@ -65,7 +65,7 @@ public class ItemTranslator {
|
||||
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
return wrapper.read(Typesb1_8_0_1.CREATIVE_ITEM);
|
||||
} else {
|
||||
return wrapper.read(Type.ITEM);
|
||||
return wrapper.read(Type.ITEM1_8);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ViaFabricPlus.LOGGER.error("Failed to translate item", e);
|
||||
@ -78,7 +78,7 @@ public class ItemTranslator {
|
||||
if (protocolPath == null) return null;
|
||||
|
||||
// Make sure that ViaVersion doesn't track stuff and change its behaviour
|
||||
DUMMY_USER_CONNECTION.put(new WindowTracker(DUMMY_USER_CONNECTION));
|
||||
DUMMY_USER_CONNECTION.put(new WindowTracker());
|
||||
DUMMY_USER_CONNECTION.put(new InventoryTracker());
|
||||
|
||||
try {
|
||||
@ -95,7 +95,7 @@ public class ItemTranslator {
|
||||
wrapper.read(Type.VAR_INT);
|
||||
wrapper.read(Type.SHORT);
|
||||
|
||||
final var viaItem = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
final var viaItem = wrapper.read(Type.ITEM1_13_2);
|
||||
return new ItemStack(() -> Registries.ITEM.get(viaItem.identifier()), viaItem.amount());
|
||||
} catch (Exception e) {
|
||||
ViaFabricPlus.LOGGER.error("Failed to translate item", e);
|
||||
|
Loading…
Reference in New Issue
Block a user