Migrated to ViaLoader / ViaVersion organisation

This commit is contained in:
FlorianMichael 2023-05-28 19:49:13 +02:00
parent 69de7b79c5
commit 9fe71ee548
132 changed files with 1969 additions and 2263 deletions

View File

@ -53,8 +53,8 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
library "com.github.FlorianMichael:ViaLoadingBase:${project.vialoadingbase_version}"
library "com.github.FlorianMichael:Classic4J:${project.classic4j_version}"
library "net.raphimc:ViaLoader:${project.vialoader_version}"
library "com.viaversion:viaversion:${project.viaversion_version}"
library ("com.viaversion:viabackwards-common:${project.viabackwards_version}") {

View File

@ -14,7 +14,6 @@ maven_group=de.florianmichael
archives_base_name=viafabricplus
# base lib
vialoadingbase_version=1f4e409d86
raknet_transport_version=1.0.0.CR1-SNAPSHOT
classic4j_version=1.2.0
@ -24,10 +23,11 @@ viabackwards_version=4.7.0-1.20-pre5-SNAPSHOT
snake_yml_version=2.0
# raphimc libs
vialegacy_version=2.2.16
vialegacy_version=2.2.17-SNAPSHOT
viaaprilfools_version=2.0.7-SNAPSHOT
viabedrock_version=0.0.1-SNAPSHOT
minecraftauth_version=2.1.4-SNAPSHOT
vialoader_version=2.2.5-SNAPSHOT
# lenni0451 libs
mcstructs_text_version=2.2.5

View File

@ -17,9 +17,9 @@
*/
package de.florianmichael.viafabricplus.base.event;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.raphimc.vialoader.util.VersionEnum;
public interface ChangeProtocolVersionCallback {
@ -29,5 +29,5 @@ public interface ChangeProtocolVersionCallback {
}
});
void onChangeProtocolVersion(final ComparableProtocolVersion protocolVersion);
void onChangeProtocolVersion(final VersionEnum protocolVersion);
}

View File

