added System to force version for singleton server

This commit is contained in:
FlorianMichael 2023-03-21 18:47:49 +01:00
parent 73836131ec
commit 008523c103
101 changed files with 809 additions and 498 deletions

View File

@ -14,7 +14,7 @@ maven_group=de.florianmichael
archives_base_name=viafabricplus
# base lib
vialoadingbase_version=6dad0a2561
vialoadingbase_version=a6bda59904
raknet_transport_version=1.0.0.CR1-SNAPSHOT
# viaversion (and required) libs

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.definition;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
import de.florianmichael.vialoadingbase.platform.ProtocolRange;
import net.minecraft.item.Item;
@ -40,7 +40,7 @@ public class ItemReleaseVersionDefinition {
public static void create() {
INSTANCE = new ItemReleaseVersionDefinition();
INSTANCE.load();
INSTANCE.update(ViaLoadingBase.getClassWrapper().getTargetVersion());
INSTANCE.update(ProtocolHack.getTargetVersion());
ChangeProtocolVersionCallback.EVENT.register(protocolVersion -> INSTANCE.update(protocolVersion));
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.definition;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.GameVersion;
import net.minecraft.SaveVersion;
import net.minecraft.SharedConstants;
@ -85,7 +85,7 @@ public class PackFormatsDefinition {
}
public static GameVersion current() {
final int targetVersion = ViaLoadingBase.getClassWrapper().getTargetVersion().getOriginalVersion();
final int targetVersion = ProtocolHack.getTargetVersion().getOriginalVersion();
if (!protocolMap.containsKey(targetVersion)) return SharedConstants.getGameVersion();
return protocolMap.get(targetVersion);
}

View File

@ -29,7 +29,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
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;
@ -50,7 +50,7 @@ public class ClassicWorldHeightInjection {
parentRemapper.handle(wrapper);
if (wrapper.isCancelled()) return;
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
for (Tag dimension : wrapper.get(Type.NBT, 0).<CompoundTag>get("minecraft:dimension_type").<ListTag>get("value")) {
changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element"));
}
@ -69,7 +69,7 @@ public class ClassicWorldHeightInjection {
parentRemapper.handle(wrapper);
if (wrapper.isCancelled()) return;
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 0));
}
});
@ -85,7 +85,7 @@ public class ClassicWorldHeightInjection {
parentRemapper.handle(wrapper);
if (wrapper.isCancelled()) return;
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
wrapper.resetReader();
final Chunk chunk = wrapper.read(new Chunk1_17Type(16));
wrapper.write(new Chunk1_17Type(chunk.getSections().length), chunk);
@ -179,7 +179,7 @@ public class ClassicWorldHeightInjection {
@Override
public void register() {
handler(wrapper -> {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
classicLightHandler.handle(wrapper);
} else {
parentRemapper.handle(wrapper);

View File

@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.definition.ChatLengthDefinition;
import de.florianmichael.viafabricplus.definition.c0_30.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import io.netty.buffer.ByteBuf;
import net.lenni0451.reflect.Enums;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.ClientboundPacketsc0_30cpe;
@ -45,7 +45,7 @@ public class CustomClassicProtocolExtensions {
LoadClassicProtocolExtensionCallback.EVENT.register(classicProtocolExtension -> {
if (classicProtocolExtension == ClassicProtocolExtension.LONGER_MESSAGES) ChatLengthDefinition.INSTANCE.expand();
if (classicProtocolExtension == ClassicProtocolExtension.CUSTOM_BLOCKS) ClassicItemSelectionScreen.INSTANCE.reload(ViaLoadingBase.getClassWrapper().getTargetVersion(), true);
if (classicProtocolExtension == ClassicProtocolExtension.CUSTOM_BLOCKS) ClassicItemSelectionScreen.INSTANCE.reload(ProtocolHack.getTargetVersion(), true);
});
}

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import java.util.List;
@ -32,6 +32,6 @@ public class GeneralInformation extends AbstractInformationGroup {
@Override
public void applyInformation(UserConnection userConnection, List<String> output) {
output.add("Pipeline count: " + userConnection.getProtocolInfo().getPipeline().pipes().size());
output.add("Target version: " + ViaLoadingBase.getClassWrapper().getTargetVersion().getName() + " (" + ViaLoadingBase.getClassWrapper().getTargetVersion().getVersion() + ")");
output.add("Target version: " + ProtocolHack.getTargetVersion().getName() + " (" + ProtocolHack.getTargetVersion().getVersion() + ")");
}
}

View File

@ -28,9 +28,6 @@ public interface IClientConnection {
void viafabricplus_setupPreNettyEncryption();
void viafabricplus_captureAddress(final InetSocketAddress address);
InetSocketAddress viafabricplus_capturedAddress();
void viafabricplus_enableZLibCompression();
void viafabricplus_enableSnappyCompression();
void viafabricplus_enableAesGcmEncryption(final SecretKey secretKey) throws InvalidAlgorithmParameterException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException;

View File

@ -15,20 +15,12 @@
* 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.protocolhack.platform.viabedrock;
package de.florianmichael.viafabricplus.injection.access;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
public class RakNetPingSessions {
public final static List<InetAddress> pingSessions = new ArrayList<>();
public interface IServerInfo {
public static void storePingSession(final InetAddress address) {
pingSessions.add(address);
}
public static boolean isPingSession(final InetAddress address) {
return pingSessions.contains(address);
}
ComparableProtocolVersion viafabricplus_forcedVersion();
void viafabricplus_forceVersion(ComparableProtocolVersion version);
}

View File

@ -17,46 +17,66 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.connection.UserConnectionImpl;
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
import de.florianmichael.viafabricplus.protocolhack.constants.PreNettyConstants;
import de.florianmichael.viafabricplus.protocolhack.constants.BedrockRakNetConstants;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.RakNetPingSessions;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.DisconnectHandler;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.PingEncapsulationCodec;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.RakMessageEncapsulationCodec;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.library_fix.FixedUnconnectedPingEncoder;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.library_fix.FixedUnconnectedPongDecoder;
import de.florianmichael.viafabricplus.protocolhack.platform.vialegacy.VFPPreNettyDecoder;
import de.florianmichael.viafabricplus.protocolhack.platform.vialegacy.VFPPreNettyEncoder;
import de.florianmichael.viafabricplus.protocolhack.replacement.ViaFabricPlusVLBViaDecodeHandler;
import de.florianmichael.vialoadingbase.event.PipelineReorderEvent;
import io.netty.bootstrap.AbstractBootstrap;
import de.florianmichael.vialoadingbase.netty.NettyConstants;
import de.florianmichael.vialoadingbase.netty.VLBViaEncodeHandler;
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.epoll.Epoll;
import io.netty.channel.epoll.EpollDatagramChannel;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.timeout.ReadTimeoutHandler;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.NetworkSide;
import net.minecraft.network.encryption.PacketDecryptor;
import net.minecraft.network.encryption.PacketEncryptor;
import net.minecraft.network.packet.Packet;
import net.minecraft.util.Lazy;
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
import net.raphimc.viabedrock.netty.AesGcmEncryption;
import net.raphimc.viabedrock.netty.SnappyCompression;
import net.raphimc.viabedrock.netty.ZLibCompression;
import net.raphimc.viabedrock.netty.*;
import net.raphimc.viabedrock.protocol.BedrockBaseProtocol;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.baseprotocols.PreNettyBaseProtocol;
import org.cloudburstmc.netty.channel.raknet.RakChannelFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.cloudburstmc.netty.channel.raknet.RakClientChannel;
import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
import org.cloudburstmc.netty.handler.codec.raknet.common.UnconnectedPingEncoder;
import org.cloudburstmc.netty.handler.codec.raknet.common.UnconnectedPongDecoder;
import org.jetbrains.annotations.NotNull;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.ThreadLocalRandom;
@Mixin(ClientConnection.class)
public abstract class MixinClientConnection extends SimpleChannelInboundHandler<Packet<?>> implements IClientConnection {
@ -67,6 +87,9 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
@Shadow public abstract void channelActive(ChannelHandlerContext context) throws Exception;
@Shadow @Final public static Lazy<EpollEventLoopGroup> EPOLL_CLIENT_IO_GROUP;
@Shadow @Final public static Lazy<NioEventLoopGroup> CLIENT_IO_GROUP;
@Unique
private Cipher viafabricplus_decryptionCipher;
@ -76,9 +99,6 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
@Unique
private boolean viafabricplus_compressionEnabled = false;
@Unique
private InetSocketAddress viafabricplus_capturedAddress;
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) {
channel.pipeline().fireUserEventTriggered(new PipelineReorderEvent());
@ -86,40 +106,121 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
private void storeEncryptionCiphers(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
ci.cancel();
this.viafabricplus_decryptionCipher = decryptionCipher;
this.viafabricplus_encryptionCipher = encryptionCipher;
}
}
@Inject(method = "connect", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Lazy;get()Ljava/lang/Object;"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void captureAddress(InetSocketAddress address, boolean useEpoll, CallbackInfoReturnable<ClientConnection> cir, final ClientConnection clientConnection) {
((IClientConnection) clientConnection).viafabricplus_captureAddress(address);
}
/**
* @author Mojang, FlorianMichael as EnZaXD
* @reason Hack Netty Pipeline (do cursed shit)
*/
@Overwrite
public static ClientConnection connect(InetSocketAddress address, boolean useEpoll) {
final ClientConnection clientConnection = new ClientConnection(NetworkSide.CLIENTBOUND);
@Redirect(method = "connect", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;channel(Ljava/lang/Class;)Lio/netty/bootstrap/AbstractBootstrap;"))
private static AbstractBootstrap applyRakNetChannelFactory(Bootstrap instance, Class aClass) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
return instance.channelFactory(aClass == EpollSocketChannel.class ? RakChannelFactory.client(EpollDatagramChannel.class) : RakChannelFactory.client(NioDatagramChannel.class));
}
return instance.channel(aClass);
}
final Class<? extends AbstractChannel> channelType = Epoll.isAvailable() && useEpoll ? EpollSocketChannel.class : NioSocketChannel.class;
final Lazy<? extends MultithreadEventLoopGroup> lazy = Epoll.isAvailable() && useEpoll ? EPOLL_CLIENT_IO_GROUP : CLIENT_IO_GROUP;
@Redirect(method = "connect", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;connect(Ljava/net/InetAddress;I)Lio/netty/channel/ChannelFuture;"))
private static ChannelFuture applyRakNetPing(Bootstrap instance, InetAddress inetHost, int inetPort) {
if (RakNetPingSessions.isPingSession(inetHost)) {
return instance.bind(new InetSocketAddress(0)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
final boolean rakNet = ProtocolHack.getForcedVersions().containsKey(address) ?
(ProtocolHack.getForcedVersions().get(address).getVersion() == BedrockProtocolVersion.bedrockLatest.getVersion()) :
ProtocolHack.getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest);
Bootstrap nettyBoostrap = new Bootstrap();
nettyBoostrap = nettyBoostrap.group(lazy.get());
nettyBoostrap = nettyBoostrap.handler(new ChannelInitializer<>() {
@Override
protected void initChannel(@NotNull Channel channel) throws Exception {
try {
if (rakNet) {
channel.config().setOption(RakChannelOption.RAK_PROTOCOL_VERSION, 11);
channel.config().setOption(RakChannelOption.RAK_CONNECT_TIMEOUT, 4_000L);
channel.config().setOption(RakChannelOption.RAK_SESSION_TIMEOUT, 30_000L);
channel.config().setOption(RakChannelOption.RAK_GUID, ThreadLocalRandom.current().nextLong());
} else {
channel.config().setOption(ChannelOption.TCP_NODELAY, true);
}
} catch (Exception ignored) {
}
ChannelPipeline channelPipeline = channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30));
ClientConnection.addHandlers(channelPipeline, NetworkSide.CLIENTBOUND);
channelPipeline.addLast("packet_handler", clientConnection);
if (channel instanceof SocketChannel || rakNet) {
if (ProtocolHack.getForcedVersions().containsKey(address)) {
channel.attr(ProtocolHack.FORCED_VERSION).set(ProtocolHack.getForcedVersions().get(address));
ProtocolHack.getForcedVersions().remove(address);
}
final UserConnection user = new UserConnectionImpl(channel, true);
channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).set(user);
channel.attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).set(clientConnection);
new ProtocolPipelineImpl(user);
channel.pipeline().addBefore("encoder", NettyConstants.HANDLER_ENCODER_NAME, new VLBViaEncodeHandler(user));
channel.pipeline().addBefore("decoder", NettyConstants.HANDLER_DECODER_NAME, new ViaFabricPlusVLBViaDecodeHandler(user));
if (rakNet) {
user.getProtocolInfo().getPipeline().add(BedrockBaseProtocol.INSTANCE);
channel.pipeline().replace("splitter", BedrockRakNetConstants.BATCH_LENGTH_HANDLER_NAME, new BatchLengthCodec());
channel.pipeline().addBefore(BedrockRakNetConstants.BATCH_LENGTH_HANDLER_NAME, BedrockRakNetConstants.DISCONNECT_HANDLER_NAME, new DisconnectHandler());
channel.pipeline().addAfter(BedrockRakNetConstants.DISCONNECT_HANDLER_NAME, BedrockRakNetConstants.FRAME_ENCAPSULATION_HANDLER_NAME, new RakMessageEncapsulationCodec());
channel.pipeline().addAfter(BedrockRakNetConstants.BATCH_LENGTH_HANDLER_NAME, BedrockRakNetConstants.PACKET_ENCAPSULATION_HANDLER_NAME, new PacketEncapsulationCodec());
channel.pipeline().remove("prepender");
channel.pipeline().remove("timeout");
// Pinging in RakNet is something different
if (ProtocolHack.getRakNetPingSessions().contains(address)) {
ProtocolHack.getRakNetPingSessions().remove(address);
{ // Temporary fix for the ping encoder
final RakClientChannel rakChannel = (RakClientChannel) channel;
rakChannel.parent().pipeline().replace(UnconnectedPingEncoder.NAME, UnconnectedPingEncoder.NAME, new FixedUnconnectedPingEncoder(rakChannel));
rakChannel.parent().pipeline().replace(UnconnectedPongDecoder.NAME, UnconnectedPongDecoder.NAME, new FixedUnconnectedPongDecoder(rakChannel));
}
channel.pipeline().replace(BedrockRakNetConstants.FRAME_ENCAPSULATION_HANDLER_NAME, BedrockRakNetConstants.PING_ENCAPSULATION_HANDLER_NAME, new PingEncapsulationCodec(address));
channel.pipeline().remove(BedrockRakNetConstants.PACKET_ENCAPSULATION_HANDLER_NAME);
channel.pipeline().remove(BedrockRakNetConstants.BATCH_LENGTH_HANDLER_NAME);
}
}
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE);
channel.pipeline().addBefore("prepender", PreNettyConstants.HANDLER_ENCODER_NAME, new VFPPreNettyEncoder(user));
channel.pipeline().addBefore("splitter", PreNettyConstants.HANDLER_DECODER_NAME, new VFPPreNettyDecoder(user));
}
}
}
});
if (rakNet) {
nettyBoostrap = nettyBoostrap.channelFactory(channelType == EpollSocketChannel.class ? RakChannelFactory.client(EpollDatagramChannel.class) : RakChannelFactory.client(NioDatagramChannel.class));
} else {
nettyBoostrap = nettyBoostrap.channel(channelType);
}
return instance.connect(inetHost, inetPort);
if (ProtocolHack.getRakNetPingSessions().contains(address)) {
nettyBoostrap.bind(new InetSocketAddress(0)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE).syncUninterruptibly();
} else {
nettyBoostrap.connect(address.getAddress(), address.getPort()).syncUninterruptibly();
}
return clientConnection;
}
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
super.channelRegistered(ctx);
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
channelActive(ctx);
}
channelActive(ctx);
}
@Override
@ -129,16 +230,6 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
this.channel.pipeline().addBefore(PreNettyConstants.HANDLER_ENCODER_NAME, "encrypt", new PacketEncryptor(this.viafabricplus_encryptionCipher));
}
@Override
public void viafabricplus_captureAddress(InetSocketAddress address) {
this.viafabricplus_capturedAddress = address;
}
@Override
public InetSocketAddress viafabricplus_capturedAddress() {
return this.viafabricplus_capturedAddress;
}
@Override
public void viafabricplus_enableZLibCompression() {
if (this.viafabricplus_compressionEnabled) throw new IllegalStateException("Compression is already enabled");

View File

@ -1,133 +0,0 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD 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.base;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.connection.UserConnectionImpl;
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.constants.BedrockRakNetConstants;
import de.florianmichael.viafabricplus.protocolhack.constants.PreNettyConstants;
import de.florianmichael.viafabricplus.protocolhack.platform.vialegacy.VFPPreNettyDecoder;
import de.florianmichael.viafabricplus.protocolhack.platform.vialegacy.VFPPreNettyEncoder;
import de.florianmichael.viafabricplus.protocolhack.replacement.VFPVLBViaDecodeHandler;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.*;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.library_fix.FixedUnconnectedPingEncoder;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.library_fix.FixedUnconnectedPongDecoder;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.netty.VLBViaEncodeHandler;
import de.florianmichael.vialoadingbase.netty.NettyConstants;
import io.netty.channel.Channel;
import io.netty.channel.ChannelConfig;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.SocketChannel;
import net.minecraft.network.ClientConnection;
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
import net.raphimc.viabedrock.netty.BatchLengthCodec;
import net.raphimc.viabedrock.netty.PacketEncapsulationCodec;
import net.raphimc.viabedrock.protocol.BedrockBaseProtocol;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.baseprotocols.PreNettyBaseProtocol;
import org.cloudburstmc.netty.channel.raknet.RakClientChannel;
import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
import org.cloudburstmc.netty.handler.codec.raknet.common.UnconnectedPingEncoder;
import org.cloudburstmc.netty.handler.codec.raknet.common.UnconnectedPongDecoder;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.net.InetSocketAddress;
import java.util.concurrent.ThreadLocalRandom;
@Mixin(targets = "net.minecraft.network.ClientConnection$1")
public class MixinClientConnection_1 {
@Final
@Shadow
ClientConnection field_11663;
@Redirect(method = "initChannel", at = @At(value = "INVOKE", target = "Lio/netty/channel/ChannelConfig;setOption(Lio/netty/channel/ChannelOption;Ljava/lang/Object;)Z"))
public boolean applyRakNetOptions(ChannelConfig instance, ChannelOption<Object> tChannelOption, Object t) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
instance.setOption(RakChannelOption.RAK_PROTOCOL_VERSION, 11);
instance.setOption(RakChannelOption.RAK_CONNECT_TIMEOUT, 4_000L);
instance.setOption(RakChannelOption.RAK_SESSION_TIMEOUT, 30_000L);
return instance.setOption(RakChannelOption.RAK_GUID, ThreadLocalRandom.current().nextLong());
}
return instance.setOption(tChannelOption, t);
}
@Inject(method = "initChannel", at = @At("TAIL"))
public void hackNettyPipeline(Channel channel, CallbackInfo ci) {
final boolean rakNet = ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest);
if (channel instanceof SocketChannel || rakNet) {
final UserConnection user = new UserConnectionImpl(channel, true);
channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).set(user);
channel.attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).set(field_11663);
new ProtocolPipelineImpl(user);
channel.pipeline().addBefore("encoder", NettyConstants.HANDLER_ENCODER_NAME, new VLBViaEncodeHandler(user));
channel.pipeline().addBefore("decoder", NettyConstants.HANDLER_DECODER_NAME, new VFPVLBViaDecodeHandler(user));
if (rakNet) {
user.getProtocolInfo().getPipeline().add(BedrockBaseProtocol.INSTANCE);
channel.pipeline().replace("splitter", BedrockRakNetConstants.BATCH_LENGTH_HANDLER_NAME, new BatchLengthCodec());
channel.pipeline().addBefore(BedrockRakNetConstants.BATCH_LENGTH_HANDLER_NAME, BedrockRakNetConstants.DISCONNECT_HANDLER_NAME, new DisconnectHandler());
channel.pipeline().addAfter(BedrockRakNetConstants.DISCONNECT_HANDLER_NAME, BedrockRakNetConstants.FRAME_ENCAPSULATION_HANDLER_NAME, new RakMessageEncapsulationCodec());
channel.pipeline().addAfter(BedrockRakNetConstants.BATCH_LENGTH_HANDLER_NAME, BedrockRakNetConstants.PACKET_ENCAPSULATION_HANDLER_NAME, new PacketEncapsulationCodec());
channel.pipeline().remove("prepender");
channel.pipeline().remove("timeout");
final InetSocketAddress address = ((IClientConnection) field_11663).viafabricplus_capturedAddress();
// Pinging in RakNet is something different
if (RakNetPingSessions.isPingSession(address.getAddress())) {
RakNetPingSessions.pingSessions.remove(address.getAddress());
{ // Temporary fix for the ping encoder
final RakClientChannel rakChannel = (RakClientChannel) channel;
rakChannel.parent().pipeline().replace(UnconnectedPingEncoder.NAME, UnconnectedPingEncoder.NAME, new FixedUnconnectedPingEncoder(rakChannel));
rakChannel.parent().pipeline().replace(UnconnectedPongDecoder.NAME, UnconnectedPongDecoder.NAME, new FixedUnconnectedPongDecoder(rakChannel));
}
channel.pipeline().replace(BedrockRakNetConstants.FRAME_ENCAPSULATION_HANDLER_NAME, BedrockRakNetConstants.PING_ENCAPSULATION_HANDLER_NAME, new PingEncapsulationCodec(address));
channel.pipeline().remove(BedrockRakNetConstants.PACKET_ENCAPSULATION_HANDLER_NAME);
channel.pipeline().remove(BedrockRakNetConstants.BATCH_LENGTH_HANDLER_NAME);
}
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE);
channel.pipeline().addBefore("prepender", PreNettyConstants.HANDLER_ENCODER_NAME, new VFPPreNettyEncoder(user));
channel.pipeline().addBefore("splitter", PreNettyConstants.HANDLER_DECODER_NAME, new VFPPreNettyDecoder(user));
}
}
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.network.ClientLoginNetworkHandler;
import net.minecraft.network.ClientConnection;
import net.minecraft.text.Text;
@ -39,7 +39,7 @@ public class MixinClientLoginNetworkHandler {
@Inject(method = "joinServerSession", at = @At("HEAD"), cancellable = true)
public void dontVerifySessionIfCracked(String serverId, CallbackInfoReturnable<Text> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
if (!connection.channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get().get(ProtocolMetadataStorage.class).authenticate) {
cir.setReturnValue(null);
}

View File

@ -17,13 +17,18 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.RakNetPingSessions;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
import net.minecraft.client.network.MultiplayerServerListPinger;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.network.ServerInfo;
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.net.InetSocketAddress;
import java.util.Optional;
@ -31,12 +36,15 @@ import java.util.Optional;
@Mixin(MultiplayerServerListPinger.class)
public class MixinMultiplayerServerListPinger {
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Ljava/util/Optional;get()Ljava/lang/Object;"))
public Object mapSocketAddress(Optional<InetSocketAddress> instance) {
final InetSocketAddress address = instance.get();
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
RakNetPingSessions.storePingSession(address.getAddress());
@Inject(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;Z)Lnet/minecraft/network/ClientConnection;"), locals = LocalCapture.CAPTURE_FAILHARD)
public void trackSessions(ServerInfo entry, Runnable saver, CallbackInfo ci, ServerAddress serverAddress, Optional optional, InetSocketAddress inetSocketAddress) {
final ComparableProtocolVersion version = ((IServerInfo) entry).viafabricplus_forcedVersion();
if (version != null) {
ProtocolHack.getForcedVersions().put(inetSocketAddress, version);
}
if (ProtocolHack.isSelectedOrForced(inetSocketAddress, BedrockProtocolVersion.bedrockLatest)) {
ProtocolHack.getRakNetPingSessions().add(inetSocketAddress);
}
return address;
}
}

View File

@ -0,0 +1,53 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD 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.bridge;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.screen.ForceVersionScreen;
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
import net.minecraft.client.gui.screen.AddServerScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(AddServerScreen.class)
public class MixinAddServerScreen extends Screen {
@Shadow @Final private ServerInfo server;
public MixinAddServerScreen(Text title) {
super(title);
}
@Inject(method = "init", at = @At("RETURN"))
public void injectButton(CallbackInfo ci) {
final ComparableProtocolVersion forcedVersion = ((IServerInfo) server).viafabricplus_forcedVersion();
this.addDrawableChild(ButtonWidget.
builder(Text.literal(forcedVersion == null ? "Set version for this server" :forcedVersion.getName()), button ->
client.setScreen(new ForceVersionScreen(this, version -> ((IServerInfo) server).viafabricplus_forceVersion(version)))).
position(width - (forcedVersion == null ? 150 : 98) - 5, 5).
size(forcedVersion == null ? 150 : 98, 20).build());
}
}

View File

@ -23,7 +23,7 @@ import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.BridgeSettings;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.DebugHud;
import org.spongepowered.asm.mixin.Mixin;
@ -49,7 +49,7 @@ public class MixinDebugHud {
information.add(ScreenUtil.prefixedMessage("").trim());
for (AbstractInformationGroup group : ViaFabricPlus.INSTANCE.getInformationSystem().getGroups()) {
if (group.getProtocolRange() != null && !group.getProtocolRange().contains(ViaLoadingBase.getClassWrapper().getTargetVersion())) continue;
if (group.getProtocolRange() != null && !group.getProtocolRange().contains(ProtocolHack.getTargetVersion())) continue;
final List<String> groupInformation = new ArrayList<>();
group.applyInformation(userConnection, groupInformation);

View File

@ -0,0 +1,69 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD 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.bridge;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.nbt.NbtCompound;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(ServerInfo.class)
public class MixinServerInfo implements IServerInfo {
@Shadow public String name;
@Unique
private ComparableProtocolVersion viafabricplus_forcedVersion = null;
@Override
public ComparableProtocolVersion viafabricplus_forcedVersion() {
return viafabricplus_forcedVersion;
}
@Override
public void viafabricplus_forceVersion(ComparableProtocolVersion version) {
viafabricplus_forcedVersion = version;
}
@Inject(method = "toNbt", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
public void saveForcedVersion(CallbackInfoReturnable<NbtCompound> cir, NbtCompound nbtCompound) {
if (viafabricplus_forcedVersion == null) return;
nbtCompound.putInt("viafabricplus_forcedversion", viafabricplus_forcedVersion.getVersion());
}
@Inject(method = "fromNbt", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void loadForcedVersion(NbtCompound root, CallbackInfoReturnable<ServerInfo> cir, ServerInfo serverInfo) {
if (root.contains("viafabricplus_forcedversion")) {
((IServerInfo) serverInfo).viafabricplus_forceVersion(InternalProtocolList.fromProtocolVersion(InternalProtocolList.fromProtocolId(root.getInt("viafabricplus_forcedversion"))));
}
}
@Inject(method = "copyFrom", at = @At("RETURN"))
public void trackForcedVersion(ServerInfo serverInfo, CallbackInfo ci) {
viafabricplus_forceVersion(((IServerInfo) serverInfo).viafabricplus_forcedVersion());
}
}

View File

@ -22,7 +22,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.injection.access.IPlayerPositionLookS2CPacket;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
import net.minecraft.client.gui.screen.Screen;
@ -77,14 +77,14 @@ public abstract class MixinClientPlayNetworkHandler {
@Inject(method = "<init>", at = @At("RETURN"))
public void fixPlayerListOrdering(MinecraftClient client, Screen screen, ClientConnection connection, ServerInfo serverInfo, GameProfile profile, WorldSession worldSession, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
this.listedPlayerListEntries = new LinkedHashSet<>();
}
}
@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(PlayPingS2CPacket packet, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_17)) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_17)) {
return;
}
@ -101,14 +101,14 @@ public abstract class MixinClientPlayNetworkHandler {
@Inject(method = "onChunkLoadDistance", at = @At("RETURN"))
public void emulateSimulationDistance(ChunkLoadDistanceS2CPacket packet, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
this.onSimulationDistance(new SimulationDistanceS2CPacket(packet.getDistance()));
}
}
@Inject(method = "onEntitySpawn", at = @At("TAIL"))
public void forceEntityVelocity(EntitySpawnS2CPacket packet, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (packet.getEntityType() == EntityType.ITEM || packet.getEntityType() == EntityType.ARROW || packet.getEntityType() == EntityType.SPECTRAL_ARROW || packet.getEntityType() == EntityType.TRIDENT) {
onEntityVelocityUpdate(new EntityVelocityUpdateS2CPacket(packet.getId(), new Vec3d(packet.getVelocityX(), packet.getVelocityY(), packet.getVelocityZ())));
}
@ -117,7 +117,7 @@ public abstract class MixinClientPlayNetworkHandler {
@Inject(method = { "onGameJoin", "onPlayerRespawn" }, at = @At("TAIL"))
private void injectOnOnGameJoinOrRespawn(CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
ClientPlayerEntity player = MinecraftClient.getInstance().player;
assert player != null;
onEntityStatus(new EntityStatusS2CPacket(player, (byte) 28));
@ -126,14 +126,14 @@ public abstract class MixinClientPlayNetworkHandler {
@Redirect(method = "onPlayerSpawnPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/DownloadingTerrainScreen;setReady()V"))
public void moveDownloadingTerrainClosing(DownloadingTerrainScreen instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19)) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19)) {
instance.setReady();
}
}
@Inject(method = "onPlayerPositionLook", at = @At("RETURN"))
public void closeDownloadingTerrain(PlayerPositionLookS2CPacket packet, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2) && MinecraftClient.getInstance().currentScreen instanceof DownloadingTerrainScreen) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2) && MinecraftClient.getInstance().currentScreen instanceof DownloadingTerrainScreen) {
MinecraftClient.getInstance().setScreen(null);
}
}
@ -141,7 +141,7 @@ public abstract class MixinClientPlayNetworkHandler {
@SuppressWarnings("InvalidInjectorMethodSignature")
@ModifyConstant(method = "onEntityPassengersSet", constant = @Constant(classValue = BoatEntity.class))
public Class<?> dontChangePlayerYaw(Object entity, Class<?> constant) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
return Integer.class;
}
return constant;
@ -149,7 +149,7 @@ public abstract class MixinClientPlayNetworkHandler {
@Redirect(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
public void removeNewWarning(Logger instance, String s, Object o) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19_3)) {
instance.warn(s, o);
}
}
@ -163,7 +163,7 @@ public abstract class MixinClientPlayNetworkHandler {
@Redirect(method = "onKeepAlive", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;Ljava/util/function/BooleanSupplier;Ljava/time/Duration;)V"))
public void forceSendKeepAlive(ClientPlayNetworkHandler instance, Packet<ServerPlayPacketListener> packet, BooleanSupplier sendCondition, Duration expirationTime) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
sendPacket(packet);
return;
}

