Merge remote-tracking branch 'origin/1.19.2' into 1.19.4
This commit is contained in:
commit
e45acac6b6
13
build.gradle
13
build.gradle
|
|
@ -28,6 +28,10 @@ allprojects {
|
|||
}
|
||||
}
|
||||
|
||||
architectury {
|
||||
compileOnly()
|
||||
}
|
||||
|
||||
group = 'org.embeddedt'
|
||||
// extract base version from tag, generate other metadata ourselves
|
||||
def details = versionDetails()
|
||||
|
|
@ -200,6 +204,15 @@ configure(subprojects.findAll {it.name == "forge" || it.name == "fabric"}) {
|
|||
apply plugin: 'com.matthewprenger.cursegradle'
|
||||
apply plugin: 'com.modrinth.minotaur'
|
||||
|
||||
loom {
|
||||
mods {
|
||||
main { // to match the default mod generated for Forge
|
||||
sourceSet project.sourceSets.main
|
||||
sourceSet project(':common').sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def copyJarNameConsistent = tasks.register('copyJarNameConsistent', Copy) {
|
||||
from remapJar // shortcut for createJar.outputs.files
|
||||
into project.file("build/libs")
|
||||
|
|
|
|||
|
|
@ -50,15 +50,15 @@ public class ModernFix {
|
|||
INSTANCE = this;
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.snapshot_easter_egg.NameChange") && !SharedConstants.getCurrentVersion().isStable())
|
||||
NAME = "PreemptiveFix";
|
||||
ModernFixPlatformHooks.onServerCommandRegister(ModernFixCommands::register);
|
||||
ModernFixPlatformHooks.INSTANCE.onServerCommandRegister(ModernFixCommands::register);
|
||||
}
|
||||
|
||||
public void onServerStarted() {
|
||||
if(ModernFixPlatformHooks.isDedicatedServer()) {
|
||||
if(ModernFixPlatformHooks.INSTANCE.isDedicatedServer()) {
|
||||
float gameStartTime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.measure_time.ServerLoad"))
|
||||
ModernFix.LOGGER.warn("Dedicated server took " + gameStartTime + " seconds to load");
|
||||
ModernFixPlatformHooks.onLaunchComplete();
|
||||
ModernFixPlatformHooks.INSTANCE.onLaunchComplete();
|
||||
}
|
||||
ClassInfoManager.clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ public class ModernFixClient {
|
|||
// clear reserve as it's not needed
|
||||
MemoryReserve.release();
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.branding.F3Screen")) {
|
||||
brandingString = ModernFix.NAME + " " + ModernFixPlatformHooks.getVersionString();
|
||||
brandingString = ModernFix.NAME + " " + ModernFixPlatformHooks.INSTANCE.getVersionString();
|
||||
}
|
||||
SearchTreeProviderRegistry.register(JEIBackedSearchTree.PROVIDER);
|
||||
SearchTreeProviderRegistry.register(REIBackedSearchTree.PROVIDER);
|
||||
for(String className : ModernFixPlatformHooks.getCustomModOptions().get(IntegrationConstants.CLIENT_INTEGRATION_CLASS)) {
|
||||
for(String className : ModernFixPlatformHooks.INSTANCE.getCustomModOptions().get(IntegrationConstants.CLIENT_INTEGRATION_CLASS)) {
|
||||
try {
|
||||
CLIENT_INTEGRATIONS.add((ModernFixClientIntegration)Class.forName(className).getDeclaredConstructor().newInstance());
|
||||
} catch(ReflectiveOperationException | ClassCastException e) {
|
||||
|
|
@ -73,7 +73,7 @@ public class ModernFixClient {
|
|||
gameStartTimeSeconds = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.measure_time.GameLoad"))
|
||||
ModernFix.LOGGER.warn("Game took " + gameStartTimeSeconds + " seconds to start");
|
||||
ModernFixPlatformHooks.onLaunchComplete();
|
||||
ModernFixPlatformHooks.INSTANCE.onLaunchComplete();
|
||||
ClassInfoManager.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public abstract class MinecraftMixin {
|
|||
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, nameSupplier);
|
||||
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, tagSupplier);
|
||||
this.searchRegistry.register(SearchRegistry.RECIPE_COLLECTIONS, list -> new DummySearchTree<>());
|
||||
ModernFixPlatformHooks.registerCreativeSearchTrees(this.searchRegistry, nameSupplier, tagSupplier, this::populateSearchTree);
|
||||
ModernFixPlatformHooks.INSTANCE.registerCreativeSearchTrees(this.searchRegistry, nameSupplier, tagSupplier, this::populateSearchTree);
|
||||
// grab components for all key mappings in order to prevent them from being loaded off-thread later
|
||||
// this populates the LazyLoadedValues
|
||||
// we also need to suppress GLFW errors to prevent crashes if a key is missing
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class StitcherMixin<T extends Stitcher.Entry> {
|
|||
*/
|
||||
@Inject(method = "stitch", at = @At("HEAD"), cancellable = true)
|
||||
private void stitchFast(CallbackInfo ci) {
|
||||
if(!ModernFixPlatformHooks.isLoadingNormally()) {
|
||||
if(!ModernFixPlatformHooks.INSTANCE.isLoadingNormally()) {
|
||||
ModernFix.LOGGER.error("Using vanilla stitcher implementation due to invalid loading state");
|
||||
return;
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ public class StitcherMixin<T extends Stitcher.Entry> {
|
|||
*/
|
||||
@Inject(method = "gatherSprites", at = @At("HEAD"), cancellable = true)
|
||||
private void gatherSpritesFast(Stitcher.SpriteLoader<T> spriteLoader, CallbackInfo ci) {
|
||||
if(!ModernFixPlatformHooks.isLoadingNormally())
|
||||
if(!ModernFixPlatformHooks.INSTANCE.isLoadingNormally())
|
||||
return;
|
||||
ci.cancel();
|
||||
for(StbStitcher.LoadableSpriteInfo<T> info : loadableSpriteInfos) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
|
|||
|
||||
public ModernFixMixinPlugin() {
|
||||
/* invoke early to ensure it gets read on one thread */
|
||||
ModernFixPlatformHooks.getCustomModOptions();
|
||||
ModernFixPlatformHooks.INSTANCE.getCustomModOptions();
|
||||
boolean firstConfig = instance == null;
|
||||
if(firstConfig) {
|
||||
instance = this;
|
||||
|
|
@ -33,7 +33,7 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
|
|||
}
|
||||
|
||||
this.logger.info("Loaded configuration file for ModernFix {}: {} options available, {} override(s) found",
|
||||
ModernFixPlatformHooks.getVersionString(), config.getOptionCount(), config.getOptionOverrideCount());
|
||||
ModernFixPlatformHooks.INSTANCE.getVersionString(), config.getOptionCount(), config.getOptionOverrideCount());
|
||||
|
||||
config.getOptionMap().values().forEach(option -> {
|
||||
if (option.isOverridden()) {
|
||||
|
|
@ -41,7 +41,7 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
|
|||
|
||||
if (option.isUserDefined()) {
|
||||
source = "user configuration";
|
||||
} else if (!ModernFixPlatformHooks.isEarlyLoadingNormally()) {
|
||||
} else if (!ModernFixPlatformHooks.INSTANCE.isEarlyLoadingNormally()) {
|
||||
source = "load error";
|
||||
} else if (option.isModDefined()) {
|
||||
source = "mods [" + String.join(", ", option.getDefiningMods()) + "]";
|
||||
|
|
@ -64,7 +64,7 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
|
|||
}
|
||||
|
||||
/* We abuse the constructor of a mixin plugin as a safe location to start modifying the classloader */
|
||||
ModernFixPlatformHooks.injectPlatformSpecificHacks();
|
||||
ModernFixPlatformHooks.INSTANCE.injectPlatformSpecificHacks();
|
||||
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.spam_thread_dump.ThreadDumper")) {
|
||||
// run once to trigger classloading
|
||||
|
|
@ -119,7 +119,7 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
|
|||
|
||||
if (option == null) {
|
||||
String msg = "No rules matched mixin '{}', treating as foreign and disabling!";
|
||||
if(ModernFixPlatformHooks.isDevEnv())
|
||||
if(ModernFixPlatformHooks.INSTANCE.isDevEnv())
|
||||
this.logger.error(msg, mixin);
|
||||
else
|
||||
this.logger.debug(msg, mixin);
|
||||
|
|
@ -146,6 +146,6 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
|
|||
|
||||
@Override
|
||||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
ModernFixPlatformHooks.applyASMTransformers(mixinClassName, targetClass);
|
||||
ModernFixPlatformHooks.INSTANCE.applyASMTransformers(mixinClassName, targetClass);
|
||||
}
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ public class ModernFixEarlyConfig {
|
|||
if(modId.equals("optifine"))
|
||||
return OPTIFINE_PRESENT;
|
||||
else
|
||||
return ModernFixPlatformHooks.modPresent(modId);
|
||||
return ModernFixPlatformHooks.INSTANCE.modPresent(modId);
|
||||
}
|
||||
|
||||
private static final String MIXIN_DESC = Type.getDescriptor(Mixin.class);
|
||||
|
|
@ -122,11 +122,11 @@ public class ModernFixEarlyConfig {
|
|||
isDevOnly = true;
|
||||
}
|
||||
}
|
||||
if(isMixin && (!isDevOnly || ModernFixPlatformHooks.isDevEnv())) {
|
||||
if(isMixin && (!isDevOnly || ModernFixPlatformHooks.INSTANCE.isDevEnv())) {
|
||||
String mixinClassName = sanitize(node.name.replace('/', '.')).replace("org.embeddedt.modernfix.mixin.", "");
|
||||
if(!requiredModPresent)
|
||||
mixinsMissingMods.put(mixinClassName, requiredModId);
|
||||
else if(isClientOnly && !ModernFixPlatformHooks.isClient())
|
||||
else if(isClientOnly && !ModernFixPlatformHooks.INSTANCE.isClient())
|
||||
mixinsMissingMods.put(mixinClassName, "[not client]");
|
||||
List<String> mixinOptionNames = dotSplitter.splitToList(mixinClassName);
|
||||
StringBuilder optionBuilder = new StringBuilder(mixinClassName.length());
|
||||
|
|
@ -150,7 +150,7 @@ public class ModernFixEarlyConfig {
|
|||
}
|
||||
}
|
||||
|
||||
private static final boolean isDevEnv = ModernFixPlatformHooks.isDevEnv();
|
||||
private static final boolean isDevEnv = ModernFixPlatformHooks.INSTANCE.isDevEnv();
|
||||
|
||||
private static class DefaultSettingMapBuilder extends ImmutableMap.Builder<String, Boolean> {
|
||||
public DefaultSettingMapBuilder putConditionally(BooleanSupplier condition, String k, Boolean v) {
|
||||
|
|
@ -169,7 +169,7 @@ public class ModernFixEarlyConfig {
|
|||
private static final ImmutableMap<String, Boolean> DEFAULT_SETTING_OVERRIDES = new DefaultSettingMapBuilder()
|
||||
.put("mixin.perf.dynamic_resources", false)
|
||||
.put("mixin.feature.direct_stack_trace", false)
|
||||
.putConditionally(ModernFixPlatformHooks::isDevEnv, "mixin.perf.rewrite_registry", false)
|
||||
.putConditionally(ModernFixPlatformHooks.INSTANCE::isDevEnv, "mixin.perf.rewrite_registry", false)
|
||||
.put("mixin.perf.clear_mixin_classinfo", false)
|
||||
.put("mixin.perf.deduplicate_climate_parameters", false)
|
||||
.put("mixin.bugfix.packet_leak", false)
|
||||
|
|
@ -242,7 +242,7 @@ public class ModernFixEarlyConfig {
|
|||
|
||||
private void disableIfModPresent(String configName, String... ids) {
|
||||
for(String id : ids) {
|
||||
if(!ModernFixPlatformHooks.isEarlyLoadingNormally() || modPresent(id)) {
|
||||
if(!ModernFixPlatformHooks.INSTANCE.isEarlyLoadingNormally() || modPresent(id)) {
|
||||
Option option = this.options.get(configName);
|
||||
if(option != null)
|
||||
option.addModOverride(false, id);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class EntityDataIDSyncHandler {
|
|||
}
|
||||
EntityIDSyncPacket packet = new EntityIDSyncPacket(fieldsToSyncMap);
|
||||
ModernFix.LOGGER.debug("Sending ID correction packet to client with " + fieldsToSyncMap.size() + " classes");
|
||||
ModernFixPlatformHooks.sendPacket(targetPlayer, packet);
|
||||
ModernFixPlatformHooks.INSTANCE.sendPacket(targetPlayer, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package org.embeddedt.modernfix.platform;
|
|||
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.architectury.injectables.annotations.ExpectPlatform;
|
||||
import net.minecraft.client.searchtree.SearchRegistry;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
|
@ -15,89 +14,86 @@ import java.util.List;
|
|||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ModernFixPlatformHooks {
|
||||
@ExpectPlatform
|
||||
public static boolean isClient() {
|
||||
public interface ModernFixPlatformHooks {
|
||||
ModernFixPlatformHooks INSTANCE = PlatformHookLoader.findInstance();
|
||||
|
||||
default boolean isClient() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static boolean isDedicatedServer() {
|
||||
|
||||
default boolean isDedicatedServer() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static String getVersionString() {
|
||||
|
||||
default String getVersionString() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static boolean modPresent(String modId) {
|
||||
|
||||
default boolean modPresent(String modId) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static boolean isDevEnv() {
|
||||
|
||||
default boolean isDevEnv() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static void injectPlatformSpecificHacks() {
|
||||
|
||||
default void injectPlatformSpecificHacks() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static void applyASMTransformers(String mixinClassName, ClassNode targetClass) {
|
||||
|
||||
default void applyASMTransformers(String mixinClassName, ClassNode targetClass) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static MinecraftServer getCurrentServer() {
|
||||
|
||||
default MinecraftServer getCurrentServer() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static boolean isEarlyLoadingNormally() {
|
||||
|
||||
default boolean isEarlyLoadingNormally() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static boolean isLoadingNormally() {
|
||||
|
||||
default boolean isLoadingNormally() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static Path getGameDirectory() {
|
||||
default Path getGameDirectory() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static void sendPacket(ServerPlayer player, Object packet) {
|
||||
|
||||
default void sendPacket(ServerPlayer player, Object packet) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static void onServerCommandRegister(Consumer<CommandDispatcher<CommandSourceStack>> handler) {
|
||||
|
||||
default void onServerCommandRegister(Consumer<CommandDispatcher<CommandSourceStack>> handler) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static Multimap<String, String> getCustomModOptions() {
|
||||
|
||||
default Multimap<String, String> getCustomModOptions() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static void registerCreativeSearchTrees(SearchRegistry registry, SearchRegistry.TreeBuilderSupplier<ItemStack> nameSupplier, SearchRegistry.TreeBuilderSupplier<ItemStack> tagSupplier, BiConsumer<SearchRegistry.Key<ItemStack>, List<ItemStack>> populator) {
|
||||
default void registerCreativeSearchTrees(SearchRegistry registry, SearchRegistry.TreeBuilderSupplier<ItemStack> nameSupplier, SearchRegistry.TreeBuilderSupplier<ItemStack> tagSupplier, BiConsumer<SearchRegistry.Key<ItemStack>, List<ItemStack>> populator) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
default void onLaunchComplete() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static void onLaunchComplete() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
public static String getPlatformName() {
|
||||
default String getPlatformName() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package org.embeddedt.modernfix.platform;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
class PlatformHookLoader {
|
||||
static ModernFixPlatformHooks findInstance() {
|
||||
String[] locations = new String[] { "forge", "fabric" };
|
||||
for(String location : locations) {
|
||||
try {
|
||||
Class<?> clz = Class.forName("org.embeddedt.modernfix.platform." + location + ".ModernFixPlatformHooksImpl");
|
||||
Constructor<?> constructor = clz.getConstructor();
|
||||
constructor.setAccessible(true);
|
||||
return (ModernFixPlatformHooks)constructor.newInstance();
|
||||
} catch(ClassNotFoundException ignored) {
|
||||
} catch(ReflectiveOperationException | ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.err.println("ModernFix has failed to load platform hooks. It cannot function, the game will now close");
|
||||
Runtime.getRuntime().exit(1);
|
||||
throw new AssertionError("Somehow couldn't exit");
|
||||
}
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ public class PackResourcesCacheEngine {
|
|||
}
|
||||
|
||||
public static void invalidate() {
|
||||
if(!ModernFixPlatformHooks.isDevEnv())
|
||||
if(!ModernFixPlatformHooks.INSTANCE.isDevEnv())
|
||||
return;
|
||||
synchronized (cachingPacks) {
|
||||
cachingPacks.keySet().forEach(pack -> {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public class OptionList extends ContainerObjectSelectionList<OptionList.Entry> {
|
|||
}).pos(75, 0).size(20, 20).build();
|
||||
if(!I18n.exists("modernfix.option." + optionName)) {
|
||||
this.helpButton.active = false;
|
||||
if(ModernFixPlatformHooks.isDevEnv() && OPTIONS_MISSING_HELP.add(optionName))
|
||||
if(ModernFixPlatformHooks.INSTANCE.isDevEnv() && OPTIONS_MISSING_HELP.add(optionName))
|
||||
ModernFix.LOGGER.warn("Missing help for {}", optionName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class JEIBackedSearchTree extends DummySearchTree<ItemStack> {
|
|||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
return ModernFixPlatformHooks.modPresent("jei") && !ModernFixPlatformHooks.modPresent("emi") && getIngredientListUncached != null && filterField != null;
|
||||
return ModernFixPlatformHooks.INSTANCE.modPresent("jei") && !ModernFixPlatformHooks.INSTANCE.modPresent("emi") && getIngredientListUncached != null && filterField != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class REIBackedSearchTree extends DummySearchTree<ItemStack> {
|
|||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
return ModernFixPlatformHooks.modPresent("roughlyenoughitems");
|
||||
return ModernFixPlatformHooks.INSTANCE.modPresent("roughlyenoughitems");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -87,17 +87,17 @@ public class SparkLaunchProfiler {
|
|||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return ModernFixPlatformHooks.isClient() ? Type.CLIENT : Type.SERVER;
|
||||
return ModernFixPlatformHooks.INSTANCE.isClient() ? Type.CLIENT : Type.SERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ModernFixPlatformHooks.getPlatformName();
|
||||
return ModernFixPlatformHooks.INSTANCE.getPlatformName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return ModernFixPlatformHooks.getVersionString();
|
||||
return ModernFixPlatformHooks.INSTANCE.getVersionString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -146,7 +146,7 @@ public class SparkLaunchProfiler {
|
|||
|
||||
@Override
|
||||
public Path getPluginDirectory() {
|
||||
return ModernFixPlatformHooks.getGameDirectory().resolve("spark-modernfix");
|
||||
return ModernFixPlatformHooks.INSTANCE.getGameDirectory().resolve("spark-modernfix");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class CachingStructureManager {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
private static final File STRUCTURE_CACHE_FOLDER = FileUtil.childFile(ModernFixPlatformHooks.getGameDirectory().resolve("modernfix").resolve("structureCacheV1").toFile());
|
||||
private static final File STRUCTURE_CACHE_FOLDER = FileUtil.childFile(ModernFixPlatformHooks.INSTANCE.getGameDirectory().resolve("modernfix").resolve("structureCacheV1").toFile());
|
||||
|
||||
static {
|
||||
STRUCTURE_CACHE_FOLDER.mkdirs();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ configurations {
|
|||
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentFabric.extendsFrom common
|
||||
|
||||
modIncludeImplementation
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ import net.minecraft.world.item.ItemStack;
|
|||
import org.embeddedt.modernfix.ModernFixFabric;
|
||||
import org.embeddedt.modernfix.api.constants.IntegrationConstants;
|
||||
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
|
||||
import org.embeddedt.modernfix.platform.ModernFixPlatformHooks;
|
||||
import org.embeddedt.modernfix.spark.SparkLaunchProfiler;
|
||||
import org.embeddedt.modernfix.util.CommonModUtil;
|
||||
import org.objectweb.asm.tree.*;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
|
@ -28,18 +29,18 @@ import java.util.Map;
|
|||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ModernFixPlatformHooksImpl {
|
||||
public static boolean isClient() {
|
||||
public class ModernFixPlatformHooksImpl implements ModernFixPlatformHooks {
|
||||
public boolean isClient() {
|
||||
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT;
|
||||
}
|
||||
|
||||
public static boolean isDedicatedServer() {
|
||||
public boolean isDedicatedServer() {
|
||||
return FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER;
|
||||
}
|
||||
|
||||
private static String verString;
|
||||
|
||||
public static String getVersionString() {
|
||||
public String getVersionString() {
|
||||
if(verString == null) {
|
||||
ModContainer mfModContainer = FabricLoader.getInstance().getModContainer("modernfix").get();
|
||||
verString = mfModContainer.getMetadata().getVersion().getFriendlyString();
|
||||
|
|
@ -47,47 +48,47 @@ public class ModernFixPlatformHooksImpl {
|
|||
return verString;
|
||||
}
|
||||
|
||||
public static boolean modPresent(String modId) {
|
||||
public boolean modPresent(String modId) {
|
||||
return FabricLoader.getInstance().getModContainer(modId).isPresent();
|
||||
}
|
||||
|
||||
public static boolean isDevEnv() {
|
||||
public boolean isDevEnv() {
|
||||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||
}
|
||||
|
||||
public static MinecraftServer getCurrentServer() {
|
||||
public MinecraftServer getCurrentServer() {
|
||||
return ModernFixFabric.theServer.get();
|
||||
}
|
||||
|
||||
public static boolean isEarlyLoadingNormally() {
|
||||
public boolean isEarlyLoadingNormally() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isLoadingNormally() {
|
||||
public boolean isLoadingNormally() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Path getGameDirectory() {
|
||||
public Path getGameDirectory() {
|
||||
return FabricLoader.getInstance().getGameDir();
|
||||
}
|
||||
|
||||
public static void sendPacket(ServerPlayer player, Object packet) {
|
||||
public void sendPacket(ServerPlayer player, Object packet) {
|
||||
//PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), packet);
|
||||
}
|
||||
|
||||
public static void injectPlatformSpecificHacks() {
|
||||
public void injectPlatformSpecificHacks() {
|
||||
}
|
||||
|
||||
public static void applyASMTransformers(String mixinClassName, ClassNode targetClass) {
|
||||
public void applyASMTransformers(String mixinClassName, ClassNode targetClass) {
|
||||
|
||||
}
|
||||
|
||||
public static void onServerCommandRegister(Consumer<CommandDispatcher<CommandSourceStack>> handler) {
|
||||
public void onServerCommandRegister(Consumer<CommandDispatcher<CommandSourceStack>> handler) {
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, arg, env) -> handler.accept(dispatcher));
|
||||
}
|
||||
|
||||
private static Multimap<String, String> modOptions;
|
||||
public static Multimap<String, String> getCustomModOptions() {
|
||||
public Multimap<String, String> getCustomModOptions() {
|
||||
if(modOptions == null) {
|
||||
modOptions = ArrayListMultimap.create();
|
||||
for (ModContainer container : FabricLoader.getInstance().getAllMods()) {
|
||||
|
|
@ -108,21 +109,20 @@ public class ModernFixPlatformHooksImpl {
|
|||
return modOptions;
|
||||
}
|
||||
|
||||
|
||||
public static void registerCreativeSearchTrees(SearchRegistry registry, SearchRegistry.TreeBuilderSupplier<ItemStack> nameSupplier, SearchRegistry.TreeBuilderSupplier<ItemStack> tagSupplier, BiConsumer<SearchRegistry.Key<ItemStack>, List<ItemStack>> populator) {
|
||||
public void registerCreativeSearchTrees(SearchRegistry registry, SearchRegistry.TreeBuilderSupplier<ItemStack> nameSupplier, SearchRegistry.TreeBuilderSupplier<ItemStack> tagSupplier, BiConsumer<SearchRegistry.Key<ItemStack>, List<ItemStack>> populator) {
|
||||
CreativeModeTabs.searchTab().setSearchTreeBuilder((list) -> {
|
||||
populator.accept(SearchRegistry.CREATIVE_NAMES, list);
|
||||
populator.accept(SearchRegistry.CREATIVE_TAGS, list);
|
||||
});
|
||||
}
|
||||
|
||||
public static void onLaunchComplete() {
|
||||
public void onLaunchComplete() {
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.spark_profile_launch.OnFabric")) {
|
||||
CommonModUtil.runWithoutCrash(() -> SparkLaunchProfiler.stop("launch"), "Failed to stop profiler");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPlatformName() {
|
||||
public String getPlatformName() {
|
||||
return "Fabric";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ configurations {
|
|||
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentForge.extendsFrom common
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
|
|||
import org.embeddedt.modernfix.forge.classloading.FastAccessTransformerList;
|
||||
import org.embeddedt.modernfix.forge.config.NightConfigFixer;
|
||||
import org.embeddedt.modernfix.forge.packet.PacketHandler;
|
||||
import org.embeddedt.modernfix.platform.ModernFixPlatformHooks;
|
||||
import org.embeddedt.modernfix.spark.SparkLaunchProfiler;
|
||||
import org.embeddedt.modernfix.util.CommonModUtil;
|
||||
import org.embeddedt.modernfix.util.DummyList;
|
||||
|
|
@ -39,18 +40,18 @@ import java.util.Objects;
|
|||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ModernFixPlatformHooksImpl {
|
||||
public static boolean isClient() {
|
||||
public class ModernFixPlatformHooksImpl implements ModernFixPlatformHooks {
|
||||
public boolean isClient() {
|
||||
return FMLLoader.getDist() == Dist.CLIENT;
|
||||
}
|
||||
|
||||
public static boolean isDedicatedServer() {
|
||||
public boolean isDedicatedServer() {
|
||||
return FMLLoader.getDist().isDedicatedServer();
|
||||
}
|
||||
|
||||
private static String verString;
|
||||
|
||||
public static String getVersionString() {
|
||||
public String getVersionString() {
|
||||
if(verString == null) {
|
||||
try {
|
||||
verString = ModernFixMixinPlugin.class.getPackage().getImplementationVersion();
|
||||
|
|
@ -62,35 +63,35 @@ public class ModernFixPlatformHooksImpl {
|
|||
return verString;
|
||||
}
|
||||
|
||||
public static boolean modPresent(String modId) {
|
||||
public boolean modPresent(String modId) {
|
||||
return FMLLoader.getLoadingModList().getModFileById(modId) != null;
|
||||
}
|
||||
|
||||
public static boolean isDevEnv() {
|
||||
public boolean isDevEnv() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
|
||||
public static MinecraftServer getCurrentServer() {
|
||||
public MinecraftServer getCurrentServer() {
|
||||
return ServerLifecycleHooks.getCurrentServer();
|
||||
}
|
||||
|
||||
public static boolean isEarlyLoadingNormally() {
|
||||
public boolean isEarlyLoadingNormally() {
|
||||
return LoadingModList.get().getErrors().isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isLoadingNormally() {
|
||||
public boolean isLoadingNormally() {
|
||||
return isEarlyLoadingNormally() && ModLoader.isLoadingStateValid();
|
||||
}
|
||||
|
||||
public static Path getGameDirectory() {
|
||||
public Path getGameDirectory() {
|
||||
return FMLPaths.GAMEDIR.get();
|
||||
}
|
||||
|
||||
public static void sendPacket(ServerPlayer player, Object packet) {
|
||||
public void sendPacket(ServerPlayer player, Object packet) {
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), packet);
|
||||
}
|
||||
|
||||
public static void injectPlatformSpecificHacks() {
|
||||
public void injectPlatformSpecificHacks() {
|
||||
FastAccessTransformerList.attemptReplace();
|
||||
|
||||
/* https://github.com/FabricMC/Mixin/pull/99 */
|
||||
|
|
@ -112,18 +113,18 @@ public class ModernFixPlatformHooksImpl {
|
|||
NightConfigFixer.monitorFileWatcher();
|
||||
}
|
||||
|
||||
public static void applyASMTransformers(String mixinClassName, ClassNode targetClass) {
|
||||
public void applyASMTransformers(String mixinClassName, ClassNode targetClass) {
|
||||
|
||||
}
|
||||
|
||||
public static void onServerCommandRegister(Consumer<CommandDispatcher<CommandSourceStack>> handler) {
|
||||
public void onServerCommandRegister(Consumer<CommandDispatcher<CommandSourceStack>> handler) {
|
||||
MinecraftForge.EVENT_BUS.addListener((RegisterCommandsEvent event) -> {
|
||||
handler.accept(event.getDispatcher());
|
||||
});
|
||||
}
|
||||
|
||||
private static Multimap<String, String> modOptions;
|
||||
public static Multimap<String, String> getCustomModOptions() {
|
||||
public Multimap<String, String> getCustomModOptions() {
|
||||
if(modOptions == null) {
|
||||
modOptions = ArrayListMultimap.create();
|
||||
for (ModInfo meta : LoadingModList.get().getMods()) {
|
||||
|
|
@ -142,7 +143,7 @@ public class ModernFixPlatformHooksImpl {
|
|||
return modOptions;
|
||||
}
|
||||
|
||||
public static void registerCreativeSearchTrees(SearchRegistry registry, SearchRegistry.TreeBuilderSupplier<ItemStack> nameSupplier, SearchRegistry.TreeBuilderSupplier<ItemStack> tagSupplier, BiConsumer<SearchRegistry.Key<ItemStack>, List<ItemStack>> populator) {
|
||||
public void registerCreativeSearchTrees(SearchRegistry registry, SearchRegistry.TreeBuilderSupplier<ItemStack> nameSupplier, SearchRegistry.TreeBuilderSupplier<ItemStack> tagSupplier, BiConsumer<SearchRegistry.Key<ItemStack>, List<ItemStack>> populator) {
|
||||
for (SearchRegistry.Key<ItemStack> nameKey : CreativeModeTabSearchRegistry.getNameSearchKeys().values()) {
|
||||
registry.register(nameKey, nameSupplier);
|
||||
}
|
||||
|
|
@ -159,13 +160,13 @@ public class ModernFixPlatformHooksImpl {
|
|||
});
|
||||
}
|
||||
|
||||
public static void onLaunchComplete() {
|
||||
public void onLaunchComplete() {
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.spark_profile_launch.OnForge")) {
|
||||
CommonModUtil.runWithoutCrash(() -> SparkLaunchProfiler.stop("launch"), "Failed to stop profiler");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPlatformName() {
|
||||
public String getPlatformName() {
|
||||
return "Forge";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user