Remove hacks around RegistryEntry (#144)

This commit is contained in:
shedaniel
2021-12-11 19:05:13 +08:00
parent 5e338b40da
commit 452d0d1bb9
6 changed files with 97 additions and 55 deletions

View File

@@ -1,27 +0,0 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 architectury
*
* 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
* Lesser 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, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.mixin.forge;
import me.shedaniel.architectury.core.RegistryEntry;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(RegistryEntry.class)
public class MixinRegistryEntry<T> {
}

View File

@@ -19,16 +19,11 @@
package me.shedaniel.architectury.plugin.forge;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.List;
import java.util.Objects;
import java.util.Set;
public class ArchitecturyMixinPlugin implements IMixinConfigPlugin {
@@ -59,26 +54,7 @@ public class ArchitecturyMixinPlugin implements IMixinConfigPlugin {
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
// Inject our own sugar
switch (mixinClassName) {
case "me.shedaniel.architectury.mixin.forge.MixinRegistryEntry":
targetClass.superName = "net/minecraftforge/registries/ForgeRegistryEntry";
for (MethodNode method : targetClass.methods) {
if (Objects.equals(method.name, "<init>")) {
for (AbstractInsnNode insnNode : method.instructions) {
if (insnNode.getOpcode() == Opcodes.INVOKESPECIAL && insnNode instanceof MethodInsnNode) {
MethodInsnNode node = (MethodInsnNode) insnNode;
if (Objects.equals(node.name, "<init>") && Objects.equals(node.owner, "java/lang/Object")) {
node.owner = "net/minecraftforge/registries/ForgeRegistryEntry";
break;
}
}
}
}
}
targetClass.signature = "<T::Lnet/minecraftforge/registries/IForgeRegistryEntry<TT;>;>Lnet/minecraftforge/registries/ForgeRegistryEntry<TT;>;";
break;
}
}
@Override

View File

@@ -20,7 +20,6 @@
"MixinBlockEntityExtension",
"MixinChunkSerializer",
"MixinItemExtension",
"MixinRegistryEntry",
"MixinWorldEvent",
"MobSpawnSettingsBuilderAccessor"
],