mixin fix attempt

This commit is contained in:
FalsePattern committed 2022-08-23 21:18:43 +02:00
1 parent 4cf5f39fe5
commit 42543dc388
4 files changed
+52 -52

No files matched your search

@@ -26,9 +26,6 @@ import com.falsepattern.lib.internal.Tags;
import com.falsepattern.lib.mixin.MixinInfo;
import lombok.val;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import java.util.ArrayList;
public class IMixinPluginTransformer implements IClassNodeTransformer {
@Override
@@ -44,21 +41,18 @@ public class IMixinPluginTransformer implements IClassNodeTransformer {
@Override
public void transform(ClassNode cn, String transformedName, boolean obfuscated) {
val methods = cn.methods;
val remove = new ArrayList<MethodNode>();
String name;
if (!MixinInfo.isMixinBooterLegacy()) {
FPTransformer.LOG.info("Could not detect MixinBooterLegacy. Removing MBL compat code.");
name = "org/spongepowered/libraries/org/objectweb/asm/tree/ClassNode";
} else {
FPTransformer.LOG.info("Detected MixinBooterLegacy. Removing SpongeMixins compat code.");
name = "org/spongepowered/asm/lib/tree/ClassNode";
}
for (val method: methods) {
if ((method.name.equals("preApply") || method.name.equals("postApply")) &&
method.desc.contains(name)) {
remove.add(method);
FPTransformer.LOG.info("Could not detect MixinBooterLegacy. Converting IMixinPlugin to legacy compat mode.");
for (val method : methods) {
if (method.name.equals("preApply") || method.name.equals("postApply")) {
method.desc = method.desc.replace("org/spongepowered/libraries/org/objectweb/asm/tree/ClassNode",
"org/spongepowered/asm/lib/tree/ClassNode");
for (val local: method.localVariables) {
local.desc = local.desc.replace("org/spongepowered/libraries/org/objectweb/asm/tree/ClassNode",
"org/spongepowered/asm/lib/tree/ClassNode");
}
}
}
}
methods.removeAll(remove);
}
}
@@ -21,11 +21,11 @@
package com.falsepattern.lib.mixin;
import com.falsepattern.lib.StableAPI;
import com.falsepattern.lib.mixin.stubpackage.org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import com.falsepattern.lib.util.FileUtil;
import lombok.val;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import org.spongepowered.libraries.org.objectweb.asm.tree.ClassNode;
@@ -157,14 +157,4 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
default void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@StableAPI.Expose(since = "__INTERNAL__")
default void preApply(String targetClassName, com.falsepattern.lib.mixin.stubpackage.org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@StableAPI.Expose(since = "__INTERNAL__")
default void postApply(String targetClassName, com.falsepattern.lib.mixin.stubpackage.org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
}
@@ -1,25 +0,0 @@
/*
* Copyright (C) 2022 FalsePattern
* All Rights Reserved
*
* The above copyright notice, this permission notice and the word "SNEED"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser 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 Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.lib.mixin.stubpackage.org.spongepowered.asm.lib.tree;
public class ClassNode {
}
@@ -0,0 +1,41 @@
/*
* This file is part of Mixin, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.falsepattern.lib.mixin.stubpackage.org.spongepowered.asm.mixin.extensibility;
import java.util.List;
import java.util.Set;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import org.spongepowered.libraries.org.objectweb.asm.tree.ClassNode;
public interface IMixinConfigPlugin {
void onLoad(String mixinPackage);
String getRefMapperConfig();
boolean shouldApplyMixin(String targetClassName, String mixinClassName);
void acceptTargets(Set<String> myTargets, Set<String> otherTargets);
List<String> getMixins();
void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo);
void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo);
}