@ -20,13 +20,13 @@ package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
public interface FinishViaLoadingBaseStartupCallback {
public interface FinishViaVersionStartupCallback {
Event<FinishViaLoadingBaseStartupCallback> EVENT = EventFactory.createArrayBacked(FinishViaLoadingBaseStartupCallback.class, listeners -> () -> {
for (FinishViaLoadingBaseStartupCallback listener : listeners) {
listener.onFinishViaLoadingBaseStartup();
Event<FinishViaVersionStartupCallback> EVENT = EventFactory.createArrayBacked(FinishViaVersionStartupCallback.class, listeners -> () -> {
for (FinishViaVersionStartupCallback listener : listeners) {
listener.onFinishViaVersionStartup();
}
});
void onFinishViaLoadingBaseStartup();
void onFinishViaVersionStartup();
}

View File

@ -1,33 +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.base.event;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
public interface ViaLoadingBaseBuilderCallback {
Event<ViaLoadingBaseBuilderCallback> EVENT = EventFactory.createArrayBacked(ViaLoadingBaseBuilderCallback.class, listeners -> builder -> {
for (ViaLoadingBaseBuilderCallback listener : listeners) {
listener.onBuildViaLoadingBase(builder);
}
});
void onBuildViaLoadingBase(final ViaLoadingBase.ViaLoadingBaseBuilder builder);
}

View File

@ -23,8 +23,8 @@ import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.groups.*;
import de.florianmichael.viafabricplus.base.FileSaver;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.raphimc.vialoader.util.VersionEnum;
import java.util.ArrayList;
import java.util.Collections;
@ -54,7 +54,7 @@ public class SettingsSystem extends FileSaver {
@Override
public void write(JsonObject object) {
object.addProperty("protocol", ViaLoadingBase.getInstance().getTargetVersion().getVersion());
object.addProperty("protocol", ProtocolHack.getTargetVersion().getVersion());
for (SettingGroup group : groups) {
for (AbstractSetting<?> setting : group.getSettings()) {
setting.write(object);
@ -65,9 +65,9 @@ public class SettingsSystem extends FileSaver {
@Override
public void read(JsonObject object) {
if (object.has("protocol")) {
final ComparableProtocolVersion protocolVersion = ViaLoadingBase.fromProtocolId(object.get("protocol").getAsInt());
final VersionEnum protocolVersion = VersionEnum.fromProtocolId(object.get("protocol").getAsInt());
if (protocolVersion != null) ViaLoadingBase.getInstance().reload(protocolVersion);
if (protocolVersion != null) ProtocolHack.setTargetVersion(protocolVersion);
}
for (SettingGroup group : groups) {
for (AbstractSetting<?> setting : group.getSettings()) {

View File

@ -17,40 +17,43 @@
*/
package de.florianmichael.viafabricplus.base.settings.groups;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.minecraft.text.Text;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialoader.util.VersionRange;
public class DebugSettings extends SettingGroup {
public final static DebugSettings INSTANCE = new DebugSettings();
// 1.19 -> 1.18.2
public final ProtocolSyncBooleanSetting disableSequencing = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.sequence"), ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
public final ProtocolSyncBooleanSetting disableSequencing = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.sequence"), VersionRange.andOlder(VersionEnum.r1_18_2));
// 1.14 -> 1.13.2
public final ProtocolSyncBooleanSetting smoothOutMerchantScreens = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.merchant"), ProtocolRange.andOlder(ProtocolVersion.v1_13_2));
public final ProtocolSyncBooleanSetting smoothOutMerchantScreens = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.merchant"), VersionRange.andOlder(VersionEnum.r1_13_2));
// 1.13 -> 1.12.2
public final ProtocolSyncBooleanSetting executeInputsInSync = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.postfix"), ProtocolRange.andOlder(ProtocolVersion.v1_12_2));
public final ProtocolSyncBooleanSetting sneakInstant = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.sneakinstant"), new ProtocolRange(ProtocolVersion.v1_12_2, ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting executeInputsInSync = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.postfix"), VersionRange.andOlder(VersionEnum.r1_12_2));
public final ProtocolSyncBooleanSetting sneakInstant = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.sneakinstant"), new VersionRange(VersionEnum.r1_12_2, VersionEnum.r1_8));
// 1.12 -> 1.11.1-1.11.2
public final ProtocolSyncBooleanSetting sendOpenInventoryPacket = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.inventory"), ProtocolRange.andOlder(ProtocolVersion.v1_11_1));
public final ProtocolSyncBooleanSetting sendOpenInventoryPacket = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.inventory"), VersionRange.andOlder(VersionEnum.r1_11_1to1_11_2));
// 1.9 -> 1.8.x
public final ProtocolSyncBooleanSetting removeCooldowns = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.cooldown"), ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting sendIdlePacket = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.idle"), new ProtocolRange(ProtocolVersion.v1_8, LegacyProtocolVersion.r1_3_1tor1_3_2));
public final ProtocolSyncBooleanSetting replaceAttributeModifiers = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.attribute"), ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting removeCooldowns = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.cooldown"), VersionRange.andOlder(VersionEnum.r1_8));
public final ProtocolSyncBooleanSetting sendIdlePacket = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.idle"), new VersionRange(VersionEnum.r1_8, VersionEnum.r1_3_1tor1_3_2));
public final ProtocolSyncBooleanSetting replaceAttributeModifiers = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.attribute"), VersionRange.andOlder(VersionEnum.r1_8));
// 1.8.x -> 1.7.6
public final ProtocolSyncBooleanSetting replaceSneaking = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.replacesneak"), ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
public final ProtocolSyncBooleanSetting longSneaking = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.longsneak"), ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
public final ProtocolSyncBooleanSetting replaceSneaking = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.replacesneak"), VersionRange.andOlder(VersionEnum.r1_7_6tor1_7_10));
public final ProtocolSyncBooleanSetting longSneaking = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.longsneak"), VersionRange.andOlder(VersionEnum.r1_7_6tor1_7_10));
// r1_5tor1_5_1 -> r1_4_6tor1_4_7
public final ProtocolSyncBooleanSetting legacyMiningSpeeds = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.legacypseeds"), ProtocolRange.andOlder(LegacyProtocolVersion.r1_4_6tor1_4_7));
public final ProtocolSyncBooleanSetting legacyMiningSpeeds = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.legacypseeds"), VersionRange.andOlder(VersionEnum.r1_4_6tor1_4_7));
public DebugSettings() {
super("Debug");

View File

@ -17,42 +17,44 @@
*/
package de.florianmichael.viafabricplus.base.settings.groups;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.minecraft.text.Text;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialoader.util.VersionRange;
public class VisualSettings extends SettingGroup {
public final static VisualSettings INSTANCE = new VisualSettings();
// 1.19.2 -> 1.19
public final ProtocolSyncBooleanSetting disableSecureChatWarning = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.secure"), ProtocolRange.andOlder(ProtocolVersion.v1_19));
public final ProtocolSyncBooleanSetting disableSecureChatWarning = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.secure"), VersionRange.andOlder(VersionEnum.r1_19));
// 1.19 -> 1.18.2
public final ProtocolSyncBooleanSetting hideSignatureIndicator = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.indicator"), ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
public final ProtocolSyncBooleanSetting hideSignatureIndicator = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.indicator"), VersionRange.andOlder(VersionEnum.r1_18_2));
// 1.16 -> 1.15.2
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromJigsawScreen = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.jigsaw"), ProtocolRange.andOlder(ProtocolVersion.v1_15_2));
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromJigsawScreen = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.jigsaw"), VersionRange.andOlder(VersionEnum.r1_15_2));
// 1.13 -> 1.12.2
public final ProtocolSyncBooleanSetting replacePetrifiedOakSlab = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.stoneslab"), new ProtocolRange(ProtocolVersion.v1_12_2, LegacyProtocolVersion.r1_3_1tor1_3_2));
public final ProtocolSyncBooleanSetting replacePetrifiedOakSlab = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.stoneslab"), new VersionRange(VersionEnum.r1_12_2, VersionEnum.r1_3_1tor1_3_2));
// 1.9 -> 1.8.x
public final ProtocolSyncBooleanSetting emulateArmorHud = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.armor"), ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromCommandBlockScreen = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.command"), ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting emulateArmorHud = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.armor"), VersionRange.andOlder(VersionEnum.r1_8));
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromCommandBlockScreen = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.command"), VersionRange.andOlder(VersionEnum.r1_8));
// r1_0_0tor1_0_1 -> b1_8tob1_8_1
public final ProtocolSyncBooleanSetting replaceHurtSoundWithOOFSound = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.oof"), ProtocolRange.andOlder(LegacyProtocolVersion.b1_8tob1_8_1));
public final ProtocolSyncBooleanSetting replaceHurtSoundWithOOFSound = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.oof"), VersionRange.andOlder(VersionEnum.b1_8tob1_8_1));
// b1_8tob1_8_1 -> b1_7tob1_7_3
public final ProtocolSyncBooleanSetting removeNewerHudElements = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.betahud"), ProtocolRange.andOlder(LegacyProtocolVersion.b1_7tob1_7_3));
public final ProtocolSyncBooleanSetting removeNewerHudElements = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.betahud"), VersionRange.andOlder(VersionEnum.b1_7tob1_7_3));
// a1_0_15 -> c0_28toc0_30
public final ProtocolSyncBooleanSetting replaceCreativeInventory = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.classic"), ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
public final ProtocolSyncBooleanSetting oldWalkingAnimation = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.walkanimation"), ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
public final ProtocolSyncBooleanSetting fixSodiumChunkRendering = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.sodium"), ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
public final ProtocolSyncBooleanSetting replaceCreativeInventory = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.classic"), VersionRange.andOlder(VersionEnum.c0_28toc0_30));
public final ProtocolSyncBooleanSetting oldWalkingAnimation = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.walkanimation"), VersionRange.andOlder(VersionEnum.c0_28toc0_30));
public final ProtocolSyncBooleanSetting fixSodiumChunkRendering = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.sodium"), VersionRange.andOlder(VersionEnum.c0_28toc0_30));
public VisualSettings() {
super("Visual");

View File

@ -23,13 +23,13 @@ import de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer.P
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.minecraft.text.MutableText;
import net.raphimc.vialoader.util.VersionRange;
public class ProtocolSyncBooleanSetting extends BooleanSetting {
private final ProtocolRange protocolRange;
private final VersionRange protocolRange;
public ProtocolSyncBooleanSetting(SettingGroup parent, MutableText name, ProtocolRange protocolRange) {
public ProtocolSyncBooleanSetting(SettingGroup parent, MutableText name, VersionRange protocolRange) {
super(parent, name, true);
this.protocolRange = protocolRange;
@ -59,7 +59,7 @@ public class ProtocolSyncBooleanSetting extends BooleanSetting {
return super.getValue();
}
public ProtocolRange getProtocolRange() {
public VersionRange getProtocolRange() {
return protocolRange;
}
}

View File

@ -17,10 +17,12 @@
*/
package de.florianmichael.viafabricplus.definition;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.LoadClassicProtocolExtensionCallback;
import net.minecraft.client.MinecraftClient;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
@ -34,10 +36,10 @@ public class ChatLengthCalculation {
ChangeProtocolVersionCallback.EVENT.register(protocolVersion -> {
INSTANCE.maxLength = 256;
if (protocolVersion.isOlderThanOrEqualTo(ProtocolVersion.v1_10)) {
if (protocolVersion.isOlderThanOrEqualTo(VersionEnum.r1_10)) {
INSTANCE.maxLength = 100;
if (protocolVersion.isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
if (protocolVersion.isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
INSTANCE.maxLength = 64 - MinecraftClient.getInstance().getSession().getUsername().length() - 2;
}
}

View File

@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.definition.c0_30.command.ClassicViaSubCommand;
import de.florianmichael.viafabricplus.injection.access.IExtensionProtocolMetadataStorage;
import net.minecraft.util.Formatting;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
public class ListExtensionsCommand extends ClassicViaSubCommand {
@ -33,14 +33,14 @@ public class ListExtensionsCommand extends ClassicViaSubCommand {
@Override
public String description() {
return "Shows all classic extensions (only for " + LegacyProtocolVersion.c0_30cpe.getName() + ")";
return "Shows all classic extensions (only for " + VersionEnum.c0_30cpe.getName() + ")";
}
@Override
public boolean execute(ViaCommandSender sender, String[] args) {
final UserConnection connection = getUser();
if (!connection.has(ExtensionProtocolMetadataStorage.class)) {
sendMessage(sender, Formatting.RED + "Only for " + LegacyProtocolVersion.c0_30cpe.getName());
sendMessage(sender, Formatting.RED + "Only for " + VersionEnum.c0_30cpe.getName());
return true;
}
((IExtensionProtocolMetadataStorage) connection.get(ExtensionProtocolMetadataStorage.class)).getServerExtensions().forEach((extension, version) -> {

View File

@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.command.ViaCommandSender;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.definition.c0_30.command.ClassicViaSubCommand;
import net.minecraft.util.Formatting;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.storage.TimeLockStorage;
@ -32,7 +33,7 @@ public class SetTimeCommand extends ClassicViaSubCommand {
@Override
public String description() {
return "Changes the time (Only for <= " + LegacyProtocolVersion.a1_0_16toa1_0_16_2.getName() + ")";
return "Changes the time (Only for <= " + VersionEnum.a1_0_16toa1_0_16_2.getName() + ")";
}
@Override
@ -44,7 +45,7 @@ public class SetTimeCommand extends ClassicViaSubCommand {
public boolean execute(ViaCommandSender sender, String[] args) {
final UserConnection connection = getUser();
if (!connection.has(TimeLockStorage.class)) {
sendMessage(sender, Formatting.RED + "Only for <= " + LegacyProtocolVersion.a1_0_16toa1_0_16_2.getName());
sendMessage(sender, Formatting.RED + "Only for <= " + VersionEnum.a1_0_16toa1_0_16_2.getName());
return true;
}
try {

View File

@ -30,6 +30,7 @@ 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.viafabricplus.protocolhack.ProtocolHack;
import net.raphimc.vialoader.util.VersionEnum;
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;
@ -46,7 +47,7 @@ public class ClassicWorldHeightInjection {
parentHandler.handle(wrapper);
if (wrapper.isCancelled()) return;
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.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"));
}
@ -60,7 +61,7 @@ public class ClassicWorldHeightInjection {
parentHandler.handle(wrapper);
if (wrapper.isCancelled()) return;
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 0));
}
};
@ -71,7 +72,7 @@ public class ClassicWorldHeightInjection {
parentHandler.handle(wrapper);
if (wrapper.isCancelled()) return;
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
wrapper.resetReader();
final Chunk chunk = wrapper.read(new Chunk1_17Type(16));
wrapper.write(new Chunk1_17Type(chunk.getSections().length), chunk);
@ -161,7 +162,7 @@ public class ClassicWorldHeightInjection {
};
return wrapper -> {
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
classicLightHandler.handle(wrapper);
} else {
parentHandler.handle(wrapper);

View File

@ -18,18 +18,18 @@
package de.florianmichael.viafabricplus.definition.v1_12_2;
import com.mojang.blaze3d.systems.RenderSystem;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.injection.access.IFontStorage;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.Glyph;
import net.minecraft.client.font.GlyphRenderer;
import net.minecraft.client.font.RenderableGlyph;
import net.minecraft.client.texture.NativeImage;
import net.raphimc.vialoader.util.VersionEnum;
import java.util.function.Function;
import java.util.function.Supplier;
@ -37,7 +37,7 @@ import java.util.function.Supplier;
public class FontCacheFix {
public final static boolean DASH_LOADER = FabricLoader.getInstance().isModLoaded("dashloader");
private static ComparableProtocolVersion protocolVersion;
private static VersionEnum protocolVersion;
public static void init() {
if (DASH_LOADER) return;
@ -50,9 +50,9 @@ public class FontCacheFix {
}
public static boolean shouldReplaceFontRenderer() {
if (ViaLoadingBase.getInstance() == null || DASH_LOADER || protocolVersion == null) return false;
if (DASH_LOADER || protocolVersion == null) return false;
return ExperimentalSettings.INSTANCE.fixFontCache.getValue() && protocolVersion.isOlderThanOrEqualTo(ProtocolVersion.v1_12_2);
return ExperimentalSettings.INSTANCE.fixFontCache.getValue() && protocolVersion.isOlderThanOrEqualTo(VersionEnum.r1_12_2);
}
public enum BuiltinEmptyGlyph1_12_2 implements Glyph {

View File

@ -17,22 +17,19 @@
*/
package de.florianmichael.viafabricplus.definition.v1_14_4;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.network.AllowedAddressResolver;
import net.minecraft.client.network.ServerAddress;
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialoader.util.VersionRange;
public class LegacyServerAddress {
private final static ProtocolRange SRV_RANGE = new ProtocolRange(ProtocolVersion.v1_16_4, LegacyProtocolVersion.r1_3_1tor1_3_2);
private final static VersionRange SRV_RANGE = new VersionRange(VersionEnum.r1_16_4tor1_16_5, VersionEnum.r1_3_1tor1_3_2);
public static ServerAddress parse(ComparableProtocolVersion version, String address) {
if (version == null) version = ViaLoadingBase.getInstance().getTargetVersion();
public static ServerAddress parse(VersionEnum version, String address) {
if (version == null) version = ProtocolHack.getTargetVersion();
final ServerAddress mc = ServerAddress.parse(address);
if (SRV_RANGE.contains(version) || version.isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
if (SRV_RANGE.contains(version) || version == VersionEnum.bedrockLatest) {
if (!mc.equals(ServerAddress.INVALID)) {
return AllowedAddressResolver.DEFAULT.redirectResolver.lookupRedirect(mc).orElse(mc);
}

View File

@ -17,10 +17,10 @@
*/
package de.florianmichael.viafabricplus.injection.access;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.raphimc.vialoader.util.VersionEnum;
public interface IServerInfo {
ComparableProtocolVersion viafabricplus_forcedVersion();
void viafabricplus_forceVersion(ComparableProtocolVersion version);
VersionEnum viafabricplus_forcedVersion();
void viafabricplus_forceVersion(VersionEnum version);
}

View File

@ -19,12 +19,12 @@ package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.ui.screen.impl.base.ForceVersionScreen;
import de.florianmichael.vialoadingbase.model.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 net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -43,7 +43,7 @@ public class MixinAddServerScreen extends Screen {
@Inject(method = "init", at = @At("RETURN"))
public void injectButton(CallbackInfo ci) {
final ComparableProtocolVersion forcedVersion = ((IServerInfo) server).viafabricplus_forcedVersion();
final VersionEnum 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

@ -21,10 +21,8 @@ import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLBPipeline;
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLLegacyPipeline;
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.RakNetClientConnection;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.netty.event.CompressionReorderEvent;
import io.netty.channel.*;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.encryption.PacketDecryptor;
@ -32,9 +30,10 @@ import net.minecraft.network.encryption.PacketEncryptor;
import net.minecraft.network.packet.Packet;
import net.minecraft.text.Text;
import net.minecraft.util.Lazy;
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
import net.raphimc.viabedrock.netty.*;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialoader.netty.VLLegacyPipeline;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialoader.netty.CompressionReorderEvent;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -70,12 +69,12 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) {
channel.pipeline().fireUserEventTriggered(new CompressionReorderEvent());
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
}
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
private void storeEncryptionCiphers(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion(channel).isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
if (ProtocolHack.getTargetVersion(channel).isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
ci.cancel();
this.viafabricplus_decryptionCipher = decryptionCipher;
this.viafabricplus_setupPreNettyEncryption(encryptionCipher);
@ -86,7 +85,8 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
private static void captureAddress(InetSocketAddress address, boolean useEpoll, CallbackInfoReturnable<ClientConnection> cir, final ClientConnection clientConnection, Class class_, Lazy lazy) {
((IClientConnection) clientConnection).viafabricplus_captureAddress(address);
if (ProtocolHack.getForcedVersions().containsKey(address) ? (ProtocolHack.getForcedVersions().get(address).getVersion() == BedrockProtocolVersion.bedrockLatest.getVersion()) : ProtocolHack.getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
if (ProtocolHack.getForcedVersions().containsKey(address) ? (ProtocolHack.getForcedVersions().get(address).getVersion() == VersionEnum.bedrockLatest.getVersion()) :
ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
RakNetClientConnection.connectRakNet(clientConnection, address, lazy, class_);
cir.setReturnValue(clientConnection);
}
@ -104,20 +104,20 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
@Inject(method = "disconnect", at = @At("RETURN"))
public void resetStorages(Text disconnectReason, CallbackInfo ci) {
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(ViaLoadingBase.getInstance().getTargetVersion());
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(ProtocolHack.getTargetVersion());
DisconnectConnectionCallback.EVENT.invoker().onDisconnect();
}
@Unique
public void viafabricplus_setupPreNettyEncryption(final Cipher encryptionCipher) {
this.encrypted = true;
this.channel.pipeline().addBefore(ViaFabricPlusVLBPipeline.VIA_LEGACY_PRE_NETTY_LENGTH_REMOVER_HANDLER_NAME, "encrypt", new PacketEncryptor(encryptionCipher));
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new PacketEncryptor(encryptionCipher));
}
@Override
public void viafabricplus_setupPreNettyDecryption() {
this.encrypted = true;
this.channel.pipeline().addBefore(ViaFabricPlusVLBPipeline.VIA_LEGACY_PRE_NETTY_LENGTH_PREPENDER_HANDLER_NAME, "decrypt", new PacketDecryptor(this.viafabricplus_decryptionCipher));
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_PREPENDER_NAME, "decrypt", new PacketDecryptor(this.viafabricplus_decryptionCipher));
}
@Override
@ -135,7 +135,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
if (this.viafabricplus_compressionEnabled) throw new IllegalStateException("Compression is already enabled");
this.viafabricplus_compressionEnabled = true;
this.channel.pipeline().addBefore(ViaFabricPlusVLBPipeline.VIA_BEDROCK_BATCH_LENGTH_HANDLER_NAME, ViaFabricPlusVLBPipeline.VIA_BEDROCK_COMPRESSION_HANDLER_NAME, new ZLibCompression());
this.channel.pipeline().addBefore("splitter", ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME, new ZLibCompression());
}
@Override
@ -143,7 +143,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
if (this.viafabricplus_compressionEnabled) throw new IllegalStateException("Compression is already enabled");
this.viafabricplus_compressionEnabled = true;
this.channel.pipeline().addBefore(ViaFabricPlusVLBPipeline.VIA_BEDROCK_BATCH_LENGTH_HANDLER_NAME, ViaFabricPlusVLBPipeline.VIA_BEDROCK_COMPRESSION_HANDLER_NAME, new SnappyCompression());
this.channel.pipeline().addBefore("splitter", ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME, new SnappyCompression());
}
@Override
@ -151,6 +151,6 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
if (this.encrypted) throw new IllegalStateException("Encryption is already enabled");
this.encrypted = true;
this.channel.pipeline().addAfter(ViaFabricPlusVLBPipeline.VIA_BEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, ViaFabricPlusVLBPipeline.VIA_BEDROCK_ENCRYPTION_HANDLER_NAME, new AesEncryption(secretKey));
this.channel.pipeline().addAfter(ViaFabricPlusVLLegacyPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, ViaFabricPlusVLLegacyPipeline.VIABEDROCK_ENCRYPTION_HANDLER_NAME, new AesEncryption(secretKey));
}
}

View File

@ -22,6 +22,7 @@ import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.network.ClientLoginNetworkHandler;
import net.minecraft.network.ClientConnection;
import net.minecraft.text.Text;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
import org.spongepowered.asm.mixin.Final;
@ -39,7 +40,7 @@ public class MixinClientLoginNetworkHandler {
@Inject(method = "joinServerSession", at = @At("HEAD"), cancellable = true)
public void dontVerifySessionIfCracked(String serverId, CallbackInfoReturnable<Text> cir) {
if (ProtocolHack.getTargetVersion(connection.channel).isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
if (ProtocolHack.getTargetVersion(connection.channel).isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
if (!connection.channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get().get(ProtocolMetadataStorage.class).authenticate) {
cir.setReturnValue(null);
}

View File

@ -20,8 +20,8 @@ package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.network.ServerInfo;
import net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -43,7 +43,7 @@ public class MixinConnectScreen_1 {
final InetSocketAddress address = instance.get();
if (field_40415 == null) return address;
final ComparableProtocolVersion forcedVersion = ((IServerInfo) field_40415).viafabricplus_forcedVersion();
final VersionEnum forcedVersion = ((IServerInfo) field_40415).viafabricplus_forcedVersion();
if (forcedVersion != null) {
ProtocolHack.getForcedVersions().put(address, forcedVersion);
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(forcedVersion);

View File

@ -48,7 +48,7 @@ public class MixinDebugHud {
information.add(Formatting.GOLD + "[ViaFabricPlus] " + Formatting.WHITE);
for (AbstractInformationGroup group : ViaFabricPlus.INSTANCE.getInformationSystem().getGroups()) {
if (group.getProtocolRange() != null && !group.getProtocolRange().contains(ProtocolHack.getTargetVersion())) continue;
if (group.getVersionRange() != null && !group.getVersionRange().contains(ProtocolHack.getTargetVersion())) continue;
final List<String> groupInformation = new ArrayList<>();
try {
@ -56,7 +56,7 @@ public class MixinDebugHud {
} catch (Exception ignored) {}
if (groupInformation.isEmpty()) continue;
information.add(group.getProtocolRange() == null ? "General" : group.getProtocolRange().toString());
information.add(group.getVersionRange() == null ? "General" : group.getVersionRange().toString());
information.addAll(groupInformation);
information.add("");
}

View File

@ -20,11 +20,10 @@ package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.RakNetClientConnection;
import de.florianmichael.vialoadingbase.model.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 net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -39,12 +38,12 @@ public class MixinMultiplayerServerListPinger {
@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();
final VersionEnum version = ((IServerInfo) entry).viafabricplus_forcedVersion();
if (version != null) {
ProtocolHack.getForcedVersions().put(inetSocketAddress, version);
}
if (ProtocolHack.getTargetVersion(inetSocketAddress).isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
if (ProtocolHack.getTargetVersion(inetSocketAddress) == VersionEnum.bedrockLatest) {
RakNetClientConnection.getRakNetPingSessions().add(inetSocketAddress);
}
}

View File

@ -18,10 +18,9 @@
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.nbt.NbtCompound;
import net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
@ -37,15 +36,15 @@ public class MixinServerInfo implements IServerInfo {
@Shadow public String name;
@Unique
private ComparableProtocolVersion viafabricplus_forcedVersion = null;
private VersionEnum viafabricplus_forcedVersion = null;
@Override
public ComparableProtocolVersion viafabricplus_forcedVersion() {
public VersionEnum viafabricplus_forcedVersion() {
return viafabricplus_forcedVersion;
}
@Override
public void viafabricplus_forceVersion(ComparableProtocolVersion version) {
public void viafabricplus_forceVersion(VersionEnum version) {
viafabricplus_forcedVersion = version;
}
@ -60,7 +59,7 @@ public class MixinServerInfo implements IServerInfo {
private static void loadForcedVersion(NbtCompound root, CallbackInfoReturnable<ServerInfo> cir, ServerInfo serverInfo) {
if (root.contains("viafabricplus_forcedversion")) {
try {
((IServerInfo) serverInfo).viafabricplus_forceVersion(ViaLoadingBase.fromProtocolId(root.getInt("viafabricplus_forcedversion")));
((IServerInfo) serverInfo).viafabricplus_forceVersion(VersionEnum.fromProtocolId(root.getInt("viafabricplus_forcedversion")));
} catch (Exception ignored) {
// Version doesn't exist anymore
}

View File

@ -19,6 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.mojang.authlib.GameProfile;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
@ -74,14 +75,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
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 (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_17)) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_17)) {
return;
}
@ -98,14 +99,14 @@ public abstract class MixinClientPlayNetworkHandler {
@Inject(method = "onChunkLoadDistance", at = @At("RETURN"))
public void emulateSimulationDistance(ChunkLoadDistanceS2CPacket packet, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17_1)) {
this.onSimulationDistance(new SimulationDistanceS2CPacket(packet.getDistance()));
}
}
@Inject(method = { "onGameJoin", "onPlayerRespawn" }, at = @At("TAIL"))
private void injectOnOnGameJoinOrRespawn(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
ClientPlayerEntity player = MinecraftClient.getInstance().player;
assert player != null;
onEntityStatus(new EntityStatusS2CPacket(player, (byte) 28));
@ -114,12 +115,12 @@ public abstract class MixinClientPlayNetworkHandler {
@WrapWithCondition(method = "onPlayerSpawnPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/DownloadingTerrainScreen;setReady()V"))
public boolean moveDownloadingTerrainClosing(DownloadingTerrainScreen instance) {
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19);
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19);
}
@Inject(method = "onPlayerPositionLook", at = @At("RETURN"))
public void closeDownloadingTerrain(PlayerPositionLookS2CPacket packet, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2) && MinecraftClient.getInstance().currentScreen instanceof DownloadingTerrainScreen) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18_2) && MinecraftClient.getInstance().currentScreen instanceof DownloadingTerrainScreen) {
MinecraftClient.getInstance().setScreen(null);
}
}
@ -127,7 +128,7 @@ public abstract class MixinClientPlayNetworkHandler {
@SuppressWarnings("InvalidInjectorMethodSignature")
@ModifyConstant(method = "onEntityPassengersSet", constant = @Constant(classValue = BoatEntity.class))
public Class<?> dontChangePlayerYaw(Object entity, Class<?> constant) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18_2)) {
return Integer.class;
}
return constant;
@ -135,12 +136,12 @@ public abstract class MixinClientPlayNetworkHandler {
@WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
public boolean removeWarning(Logger instance, String s, Object o) {
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19_3);
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19_3);
}
@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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
sendPacket(packet);
return;
}
@ -154,7 +155,7 @@ public abstract class MixinClientPlayNetworkHandler {
@Inject(method = "onSetTradeOffers", 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)
public void checkLoginPacket(SetTradeOffersS2CPacket packet, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion(connection.channel).isOlderThanOrEqualTo(ProtocolVersion.v1_13_2) && this.client.player == null) {
if (ProtocolHack.getTargetVersion(connection.channel).isOlderThanOrEqualTo(VersionEnum.r1_13_2) && this.client.player == null) {
ViaFabricPlus.LOGGER.error("Server tried to send Play packet in Login process, dropping \"SetTradeOffers\"");
ci.cancel();
}

View File

@ -21,6 +21,7 @@ import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
@ -76,7 +77,7 @@ public abstract class MixinClientPlayerInteractionManager {
@Inject(method = "attackEntity", at = @At("HEAD"))
private void injectAttackEntity(PlayerEntity player, Entity target, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && player instanceof IClientPlayerEntity) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && player instanceof IClientPlayerEntity) {
player.swingHand(Hand.MAIN_HAND);
((IClientPlayerEntity) player).viafabricplus_cancelSwingOnce();
}
@ -96,7 +97,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 && ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_11_1)) return true;
if (type == SlotActionType.QUICK_MOVE && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_11_1to1_11_2)) return true;
// pickup with slot -999 (outside window) to throw items always uses empty stack for verification
return type == SlotActionType.PICKUP && slot == -999;
@ -104,7 +105,7 @@ public abstract class MixinClientPlayerInteractionManager {
@WrapWithCondition(method = "clickSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V"))
private boolean modifySlotClickPacket(ClientPlayNetworkHandler instance, Packet<?> packet) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4) && packet instanceof ClickSlotC2SPacket clickSlot) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5) && packet instanceof ClickSlotC2SPacket clickSlot) {
ItemStack slotItemBeforeModification;
if (this.viafabricplus_shouldEmpty(clickSlot.getActionType(), clickSlot.getSlot()))
@ -120,7 +121,7 @@ public abstract class MixinClientPlayerInteractionManager {
final byte button = (byte) clickSlot.getButton();
final short lastActionId = ((IScreenHandler) client.player.currentScreenHandler).viafabricplus_getAndIncrementLastActionId();
final int actionType = clickSlot.getActionType().ordinal();
final Item item = ItemTranslator.minecraftToViaVersion(viaConnection, slotItemBeforeModification, ProtocolVersion.v1_16.getVersion());
final Item item = ItemTranslator.minecraftToViaVersion(viaConnection, slotItemBeforeModification, VersionEnum.r1_16.getVersion());
viaConnection.getChannel().eventLoop().submit(() -> {
final PacketWrapper clickSlotPacket = PacketWrapper.create(ServerboundPackets1_16_2.CLICK_WINDOW, viaConnection);
@ -149,7 +150,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 boolean redirectInteractItem(ClientPlayNetworkHandler instance, Packet<?> packet) {
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_17);
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_17);
}
@Inject(method = "interactItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 0, shift = At.Shift.BEFORE))
@ -167,7 +168,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
this.viafabricplus_actionResult = this.interactBlockInternal(player, hand, hitResult);
if (this.viafabricplus_actionResult == ActionResult.FAIL) {
@ -178,7 +179,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
return this.viafabricplus_actionResult;
}
return interactBlockInternal(player, hand, hitResult);

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
@ -53,7 +54,7 @@ public class MixinItemRenderer {
@Redirect(method = "renderGuiItemOverlay(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Ljava/lang/String;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I"))
public int recolor(TextRenderer instance, String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10) && text.startsWith("-")) color = -43213;
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10) && text.startsWith("-")) color = -43213;
return instance.draw(text, x, y, color, shadow, matrix, vertexConsumers, layerType, backgroundColor, light);
}
}

View File

@ -26,6 +26,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPac
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
@ -61,14 +62,14 @@ public abstract class MixinMinecraftClient implements IMinecraftClient {
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))
public boolean removeEquipProgressReset(HeldItemRenderer instance, Hand hand) {
return ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem);
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem);
}
@Redirect(method = "doItemUse",
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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
return false;
}
@ -77,7 +78,7 @@ public abstract class MixinMinecraftClient implements IMinecraftClient {
@Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;attackCooldown:I", ordinal = 1))
public int unwrapOperation(MinecraftClient instance) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return 0;
}
return attackCooldown;
@ -85,7 +86,7 @@ public abstract class MixinMinecraftClient implements IMinecraftClient {
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.BEFORE))
public void updateCooldown(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
if (this.attackCooldown > 0) {
--this.attackCooldown;
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.network.AbstractClientPlayerEntity;
@ -34,7 +35,7 @@ public class MixinPlayerEntityRenderer {
@Inject(method = "getPositionOffset*", at = @At("RETURN"), cancellable = true)
private void injectGetPositionOffset(AbstractClientPlayerEntity player, float delta, CallbackInfoReturnable<Vec3d> ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
if (player.getSleepingDirection() != null) {
ci.setReturnValue(ci.getReturnValue().subtract(player.getSleepingDirection().getOffsetX() * 0.4, 0, player.getSleepingDirection().getOffsetZ() * 0.4));
}
@ -44,6 +45,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 (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_11_1)) && player.isInSneakingPose();
return (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_11_1to1_11_2)) && player.isInSneakingPose();
}
}

View File

@ -20,6 +20,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hashing;
import com.google.common.io.Files;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.mappings.PackFormatsMappings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
@ -54,10 +55,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 (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_14)) {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_14)) {
modifiableMap.remove("X-Minecraft-Version-ID");
}
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_13)) {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_13)) {
modifiableMap.remove("X-Minecraft-Pack-Format");
modifiableMap.remove("User-Agent");
}
@ -73,10 +74,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
//noinspection deprecation
return Hashing.sha1().hashBytes(Files.toByteArray(viafabricplus_trackedFile)).toString();
} else if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_18)) {
} else if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_18tor1_18_1)) {
return DigestUtils.sha1Hex(new FileInputStream(viafabricplus_trackedFile));
}
} catch (IOException ignored) {
@ -86,7 +87,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return instance;
}
return instance.toLowerCase(locale);

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.AbstractBlock;
@ -41,25 +42,25 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
public void changeHardness(BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
final BlockState state = this.asBlockState();
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
if (state.getBlock() instanceof InfestedBlock) {
cir.setReturnValue(0.75F);
}
}
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
if (state.getBlock() == Blocks.PISTON || state.getBlock() == Blocks.STICKY_PISTON || state.getBlock() == Blocks.PISTON_HEAD) {
cir.setReturnValue(0.5F);
}
}
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
if (state.getBlock() instanceof InfestedBlock) {
cir.setReturnValue(0F);
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.AnvilBlock;
@ -51,7 +52,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BambooBlock;
@ -33,7 +34,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17)) {
cir.setReturnValue(true);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BedBlock;
@ -42,14 +43,14 @@ public class MixinBedBlock {
@Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true)
public void injectBounceEntity(Entity entity, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
cir.setReturnValue(viafabricplus_bed_shape_v1_13_2);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -34,19 +35,19 @@ public class MixinBlock {
private void modifyBlastResistance(CallbackInfoReturnable<Float> ci) {
final Block block = ((Block) (Object) this);
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
if (block == Blocks.PISTON || block == Blocks.STICKY_PISTON || block == Blocks.PISTON_HEAD) {
ci.setReturnValue(0.5F);
}
}
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
if (block instanceof InfestedBlock) {
ci.setReturnValue(0.75F);
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -44,7 +45,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(viafabricplus_base_shape_v1_12_2);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
@ -48,7 +49,7 @@ public abstract class MixinCauldronBlock extends AbstractCauldronBlock {
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
return viafabricplus_cauldron_shape_v1_12_2;
}
return super.getOutlineShape(state, world, pos, context);

View File

@ -25,6 +25,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.spongepowered.asm.mixin.Mixin;
@ -39,7 +40,7 @@ public abstract class MixinChestBlock extends AbstractChestBlock<ChestBlockEntit
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
return VoxelShapes.fullCube();
}
return super.getCollisionShape(state, world, pos, context);

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
@ -47,10 +48,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
cir.setReturnValue(viafabricplus_shape_v1_8_x);
}
else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
cir.setReturnValue(viafabricplus_shape_v1_16_5);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -44,7 +45,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
return VoxelShapes.union(FRAME_SHAPE, viafabricplus_eye_shape_v1_12_2);
}
return FRAME_WITH_EYE_SHAPE;

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -50,7 +51,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) {
cir.setReturnValue(viafabricplus_shape_v1_9_4);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
@ -25,6 +26,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
@ -41,7 +43,7 @@ public class MixinFenceBlock extends HorizontalConnectingBlock {
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
private void injectOnUse(CallbackInfoReturnable<ActionResult> ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) {
ci.setReturnValue(ActionResult.SUCCESS);
}
}
@ -51,7 +53,7 @@ public class MixinFenceBlock extends HorizontalConnectingBlock {
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
return viafabricplus_fence_shape_b1_8_1;
}
return super.getCollisionShape(state, world, pos, context);
@ -59,7 +61,7 @@ public class MixinFenceBlock extends HorizontalConnectingBlock {
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
return VoxelShapes.fullCube();
}
return super.getOutlineShape(state, world, pos, context);

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BlockState;
@ -36,7 +37,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
cir.setReturnValue(VoxelShapes.empty());
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -39,7 +40,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10) && content != Blocks.AIR) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10) && content != Blocks.AIR) {
ci.setReturnValue(ActionResult.CONSUME);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -48,14 +49,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(viafabricplus_inside_shape_v1_12_2);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -49,7 +50,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.LightBlock;
@ -31,7 +32,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
return true;
}
return instance.isCreativeLevelTwoOp();

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -40,7 +41,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
cir.setReturnValue(viafabricplus_shape_v1_8_x);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
@ -36,7 +37,7 @@ public class MixinPaneBlock extends HorizontalConnectingBlock {
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return viafabricplus_get1_8Shape(state);
}
return super.getOutlineShape(state, world, pos, context);
@ -44,7 +45,7 @@ public class MixinPaneBlock extends HorizontalConnectingBlock {
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return viafabricplus_get1_8Shape(state);
}
return super.getCollisionShape(state, world, pos, context);

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.*;
@ -40,14 +41,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(viafabricplus_getCoreShape_v1_8_x(state));
}
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return VoxelShapes.union(viafabricplus_getHeadShape_v1_8_x(state), viafabricplus_getCoreShape_v1_8_x(state));
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -56,7 +57,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(viafabricplus_layers_to_shape_v1_12_2[state.get(LAYERS) - 1]);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -43,7 +44,7 @@ public class MixinSoulSandBlock extends Block {
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
super.onEntityCollision(state, world, pos, entity);
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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 +54,7 @@ public class MixinSoulSandBlock extends Block {
@Override
public float getVelocityMultiplier() {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4) && !this.viafabricplus_forceValue) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4) && !this.viafabricplus_forceValue) {
return 1.0F;
}
return super.getVelocityMultiplier();

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -33,7 +34,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -150,21 +151,21 @@ public class MixinWallBlock extends Block {
@Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true)
public void injectGetPlacementState(ItemPlacementContext ctx, CallbackInfoReturnable<BlockState> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(viafabricplus_cip_shape_by_index_v1_12_2[viafabricplus_getShapeIndex_v1_12_2(state)]);
}
}
@ -176,7 +177,7 @@ public class MixinWallBlock 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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(viafabricplus_shape_by_index_v1_12_2[viafabricplus_getShapeIndex_v1_12_2(state)]);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Blocks;
@ -50,7 +51,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
ItemStack lv = player.getStackInHand(hand);
if (!this.isBaby()) {
if (this.isTame() && player.shouldCancelInteraction()) {

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.passive.AllayEntity;
@ -30,7 +31,7 @@ public class MixinAllayEntity {
@Inject(method = "getHeightOffset", at = @At("HEAD"), cancellable = true)
public void changeHeightOffset(CallbackInfoReturnable<Double> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
cir.setReturnValue(0.0);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.passive.AnimalEntity;
@ -30,6 +31,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 && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_15);
return instance.isClient && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_15);
}
}

View File

@ -18,6 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.mojang.authlib.GameProfile;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.definition.v1_8.ArmorPointCalculation;
@ -69,7 +70,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;square(D)D"))
public double changeMagnitude(double n) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18_2)) {
n = 9.0E-4D;
}
return MathHelper.square(n);
@ -78,7 +79,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;ticksSinceLastPositionPacketSent:I", ordinal = 0))
public int revertLastPositionPacketSentIncrementor(ClientPlayerEntity instance) {
// Mixin calls the redirector and sets the original field to the return value of the redirector + 1, therefore the -1 results, so we truncate the + 1 again and the field does not change
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return ticksSinceLastPositionPacketSent - 1;
}
return ticksSinceLastPositionPacketSent;
@ -86,7 +87,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Inject(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
public void incrementLastPositionPacketSentCounter(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
++this.ticksSinceLastPositionPacketSent;
}
}
@ -101,7 +102,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Inject(method = "swingHand", at = @At("HEAD"), cancellable = true)
public void injectSwingHand(Hand hand, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && viafabricplus_areSwingCanceledThisTick) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && viafabricplus_areSwingCanceledThisTick) {
ci.cancel();
}
@ -114,7 +115,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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);
@ -126,7 +127,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
return false;
} else {
return _this.isSwimming();
@ -135,7 +136,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
return false;
}
return instance.isSubmergedInWater();
@ -143,7 +144,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
return input.movementForward >= 0.8F;
}
@ -152,7 +153,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
return false; // Disable all water related movement
}
@ -161,14 +162,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 (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
final float var1 = 0.5F * x;
int var2 = Float.floatToIntBits(x);
var2 = 1597463007 - (var2 >> 1);

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EntityType;
@ -40,7 +41,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && player.getAbilities().creativeMode) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2) && player.getAbilities().creativeMode) {
cir.setReturnValue(super.interactMob(player, hand));
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.mob.CreeperEntity;
@ -31,7 +32,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
return SoundEvents.ITEM_FLINTANDSTEEL_USE;
}
return SoundEvents.ITEM_FIRECHARGE_USE;

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import it.unimi.dsi.fastutil.objects.Object2DoubleMap;
@ -59,7 +60,7 @@ public abstract class MixinEntity {
@ModifyConstant(method = "movementInputToVelocity", constant = @Constant(doubleValue = 1E-7))
private static double injectMovementInputToVelocity(double epsilon) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return 1E-4;
}
return epsilon;
@ -67,21 +68,21 @@ public abstract class MixinEntity {
@Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true)
public void injectGetVelocityAffectingPos(CallbackInfoReturnable<BlockPos> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(Vec3d.fromPolar(pitch, yaw));
}
}
@Inject(method = "setSwimming", at = @At("HEAD"), cancellable = true)
private void onSetSwimming(boolean swimming, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && swimming) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && swimming) {
ci.cancel();
}
}
@ -89,7 +90,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 (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2)) {
return;
}
@ -139,19 +140,19 @@ public abstract class MixinEntity {
@Inject(method = "getTargetingMargin", at = @At("HEAD"), cancellable = true)
public void expandHitBox(CallbackInfoReturnable<Float> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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 && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2));
return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2));
}
@ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 1.0E-7))
public double changeBlockCollisionConstant(double constant) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
return 0.001;
}
return constant;
@ -160,7 +161,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 (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19)) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19)) {
instance.onLanding();
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@ -42,12 +43,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) && ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_16_4);
return instance.containsKey(o) && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_16_4tor1_16_5);
}
@Inject(method = "size", at = @At("HEAD"), cancellable = true)
private void returnRealSize(CallbackInfoReturnable<Integer> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
cir.setReturnValue(this.idToEntity.size());
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
@ -31,7 +32,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return false;
}
return player.isMainPlayer();

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.ItemEntity;
@ -30,7 +31,7 @@ public class MixinItemEntity {
@Inject(method = "applyWaterBuoyancy", at = @At("HEAD"), cancellable = true)
public void injectApplyWaterBuoyancy(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
ci.cancel();
}
}

