mark Loom 0.2.0, update Mixin library
parent
a39d0b6656
commit
baaf430fd8
|
@ -11,7 +11,7 @@ targetCompatibility = 1.8
|
|||
|
||||
group = 'net.fabricmc'
|
||||
archivesBaseName = project.name
|
||||
version = '0.1.1-SNAPSHOT'
|
||||
version = '0.2.0-SNAPSHOT'
|
||||
|
||||
def build = "local"
|
||||
def ENV = System.getenv()
|
||||
|
@ -25,10 +25,6 @@ repositories {
|
|||
name = "Fabric"
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
maven {
|
||||
name = "SonaType"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -45,7 +41,7 @@ dependencies {
|
|||
// implementation ('org.benf:cfr:0.136')
|
||||
implementation ('org.jetbrains:intellij-fernflower:1.0.0.2')
|
||||
|
||||
implementation ('net.fabricmc:sponge-mixin:0.7.11.10') {
|
||||
implementation ('net.fabricmc:sponge-mixin:0.7.11.12:full') {
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
}
|
||||
|
|
|
@ -25,41 +25,109 @@
|
|||
package net.fabricmc.loom.mixin;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import org.spongepowered.asm.service.IClassBytecodeProvider;
|
||||
import org.spongepowered.asm.service.mojang.MixinServiceLaunchWrapper;
|
||||
import com.strobel.collections.ImmutableList;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.service.*;
|
||||
import org.spongepowered.asm.util.ReEntranceLock;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
public class MixinServiceGradle extends MixinServiceLaunchWrapper implements IClassBytecodeProvider {
|
||||
|
||||
public class MixinServiceGradle implements IClassBytecodeProvider, IClassProvider, IMixinService {
|
||||
private static List<JarFile> jars = new ArrayList<>();
|
||||
private final ReEntranceLock lock = new ReEntranceLock(1);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "FabricGradle";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MixinEnvironment.Phase getInitialPhase() {
|
||||
return MixinEnvironment.Phase.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginPhase() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkEnv(Object bootSource) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReEntranceLock getReEntranceLock() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClassProvider getClassProvider() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String name) {
|
||||
for (JarFile file : jars) {
|
||||
ZipEntry entry = file.getEntry(name);
|
||||
if(entry != null){
|
||||
try {
|
||||
InputStream stream = file.getInputStream(entry);
|
||||
return stream;
|
||||
return file.getInputStream(entry);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to read mod file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getResourceAsStream(name);
|
||||
|
||||
return getClass().getClassLoader().getResourceAsStream(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerInvalidClass(String className) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClassLoaded(String className) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassRestrictions(String className) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ITransformer> getTransformers() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSideName() {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
public static void setupModFiles(Set<File> mods, File minecraft) throws IOException {
|
||||
|
@ -76,13 +144,48 @@ public class MixinServiceGradle extends MixinServiceLaunchWrapper implements ICl
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getPlatformAgents() {
|
||||
return ImmutableList.of("org.spongepowered.asm.launch.platform.MixinPlatformAgentDefault");
|
||||
}
|
||||
|
||||
public byte[] getClassBytes(String name, String transformedName) throws IOException {
|
||||
InputStream inputStream = getResourceAsStream(name.replace(".", "/") + ".class");
|
||||
byte[] classBytes = ByteStreams.toByteArray(inputStream);
|
||||
inputStream.close();
|
||||
if(classBytes == null){
|
||||
return super.getClassBytes(name, transformedName);
|
||||
}
|
||||
return classBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getClassBytes(String name, boolean runTransformers) throws ClassNotFoundException, IOException {
|
||||
return getClassBytes(name, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassNode getClassNode(String name) throws ClassNotFoundException, IOException {
|
||||
ClassReader reader = new ClassReader(getClassBytes(name, name));
|
||||
ClassNode node = new ClassNode();
|
||||
reader.accept(node, 0);
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL[] getClassPath() {
|
||||
return new URL[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> findClass(String name) throws ClassNotFoundException {
|
||||
return Class.forName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> findClass(String name, boolean initialize) throws ClassNotFoundException {
|
||||
return Class.forName(name, initialize, getClass().getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> findAgentClass(String name, boolean initialize) throws ClassNotFoundException {
|
||||
return Class.forName(name, initialize, getClass().getClassLoader());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue