Skip to content

Commit

Permalink
Support 1.21.1 with NeoForge
Browse files Browse the repository at this point in the history
Signed-off-by: Hendrix-Shen <[email protected]>
  • Loading branch information
Hendrix-Shen committed Oct 14, 2024
1 parent 9def4a0 commit cefb93a
Show file tree
Hide file tree
Showing 33 changed files with 587 additions and 124 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ preprocess {
mc12002_fabric.link(mc12004_fabric, null)
mc12004_fabric.link(mc12006_fabric, null)
mc12006_fabric.link(mc12101_fabric, null)

// NeoForge
Node mc12101_neoforge = createNode("1.21.1-neoforge", 1_21_01, "mojang")
mc12101_fabric.link(mc12101_neoforge, null)
}

ext {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ mod.version=4.0
## Annotation processor
dependencies.lombok_version=1.18.34
## MagicLib
dependencies.magiclib_dependency=0.8.619
dependencies.magiclib_version=0.8.619-beta
dependencies.magiclib_dependency=0.8.633
dependencies.magiclib_version=0.8.633

# Gradle Plugins
architectury_loom_version=1.7-SNAPSHOT
Expand Down
4 changes: 3 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"1.20.2-fabric",
"1.20.4-fabric",
"1.20.6-fabric",
"1.21.1-fabric"
"1.21.1-fabric",

"1.21.1-neoforge"
]
}
12 changes: 12 additions & 0 deletions src/main/java/com/plusls/MasaGadget/MasaGadgetFabricMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//#if FABRIC_LIKE
package com.plusls.MasaGadget;

import net.fabricmc.api.ClientModInitializer;

public class MasaGadgetFabricMod implements ClientModInitializer {
@Override
public void onInitializeClient() {
MasaGadgetMod.onInitializeClient();
}
}
//#endif
25 changes: 7 additions & 18 deletions src/main/java/com/plusls/MasaGadget/MasaGadgetMod.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.plusls.MasaGadget;

import com.plusls.MasaGadget.game.Configs;
import com.plusls.MasaGadget.game.MalilibStuffsInitializer;
import com.plusls.MasaGadget.impl.feature.entityInfo.EntityInfoRenderer;
import com.plusls.MasaGadget.impl.feature.entityTrace.EntityTraceRenderer;
import com.plusls.MasaGadget.impl.mod_tweak.malilib.fastSwitchMasaConfigGui.FastMasaGuiSwitcher;
Expand All @@ -9,33 +9,22 @@
import com.plusls.MasaGadget.impl.mod_tweak.tweakeroo.inventoryPreviewSupportComparator.ComparatorInfo;
import com.plusls.MasaGadget.impl.mod_tweak.tweakeroo.inventoryPreviewSupportSelect.MouseScrollInputHandler;
import com.plusls.MasaGadget.util.PcaSyncProtocol;
import fi.dy.masa.malilib.config.ConfigManager;
import fi.dy.masa.malilib.event.InitializationHandler;
import fi.dy.masa.malilib.event.InputEventHandler;
import fi.dy.masa.malilib.hotkeys.IKeybindProvider;
import net.fabricmc.api.ClientModInitializer;
import top.hendrixshen.magiclib.MagicLib;
import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies;
import top.hendrixshen.magiclib.api.dependency.annotation.Dependency;
import top.hendrixshen.magiclib.api.event.minecraft.MinecraftListener;