View File

@ -18,6 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
@ -52,7 +53,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_9_3) && stack.isOf(Items.SHIELD)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4) && stack.isOf(Items.SHIELD)) {
cir.setReturnValue(EquipmentSlot.MAINHAND);
}
}
@ -62,7 +63,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return false;
}
@ -73,7 +74,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return false;
}
@ -82,7 +83,7 @@ public abstract class MixinLivingEntity extends Entity {
@ModifyVariable(method = "applyFluidMovingSpeed", ordinal = 0, at = @At("HEAD"), argsOnly = true)
private boolean modifyMovingDown(boolean movingDown) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return true;
}
@ -93,12 +94,12 @@ 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 boolean dontResetLevitationFallDistance(LivingEntity instance) {
return ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_12_2);
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2);
}
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSprinting()Z", ordinal = 0))
private boolean modifySwimSprintSpeed(LivingEntity self) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
return false;
}
return self.isSprinting();
@ -106,7 +107,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 (ExperimentalSettings.INSTANCE.waterMovementEdgeDetection.getValue() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && tagKey == FluidTags.WATER) {
if (ExperimentalSettings.INSTANCE.waterMovementEdgeDetection.getValue() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && tagKey == FluidTags.WATER) {
if (instance.getFluidHeight(tagKey) > 0) {
return 1;
}
@ -116,14 +117,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && !hasNoGravity()) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return 0.005D;
}
return constant;
@ -131,14 +132,14 @@ public abstract class MixinLivingEntity extends Entity {
@Inject(method = "canEnterTrapdoor", at = @At("HEAD"), cancellable = true)
private void onCanEnterTrapdoor(CallbackInfoReturnable<Boolean> ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
ci.setReturnValue(false);
}
}
@ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.9F))
private float changeEntitySpeed(float constant) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
//noinspection ConstantConditions
if ((Entity) this instanceof SkeletonHorseEntity) {
return this.getBaseMovementSpeedMultiplier(); // 0.96F
@ -150,7 +151,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18_2)) {
return MathHelper.cos((float) a);
}
return Math.cos(a);
@ -160,7 +161,7 @@ public abstract class MixinLivingEntity extends Entity {
public double fixLavaMovement(LivingEntity instance, TagKey<Fluid> tagKey) {
double height = instance.getFluidHeight(tagKey);
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
height += getSwimHeight() + 4;
}
return height;
@ -168,7 +169,7 @@ public abstract class MixinLivingEntity extends Entity {
@ModifyConstant(method = "isBlocking", constant = @Constant(intValue = 5))
public int shieldBlockCounter(int constant) {
if(ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if(ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return 0;
}
return constant;
@ -176,7 +177,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
return false;
}
return instance.isClient();

View File

@ -18,6 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.mojang.authlib.GameProfile;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.network.AbstractClientPlayerEntity;
@ -37,7 +38,7 @@ public class MixinOtherClientPlayerEntity extends AbstractClientPlayerEntity {
@Inject(method = "updatePose", at = @At("HEAD"))
public void injectUpdatePose(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
super.updatePose();
}
}

View File

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

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
@ -59,7 +60,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
@Inject(method = "updatePose", at = @At("HEAD"), cancellable = true)
private void onUpdatePose(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
EntityPose pose;
if (isFallFlying())
@ -83,9 +84,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
ci.setReturnValue(PlayerEntity.STANDING_DIMENSIONS);
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2) || ProtocolHack.getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2) || ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
ci.setReturnValue(viafabricplus_sneaking_dimensions_v1_13_2);
}
}
@ -93,7 +94,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
@Inject(method = "getAttackCooldownProgress", at = @At("HEAD"), cancellable = true)
private void injectGetAttackCooldownProgress(CallbackInfoReturnable<Float> ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
ci.setReturnValue(1f);
}
}
@ -107,7 +108,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
@ModifyConstant(method = "getActiveEyeHeight", constant = @Constant(floatValue = 1.27f))
private float modifySneakEyeHeight(float prevEyeHeight) {
if (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_13_2)) {
return prevEyeHeight;
} else {
return 1.54f;
@ -124,7 +125,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
@Redirect(method = "getOffGroundSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSprinting()Z"))
public boolean useOldField(PlayerEntity instance) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
return viafabricplus_isSprinting;
}
return instance.isSprinting();

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.passive.SquidEntity;
@ -31,7 +32,7 @@ public class MixinSquidEntity {
@Inject(method = "canBeLeashedBy", at = @At("HEAD"), cancellable = true)
public void injectCanBeLeashedBy(PlayerEntity player, CallbackInfoReturnable<Boolean> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
cir.setReturnValue(false);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EntityType;
@ -37,7 +38,7 @@ public class MixinVexEntity extends HostileEntity {
@Inject(method = "getHeightOffset", at = @At("HEAD"), cancellable = true)
public void changeHeightOffset(CallbackInfoReturnable<Double> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
cir.setReturnValue(0.0);
}
}

View File

@ -18,6 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.connection.UserConnection;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.definition.v1_14_4.Meta18Storage;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
@ -35,7 +36,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
final UserConnection userConnection = MinecraftClient.getInstance().getNetworkHandler().getConnection().channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get();
if (!userConnection.has(Meta18Storage.class)) userConnection.put(new Meta18Storage(userConnection));
return userConnection.get(Meta18Storage.class).getHealthDataMap().getOrDefault(instance.getId(), health);

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
@ -43,7 +44,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 (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
return false;
}
return instance.sendCommand(command);

View File

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

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EquipmentSlot;
@ -43,7 +44,7 @@ public class MixinArmorItem extends Item {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
public void implementLegacyAction(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
ItemStack itemStack = user.getStackInHand(hand);
EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(itemStack);
ItemStack itemStack2 = user.getEquippedStack(equipmentSlot);

View File

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

View File

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

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EquipmentSlot;
@ -43,7 +44,7 @@ public class MixinElytraItem extends Item {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
public void implementLegacyAction(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
ItemStack itemStack = user.getStackInHand(hand);
EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(itemStack);
ItemStack itemStack2 = user.getEquippedStack(equipmentSlot);

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
@ -35,7 +36,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && user.getAbilities().creativeMode) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && user.getAbilities().creativeMode) {
ci.setReturnValue(TypedActionResult.pass(user.getStackInHand(hand)));
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
@ -30,7 +31,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11)) {
return false;
}

View File

@ -23,6 +23,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
@ -53,7 +54,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && client.player.isBlocking()) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_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

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

View File

@ -19,11 +19,11 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemGroups;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.resource.featuretoggle.FeatureSet;
import net.raphimc.vialoader.util.VersionEnum;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -41,7 +41,7 @@ public abstract class MixinItemGroups {
protected static void updateEntries(ItemGroup.DisplayContext displayContext) {
}
@Unique
private static ComparableProtocolVersion viafabricplus_version;
private static VersionEnum viafabricplus_version;
@Unique
private static boolean viafabricplus_state;

View File

@ -23,6 +23,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.player.PlayerEntity;
@ -42,9 +43,9 @@ public class MixinItemPlacementContext {
final ItemPlacementContext self = (ItemPlacementContext) (Object) this;
final PlayerEntity player = self.getPlayer();
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && player != null) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && player != null) {
final BlockPos placementPos = self.getBlockPos();
final double blockPosCenterFactor = ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_10) ? 0.5 : 0;
final double blockPosCenterFactor = ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_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

@ -19,6 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
@ -50,7 +51,7 @@ public abstract class MixinItemStack {
@Inject(method = "updateEmptyState", at = @At("HEAD"), cancellable = true)
public void allowNegativeItems(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) {
this.empty = false;
final ItemStack self = (ItemStack) (Object) this;
this.empty = self == EMPTY || this.getItem() == null || self.isOf(Items.AIR) || count == 0;
@ -60,7 +61,7 @@ public abstract class MixinItemStack {
@Inject(method = "isEmpty", at = @At("HEAD"), cancellable = true)
public void dontRecalculateState(CallbackInfoReturnable<Boolean> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) {
cir.setReturnValue(this.empty);
}
}
@ -69,7 +70,7 @@ public abstract class MixinItemStack {
private void modifyMiningSpeedMultiplier(BlockState state, CallbackInfoReturnable<Float> ci) {
final Item toolItem = ((ItemStack) (Object) this).getItem();
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && toolItem instanceof HoeItem) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2) && toolItem instanceof HoeItem) {
ci.setReturnValue(1F);
}
}
@ -78,7 +79,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return 0;
} else {
return player.getAttributeBaseValue(attribute);

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BlockState;
@ -34,7 +35,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && (Object) this instanceof HoeItem) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2) && (Object) this instanceof HoeItem) {
cir.setReturnValue(1.0F);
}
}

