Update implementer
This commit is contained in:
parent
1c26df7449
commit
2bc5937db5
|
@ -2,6 +2,7 @@ package io.izzel.arclight.common.asm;
|
||||||
|
|
||||||
import cpw.mods.modlauncher.api.NamedPath;
|
import cpw.mods.modlauncher.api.NamedPath;
|
||||||
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
|
import io.izzel.arclight.api.ArclightVersion;
|
||||||
import io.izzel.arclight.common.mod.util.log.ArclightI18nLogger;
|
import io.izzel.arclight.common.mod.util.log.ArclightI18nLogger;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
|
@ -22,6 +23,12 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
public class ArclightImplementer implements ILaunchPluginService {
|
public class ArclightImplementer implements ILaunchPluginService {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
ArclightVersion.setVersion(ArclightVersion.v1_17_R1);
|
||||||
|
} catch (Throwable ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
static final Logger LOGGER = ArclightI18nLogger.getLogger("Implementer");
|
static final Logger LOGGER = ArclightI18nLogger.getLogger("Implementer");
|
||||||
|
|
||||||
private static final EnumSet<Phase> OH_YES_SIR = EnumSet.of(Phase.AFTER);
|
private static final EnumSet<Phase> OH_YES_SIR = EnumSet.of(Phase.AFTER);
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.io.InputStream;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -35,7 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
public class InventoryImplementer implements Implementer {
|
public class InventoryImplementer implements Implementer {
|
||||||
|
|
||||||
private static final Marker MARKER = MarkerManager.getMarker("INVENTORY");
|
private static final Marker MARKER = MarkerManager.getMarker("INVENTORY");
|
||||||
private static final String INV_TYPE = "net/minecraft/inventory/IInventory";
|
private static final String INV_TYPE = "net/minecraft/world/Container";
|
||||||
private static final String BRIDGE_TYPE = "io/izzel/arclight/common/bridge/inventory/IInventoryBridge";
|
private static final String BRIDGE_TYPE = "io/izzel/arclight/common/bridge/inventory/IInventoryBridge";
|
||||||
|
|
||||||
private final Map<String, Integer> map = new ConcurrentHashMap<>();
|
private final Map<String, Integer> map = new ConcurrentHashMap<>();
|
||||||
|
@ -114,7 +113,7 @@ public class InventoryImplementer implements Implementer {
|
||||||
for (MethodNode method : node.methods) {
|
for (MethodNode method : node.methods) {
|
||||||
String desc = method.name + method.desc;
|
String desc = method.name + method.desc;
|
||||||
methods.add(desc);
|
methods.add(desc);
|
||||||
if (desc.equals("func_70297_j_()I")) {
|
if (desc.equals("m_6893_()I")) {
|
||||||
stackLimitMethod = method;
|
stackLimitMethod = method;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +175,7 @@ public class InventoryImplementer implements Implementer {
|
||||||
stackLimitMethod.instructions.insert(list);
|
stackLimitMethod.instructions.insert(list);
|
||||||
} else {
|
} else {
|
||||||
MethodNode methodNode = stackLimitMethod == null
|
MethodNode methodNode = stackLimitMethod == null
|
||||||
? new MethodNode(0, "func_70297_j_", "()I", null, null)
|
? new MethodNode(0, "m_6893_()I", "()I", null, null)
|
||||||
: stackLimitMethod;
|
: stackLimitMethod;
|
||||||
methodNode.access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC;
|
methodNode.access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC;
|
||||||
int level = map.get(node.name);
|
int level = map.get(node.name);
|
||||||
|
@ -223,21 +222,4 @@ public class InventoryImplementer implements Implementer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<FieldNode> findPossibleList(ClassNode node) {
|
|
||||||
LinkedList<FieldNode> list = new LinkedList<>();
|
|
||||||
for (FieldNode fieldNode : node.fields) {
|
|
||||||
boolean nonNullList = fieldNode.desc.equals("Lnet/minecraft/util/NonNullList;");
|
|
||||||
if (nonNullList || fieldNode.desc.equals("Ljava/util/List;")) {
|
|
||||||
if (fieldNode.signature != null && fieldNode.signature.contains("<Lnet/minecraft/item/ItemStack;>")) {
|
|
||||||
if (nonNullList) {
|
|
||||||
list.addFirst(fieldNode);
|
|
||||||
} else {
|
|
||||||
list.addLast(fieldNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,14 @@ import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fmllegacy.network.FMLNetworkConstants;
|
import net.minecraftforge.fmllegacy.network.FMLNetworkConstants;
|
||||||
import net.minecraftforge.server.permission.PermissionAPI;
|
import net.minecraftforge.server.permission.PermissionAPI;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
@Mod("arclight")
|
@Mod("arclight")
|
||||||
public class ArclightMod {
|
public class ArclightMod {
|
||||||
|
@ -18,10 +25,34 @@ public class ArclightMod {
|
||||||
|
|
||||||
public ArclightMod() {
|
public ArclightMod() {
|
||||||
LOGGER.info("mod-load");
|
LOGGER.info("mod-load");
|
||||||
ArclightVersion.setVersion(ArclightVersion.v1_16_4);
|
ArclightVersion.setVersion(ArclightVersion.v1_17_R1);
|
||||||
|
System.setOut(new LoggingPrintStream("STDOUT", System.out, Level.INFO));
|
||||||
|
System.setErr(new LoggingPrintStream("STDERR", System.err, Level.ERROR));
|
||||||
ArclightEventDispatcherRegistry.registerAllEventDispatchers();
|
ArclightEventDispatcherRegistry.registerAllEventDispatchers();
|
||||||
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
|
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
|
||||||
() -> new IExtensionPoint.DisplayTest(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
|
() -> new IExtensionPoint.DisplayTest(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
|
||||||
PermissionAPI.setPermissionHandler(ArclightPermissionHandler.INSTANCE);
|
PermissionAPI.setPermissionHandler(ArclightPermissionHandler.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class LoggingPrintStream extends PrintStream {
|
||||||
|
|
||||||
|
private final Logger logger;
|
||||||
|
private final Level level;
|
||||||
|
|
||||||
|
public LoggingPrintStream(String name, @NotNull OutputStream out, Level level) {
|
||||||
|
super(out);
|
||||||
|
this.logger = LogManager.getLogger(name);
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void println(@Nullable String x) {
|
||||||
|
logger.log(level, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void println(@Nullable Object x) {
|
||||||
|
logger.log(level, String.valueOf(x));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,28 @@
|
||||||
{
|
{
|
||||||
"net/minecraft/world/server/ServerWorld": {
|
"net/minecraft/server/level/ServerLevel": {
|
||||||
"func_72838_d(Lnet/minecraft/entity/Entity;)Z": "entity add",
|
"m_8872_(Lnet/minecraft/world/entity/Entity;)Z": "entity add",
|
||||||
"func_217465_m(Lnet/minecraft/entity/Entity;)V": "entity register",
|
"m_142646_()Lnet/minecraft/world/level/entity/LevelEntityGetter;": "chunk entity get"
|
||||||
"removeEntityComplete(Lnet/minecraft/entity/Entity;Z)V": "entity unregister"
|
|
||||||
},
|
},
|
||||||
"net/minecraft/world/server/ChunkManager$EntityTracker": {
|
"net/minecraft/server/level/ServerLevel$EntityCallbacks": {
|
||||||
"func_219399_a(Lnet/minecraft/entity/player/ServerPlayerEntity;)V": "player tracker clear",
|
"m_141985_(Lnet/minecraft/world/entity/Entity;)V": "entity register",
|
||||||
"func_219400_b(Lnet/minecraft/entity/player/ServerPlayerEntity;)V": "player tracker update"
|
"m_141981_(Lnet/minecraft/world/entity/Entity;)V": "entity unregister"
|
||||||
},
|
},
|
||||||
"net/minecraft/block/Block": {
|
"net/minecraft/server/level/ChunkMap$TrackedEntity": {
|
||||||
"func_220082_b(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Z)V": "block place",
|
"m_140485_(Lnet/minecraft/server/level/ServerPlayer;)V": "player tracker clear",
|
||||||
"func_196243_a(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Z)V": "block remove"
|
"m_140497_(Lnet/minecraft/server/level/ServerPlayer;)V": "player tracker update"
|
||||||
},
|
},
|
||||||
"net/minecraft/entity/LivingEntity": {
|
"net/minecraft/world/level/block/state/BlockBehaviour": {
|
||||||
"func_195064_c(Lnet/minecraft/potion/EffectInstance;)Z": "effect add"
|
"m_6807_(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Z)V": "block place",
|
||||||
|
"m_6810_(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Z)V": "block remove"
|
||||||
},
|
},
|
||||||
"net/minecraft/world/server/ChunkManager": {
|
"net/minecraft/world/entity/LivingEntity": {
|
||||||
"func_219210_a(Lnet/minecraft/entity/Entity;)V": "entity track",
|
"m_147207_(Lnet/minecraft/world/effect/MobEffectInstance;Lnet/minecraft/world/entity/Entity;)Z": "effect add"
|
||||||
"func_219231_b(Lnet/minecraft/entity/Entity;)V": "entity untrack"
|
|
||||||
},
|
},
|
||||||
"net/minecraft/world/chunk/Chunk": {
|
"net/minecraft/server/level/ChunkMap": {
|
||||||
"func_177414_a(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/List;Ljava/util/function/Predicate;)V": "chunk entity get",
|
"m_140199_(Lnet/minecraft/world/entity/Entity;)V": "entity track",
|
||||||
"func_217313_a(Lnet/minecraft/entity/EntityType;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/List;Ljava/util/function/Predicate;)V": "chunk entity get",
|
"m_140331_(Lnet/minecraft/world/entity/Entity;)V": "entity untrack"
|
||||||
"func_177430_a(Ljava/lang/Class;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/List;Ljava/util/function/Predicate;)V": "chunk entity get"
|
|
||||||
},
|
},
|
||||||
"net/minecraft/loot/LootTable": {
|
"net/minecraft/world/level/storage/loot/LootTable": {
|
||||||
"func_216118_a(Lnet/minecraft/inventory/IInventory;Lnet/minecraft/loot/LootContext;)V": "loot generate"
|
"m_79123_(Lnet/minecraft/world/Container;Lnet/minecraft/world/level/storage/loot/LootContext;)V": "loot generate"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package io.izzel.arclight.boot;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.NamedPath;
|
||||||
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class ArclightImplementer_Forge implements ILaunchPluginService {
|
||||||
|
|
||||||
|
private final ILaunchPluginService delegate;
|
||||||
|
|
||||||
|
public ArclightImplementer_Forge() {
|
||||||
|
var module = getClass().getModule();
|
||||||
|
for (var m : module.getLayer().modules()) {
|
||||||
|
module.addReads(m);
|
||||||
|
}
|
||||||
|
for (var layer : module.getLayer().parents()) {
|
||||||
|
layer.modules().forEach(module::addReads);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
delegate = (ILaunchPluginService) Class.forName("io.izzel.arclight.common.asm.ArclightImplementer")
|
||||||
|
.getConstructor().newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return delegate.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
|
||||||
|
return delegate.handlesClass(classType, isEmpty);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty, String reason) {
|
||||||
|
return delegate.handlesClass(classType, isEmpty, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean processClass(Phase phase, ClassNode classNode, Type classType, String reason) {
|
||||||
|
return delegate.processClass(phase, classNode, classType, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initializeLaunch(ITransformerLoader transformerLoader, NamedPath[] specialPaths) {
|
||||||
|
delegate.initializeLaunch(transformerLoader, specialPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customAuditConsumer(String className, Consumer<String[]> auditDataAcceptor) {
|
||||||
|
delegate.customAuditConsumer(className, auditDataAcceptor);
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,13 +60,6 @@ public class ArclightLocator_Forge implements IModLocator {
|
||||||
|
|
||||||
protected IModFile loadJar() {
|
protected IModFile loadJar() {
|
||||||
try {
|
try {
|
||||||
var module = getClass().getModule();
|
|
||||||
for (var m : module.getLayer().modules()) {
|
|
||||||
module.addReads(m);
|
|
||||||
}
|
|
||||||
for (var layer : module.getLayer().parents()) {
|
|
||||||
layer.modules().forEach(module::addReads);
|
|
||||||
}
|
|
||||||
var cl = forName("net.minecraftforge.fml.loading.moddiscovery.ModFile");
|
var cl = forName("net.minecraftforge.fml.loading.moddiscovery.ModFile");
|
||||||
var lookup = MethodHandles.lookup();
|
var lookup = MethodHandles.lookup();
|
||||||
var handle = lookup.findStatic(cl, "newFMLInstance", MethodType.methodType(cl, IModLocator.class, SecureJar.class));
|
var handle = lookup.findStatic(cl, "newFMLInstance", MethodType.methodType(cl, IModLocator.class, SecureJar.class));
|
||||||
|
@ -87,10 +80,6 @@ public class ArclightLocator_Forge implements IModLocator {
|
||||||
|
|
||||||
private JarMetadata excludePackages(SecureJar secureJar) {
|
private JarMetadata excludePackages(SecureJar secureJar) {
|
||||||
secureJar.getPackages().removeIf(it -> EXCLUDES.stream().anyMatch(it::startsWith));
|
secureJar.getPackages().removeIf(it -> EXCLUDES.stream().anyMatch(it::startsWith));
|
||||||
return new SimpleJarMetadata("arclight", null, secureJar.getPackages(),
|
return new SimpleJarMetadata("arclight", null, secureJar.getPackages(), List.of());
|
||||||
List.of(new SecureJar.Provider(
|
|
||||||
"cpw.mods.modlauncher.serviceapi.ILaunchPluginService",
|
|
||||||
List.of("io.izzel.arclight.common.asm.ArclightImplementer")
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,20 @@
|
||||||
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
|
import io.izzel.arclight.boot.ArclightImplementer_Forge;
|
||||||
import io.izzel.arclight.boot.ArclightLocator_Forge;
|
import io.izzel.arclight.boot.ArclightLocator_Forge;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||||
|
|
||||||
open module arclight.boot {
|
open module arclight.boot {
|
||||||
requires net.minecraftforge.forgespi;
|
requires net.minecraftforge.forgespi;
|
||||||
requires cpw.mods.securejarhandler;
|
requires cpw.mods.securejarhandler;
|
||||||
|
requires cpw.mods.modlauncher;
|
||||||
|
requires org.objectweb.asm;
|
||||||
requires jdk.unsupported;
|
requires jdk.unsupported;
|
||||||
|
requires org.objectweb.asm.tree;
|
||||||
|
|
||||||
exports io.izzel.arclight.boot;
|
exports io.izzel.arclight.boot;
|
||||||
uses net.minecraftforge.forgespi.locating.IModLocator;
|
|
||||||
provides net.minecraftforge.forgespi.locating.IModLocator with ArclightLocator_Forge;
|
uses IModLocator;
|
||||||
|
provides IModLocator with ArclightLocator_Forge;
|
||||||
|
uses ILaunchPluginService;
|
||||||
|
provides ILaunchPluginService with ArclightImplementer_Forge;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user