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() mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_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}" //modCompileOnly "dev.emi:emi:${emi_version}"
//modImplementation "dev.emi:emi:${emi_version}" //modImplementation "dev.emi:emi:${emi_version}"

View file

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

View file

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