Disabled ModMenu for now

This commit is contained in:
Frank 2022-10-28 18:11:05 +02:00
parent ff77134ead
commit a071ad5052
4 changed files with 37 additions and 48 deletions

View file

@ -56,7 +56,7 @@ dependencies {
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modCompileOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
//modCompileOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
//modCompileOnly "dev.emi:emi:${emi_version}"
//modImplementation "dev.emi:emi:${emi_version}"

View file

@ -1,12 +1,10 @@
package org.betterx.bclib.client.gui.modmenu;
import org.betterx.bclib.integration.modmenu.ModMenuIntegration;
@Deprecated()
public class EntryPoint extends ModMenuIntegration {
public static final Object entrypointObject = createEntrypoint(new EntryPoint());
public class EntryPoint /*extends ModMenuIntegration*/ {
//public static final Object entrypointObject = createEntrypoint(new EntryPoint());
public EntryPoint() {
super(MainScreen::new);
//super(MainScreen::new);
}
}

View file

@ -1,12 +1,5 @@
package org.betterx.bclib.integration.modmenu;
import org.betterx.bclib.client.gui.modmenu.MainScreen;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
@ -14,7 +7,8 @@ import java.util.function.Function;
* Internal class to hook into ModMenu, you should not need to use this class. If you want to register a
* ModMenu Screen for a Mod using BCLib, use {@link ModMenu#addModMenuScreen(String, Function)}
*/
public class ModMenuEntryPoint implements ModMenuApi {
public class ModMenuEntryPoint {
}/*implements ModMenuApi {
@Override
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
Map<String, ConfigScreenFactory<?>> copy = new HashMap<>();
@ -31,4 +25,4 @@ public class ModMenuEntryPoint implements ModMenuApi {
}
}
}*/

View file

@ -2,11 +2,7 @@ package org.betterx.bclib.integration.modmenu;
import org.betterx.bclib.integration.modmenu.ModMenuIntegration.ModMenuScreenFactory;
import net.minecraft.client.gui.screens.Screen;
import com.google.common.collect.ImmutableMap;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@ -18,12 +14,13 @@ class ModMenuScreenFactoryImpl {
record ScreenFactoryInvocationHandler(ModMenuScreenFactory act) implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return switch (method.getName()) {
case "toString" -> "";
case "equals" -> false;
case "hashCode" -> 0;
default -> act.create((Screen) args[0]);
};
// return switch (method.getName()) {
// case "toString" -> "";
// case "equals" -> false;
// case "hashCode" -> 0;
// default -> act.create((Screen) args[0]);
// };
return null;
}
}
@ -78,25 +75,25 @@ public abstract class ModMenuIntegration {
* @param target The delegate Object that will receive calls from ModMenu
* @return A Proxy that conforms to the ModMenu spec
*/
public static ModMenuApi createEntrypoint(ModMenuIntegration target) {
Class<?> iModMenuAPI;
//Class<?> iModMenuAPIMarker = null;
try {
iModMenuAPI = Class.forName("com.terraformersmc.modmenu.api.ModMenuApi");
//iModMenuAPIMarker = Class.forName("com.terraformersmc.modmenu.util.ModMenuApiMarker");
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
Object o = Proxy.newProxyInstance(
ModMenuIntegration.class.getClassLoader(),
new Class[]{iModMenuAPI},
new BCLibModMenuInvocationHandler(target)
);
return (ModMenuApi) o;
}
// public static ModMenuApi createEntrypoint(ModMenuIntegration target) {
// Class<?> iModMenuAPI;
// //Class<?> iModMenuAPIMarker = null;
// try {
// iModMenuAPI = Class.forName("com.terraformersmc.modmenu.api.ModMenuApi");
// //iModMenuAPIMarker = Class.forName("com.terraformersmc.modmenu.util.ModMenuApiMarker");
// } catch (ClassNotFoundException e) {
// e.printStackTrace();
// return null;
// }
//
// Object o = Proxy.newProxyInstance(
// ModMenuIntegration.class.getClassLoader(),
// new Class[]{iModMenuAPI},
// new BCLibModMenuInvocationHandler(target)
// );
//
// return (ModMenuApi) o;
// }
/**
* The factory passed to {@link #ModMenuIntegration(ModMenuScreenFactory)}
@ -162,21 +159,21 @@ public abstract class ModMenuIntegration {
* <p>
* The Interface matches {@code com.terraformersmc.modmenu.api.ConfigScreenFactory}
*/
@FunctionalInterface
public interface ModMenuScreenFactory extends ConfigScreenFactory {
//@FunctionalInterface
public interface ModMenuScreenFactory /*extends ConfigScreenFactory*/ {
}
record BCLibModMenuInvocationHandler(ModMenuIntegration target) implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return switch (method.getName()) {
return null; /*switch (method.getName()) {
case "getModConfigScreenFactory" -> target.getModConfigScreenFactory();
case "getProvidedConfigScreenFactories" -> target.getProvidedConfigScreenFactories();
case "toString" -> target.toString();
case "equals" -> target.equals(args[0]);
case "hashCode" -> target.hashCode();
default -> null;
};
};*/
}
}