public class MasaGadgetMod implements ClientModInitializer, MinecraftListener {
@Override
public void onInitializeClient() {
InitializationHandler.getInstance().registerInitializationHandler(() ->
ConfigManager.getInstance().registerConfigHandler(SharedConstants.getModIdentifier(),
SharedConstants.getConfigHandler()));
Configs.init();
InputEventHandler.getKeybindManager().registerKeybindProvider(
(IKeybindProvider) SharedConstants.getConfigManager());
public class MasaGadgetMod implements MinecraftListener {
private static final MasaGadgetMod instance = new MasaGadgetMod();

public static void onInitializeClient() {
MagicLib.getInstance().getEventManager().register(MinecraftListener.class, MasaGadgetMod.instance);
MalilibStuffsInitializer.init();
PcaSyncProtocol.init();
ComparatorInfo.getInstance().init();
MouseScrollInputHandler.getInstance().init();
EntityInfoRenderer.getInstance().init();
EntityTraceRenderer.getInstance().init();
HitResultHandler.getInstance().init();
ComparatorInfo.getInstance().init();
MagicLib.getInstance().getEventManager().register(MinecraftListener.class, this);
}

@Override
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/plusls/MasaGadget/MasaGadgetNeoForgeMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//#if NEO_FORGE
//$$ package com.plusls.MasaGadget;
//$$
//$$ import net.neoforged.fml.common.Mod;
//$$ import top.hendrixshen.magiclib.api.entrypoint.ModInitializer;
//$$
//$$ @Mod("@MOD_IDENTIFIER@")
//$$ public class MasaGadgetNeoForgeMod implements ModInitializer {
//$$ public MasaGadgetNeoForgeMod() {
//$$ this.construct();
//$$ }
//$$
//$$ @Override
//$$ public void onInitializeClient() {
//$$ MasaGadgetMod.onInitializeClient();
//$$ }
//$$
//$$ @Override
//$$ public void onInitializeServer() {
//$$ }
//$$
//$$ @Override
//$$ public void onInitialize() {
//$$ }
//$$ }
//#endif
112 changes: 103 additions & 9 deletions src/main/java/com/plusls/MasaGadget/game/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import net.minecraft.client.Minecraft;
import net.minecraft.world.entity.Entity;
import top.hendrixshen.magiclib.MagicLib;
import top.hendrixshen.magiclib.api.dependency.DependencyType;
import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies;
import top.hendrixshen.magiclib.api.dependency.annotation.Dependency;
import top.hendrixshen.magiclib.api.malilib.annotation.Config;
import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager;
import top.hendrixshen.magiclib.api.platform.PlatformType;
import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigFactory;
import top.hendrixshen.magiclib.impl.malilib.config.option.*;
import top.hendrixshen.magiclib.util.minecraft.ComponentUtil;
Expand Down Expand Up @@ -84,7 +86,8 @@ public class Configs {

@Dependencies(require = {
@Dependency(value = ModId.litematica, versionPredicates = "<0.0.0-dev.20210917.192300"),
@Dependency(value = ModId.tweakeroo)
@Dependency(ModId.tweakeroo),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
})
@Config(category = ConfigCategory.LITEMATICA)
public static MagicConfigBoolean nudgeSelectionSupportFreeCamera = Configs.cf.newConfigBoolean("nudgeSelectionSupportFreeCamera", false);
Expand All @@ -98,13 +101,52 @@ public class Configs {
public static MagicConfigBoolean useRelativePath = Configs.cf.newConfigBoolean("useRelativePath", false);

// MALILIB
@Dependencies(require = @Dependency(value = ModId.malilib, versionPredicates = "<0.11.0"))
@Dependencies(require = @Dependency(value = ModId.minihud, versionPredicates = "<0.20.0"))
@Dependencies(require = @Dependency(value = ModId.tweakeroo, versionPredicates = "<0.11.1"))
@Dependencies(
require = {
@Dependency(value = ModId.malilib, versionPredicates = "<0.11.0"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = "<1.18-"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minihud, versionPredicates = "<0.20.0"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = "<1.18-"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.tweakeroo, versionPredicates = "<0.11.1"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = "<1.18-"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Config(category = ConfigCategory.MALILIB)
public static MagicConfigBoolean backportI18nSupport = Configs.cf.newConfigBoolean("backportI18nSupport", false);

@Dependencies(require = @Dependency(ModId.mod_menu))
@Dependencies(
require = {
@Dependency(ModId.mod_menu),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(require = @Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE))
@Config(category = ConfigCategory.MALILIB)
public static MagicConfigBoolean fastSwitchMasaConfigGui = Configs.cf.newConfigBoolean("fastSwitchMasaConfigGui", false);

Expand All @@ -119,15 +161,48 @@ public class Configs {
@Config(category = ConfigCategory.MALILIB)
public static MagicConfigBoolean fixConfigWidgetWidthExpand = Configs.cf.newConfigBoolean("fixConfigWidgetWidthExpand", false);

@Dependencies(require = @Dependency(value = ModId.malilib, versionPredicates = "<0.11.0"))
@Dependencies(
require = {
@Dependency(value = ModId.malilib, versionPredicates = "<0.11.0"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = "<1.18-"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Config(category = ConfigCategory.MALILIB)
public static MagicConfigBoolean fixGetInventoryType = Configs.cf.newConfigBoolean("fixGetInventoryType", false);

@Dependencies(require = @Dependency(value = ModId.malilib, versionPredicates = "<0.11.6"))
@Dependencies(
require = {
@Dependency(value = ModId.malilib, versionPredicates = "<0.11.6"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = "<1.18-"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Config(category = ConfigCategory.MALILIB)
public static MagicConfigBoolean fixSearchbarHotkeyInput = Configs.cf.newConfigBoolean("fixSearchbarHotkeyInput", false);

@Dependencies(require = @Dependency(value = ModId.malilib, versionPredicates = "<0.11.0"))
@Dependencies(
require = {
@Dependency(value = ModId.malilib, versionPredicates = "<0.11.0"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = "<1.18-"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Config(category = ConfigCategory.MALILIB)
public static MagicConfigBoolean optimizeConfigWidgetSearch = Configs.cf.newConfigBoolean("optimizeConfigWidgetSearch", false);

Expand All @@ -138,7 +213,26 @@ public class Configs {
public static MagicConfigDouble showOriginalConfigNameScale = Configs.cf.newConfigDouble("showOriginalConfigNameScale", 0.65, 0, 2);

// MiniHUD
@Dependencies(require = @Dependency(value = ModId.minihud, versionPredicates = "<0.31.999-sakura.21"))
@Dependencies(
require = {
@Dependency(value = ModId.minihud, versionPredicates = "<0.31.999-sakura.21"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FABRIC_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = "<1.21.1-"),
@Dependency(value = ModId.minihud, versionPredicates = "*"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Dependencies(
require = {
@Dependency(value = ModId.minecraft, versionPredicates = ">1.21.1-"),
@Dependency(value = ModId.minihud, versionPredicates = ">0.1.21-mc1.21"),
@Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE)
}
)
@Config(category = ConfigCategory.MINIHUD)
public static MagicConfigBoolean minihudI18n = Configs.cf.newConfigBoolean("minihudI18n", false);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.plusls.MasaGadget.game;

import com.plusls.MasaGadget.SharedConstants;
import fi.dy.masa.malilib.config.ConfigManager;
import fi.dy.masa.malilib.event.InitializationHandler;
import fi.dy.masa.malilib.event.InputEventHandler;
import fi.dy.masa.malilib.hotkeys.IKeybindProvider;

//#if FORGE_LIKE
//$$ import top.hendrixshen.magiclib.util.minecraft.ForgePlatformUtil;
//#endif

public class MalilibStuffsInitializer {
public static void init() {
InitializationHandler.getInstance().registerInitializationHandler(() ->
ConfigManager.getInstance().registerConfigHandler(SharedConstants.getModIdentifier(),
SharedConstants.getConfigHandler()));
Configs.init();
InputEventHandler.getKeybindManager().registerKeybindProvider(
(IKeybindProvider) SharedConstants.getConfigManager());
//#if FORGE_LIKE
//$$ MalilibStuffsInitializer.setupForgeConfigGui();
//#endif
}

//#if FORGE_LIKE
//$$ private static void setupForgeConfigGui() {
//$$ ForgePlatformUtil.registerModConfigScreen(SharedConstants.getModIdentifier(),
//$$ screen -> {
//$$ ConfigGui gui = new ConfigGui();
//#if MC > 11903
//$$ gui.setParent(screen);
//#else
//$$ gui.setParentGui(screen);
//#endif
//$$ return gui;
//$$ });
//$$ }
//#endif
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//#if FABRIC_LIKE
package com.plusls.MasaGadget.impl.compat.modmenu;

import com.plusls.MasaGadget.SharedConstants;
Expand All @@ -23,3 +24,4 @@ public String getModIdCompat() {
return SharedConstants.getModIdentifier();
}
}
//#endif
Loading

0 comments on commit cefb93a

Please sign in to comment.