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.serviceapi.ILaunchPluginService;
|
||||
import io.izzel.arclight.api.ArclightVersion;
|
||||
import io.izzel.arclight.common.mod.util.log.ArclightI18nLogger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
@ -22,6 +23,12 @@ import java.util.function.Consumer;
|
|||
|
||||
public class ArclightImplementer implements ILaunchPluginService {
|
||||
|
||||
static {
|
||||
try {
|
||||
ArclightVersion.setVersion(ArclightVersion.v1_17_R1);
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
static final Logger LOGGER = ArclightI18nLogger.getLogger("Implementer");
|
||||
|
||||
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.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -35,7 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
public class InventoryImplementer implements Implementer {
|
||||
|
||||
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 final Map<String, Integer> map = new ConcurrentHashMap<>();
|
||||
|
@ -114,7 +113,7 @@ public class InventoryImplementer implements Implementer {
|
|||
for (MethodNode method : node.methods) {
|
||||
String desc = method.name + method.desc;
|
||||
methods.add(desc);
|
||||
if (desc.equals("func_70297_j_()I")) {
|
||||
if (desc.equals("m_6893_()I")) {
|
||||
stackLimitMethod = method;
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +175,7 @@ public class InventoryImplementer implements Implementer {
|
|||
stackLimitMethod.instructions.insert(list);
|
||||
} else {
|
||||
MethodNode methodNode = stackLimitMethod == null
|
||||
? new MethodNode(0, "func_70297_j_", "()I", null, null)
|
||||
? new MethodNode(0, "m_6893_()I", "()I", null, null)
|
||||
: stackLimitMethod;
|
||||
methodNode.access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC;
|
||||
int level = map.get(node.name);
|
||||
|
@ -223,21 +222,4 @@ public class InventoryImplementer implements Implementer {
|
|||
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.fmllegacy.network.FMLNetworkConstants;
|
||||
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.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
@Mod("arclight")
|
||||
public class ArclightMod {
|
||||
|
@ -18,10 +25,34 @@ public class ArclightMod {
|
|||
|
||||
public ArclightMod() {
|
||||
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();
|
||||
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
|
||||
() -> new IExtensionPoint.DisplayTest(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
|
||||
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": {
|
||||
"func_72838_d(Lnet/minecraft/entity/Entity;)Z": "entity add",
|
||||
"func_217465_m(Lnet/minecraft/entity/Entity;)V": "entity register",
|
||||
"removeEntityComplete(Lnet/minecraft/entity/Entity;Z)V": "entity unregister"
|
||||
"net/minecraft/server/level/ServerLevel": {
|
||||
"m_8872_(Lnet/minecraft/world/entity/Entity;)Z": "entity add",
|
||||
"m_142646_()Lnet/minecraft/world/level/entity/LevelEntityGetter;": "chunk entity get"
|
||||
},
|
||||
"net/minecraft/world/server/ChunkManager$EntityTracker": {
|
||||
"func_219399_a(Lnet/minecraft/entity/player/ServerPlayerEntity;)V": "player tracker clear",
|
||||
"func_219400_b(Lnet/minecraft/entity/player/ServerPlayerEntity;)V": "player tracker update"
|
||||
"net/minecraft/server/level/ServerLevel$EntityCallbacks": {
|
||||
"m_141985_(Lnet/minecraft/world/entity/Entity;)V": "entity register",
|
||||
"m_141981_(Lnet/minecraft/world/entity/Entity;)V": "entity unregister"
|
||||
},
|
||||
"net/minecraft/block/Block": {
|
||||
"func_220082_b(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Z)V": "block place",
|
||||
"func_196243_a(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Z)V": "block remove"
|
||||
"net/minecraft/server/level/ChunkMap$TrackedEntity": {
|
||||
"m_140485_(Lnet/minecraft/server/level/ServerPlayer;)V": "player tracker clear",
|
||||
"m_140497_(Lnet/minecraft/server/level/ServerPlayer;)V": "player tracker update"
|
||||
},
|
||||
"net/minecraft/entity/LivingEntity": {
|
||||
"func_195064_c(Lnet/minecraft/potion/EffectInstance;)Z": "effect add"
|
||||
"net/minecraft/world/level/block/state/BlockBehaviour": {
|
||||
"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": {
|
||||
"func_219210_a(Lnet/minecraft/entity/Entity;)V": "entity track",
|
||||
"func_219231_b(Lnet/minecraft/entity/Entity;)V": "entity untrack"
|
||||
"net/minecraft/world/entity/LivingEntity": {
|
||||
"m_147207_(Lnet/minecraft/world/effect/MobEffectInstance;Lnet/minecraft/world/entity/Entity;)Z": "effect add"
|
||||
},
|
||||
"net/minecraft/world/chunk/Chunk": {
|
||||
"func_177414_a(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/List;Ljava/util/function/Predicate;)V": "chunk entity get",
|
||||
"func_217313_a(Lnet/minecraft/entity/EntityType;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/List;Ljava/util/function/Predicate;)V": "chunk entity get",
|
||||
"func_177430_a(Ljava/lang/Class;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/List;Ljava/util/function/Predicate;)V": "chunk entity get"
|
||||
"net/minecraft/server/level/ChunkMap": {
|
||||
"m_140199_(Lnet/minecraft/world/entity/Entity;)V": "entity track",
|
||||
"m_140331_(Lnet/minecraft/world/entity/Entity;)V": "entity untrack"
|
||||
},
|
||||
"net/minecraft/loot/LootTable": {
|
||||
"func_216118_a(Lnet/minecraft/inventory/IInventory;Lnet/minecraft/loot/LootContext;)V": "loot generate"
|
||||
"net/minecraft/world/level/storage/loot/LootTable": {
|
||||
"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() {
|
||||
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 lookup = MethodHandles.lookup();
|
||||
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) {
|
||||
secureJar.getPackages().removeIf(it -> EXCLUDES.stream().anyMatch(it::startsWith));
|
||||
return new SimpleJarMetadata("arclight", null, secureJar.getPackages(),
|
||||
List.of(new SecureJar.Provider(
|
||||
"cpw.mods.modlauncher.serviceapi.ILaunchPluginService",
|
||||
List.of("io.izzel.arclight.common.asm.ArclightImplementer")
|
||||
)));
|
||||
return new SimpleJarMetadata("arclight", null, secureJar.getPackages(), List.of());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 net.minecraftforge.forgespi.locating.IModLocator;
|
||||
|
||||
open module arclight.boot {
|
||||
requires net.minecraftforge.forgespi;
|
||||
requires cpw.mods.securejarhandler;
|
||||
requires cpw.mods.modlauncher;
|
||||
requires org.objectweb.asm;
|
||||
requires jdk.unsupported;
|
||||
requires org.objectweb.asm.tree;
|
||||
|
||||
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