View File

@ -18,6 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.google.common.collect.ImmutableSet;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.Block;
@ -52,7 +53,7 @@ public abstract class MixinPickaxeItem extends MiningToolItem {
@Override
public boolean isSuitableFor(BlockState state) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
Block block = state.getBlock();
int i = this.getMaterial().getMiningLevel();
if (block == Blocks.OBSIDIAN) {
@ -70,9 +71,9 @@ public abstract class MixinPickaxeItem extends MiningToolItem {
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
return viafabricplus_EFFECTIVE_MATERIALS.contains(state.getMaterial()) || viafabricplus_EFFECTIVE_BLOCKS_1152.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
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

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.item.ShovelItem;
@ -34,7 +35,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return null;
} else {
return map.get(grassBlock);

View File

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

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.packet;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.network.PacketByteBuf;
@ -31,7 +32,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
cir.setReturnValue(null);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.packet;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import io.netty.buffer.ByteBuf;
@ -33,7 +34,7 @@ public class MixinUpdatePlayerAbilitiesC2SPacket {
@Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeByte(I)Lio/netty/buffer/ByteBuf;"))
public ByteBuf implementFlags(PacketByteBuf instance, int value) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
final PlayerAbilities playerAbilities = MinecraftClient.getInstance().player.getAbilities();
if (playerAbilities.invulnerable) value |= 1;

View File

@ -19,6 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ProfileKey;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.definition.bedrock.BedrockAccountHandler;
@ -29,18 +30,16 @@ import de.florianmichael.viafabricplus.definition.v1_19_2.storage.ChatSession1_1
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.encryption.PlayerKeyPair;
import net.minecraft.network.encryption.PlayerPublicKey;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.login.LoginHelloC2SPacket;
import net.raphimc.mcauth.step.bedrock.StepMCChain;
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
import net.raphimc.viabedrock.protocol.storage.AuthChainData;
import net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -66,7 +65,7 @@ public class MixinConnectScreen_1 {
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getHostName()Ljava/lang/String;", ordinal = 0))
public String replaceAddress(InetSocketAddress instance) {
if (ProtocolHack.getTargetVersion(instance).isOlderThanOrEqualTo(ProtocolVersion.v1_17) || ProtocolHack.getTargetVersion(instance).isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
if (ProtocolHack.getTargetVersion(instance).isOlderThanOrEqualTo(VersionEnum.r1_17) || ProtocolHack.getTargetVersion(instance) == VersionEnum.bedrockLatest) {
return field_33737.getAddress();
}
return instance.getHostName();
@ -74,7 +73,7 @@ public class MixinConnectScreen_1 {
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getPort()I"))
public int replacePort(InetSocketAddress instance) {
if (ProtocolHack.getTargetVersion(instance).isOlderThanOrEqualTo(ProtocolVersion.v1_17) || ProtocolHack.getTargetVersion(instance).isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
if (ProtocolHack.getTargetVersion(instance).isOlderThanOrEqualTo(VersionEnum.r1_17) || ProtocolHack.getTargetVersion(instance) == VersionEnum.bedrockLatest) {
return field_33737.getPort();
}
return instance.getPort();
@ -97,9 +96,9 @@ public class MixinConnectScreen_1 {
final UserConnection userConnection = connection.channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get();
if (userConnection == null) return;
final ComparableProtocolVersion targetVersion = ProtocolHack.getTargetVersion(connection.channel);
final VersionEnum targetVersion = ProtocolHack.getTargetVersion(connection.channel);
if (targetVersion.isEqualTo(BedrockProtocolVersion.bedrockLatest)) {
if (targetVersion == VersionEnum.bedrockLatest) {
final StepMCChain.MCChain account = BedrockAccountHandler.INSTANCE.getAccount();
if (account != null) {
@ -109,16 +108,16 @@ public class MixinConnectScreen_1 {
return;
}
if (targetVersion.isOlderThan(ProtocolVersion.v1_19)) {
if (targetVersion.isOlderThan(VersionEnum.r1_19)) {
return; // This disables the chat session emulation for all versions <= 1.18.2
}
if (targetVersion.isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
MinecraftClient.getInstance().getProfileKeys().fetchKeyPair().thenAcceptAsync(optional -> optional.ifPresentOrElse(playerKeyPair -> {
final PlayerPublicKey.PublicKeyData publicKeyData = playerKeyPair.publicKey().data();
userConnection.put(new ChatSession1_19_2(userConnection, new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), publicKeyData.keySignature()), playerKeyPair.privateKey()));
if (targetVersion.isEqualTo(ProtocolVersion.v1_19)) {
if (targetVersion == VersionEnum.r1_19) {
final var legacyKey = ((IPublicKeyData) (Object) publicKeyData).viafabricplus_getV1Key();
if (legacyKey != null) {
userConnection.put(new ChatSession1_19_0(userConnection, new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), legacyKey.array()), playerKeyPair.privateKey()));

View File

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

View File

@ -17,9 +17,11 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
@ -42,11 +44,11 @@ public class MixinGameModeSelectionScreen {
@Inject(method = "<init>", at = @At("RETURN"))
public void fixUIWidth(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
final List<GameModeSelectionScreen.GameModeSelection> gameModeSelections = new ArrayList<>(Arrays.stream(GameModeSelectionScreen.GameModeSelection.values()).toList());
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);
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_3_1tor1_3_2)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR);
viafabricplus_unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new);
UI_WIDTH = viafabricplus_unwrappedGameModes.length * 31 - 5;
@ -55,7 +57,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 (ProtocolHack.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
return viafabricplus_unwrappedGameModes;
}
return GameModeSelectionScreen.GameModeSelection.values();

View File

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

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.font.TextRenderer;
@ -36,7 +37,7 @@ 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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
ci.setReturnValue(super.charTyped(chr, keyCode));
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.merchant;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.screen.MerchantScreenHandler;
@ -30,7 +31,7 @@ public class MixinMerchantScreenHandler {
@Inject(method = "switchTo", at = @At("HEAD"), cancellable = true)
private void injectSwitchTo(int recipeId, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
ci.cancel();
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.screenhandler;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.inventory.Inventory;
@ -35,12 +36,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8))
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8))
ci.setReturnValue(false);
}
@Override
public boolean isEnabled() {
return ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_8);
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_8);
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.screenhandler;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EquipmentSlot;
@ -42,7 +43,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8))
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8))
return null;
return addSlot(slot);
}
@ -50,7 +51,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && slot == EquipmentSlot.OFFHAND)
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && slot == EquipmentSlot.OFFHAND)
return EquipmentSlot.MAINHAND;
else
return slot;

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.screenhandler;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.injection.access.IScreenHandler;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
@ -37,7 +38,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 (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && actionType == SlotActionType.SWAP && clickData == 40) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && actionType == SlotActionType.SWAP && clickData == 40) {
ci.cancel();
}
}

View File

@ -1,48 +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.fixes.vialoadingbase;
import com.viaversion.viaversion.configuration.AbstractViaConfig;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
import de.florianmichael.vialoadingbase.platform.viaversion.VLBViaConfig;
import org.spongepowered.asm.mixin.Mixin;
import java.io.File;
@Mixin(value = VLBViaConfig.class, remap = false)
public abstract class MixinVLBViaConfig extends AbstractViaConfig {
protected MixinVLBViaConfig(File configFile) {
super(configFile);
}
@Override
public boolean isLeftHandedHandling() {
return false;
}
@Override
public boolean isShieldBlocking() {
return false;
}
@Override
public boolean isChunkBorderFix() {
return ExperimentalSettings.INSTANCE.fixChunkBorders.getValue();
}
}

View File

@ -17,6 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
import net.raphimc.vialoader.util.VersionEnum;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.protocol.version.VersionRange;
import com.viaversion.viaversion.util.Pair;

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