Added Mixin Plugin to disable compat mixins

Fixed DashLoader compat
Fixed ArmorSkin compat (Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/221)
Repackage compat mixins into own package
This commit is contained in:
FlorianMichael 2023-09-18 17:43:28 +02:00
parent 8aca0ea935
commit fe5cdf2c8c
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
8 changed files with 86 additions and 16 deletions

View File

@ -35,6 +35,7 @@ ViaFabricPlus is intended to replace [multiconnect](https://github.com/Earthcomp
### Conflicts
- ***[DashLoader (*)](https://github.com/alphaqu/DashLoader/tree/fabric-1.20)*** - Font rendering related fixes aren't working
- ***[Armor Skin (*)](https://github.com/IzzyDotExe/ArmorSkin)*** - Beta HUD changes aren't working
## List of all clientside related fixes and TODO
<details>

View File

@ -22,13 +22,12 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.ArmorType;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.FinishMinecraftLoadCallback;
import de.florianmichael.viafabricplus.base.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.viafabricplus.injection.MixinPlugin;
import de.florianmichael.viafabricplus.injection.access.IFontStorage;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.FontStorage;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
@ -57,11 +56,6 @@ public class ClientsideFixes {
*/
public final static VersionRange LEGACY_SRV_RESOLVE = VersionRange.andOlder(VersionEnum.r1_2_4tor1_2_5).add(VersionRange.single(VersionEnum.bedrockLatest));
/**
* Tracks if the client is using DashLoader, so we can skip some fixes in the font rendering since they break DashLoader
*/
public final static boolean DASH_LOADER = FabricLoader.getInstance().isModLoaded("dashloader");
/**
* Contains the armor points of all armor items in legacy versions (<= 1.8.x)
*/
@ -124,7 +118,7 @@ public class ClientsideFixes {
}
}
if (DASH_LOADER) {
if (!MixinPlugin.DASH_LOADER_PRESENT) {
// Reloads all font storages to fix the font renderer
for (FontStorage storage : MinecraftClient.getInstance().fontManager.fontStorages.values()) {
RenderSystem.recordRenderCall(() -> ((IFontStorage) storage).viafabricplus_clearCaches());

View File

@ -0,0 +1,73 @@
/*
* 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;
import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.List;
import java.util.Set;
public class MixinPlugin implements IMixinConfigPlugin {
public final static String INJECTOR_PACKAGE = "de.florianmichael.viafabricplus.injection.mixin";
private final static String MC_FIXES_PACKAGE = ".fixes.minecraft";
public static boolean DASH_LOADER_PRESENT;
public static boolean ARMOR_SKIN_PRESENT;
@Override
public void onLoad(String mixinPackage) {
final var loader = FabricLoader.getInstance();
DASH_LOADER_PRESENT = loader.isModLoaded("dashloader");
ARMOR_SKIN_PRESENT = loader.isModLoaded("armorskin");
}
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (mixinClassName.equals(INJECTOR_PACKAGE + MC_FIXES_PACKAGE + ".MixinFontStorage")) {
return !DASH_LOADER_PRESENT;
}
if (mixinClassName.equals(INJECTOR_PACKAGE + MC_FIXES_PACKAGE + ".MixinInGameHud")) {
return !ARMOR_SKIN_PRESENT;
}
return true;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {}
@Override
public List<String> getMixins() {
return null;
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
}

View File

@ -15,7 +15,7 @@
* 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.ipnext;
package de.florianmichael.viafabricplus.injection.mixin.compat.ipnext;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.raphimc.vialoader.util.VersionEnum;
@ -29,7 +29,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/*
* https://github.com/blackd/Inventory-Profiles/tree/all-in-one is handling the offhand slot even when
* ViaFabricPlus removes the slot in <= 1.8.9, so we have to cancel the handling of the offhand slot
* <p>
*
* Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/209
*/
@Pseudo

View File

@ -15,7 +15,7 @@
* 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.sodium;
package de.florianmichael.viafabricplus.injection.mixin.compat.sodium;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;

View File

@ -83,7 +83,7 @@ public abstract class MixinFontStorage implements IFontStorage {
@Inject(method = "findGlyph", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/Font;getGlyph(I)Lnet/minecraft/client/font/Glyph;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
public void injectFindGlyph(int codePoint, CallbackInfoReturnable<FontStorage.GlyphPair> cir, Glyph glyph, Iterator var3, Font font) {
if (ClientsideFixes.DASH_LOADER || !this.id.getNamespace().equals("minecraft")) return;
if (!this.id.getNamespace().equals("minecraft")) return;
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
if (viafabricplus_isForbiddenCharacter(font, codePoint)) cir.setReturnValue(FontStorage.GlyphPair.MISSING);
@ -96,7 +96,7 @@ public abstract class MixinFontStorage implements IFontStorage {
@Inject(method = "findGlyphRenderer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/Font;getGlyph(I)Lnet/minecraft/client/font/Glyph;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
public void injectFindGlyphRenderer(int codePoint, CallbackInfoReturnable<GlyphRenderer> cir, Iterator var2, Font font) {
if (ClientsideFixes.DASH_LOADER || !this.id.getNamespace().equals("minecraft")) return;
if (!this.id.getNamespace().equals("minecraft")) return;
if (!viafabricplus_obfuscation && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
if (viafabricplus_isForbiddenCharacter(font, codePoint)) cir.setReturnValue(this.blankGlyphRenderer);

View File

@ -44,6 +44,7 @@
"krypton": "<=0.2.2"
},
"conflicts": {
"dashloader": "*"
"dashloader": "*",
"armorskin": "*"
}
}

View File

@ -3,6 +3,7 @@
"minVersion": "0.8",
"package": "de.florianmichael.viafabricplus.injection.mixin",
"compatibilityLevel": "JAVA_17",
"plugin": "de.florianmichael.viafabricplus.injection.MixinPlugin",
"client": [
"base.MixinAddServerScreen",
"base.MixinClientConnection",
@ -129,7 +130,7 @@
"fixes.minecraft.screen.screenhandler.MixinBrewingStandScreenHandler_FuelSlot",
"fixes.minecraft.screen.screenhandler.MixinPlayerScreenHandler",
"fixes.minecraft.screen.screenhandler.MixinScreenHandler",
"fixes.sodium.MixinChunkTracker",
"compat.sodium.MixinChunkTracker",
"fixes.viabedrock.MixinBedrockProtocol",
"fixes.viabedrock.MixinJoinPackets",
"fixes.vialegacy.MixinClassicProtocolExtension",
@ -166,7 +167,7 @@
"fixes.viaversion.protocol1_9to1_8.MixinEntityTracker1_9",
"fixes.viaversion.protocol1_9to1_8.MixinMetadataRewriter1_9To1_8",
"fixes.viaversion.protocol1_9to1_8.MixinViaIdleThread",
"ipnext.MixinAutoRefillHandler_ItemSlotMonitor",
"compat.ipnext.MixinAutoRefillHandler_ItemSlotMonitor",
"jsonwebtoken.MixinClasses",
"jsonwebtoken.MixinDefaultCompressionCodecResolver",
"jsonwebtoken.MixinDefaultJwtParserBuilder"