View File

@ -27,7 +27,7 @@ import de.florianmichael.viafabricplus.injection.access.IScreenHandler;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusHandItemProvider;
import de.florianmichael.viafabricplus.protocolhack.usage.ItemTranslator;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
@ -71,7 +71,7 @@ public abstract class MixinClientPlayerInteractionManager {
@Inject(method = "attackEntity", at = @At("HEAD"))
private void injectAttackEntity(PlayerEntity player, Entity target, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && player instanceof IClientPlayerEntity) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && player instanceof IClientPlayerEntity) {
player.swingHand(Hand.MAIN_HAND);
((IClientPlayerEntity) player).viafabricplus_cancelSwingOnce();
}
@ -91,7 +91,7 @@ public abstract class MixinClientPlayerInteractionManager {
if (type == SlotActionType.QUICK_CRAFT) return true;
// quick move always uses empty stack for verification since 1.12
if (type == SlotActionType.QUICK_MOVE && ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_11_1)) return true;
if (type == SlotActionType.QUICK_MOVE && ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_11_1)) return true;
// pickup with slot -999 (outside window) to throw items always uses empty stack for verification
return type == SlotActionType.PICKUP && slot == -999;
@ -100,7 +100,7 @@ public abstract class MixinClientPlayerInteractionManager {
@Redirect(method = "clickSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V"))
private void modifySlotClickPacket(ClientPlayNetworkHandler instance, Packet<?> packet) {
try {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4) && packet instanceof ClickSlotC2SPacket clickSlot) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4) && packet instanceof ClickSlotC2SPacket clickSlot) {
ItemStack slotItemBeforeModification;
if (this.viafabricplus_shouldEmpty(clickSlot.getActionType(), clickSlot.getSlot()))
@ -137,7 +137,7 @@ public abstract class MixinClientPlayerInteractionManager {
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;syncSelectedSlot()V"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;sendSequencedPacket(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/network/SequencedPacketCreator;)V", ordinal = 0)))
private void redirectInteractItem(ClientPlayNetworkHandler clientPlayNetworkHandler, Packet<?> packet) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_17)) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_17)) {
clientPlayNetworkHandler.sendPacket(packet);
}
}
@ -157,7 +157,7 @@ public abstract class MixinClientPlayerInteractionManager {
@Inject(method = "interactBlock", at = @At("HEAD"), cancellable = true)
public void cacheActionResult(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
this.viafabricplus_actionResult = this.interactBlockInternal(player, hand, hitResult);
if (this.viafabricplus_actionResult == ActionResult.FAIL) {
@ -168,7 +168,7 @@ public abstract class MixinClientPlayerInteractionManager {
@Redirect(method = "method_41933", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactBlockInternal(Lnet/minecraft/client/network/ClientPlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;"))
public ActionResult provideCachedResult(ClientPlayerInteractionManager instance, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return this.viafabricplus_actionResult;
}
return interactBlockInternal(player, hand, hitResult);

View File

@ -25,7 +25,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPac
import de.florianmichael.viafabricplus.definition.v1_12_2.SyncInputExecutor;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
@ -58,7 +58,7 @@ public abstract class MixinMinecraftClient {
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;resetEquipProgress(Lnet/minecraft/util/Hand;)V", ordinal = 0))
private void redirectDoItemUse(HeldItemRenderer heldItemRenderer, Hand hand) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem)) {
if (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem)) {
heldItemRenderer.resetEquipProgress(hand);
}
}
@ -67,7 +67,7 @@ public abstract class MixinMinecraftClient {
slice = @Slice(to = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;isAccepted()Z", ordinal = 0))
private boolean preventGenericInteract(ActionResult instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
return true;
}
@ -79,7 +79,7 @@ public abstract class MixinMinecraftClient {
*/
@Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;attackCooldown:I", ordinal = 1))
public int unwrapOperation(MinecraftClient instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return 0;
}
return attackCooldown;
@ -87,7 +87,7 @@ public abstract class MixinMinecraftClient {
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.BEFORE))
public void updateCooldown(CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (this.attackCooldown > 0) {
--this.attackCooldown;
}
@ -108,7 +108,7 @@ public abstract class MixinMinecraftClient {
if (getNetworkHandler() != null && DebugSettings.INSTANCE.sendOpenInventoryPacket.getValue()) {
final UserConnection viaConnection = MinecraftClient.getInstance().getNetworkHandler().getConnection().channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get();
if (viaConnection != null && ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
if (viaConnection != null && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
final PacketWrapper clientStatus = PacketWrapper.create(ServerboundPackets1_9_3.CLIENT_STATUS, viaConnection);
clientStatus.write(Type.VAR_INT, 2); // Open Inventory Achievement

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraft.util.math.Direction;
@ -34,7 +34,7 @@ public class MixinPlayerEntityRenderer {
@Inject(method = "getPositionOffset*", at = @At("RETURN"), cancellable = true)
private void injectGetPositionOffset(AbstractClientPlayerEntity player, float delta, CallbackInfoReturnable<Vec3d> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (player.getSleepingDirection() != null) {
ci.setReturnValue(ci.getReturnValue().subtract(player.getSleepingDirection().getOffsetX() * 0.4, 0, player.getSleepingDirection().getOffsetZ() * 0.4));
}
@ -44,6 +44,6 @@ public class MixinPlayerEntityRenderer {
@Redirect(method = "getPositionOffset(Lnet/minecraft/client/network/AbstractClientPlayerEntity;F)Lnet/minecraft/util/math/Vec3d;",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;isInSneakingPose()Z"))
private boolean redirectGetPositionOffset(AbstractClientPlayerEntity player) {
return (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_11_1)) && player.isInSneakingPose();
return (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_11_1)) && player.isInSneakingPose();
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.platform.ProtocolRange;
import net.minecraft.client.network.AllowedAddressResolver;
import net.minecraft.client.network.ServerAddress;
@ -35,15 +35,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ServerAddress.class)
public class MixinServerAddress {
@Shadow @Final private static ServerAddress INVALID;
@Unique
private final static ProtocolRange viafabricplus_srvRange = new ProtocolRange(ProtocolVersion.v1_16_4, LegacyProtocolVersion.r1_3_1tor1_3_2);
@Inject(method = "parse", at = @At("RETURN"), cancellable = true)
private static void fixAddress(String address, CallbackInfoReturnable<ServerAddress> cir) {
if (!cir.getReturnValue().equals(INVALID) && (viafabricplus_srvRange.contains(ViaLoadingBase.getClassWrapper().getTargetVersion()) || ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest))) {
cir.setReturnValue(AllowedAddressResolver.DEFAULT.redirectResolver.lookupRedirect(cir.getReturnValue()).orElse(cir.getReturnValue()));
}
}
// @Shadow @Final private static ServerAddress INVALID;
//
// @Unique
// private final static ProtocolRange viafabricplus_srvRange = new ProtocolRange(ProtocolVersion.v1_16_4, LegacyProtocolVersion.r1_3_1tor1_3_2);
//
// @Inject(method = "parse", at = @At("RETURN"), cancellable = true)
// private static void fixAddress(String address, CallbackInfoReturnable<ServerAddress> cir) {
// if (!cir.getReturnValue().equals(INVALID) && (viafabricplus_srvRange.contains(ProtocolHack.getTargetVersion()) || ProtocolHack.getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest))) {
// cir.setReturnValue(AllowedAddressResolver.DEFAULT.redirectResolver.lookupRedirect(cir.getReturnValue()).orElse(cir.getReturnValue()));
// }
// }
}

View File

@ -22,7 +22,7 @@ import com.google.common.hash.Hashing;
import com.google.common.io.Files;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.definition.PackFormatsDefinition;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.GameVersion;
import net.minecraft.client.resource.ServerResourcePackProvider;
import org.apache.commons.codec.digest.DigestUtils;
@ -54,10 +54,10 @@ public class MixinServerResourcePackProvider {
@Inject(method = "getDownloadHeaders", at = @At("TAIL"), cancellable = true)
private static void removeHeaders(CallbackInfoReturnable<Map<String, String>> cir) {
final LinkedHashMap<String, String> modifiableMap = new LinkedHashMap<>(cir.getReturnValue());
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_14)) {
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_14)) {
modifiableMap.remove("X-Minecraft-Version-ID");
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_13)) {
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_13)) {
modifiableMap.remove("X-Minecraft-Pack-Format");
modifiableMap.remove("User-Agent");
}
@ -73,10 +73,10 @@ public class MixinServerResourcePackProvider {
@Redirect(method = "verifyFile", at = @At(value = "INVOKE", target = "Lcom/google/common/hash/HashCode;toString()Ljava/lang/String;", remap = false))
public String revertHashAlgorithm(HashCode instance) {
try {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
//noinspection deprecation
return Hashing.sha1().hashBytes(Files.toByteArray(viafabricplus_trackedFile)).toString();
} else if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_18)) {
} else if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_18)) {
return DigestUtils.sha1Hex(new FileInputStream(viafabricplus_trackedFile));
}
} catch (IOException ignored) {
@ -86,7 +86,7 @@ public class MixinServerResourcePackProvider {
@Redirect(method = "verifyFile", at = @At(value = "INVOKE", target = "Ljava/lang/String;toLowerCase(Ljava/util/Locale;)Ljava/lang/String;"))
public String disableIgnoreCase(String instance, Locale locale) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return instance;
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -41,25 +41,25 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
public void changeHardness(BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
final BlockState state = this.asBlockState();
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (state.getBlock() instanceof InfestedBlock) {
cir.setReturnValue(0.75F);
}
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (state.getBlock() == Blocks.END_STONE_BRICKS || state.getBlock() == Blocks.END_STONE_BRICK_SLAB || state.getBlock() == Blocks.END_STONE_BRICK_STAIRS || state.getBlock() == Blocks.END_STONE_BRICK_WALL) {
cir.setReturnValue(0.8F);
}
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (state.getBlock() == Blocks.PISTON || state.getBlock() == Blocks.STICKY_PISTON || state.getBlock() == Blocks.PISTON_HEAD) {
cir.setReturnValue(0.5F);
}
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (state.getBlock() instanceof InfestedBlock) {
cir.setReturnValue(0F);
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.AnvilBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -51,7 +51,7 @@ public class MixinAnvilBlock {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(state.get(FACING).getAxis() == Direction.Axis.X ? viafabricplus_x_axis_shape_v1_12_2 : viafabricplus_z_axis_shape_v1_12_2);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BambooBlock;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
@ -33,7 +33,7 @@ public class MixinBambooBlock {
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true)
public void changeFullCube(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) {
cir.setReturnValue(true);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BedBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -42,17 +42,15 @@ public class MixinBedBlock {
@Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true)
public void injectBounceEntity(Entity entity, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
ci.cancel();
}
}
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper() != null) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
cir.setReturnValue(viafabricplus_bed_shape_v1_13_2);
}
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
cir.setReturnValue(viafabricplus_bed_shape_v1_13_2);
}
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.InfestedBlock;
@ -34,19 +34,19 @@ public class MixinBlock {
private void modifyBlastResistance(CallbackInfoReturnable<Float> ci) {
final Block block = ((Block) (Object) this);
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (block == Blocks.END_STONE_BRICKS || block == Blocks.END_STONE_BRICK_SLAB || block == Blocks.END_STONE_BRICK_STAIRS || block == Blocks.END_STONE_BRICK_WALL) {
ci.setReturnValue(0.8F);
}
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (block == Blocks.PISTON || block == Blocks.STICKY_PISTON || block == Blocks.PISTON_HEAD) {
ci.setReturnValue(0.5F);
}
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (block instanceof InfestedBlock) {
ci.setReturnValue(0.75F);
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BrewingStandBlock;
@ -44,7 +44,7 @@ public class MixinBrewingStandBlock {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(viafabricplus_base_shape_v1_12_2);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
import net.minecraft.block.cauldron.CauldronBehavior;
import net.minecraft.item.Item;
@ -48,7 +48,7 @@ public abstract class MixinCauldronBlock extends AbstractCauldronBlock {
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return viafabricplus_cauldron_shape_v1_12_2;
}
return super.getOutlineShape(state, world, pos, context);

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.ChestBlockEntity;
@ -39,7 +39,7 @@ public abstract class MixinChestBlock extends AbstractChestBlock<ChestBlockEntit
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
return VoxelShapes.fullCube();
}
return super.getCollisionShape(state, world, pos, context);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos;
@ -52,10 +52,10 @@ public abstract class MixinEndPortalBlock extends BlockWithEntity {
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (MinecraftClient.getInstance() == null || MinecraftClient.getInstance().world == null) return;
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
cir.setReturnValue(viafabricplus_shape_v1_8_x);
}
else if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
cir.setReturnValue(viafabricplus_shape_v1_16_5);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.EndPortalFrameBlock;
import net.minecraft.util.shape.VoxelShape;
@ -44,7 +44,7 @@ public class MixinEndPortalFrameBlock {
@Redirect(method = "getOutlineShape", at = @At(value = "FIELD", target = "Lnet/minecraft/block/EndPortalFrameBlock;FRAME_WITH_EYE_SHAPE:Lnet/minecraft/util/shape/VoxelShape;"))
public VoxelShape redirectGetOutlineShape() {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return VoxelShapes.union(FRAME_SHAPE, viafabricplus_eye_shape_v1_12_2);
}
return FRAME_WITH_EYE_SHAPE;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock;
@ -50,7 +50,7 @@ public class MixinFarmlandBlock extends Block {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
cir.setReturnValue(viafabricplus_shape_v1_9_4);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
@ -41,7 +41,7 @@ public class MixinFenceBlock extends HorizontalConnectingBlock {
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
private void injectOnUse(CallbackInfoReturnable<ActionResult> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10)) {
ci.setReturnValue(ActionResult.SUCCESS);
}
}
@ -51,7 +51,7 @@ public class MixinFenceBlock extends HorizontalConnectingBlock {
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
return viafabricplus_fence_shape_b1_8_1;
}
return super.getCollisionShape(state, world, pos, context);
@ -59,7 +59,7 @@ public class MixinFenceBlock extends HorizontalConnectingBlock {
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
return VoxelShapes.fullCube();
}
return super.getOutlineShape(state, world, pos, context);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BlockState;
import net.minecraft.block.FireBlock;
import net.minecraft.block.ShapeContext;
@ -36,7 +36,7 @@ public class MixinFireBlock {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
cir.setReturnValue(VoxelShapes.empty());
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.FlowerPotBlock;
@ -39,7 +39,7 @@ public class MixinFlowerPotBlock {
@Inject(method = "onUse", at = @At(value = "FIELD", target = "Lnet/minecraft/block/FlowerPotBlock;content:Lnet/minecraft/block/Block;", ordinal = 0), cancellable = true)
private void injectOnUse(CallbackInfoReturnable<ActionResult> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10) && content != Blocks.AIR) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10) && content != Blocks.AIR) {
ci.setReturnValue(ActionResult.CONSUME);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HopperBlock;
@ -48,14 +48,14 @@ public class MixinHopperBlock {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(viafabricplus_hopper_shape_v1_12_2);
}
}
@Inject(method = "getRaycastShape", at = @At("HEAD"), cancellable = true)
public void injectGetRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(viafabricplus_inside_shape_v1_12_2);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LadderBlock;
@ -49,7 +49,7 @@ public class MixinLadderBlock {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
private void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
switch (state.get(LadderBlock.FACING)) {
case NORTH -> ci.setReturnValue(viafabricplus_north_shape_v1_8_x);
case SOUTH -> ci.setReturnValue(viafabricplus_south_shape_v1_8_x);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.LightBlock;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
@ -31,7 +31,7 @@ public class MixinLightBlock {
// Not relevant for GamePlay
@Redirect(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isCreativeLevelTwoOp()Z"))
public boolean removeIf(PlayerEntity instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
return true;
}
return instance.isCreativeLevelTwoOp();

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LilyPadBlock;
@ -40,7 +40,7 @@ public class MixinLilyPadBlock {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void changeBoundingBox(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
cir.setReturnValue(viafabricplus_shape_v1_8_x);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
@ -36,7 +36,7 @@ public class MixinPaneBlock extends HorizontalConnectingBlock {
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return viafabricplus_get1_8Shape(state);
}
return super.getOutlineShape(state, world, pos, context);
@ -44,7 +44,7 @@ public class MixinPaneBlock extends HorizontalConnectingBlock {
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return viafabricplus_get1_8Shape(state);
}
return super.getCollisionShape(state, world, pos, context);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@ -40,14 +40,14 @@ public class MixinPistonHeadBlock extends FacingBlock {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(viafabricplus_getCoreShape_v1_8_x(state));
}
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return VoxelShapes.union(viafabricplus_getHeadShape_v1_8_x(state), viafabricplus_getCoreShape_v1_8_x(state));
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
@ -56,7 +56,7 @@ public class MixinSnowBlock {
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(viafabricplus_layers_to_shape_v1_12_2[state.get(LAYERS) - 1]);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoulSandBlock;
@ -43,7 +43,7 @@ public class MixinSoulSandBlock extends Block {
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
super.onEntityCollision(state, world, pos, entity);
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
final Vec3d velocity = entity.getVelocity();
this.viafabricplus_forceValue = true;
entity.setVelocity(velocity.getX() * this.getVelocityMultiplier(), velocity.getY(), velocity.getZ() * this.getVelocityMultiplier());
@ -53,7 +53,7 @@ public class MixinSoulSandBlock extends Block {
@Override
public float getVelocityMultiplier() {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4) && !this.viafabricplus_forceValue) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4) && !this.viafabricplus_forceValue) {
return 1.0F;
}
return super.getVelocityMultiplier();

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -33,7 +33,7 @@ public class MixinSugarCaneBlock {
@Redirect(method = "canPlaceAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isIn(Lnet/minecraft/registry/tag/TagKey;)Z"))
public boolean changePlaceTarget(BlockState instance, TagKey<Block> tagKey) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) {
return instance.isOf(Blocks.GRASS_BLOCK) || instance.isOf(Blocks.DIRT) || instance.isOf(Blocks.COARSE_DIRT) || instance.isOf(Blocks.PODZOL);
}
return instance.isIn(tagKey);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
@ -144,28 +144,28 @@ public class MixinWallBlock extends Block {
@Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true)
public void injectGetPlacementState(ItemPlacementContext ctx, CallbackInfoReturnable<BlockState> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
cir.setReturnValue(viafabricplus_oldWallPlacementLogic(cir.getReturnValue()));
}
}
@Inject(method = "getStateForNeighborUpdate", at = @At("RETURN"), cancellable = true)
public void injectGetStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos, CallbackInfoReturnable<BlockState> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
cir.setReturnValue(viafabricplus_oldWallPlacementLogic(cir.getReturnValue()));
}
}
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
public void injectGetCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(viafabricplus_cip_shape_by_index_v1_12_2[viafabricplus_getShapeIndex_v1_12_2(state)]);
}
}
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(viafabricplus_shape_by_index_v1_12_2[viafabricplus_getShapeIndex_v1_12_2(state)]);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.AbstractDonkeyEntity;
@ -50,7 +50,7 @@ public abstract class MixinAbstractDonkeyEntity extends AbstractHorseEntity {
@Inject(method = "interactMob", at = @At("HEAD"), cancellable = true)
public void fixInteraction(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
ItemStack lv = player.getStackInHand(hand);
if (!this.isBaby()) {
if (this.isTame() && player.shouldCancelInteraction()) {

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.passive.AllayEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@ -30,7 +30,7 @@ public class MixinAllayEntity {
@Inject(method = "getHeightOffset", at = @At("HEAD"), cancellable = true)
public void changeHeightOffset(CallbackInfoReturnable<Double> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
cir.setReturnValue(0.0);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
@ -30,6 +30,6 @@ public class MixinAnimalEntity {
@Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isClient:Z"))
public boolean redirectInteractMob(World instance) {
return instance.isClient && ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_15);
return instance.isClient && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_15);
}
}

View File

@ -24,7 +24,7 @@ import de.florianmichael.viafabricplus.event.SkipIdlePacketCallback;
import de.florianmichael.viafabricplus.injection.access.IClientPlayerEntity;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.input.Input;
import net.minecraft.client.network.AbstractClientPlayerEntity;
@ -94,11 +94,11 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
double f = this.getZ() - this.lastZ;
double g = this.getYaw() - this.lastYaw;
double h = this.getPitch() - this.lastPitch;
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_8)) {
++this.ticksSinceLastPositionPacketSent;
}
double n = MathHelper.square(2.05E-4);
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
n = 9.0E-4D;
}
boolean bl3 = MathHelper.squaredMagnitude(d, e, f) > n || this.ticksSinceLastPositionPacketSent >= 20;
@ -118,7 +118,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
} else {
SkipIdlePacketCallback.EVENT.invoker().onSkipIdlePacket();
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
++this.ticksSinceLastPositionPacketSent;
}
@ -140,7 +140,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Inject(method = "swingHand", at = @At("HEAD"), cancellable = true)
public void injectSwingHand(Hand hand, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && viafabricplus_areSwingCanceledThisTick) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && viafabricplus_areSwingCanceledThisTick) {
ci.cancel();
}
@ -153,7 +153,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/Input;sneaking:Z", ordinal = 0)
)
private void injectTickMovement(CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (this.input.sneaking) {
this.input.movementSideways = (float) ((double) this.input.movementSideways / 0.3D);
this.input.movementForward = (float) ((double) this.input.movementForward / 0.3D);
@ -165,7 +165,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")),
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSwimming()Z", ordinal = 0))
public boolean redirectIsSneakingWhileSwimming(ClientPlayerEntity _this) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
return false;
} else {
return _this.isSwimming();
@ -174,7 +174,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Redirect(method = "isWalking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSubmergedInWater()Z"))
public boolean easierUnderwaterSprinting(ClientPlayerEntity instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
return false;
}
return instance.isSubmergedInWater();
@ -182,7 +182,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Redirect(method = "tickMovement()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;hasForwardMovement()Z", ordinal = 0))
private boolean disableSprintSneak(Input input) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
return input.movementForward >= 0.8F;
}
@ -191,7 +191,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isTouchingWater()Z"))
private boolean redirectTickMovement(ClientPlayerEntity self) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return false; // Disable all water related movement
}
@ -200,14 +200,14 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSprintingPacket()V"))
public void removeSprintingPacket(ClientPlayerEntity instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19_3)) {
sendSprintingPacket();
}
}
@Redirect(method = "autoJump", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;inverseSqrt(F)F"))
public float useFastInverse(float x) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
final float var1 = 0.5F * x;
int var2 = Float.floatToIntBits(x);
var2 = 1597463007 - (var2 >> 1);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.CowEntity;
@ -40,7 +40,7 @@ public abstract class MixinCowEntity extends AnimalEntity {
@Inject(method = "interactMob", at = @At("HEAD"), cancellable = true)
public void injectInteractMob(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && player.getAbilities().creativeMode) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && player.getAbilities().creativeMode) {
cir.setReturnValue(super.interactMob(player, hand));
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.mob.CreeperEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
@ -31,7 +31,7 @@ public class MixinCreeperEntity {
@Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/sound/SoundEvents;ITEM_FIRECHARGE_USE:Lnet/minecraft/sound/SoundEvent;"))
public SoundEvent fixSound() {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
return SoundEvents.ITEM_FLINTANDSTEEL_USE;
}
return SoundEvents.ITEM_FIRECHARGE_USE;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import it.unimi.dsi.fastutil.objects.Object2DoubleMap;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
@ -59,7 +59,7 @@ public abstract class MixinEntity {
@ModifyConstant(method = "movementInputToVelocity", constant = @Constant(doubleValue = 1E-7))
private static double injectMovementInputToVelocity(double epsilon) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
return 1E-4;
}
return epsilon;
@ -67,21 +67,21 @@ public abstract class MixinEntity {
@Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true)
public void injectGetVelocityAffectingPos(CallbackInfoReturnable<BlockPos> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
cir.setReturnValue(BlockPos.ofFloored(pos.x, getBoundingBox().minY - 1, pos.z));
}
}
@Inject(method = "getRotationVector(FF)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
public void onGetRotationVector(float pitch, float yaw, CallbackInfoReturnable<Vec3d> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(Vec3d.fromPolar(pitch, yaw));
}
}
@Inject(method = "setSwimming", at = @At("HEAD"), cancellable = true)
private void onSetSwimming(boolean swimming, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && swimming) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && swimming) {
ci.cancel();
}
}
@ -89,7 +89,7 @@ public abstract class MixinEntity {
@SuppressWarnings("deprecation")
@Inject(method = "updateMovementInFluid", at = @At("HEAD"), cancellable = true)
private void modifyFluidMovementBoundingBox(TagKey<Fluid> fluidTag, double d, CallbackInfoReturnable<Boolean> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_12_2)) {
return;
}
@ -139,19 +139,19 @@ public abstract class MixinEntity {
@Inject(method = "getTargetingMargin", at = @At("HEAD"), cancellable = true)
public void expandHitBox(CallbackInfoReturnable<Float> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
cir.setReturnValue(0.1F);
}
}
@Redirect(method = {"setYaw", "setPitch"}, at = @At(value = "INVOKE", target = "Ljava/lang/Float;isFinite(F)Z"))
public boolean modifyIsFinite(float f) {
return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2));
return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2));
}
@ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 1.0E-7))
public double changeBlockCollisionConstant(double constant) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
return 0.001;
}
return constant;
@ -160,7 +160,7 @@ public abstract class MixinEntity {
// Not relevant for GamePlay
@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;onLanding()V"))
public void revertOnLanding(Entity instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19)) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19)) {
instance.onLanding();
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.world.entity.EntityIndex;
import net.minecraft.world.entity.EntityLike;
@ -42,12 +42,12 @@ public class MixinEntityIndex<T extends EntityLike> {
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Ljava/util/Map;containsKey(Ljava/lang/Object;)Z", remap = false))
private boolean allowDuplicateUuid(Map<UUID, T> instance, Object o) {
return instance.containsKey(o) && ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_16_4);
return instance.containsKey(o) && ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_16_4);
}
@Inject(method = "size", at = @At("HEAD"), cancellable = true)
private void returnRealSize(CallbackInfoReturnable<Integer> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
cir.setReturnValue(this.idToEntity.size());
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.predicate.entity.EntityPredicates;
import org.spongepowered.asm.mixin.Mixin;
@ -31,7 +31,7 @@ public class MixinEntityPredicates {
@SuppressWarnings("target")
@Redirect(method = "method_5915(Lnet/minecraft/entity/Entity;Lnet/minecraft/scoreboard/AbstractTeam;Lnet/minecraft/scoreboard/AbstractTeam$CollisionRule;Lnet/minecraft/entity/Entity;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isMainPlayer()Z"))
private static boolean makeMainPlayerUnpushable(PlayerEntity player) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return false;
}
return player.isMainPlayer();

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.ItemEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@ -30,7 +30,7 @@ public class MixinItemEntity {
@Inject(method = "applyWaterBuoyancy", at = @At("HEAD"), cancellable = true)
public void injectApplyWaterBuoyancy(CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
ci.cancel();
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;
@ -50,7 +50,7 @@ public abstract class MixinLivingEntity extends Entity {
@Inject(method = "getPreferredEquipmentSlot", at = @At("HEAD"), cancellable = true)
private static void removeShieldSlotPreference(ItemStack stack, CallbackInfoReturnable<EquipmentSlot> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_9_3) && stack.isOf(Items.SHIELD)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_9_3) && stack.isOf(Items.SHIELD)) {
cir.setReturnValue(EquipmentSlot.MAINHAND);
}
}
@ -60,7 +60,7 @@ public abstract class MixinLivingEntity extends Entity {
@Redirect(method = "applyMovementInput", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;jumping:Z"))
private boolean disableJumpOnLadder(LivingEntity self) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
return false;
}
@ -71,7 +71,7 @@ public abstract class MixinLivingEntity extends Entity {
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/effect/StatusEffects;DOLPHINS_GRACE:Lnet/minecraft/entity/effect/StatusEffect;")),
at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;horizontalCollision:Z", ordinal = 0))
private boolean disableClimbing(LivingEntity self) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
return false;
}
@ -80,7 +80,7 @@ public abstract class MixinLivingEntity extends Entity {
@ModifyVariable(method = "applyFluidMovingSpeed", ordinal = 0, at = @At("HEAD"), argsOnly = true)
private boolean modifyMovingDown(boolean movingDown) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
return true;
}
@ -91,14 +91,14 @@ public abstract class MixinLivingEntity extends Entity {
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/effect/StatusEffects;LEVITATION:Lnet/minecraft/entity/effect/StatusEffect;", ordinal = 0)),
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;onLanding()V", ordinal = 0))
private void dontResetLevitationFallDistance(LivingEntity instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_12_2)) {
instance.onLanding();
}
}
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSprinting()Z", ordinal = 0))
private boolean modifySwimSprintSpeed(LivingEntity self) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return false;
}
return self.isSprinting();
@ -106,7 +106,7 @@ public abstract class MixinLivingEntity extends Entity {
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/registry/tag/TagKey;)D"))
private double redirectFluidHeight(LivingEntity instance, TagKey<Fluid> tagKey) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && tagKey == FluidTags.WATER) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && tagKey == FluidTags.WATER) {
if (instance.getFluidHeight(tagKey) > 0) {
return 1;
}
@ -116,14 +116,14 @@ public abstract class MixinLivingEntity extends Entity {
@Inject(method = "applyFluidMovingSpeed", at = @At("HEAD"), cancellable = true)
private void modifySwimSprintFallSpeed(double gravity, boolean movingDown, Vec3d velocity, CallbackInfoReturnable<Vec3d> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && !hasNoGravity()) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && !hasNoGravity()) {
ci.setReturnValue(new Vec3d(velocity.x, velocity.y - 0.02, velocity.z));
}
}
@ModifyConstant(method = "tickMovement", constant = @Constant(doubleValue = 0.003D))
public double modifyVelocityZero(final double constant) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return 0.005D;
}
return constant;
@ -131,14 +131,14 @@ public abstract class MixinLivingEntity extends Entity {
@Inject(method = "canEnterTrapdoor", at = @At("HEAD"), cancellable = true)
private void onCanEnterTrapdoor(CallbackInfoReturnable<Boolean> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
ci.setReturnValue(false);
}
}
@ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.9F))
private float changeEntitySpeed(float constant) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
//noinspection ConstantConditions
if ((Entity) this instanceof SkeletonHorseEntity) {
return this.getBaseMovementSpeedMultiplier(); // 0.96F
@ -150,7 +150,7 @@ public abstract class MixinLivingEntity extends Entity {
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Ljava/lang/Math;cos(D)D"))
public double fixCosTable(double a) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
return MathHelper.cos((float) a);
}
return Math.cos(a);
@ -160,7 +160,7 @@ public abstract class MixinLivingEntity extends Entity {
public double fixLavaMovement(LivingEntity instance, TagKey<Fluid> tagKey) {
double height = instance.getFluidHeight(tagKey);
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
height += getSwimHeight() + 4;
}
return height;
@ -168,7 +168,7 @@ public abstract class MixinLivingEntity extends Entity {
@ModifyConstant(method = "isBlocking", constant = @Constant(intValue = 5))
public int shieldBlockCounter(int constant) {
if(ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if(ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return 0;
}
return constant;
@ -176,7 +176,7 @@ public abstract class MixinLivingEntity extends Entity {
@Redirect(method = "tickCramming", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isClient()Z"))
public boolean revertOnlyPlayerCramming(World instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
return false;
}
return instance.isClient();

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.mojang.authlib.GameProfile;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.OtherClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
@ -37,7 +37,7 @@ public class MixinOtherClientPlayerEntity extends AbstractClientPlayerEntity {
@Inject(method = "updatePose", at = @At("HEAD"))
public void injectUpdatePose(CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
super.updatePose();
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityPose;
import net.minecraft.entity.mob.PiglinEntity;
@ -35,7 +35,7 @@ public abstract class MixinPiglinEntity {
@Inject(method = "getActiveEyeHeight", at = @At("HEAD"), cancellable = true)
public void changeEyeHeight(EntityPose pose, EntityDimensions dimensions, CallbackInfoReturnable<Float> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
cir.setReturnValue(this.isBaby() ? 0.93F : 1.74F);
}
}

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityPose;
import net.minecraft.entity.EntityType;
@ -59,7 +59,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
@Inject(method = "updatePose", at = @At("HEAD"), cancellable = true)
private void onUpdatePose(CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
EntityPose pose;
if (isFallFlying())
@ -83,9 +83,9 @@ public abstract class MixinPlayerEntity extends LivingEntity {
@Inject(method = "getDimensions", at = @At("HEAD"), cancellable = true)
private void onGetDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> ci) {
if (pose == EntityPose.CROUCHING) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
ci.setReturnValue(PlayerEntity.STANDING_DIMENSIONS);
} else if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2) || ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2) || ProtocolHack.getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
ci.setReturnValue(viafabricplus_sneaking_dimensions_v1_13_2);
}
}
@ -93,7 +93,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
@ModifyConstant(method = "getActiveEyeHeight", constant = @Constant(floatValue = 1.27f))
private float modifySneakEyeHeight(float prevEyeHeight) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_19_1)) {
return prevEyeHeight;
} else {
return 1.54f;
@ -102,7 +102,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
@Inject(method = "getAttackCooldownProgress", at = @At("HEAD"), cancellable = true)
private void injectGetAttackCooldownProgress(CallbackInfoReturnable<Float> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
ci.setReturnValue(1f);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.passive.SquidEntity;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
@ -31,7 +31,7 @@ public class MixinSquidEntity {
@Inject(method = "canBeLeashedBy", at = @At("HEAD"), cancellable = true)
public void injectCanBeLeashedBy(PlayerEntity player, CallbackInfoReturnable<Boolean> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
cir.setReturnValue(false);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.mob.VexEntity;
@ -37,7 +37,7 @@ public class MixinVexEntity extends HostileEntity {
@Inject(method = "getHeightOffset", at = @At("HEAD"), cancellable = true)
public void changeHeightOffset(CallbackInfoReturnable<Double> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
cir.setReturnValue(0.0);
}
}

View File

@ -20,7 +20,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.definition.v1_14_4.Meta18Storage;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.passive.WolfEntity;
import org.spongepowered.asm.mixin.Mixin;
@ -34,7 +34,7 @@ public class MixinWolfEntity {
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;getHealth()F"))
public float rewriteHealth(WolfEntity instance) {
float health = instance.getHealth();
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
return MinecraftClient.getInstance().getNetworkHandler().getConnection().channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get().get(Meta18Storage.class).getHealthDataMap().getOrDefault(instance.getId(), health);
}
return health;

View File

@ -20,7 +20,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.definition.v1_12_2.SyncInputExecutor;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.Keyboard;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
@ -43,7 +43,7 @@ public class MixinKeyboard {
@Redirect(method = "processF3", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendCommand(Ljava/lang/String;)Z", ordinal = 0))
public boolean replaceSpectatorCommand(ClientPlayNetworkHandler instance, String command) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
return false;
}
return instance.sendCommand(command);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.input.Input;
import net.minecraft.client.input.KeyboardInput;
@ -31,9 +31,9 @@ public class MixinKeyboardInput extends Input {
@ModifyVariable(method = "tick", at = @At(value = "LOAD", ordinal = 0), argsOnly = true)
private boolean injectTick(boolean slowDown) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
return this.sneaking;
} else if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
return !MinecraftClient.getInstance().player.isSpectator() && (this.sneaking || slowDown);
}
return slowDown;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.ActionResult;
@ -32,7 +32,7 @@ public class MixinAxeItem {
@Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true)
public void injectUseOnBlock(ItemUsageContext context, CallbackInfoReturnable<ActionResult> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(ActionResult.PASS);
}
}

View File

@ -24,7 +24,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -45,7 +45,7 @@ public class MixinBlockItem {
@Inject(method = "canPlace", at = @At("HEAD"), cancellable = true)
private void injectCanPlace(ItemPlacementContext context, BlockState state, CallbackInfoReturnable<Boolean> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
Block block = state.getBlock();
if (block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) {
World world = context.getWorld();

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnderPearlItem;
import net.minecraft.item.ItemStack;
@ -35,7 +35,7 @@ public class MixinEnderPearlItem {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
private void injectUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && user.getAbilities().creativeMode) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && user.getAbilities().creativeMode) {
ci.setReturnValue(TypedActionResult.pass(user.getStackInHand(hand)));
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FireworkRocketItem;
import org.spongepowered.asm.mixin.Mixin;
@ -30,7 +30,7 @@ public class MixinFireworkRocketItem {
@Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isFallFlying()Z", ordinal = 0))
private boolean disableFireworkElytraBoost(PlayerEntity player) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11)) {
return false;
}

View File

@ -24,7 +24,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
@ -53,7 +53,7 @@ public class MixinHeldItemRenderer {
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"))
private void onRenderFirstPersonItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
//noinspection DataFlowIssue
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && client.player.isBlocking()) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && client.player.isBlocking()) {
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-102.25f));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(13.365f));
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(78.05f));

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.google.common.collect.ImmutableSet;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -60,7 +60,7 @@ public abstract class MixinHoeItem extends MiningToolItem {
@Override
public boolean isSuitableFor(BlockState state) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
return false;
}
@ -69,10 +69,10 @@ public abstract class MixinHoeItem extends MiningToolItem {
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
return 1.0F;
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
return viafabricplus_EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
}
return super.getMiningSpeedMultiplier(stack, state);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemGroups;
@ -48,8 +48,8 @@ public abstract class MixinItemGroups {
@Inject(method = "updateDisplayContext", at = @At("HEAD"), cancellable = true)
private static void trackLastVersion(FeatureSet enabledFeatures, boolean operatorEnabled, RegistryWrapper.WrapperLookup lookup, CallbackInfoReturnable<Boolean> cir) {
if (viafabricplus_version != ViaLoadingBase.getClassWrapper().getTargetVersion() || viafabricplus_state != GeneralSettings.INSTANCE.removeNotAvailableItemsFromCreativeTab.getValue()) {
viafabricplus_version = ViaLoadingBase.getClassWrapper().getTargetVersion();
if (viafabricplus_version != ProtocolHack.getTargetVersion() || viafabricplus_state != GeneralSettings.INSTANCE.removeNotAvailableItemsFromCreativeTab.getValue()) {
viafabricplus_version = ProtocolHack.getTargetVersion();
viafabricplus_state = GeneralSettings.INSTANCE.removeNotAvailableItemsFromCreativeTab.getValue();
displayContext = new ItemGroup.DisplayContext(enabledFeatures, operatorEnabled, lookup);

View File

@ -24,7 +24,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.util.math.BlockPos;
@ -42,9 +42,9 @@ public class MixinItemPlacementContext {
final ItemPlacementContext self = (ItemPlacementContext) (Object) this;
final PlayerEntity player = self.getPlayer();
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && player != null) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && player != null) {
final BlockPos placementPos = self.getBlockPos();
final double blockPosCenterFactor = ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_10) ? 0.5 : 0;
final double blockPosCenterFactor = ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_10) ? 0.5 : 0;
if (Math.abs(player.getX() - (placementPos.getX() + blockPosCenterFactor)) < 2 && Math.abs(player.getZ() - (placementPos.getZ() + blockPosCenterFactor)) < 2) {
final double eyeY = player.getY() + player.getEyeHeight(player.getPose());

View File

@ -21,7 +21,7 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BlockState;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
@ -46,7 +46,7 @@ public abstract class MixinItemStack {
private void modifyMiningSpeedMultiplier(BlockState state, CallbackInfoReturnable<Float> ci) {
final Item toolItem = ((ItemStack) (Object) this).getItem();
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && toolItem instanceof HoeItem) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && toolItem instanceof HoeItem) {
ci.setReturnValue(1F);
}
}
@ -55,7 +55,7 @@ public abstract class MixinItemStack {
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/attribute/EntityAttributes;GENERIC_ATTACK_DAMAGE:Lnet/minecraft/entity/attribute/EntityAttribute;", ordinal = 0)),
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getAttributeBaseValue(Lnet/minecraft/entity/attribute/EntityAttribute;)D", ordinal = 0))
private double redirectGetTooltip(PlayerEntity player, EntityAttribute attribute) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return 0;
} else {
return player.getAttributeBaseValue(attribute);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BlockState;
import net.minecraft.item.HoeItem;
import net.minecraft.item.ItemStack;
@ -34,7 +34,7 @@ public class MixinMiningToolItem {
@Inject(method = "getMiningSpeedMultiplier", at = @At("RETURN"), cancellable = true)
public void changeHoeEffectiveBlocks(ItemStack stack, BlockState state, CallbackInfoReturnable<Float> cir) {
//noinspection ConstantValue
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && (Object) this instanceof HoeItem) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && (Object) this instanceof HoeItem) {
cir.setReturnValue(1.0F);
}
}

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.google.common.collect.ImmutableSet;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -52,7 +52,7 @@ public abstract class MixinPickaxeItem extends MiningToolItem {
@Override
public boolean isSuitableFor(BlockState state) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
Block block = state.getBlock();
int i = this.getMaterial().getMiningLevel();
if (block == Blocks.OBSIDIAN) {
@ -70,9 +70,9 @@ public abstract class MixinPickaxeItem extends MiningToolItem {
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
return viafabricplus_EFFECTIVE_MATERIALS.contains(state.getMaterial()) || viafabricplus_EFFECTIVE_BLOCKS_1152.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
} else if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
return viafabricplus_EFFECTIVE_MATERIALS.contains(state.getMaterial()) || viafabricplus_EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
}
return super.getMiningSpeedMultiplier(stack, state);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.item.ShovelItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@ -34,7 +34,7 @@ public class MixinShovelItem {
at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0),
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/item/ShovelItem;PATH_STATES:Ljava/util/Map;")))
private Object redirectUseOnBlock(Map<Object, Object> map, Object grassBlock) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return null;
} else {
return map.get(grassBlock);

View File

@ -24,7 +24,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
@ -45,7 +45,7 @@ public class MixinSwordItem extends ToolItem {
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
ItemStack itemStack = user.getStackInHand(hand);
user.setCurrentHand(hand);
return TypedActionResult.consume(itemStack);
@ -55,7 +55,7 @@ public class MixinSwordItem extends ToolItem {
@Override
public UseAction getUseAction(ItemStack stack) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return UseAction.BLOCK;
}
return super.getUseAction(stack);
@ -63,7 +63,7 @@ public class MixinSwordItem extends ToolItem {
@Override
public int getMaxUseTime(ItemStack stack) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return 72000;
}
return super.getMaxUseTime(stack);

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.packet;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
@ -31,7 +31,7 @@ public class MixinPacketByteBuf {
@Inject(method = "readText", at = @At(value = "INVOKE", target = "Lio/netty/handler/codec/DecoderException;<init>(Ljava/lang/String;)V", shift = At.Shift.BEFORE, remap = false), cancellable = true)
public void injectReadText(CallbackInfoReturnable<Text> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18)) {
cir.setReturnValue(null);
}
}

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.packet;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.injection.access.IPlayerPositionLookS2CPacket;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
@ -36,7 +36,7 @@ public class MixinPlayerPositionLookS2CPacket implements IPlayerPositionLookS2CP
@Inject(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", at = @At("RETURN"))
public void readDismountVehicle(PacketByteBuf buf, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
viafabricplus_dismountVehicle = buf.readBoolean();
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.packet;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.network.PacketByteBuf;
@ -44,7 +44,7 @@ public class MixinUpdatePlayerAbilitiesC2SPacket {
byte b = 0;
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (this.flying) b = (byte) (b | 2); // Minecraft
if (abilities.invulnerable) b |= 1;

View File

@ -24,11 +24,14 @@ import de.florianmichael.viafabricplus.definition.bedrock.BedrockAccountHandler;
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
import de.florianmichael.viafabricplus.definition.v1_19_0.storage.ChatSession1_19_0;
import de.florianmichael.viafabricplus.definition.v1_19_2.storage.ChatSession1_19_2;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.encryption.PlayerKeyPair;
import net.minecraft.network.encryption.PlayerPublicKey;
@ -44,6 +47,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.net.InetSocketAddress;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
@ -58,9 +62,13 @@ public class MixinConnectScreen_1 {
@Shadow
ConnectScreen field_2416;
@Final
@Shadow
ServerInfo field_40415;
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getHostName()Ljava/lang/String;", ordinal = 1))
public String replaceAddress(InetSocketAddress instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17) || ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest))
if (ProtocolHack.isOrOlderSelectedOrForced(instance, ProtocolVersion.v1_17) || ProtocolHack.isSelectedOrForced(instance, BedrockProtocolVersion.bedrockLatest))
return field_33737.getAddress();
return instance.getHostString();
@ -68,12 +76,22 @@ public class MixinConnectScreen_1 {
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getPort()I"))
public int replacePort(InetSocketAddress instance) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17) || ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest))
if (ProtocolHack.isOrOlderSelectedOrForced(instance, ProtocolVersion.v1_17) || ProtocolHack.isSelectedOrForced(instance, BedrockProtocolVersion.bedrockLatest))
return field_33737.getPort();
return instance.getPort();
}
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/util/Optional;get()Ljava/lang/Object;"))
public Object mapSocketAddress(Optional<InetSocketAddress> instance) {
final InetSocketAddress address = instance.get();
final ComparableProtocolVersion forcedVersion = ((IServerInfo) field_40415).viafabricplus_forcedVersion();
if (forcedVersion != null) {
ProtocolHack.getForcedVersions().put(address, forcedVersion);
}
return address;
}
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V", ordinal = 1, shift = At.Shift.BEFORE))
public void setupConnectionSessions(CallbackInfo ci) {
final ClientConnection connection = field_2416.connection;
@ -84,7 +102,7 @@ public class MixinConnectScreen_1 {
ViaLoadingBase.LOGGER.log(Level.WARNING, "ViaVersion userConnection is null");
return;
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
if (ProtocolHack.getTargetVersion(connection.channel).isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
final StepMCChain.MCChain account = BedrockAccountHandler.INSTANCE.getAccount();
if (account != null) {
@ -93,10 +111,10 @@ public class MixinConnectScreen_1 {
return;
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_19)) {
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_19)) {
return; // This disables the chat session emulation for all versions <= 1.18.2
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
try {
final PlayerKeyPair playerKeyPair = MinecraftClient.getInstance().getProfileKeys().fetchKeyPair().get().orElse(null);
if (playerKeyPair != null) {
@ -105,7 +123,7 @@ public class MixinConnectScreen_1 {
userConnection.put(new ChatSession1_19_2(userConnection, profileKey, playerKeyPair.privateKey()));
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isEqualTo(ProtocolVersion.v1_19)) {
if (ProtocolHack.getTargetVersion().isEqualTo(ProtocolVersion.v1_19)) {
final byte[] legacyKey = ((IPublicKeyData) (Object) publicKeyData).viafabricplus_getV1Key().array();
if (legacyKey != null) {
userConnection.put(new ChatSession1_19_0(userConnection, profileKey, playerKeyPair.privateKey(), legacyKey));

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
import net.minecraft.client.gui.screen.Screen;
@ -48,14 +48,14 @@ public class MixinDownloadingTerrainScreen extends Screen {
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
public void injectTick(CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
viafabricplus_tickCounter++;
if (viafabricplus_tickCounter % 20 == 0) {
MinecraftClient.getInstance().getNetworkHandler().sendPacket(new KeepAliveC2SPacket(0));
}
}
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
final boolean isTimeOver = this.closeOnNextTick || System.currentTimeMillis() > this.loadStartTime + 2000L;
if (isTimeOver && this.client != null && this.client.player != null) {

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.spongepowered.asm.mixin.*;
@ -41,10 +41,10 @@ public class MixinGameModeSelectionScreen {
@Inject(method = "<init>", at = @At("RETURN"))
public void fixUIWidth(CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
final List<GameModeSelectionScreen.GameModeSelection> gameModeSelections = Arrays.stream(GameModeSelectionScreen.GameModeSelection.values()).toList();
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(LegacyProtocolVersion.r1_3_1tor1_3_2)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR);
if (ProtocolHack.getTargetVersion().isOlderThan(LegacyProtocolVersion.r1_3_1tor1_3_2)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR);
viafabricplus_unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new);
UI_WIDTH = viafabricplus_unwrappedGameModes.length * 31 - 5;
@ -53,7 +53,7 @@ public class MixinGameModeSelectionScreen {
@Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;"))
public GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
return viafabricplus_unwrappedGameModes;
}
return GameModeSelectionScreen.GameModeSelection.values();

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
@ -41,7 +41,7 @@ public class MixinGameModeSelectionScreen_GameModeSelection {
@Inject(method = "getCommand", at = @At("HEAD"), cancellable = true)
private void oldCommand(CallbackInfoReturnable<String> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) {
cir.setReturnValue(
"gamemode " + MinecraftClient.getInstance().getSession().getUsername() + ' ' + switch (((Enum<?>)(Object)this).ordinal()) {
case 0, 3 -> 1;
@ -54,11 +54,11 @@ public class MixinGameModeSelectionScreen_GameModeSelection {
@Inject(method = "next", at = @At("HEAD"), cancellable = true)
public void unwrapGameModes(CallbackInfoReturnable<Optional<GameModeSelectionScreen.GameModeSelection>> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
switch ((GameModeSelectionScreen.GameModeSelection)(Object)this) {
case CREATIVE -> cir.setReturnValue(Optional.of(SURVIVAL));
case SURVIVAL -> {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(LegacyProtocolVersion.r1_2_4tor1_2_5)) {
if (ProtocolHack.getTargetVersion().isOlderThan(LegacyProtocolVersion.r1_2_4tor1_2_5)) {
cir.setReturnValue(Optional.of(CREATIVE));
} else {
cir.setReturnValue(Optional.of(GameModeSelectionScreen.GameModeSelection.ADVENTURE));

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.Text;
@ -36,6 +36,6 @@ public class MixinStructureBlockScreen_1 extends TextFieldWidget {
@Inject(method = "charTyped(CI)Z", at = @At("HEAD"), cancellable = true)
private void onCharTyped(char chr, int keyCode, CallbackInfoReturnable<Boolean> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) ci.setReturnValue(super.charTyped(chr, keyCode));
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) ci.setReturnValue(super.charTyped(chr, keyCode));
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.merchant;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.screen.MerchantScreenHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@ -30,7 +30,7 @@ public class MixinMerchantScreenHandler {
@Inject(method = "switchTo", at = @At("HEAD"), cancellable = true)
private void injectSwitchTo(int recipeId, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
ci.cancel(); // no lmao?
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.screenhandler;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.inventory.Inventory;
import net.minecraft.screen.slot.Slot;
import org.spongepowered.asm.mixin.Mixin;
@ -35,12 +35,12 @@ public class MixinBrewingStandScreenHandler_FuelSlot extends Slot {
@Inject(method = "matches(Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD"), cancellable = true)
private static void removeFuelSlot(CallbackInfoReturnable<Boolean> ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8))
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8))
ci.setReturnValue(false);
}
@Override
public boolean isEnabled() {
return ViaLoadingBase.getClassWrapper().getTargetVersion().isNewerThan(ProtocolVersion.v1_8);
return ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_8);
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.screenhandler;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.screen.AbstractRecipeScreenHandler;
@ -42,7 +42,7 @@ public abstract class MixinPlayerScreenHandler extends AbstractRecipeScreenHandl
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler$2;<init>(Lnet/minecraft/screen/PlayerScreenHandler;Lnet/minecraft/inventory/Inventory;IIILnet/minecraft/entity/player/PlayerEntity;)V")),
at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler;addSlot(Lnet/minecraft/screen/slot/Slot;)Lnet/minecraft/screen/slot/Slot;", ordinal = 0))
private Slot redirectAddOffhandSlot(PlayerScreenHandler screenHandler, Slot slot) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8))
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8))
return null;
return addSlot(slot);
}
@ -50,7 +50,7 @@ public abstract class MixinPlayerScreenHandler extends AbstractRecipeScreenHandl
@SuppressWarnings("InvalidInjectorMethodSignature")
@ModifyVariable(method = "quickMove", ordinal = 0, at = @At(value = "STORE", ordinal = 0))
private EquipmentSlot injectTransferSlot(EquipmentSlot slot) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && slot == EquipmentSlot.OFFHAND)
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && slot == EquipmentSlot.OFFHAND)
return EquipmentSlot.MAINHAND;
else
return slot;

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.s
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.injection.access.IScreenHandler;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.SlotActionType;
@ -37,7 +37,7 @@ public class MixinScreenHandler implements IScreenHandler {
@Inject(method = "internalOnSlotClick", at = @At("HEAD"), cancellable = true)
private void injectInternalOnSlotClick(int slot, int clickData, SlotActionType actionType, PlayerEntity player, CallbackInfo ci) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && actionType == SlotActionType.SWAP && clickData == 40) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && actionType == SlotActionType.SWAP && clickData == 40) {
ci.cancel();
}
}

View File

@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.minecraft.BlockFace;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.AbstractFenceConnectionHandler;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@ -41,7 +41,7 @@ public abstract class MixinAbstractFenceConnectionHandler {
@Overwrite
public byte getStates(UserConnection user, Position position, int blockState) {
byte states = 0;
boolean pre1_12 = ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(ProtocolVersion.v1_12);
boolean pre1_12 = ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_12);
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1;
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)), pre1_12)) states |= 2;
if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)), pre1_12)) states |= 4;

View File

@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.AbstractFenceConnectionHandler;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.GlassConnectionHandler;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -44,6 +44,6 @@ public abstract class MixinGlassConnectionHandler extends AbstractFenceConnectio
if (states != 0) return states;
ProtocolInfo protocolInfo = user.getProtocolInfo();
return ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && protocolInfo.getServerProtocolVersion() != -1 ? 0xF : states;
return ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && protocolInfo.getServerProtocolVersion() != -1 ? 0xF : states;
}
}

View File

@ -19,6 +19,7 @@ package de.florianmichael.viafabricplus.protocolhack;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
import de.florianmichael.viafabricplus.ViaFabricPlus;
@ -33,8 +34,11 @@ import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabri
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.*;
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusHandItemProvider;
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusMovementTransmitterProvider;
import de.florianmichael.viafabricplus.protocolhack.replacement.ViaFabricPlusVLBBaseVersionProvider;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
import de.florianmichael.vialoadingbase.platform.SubPlatform;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;
import net.minecraft.SharedConstants;
import net.minecraft.client.MinecraftClient;
@ -50,13 +54,47 @@ import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.provider
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.net.InetSocketAddress;
import java.util.*;
public class ProtocolHack {
public final static AttributeKey<UserConnection> LOCAL_VIA_CONNECTION = AttributeKey.newInstance("viafabricplus-via-connection");
public final static AttributeKey<ClientConnection> LOCAL_MINECRAFT_CONNECTION = AttributeKey.newInstance("viafabricplus-minecraft-connection");
public final static AttributeKey<ComparableProtocolVersion> FORCED_VERSION = AttributeKey.newInstance("viafabricplus-forced-version");
private final static Map<InetSocketAddress, ComparableProtocolVersion> forcedVersions = new HashMap<>();
private final static List<InetSocketAddress> rakNetPingSessions = new ArrayList<>();
public static ComparableProtocolVersion getTargetVersion() {
if (MinecraftClient.getInstance() == null || MinecraftClient.getInstance().getNetworkHandler() == null) return getTargetVersion(null);
return getTargetVersion(MinecraftClient.getInstance().getNetworkHandler().getConnection().channel);
}
public static ComparableProtocolVersion getTargetVersion(final Channel channel) {
if (channel != null && channel.hasAttr(FORCED_VERSION)) return channel.attr(FORCED_VERSION).get();
return ViaLoadingBase.getClassWrapper().getTargetVersion();
}
public static Map<InetSocketAddress, ComparableProtocolVersion> getForcedVersions() {
return forcedVersions;
}
public static List<InetSocketAddress> getRakNetPingSessions() {
return rakNetPingSessions;
}
public static boolean isSelectedOrForced(final InetSocketAddress socketAddress, final ProtocolVersion version) {
if (forcedVersions.containsKey(socketAddress)) return forcedVersions.get(socketAddress).isEqualTo(version);
return ProtocolHack.getTargetVersion().isEqualTo(version);
}
public static boolean isOrOlderSelectedOrForced(final InetSocketAddress socketAddress, final ProtocolVersion version) {
if (forcedVersions.containsKey(socketAddress)) return forcedVersions.get(socketAddress).isOlderThanOrEqualTo(version);
return ProtocolHack.getTargetVersion().isEqualTo(version);
}
public ProtocolHack() {
ViaLoadingBase.ViaLoadingBaseBuilder builder = ViaLoadingBase.ViaLoadingBaseBuilder.create();
@ -97,6 +135,8 @@ public class ProtocolHack {
providers.use(ClassicMPPassProvider.class, new ViaFabricPlusClassicMPPassProvider());
providers.use(ClassicCustomCommandProvider.class, new ViaFabricPlusClassicCustomCommandProvider());
providers.use(NettyPipelineProvider.class, new ViaFabricPlusNettyPipelineProvider());
providers.use(VersionProvider.class, new ViaFabricPlusVLBBaseVersionProvider());
});
builder = builder.onProtocolReload(protocolVersion -> ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(protocolVersion));
builder.build();

View File

@ -0,0 +1,33 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD 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.protocolhack.replacement;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.provider.VLBBaseVersionProvider;
public class ViaFabricPlusVLBBaseVersionProvider extends VLBBaseVersionProvider {
@Override
public int getClosestServerProtocol(UserConnection connection) throws Exception {
if (connection.isClientSide()) {
return ProtocolHack.getTargetVersion(connection.getChannel()).getVersion();
}
return super.getClosestServerProtocol(connection);
}
}

View File

@ -28,9 +28,9 @@ import io.netty.channel.ChannelHandlerContext;
import java.util.List;
import java.util.logging.Level;
public class VFPVLBViaDecodeHandler extends VLBViaDecodeHandler {
public class ViaFabricPlusVLBViaDecodeHandler extends VLBViaDecodeHandler {
public VFPVLBViaDecodeHandler(UserConnection info) {
public ViaFabricPlusVLBViaDecodeHandler(UserConnection info) {
super(info);
}

View File

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocol.packet.PacketWrapperImpl;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import io.netty.buffer.Unpooled;
import net.minecraft.item.ItemStack;

View File

@ -0,0 +1,138 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD 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.screen;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.awt.*;
import java.util.List;
import java.util.function.Consumer;
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
public class ForceVersionScreen extends Screen {
private final Screen prevScreen;
private final Consumer<ComparableProtocolVersion> selectionConsumer;
public ForceVersionScreen(final Screen prevScreen, final Consumer<ComparableProtocolVersion> selectionConsumer) {
super(Text.literal("Force version"));
this.prevScreen = prevScreen;
this.selectionConsumer = selectionConsumer;
}
@Override
protected void init() {
super.init();
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, height + 5, textRenderer.fontHeight + 4));
}
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
matrices.push();
matrices.scale(2F, 2F, 2F);
drawCenteredTextWithShadow(matrices, textRenderer, "ViaFabricPlus", width / 4, 3, Color.ORANGE.getRGB());
matrices.pop();
drawCenteredTextWithShadow(matrices, textRenderer, Text.translatable("forceversion.viafabricplus.title"), width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
}
@Override
public void close() {
client.setScreen(prevScreen);
}
public class SlotList extends AlwaysSelectedEntryListWidget<DummyProtocolSlot> {
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
super(minecraftClient, width, height, top, bottom, entryHeight);
this.addEntry(new ResetProtocolSlot());
InternalProtocolList.getProtocols().stream().map(ViaProtocolSlot::new).forEach(this::addEntry);
}
}
public abstract static class DummyProtocolSlot extends AlwaysSelectedEntryListWidget.Entry<DummyProtocolSlot> {
}
public class ResetProtocolSlot extends DummyProtocolSlot {
@Override
public Text getNarration() {
return Text.translatable("words.viafabricplus.cancelreset");
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
ForceVersionScreen.this.selectionConsumer.accept(null);
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
ForceVersionScreen.this.close();
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
drawCenteredTextWithShadow(matrices, textRenderer, ((MutableText) getNarration()).formatted(Formatting.GOLD), x + entryWidth / 2, y + entryHeight / 2 - textRenderer.fontHeight / 2, -1);
}
}
public class ViaProtocolSlot extends DummyProtocolSlot {
private final ProtocolVersion protocolVersion;
public ViaProtocolSlot(final ProtocolVersion protocolVersion) {
this.protocolVersion = protocolVersion;
}
@Override
public Text getNarration() {
return Text.literal(this.protocolVersion.getName());
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
ForceVersionScreen.this.selectionConsumer.accept(InternalProtocolList.fromProtocolVersion(protocolVersion));
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
ForceVersionScreen.this.close();
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
drawCenteredTextWithShadow(matrices, textRenderer, this.protocolVersion.getName(), x + entryWidth / 2, y - 1 + entryHeight / 2 - textRenderer.fontHeight / 2, -1);
}
}
}

View File

@ -20,6 +20,7 @@ package de.florianmichael.viafabricplus.screen;
import com.mojang.blaze3d.systems.RenderSystem;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;
import net.minecraft.client.MinecraftClient;
@ -106,7 +107,7 @@ public class ProtocolSelectionScreen extends Screen {
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final boolean isSelected = ViaLoadingBase.getClassWrapper().getTargetVersion().getVersion() == protocolVersion.getVersion();
final boolean isSelected = ProtocolHack.getTargetVersion().getVersion() == protocolVersion.getVersion();
matrices.push();
matrices.translate(x, y - 1, 0);

View File

@ -23,6 +23,7 @@ import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.groups.*;
import de.florianmichael.viafabricplus.util.FileSaver;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.platform.InternalProtocolList;

View File

@ -22,7 +22,7 @@ import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ProtocolSyncBooleanSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.platform.ProtocolRange;
import net.minecraft.text.MutableText;
@ -54,7 +54,7 @@ public class ProtocolSyncBooleanSetting extends BooleanSetting {
@Override
public Boolean getValue() {
if (GeneralSettings.INSTANCE.automaticallyChangeValuesBasedOnTheCurrentVersion.getValue()) return this.getProtocolRange().contains(ViaLoadingBase.getClassWrapper().getTargetVersion());
if (GeneralSettings.INSTANCE.automaticallyChangeValuesBasedOnTheCurrentVersion.getValue()) return this.getProtocolRange().contains(ProtocolHack.getTargetVersion());
return super.getValue();
}

View File

@ -7,6 +7,7 @@
"words.viafabricplus.lb": "Left; Bottom",
"words.viafabricplus.rb": "Right; Bottom",
"words.viafabricplus.cancel": "Cancel",
"words.viafabricplus.cancelreset": "Cancel and reset",
"bedrock.viafabricplus.set": "Click to set account for Bedrock edition",
@ -47,5 +48,7 @@
"visual.viafabricplus.walkanimation": "Old walking animation",
"bedrocklogin.viafabricplus.text": "Your browser should have opened.\nPlease enter the following Code: %s\nClosing this screen will cancel the process!",
"bedrocklogin.viafabricplus.error": "An error has occurred! See the latest.log for more information,\nplease report the bug at: \nhttps://github.com/FlorianMichael/ViaFabricPlus/issues"
"bedrocklogin.viafabricplus.error": "An error has occurred! See the latest.log for more information,\nplease report the bug at: \nhttps://github.com/FlorianMichael/ViaFabricPlus/issues",
"forceversion.viafabricplus.title": "Please select the version with which the server should be pinged/connected"
}

Some files were not shown because too many files have changed in this diff Show More