Skip to content

Commit

Permalink
Support MC 1.20.6
Browse files Browse the repository at this point in the history
- Migrant to MagicLib 0.8
- Refactored package structure

Signed-off-by: Hendrix-Shen <[email protected]>
  • Loading branch information
Hendrix-Shen committed Jun 28, 2024
1 parent 632e6ea commit e3c09dd
Show file tree
Hide file tree
Showing 143 changed files with 4,305 additions and 3,359 deletions.
32 changes: 18 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import com.replaymod.gradle.preprocess.Node

plugins {
id("fabric-loom").version("1.4-SNAPSHOT").apply(false)
id("fabric-loom").version("${fabric_loom_version}").apply(false)
id("maven-publish")
id("org.ajoberstar.grgit").version("5.2.0")
id("com.replaymod.preprocess").version("SNAPSHOT")
id("org.ajoberstar.grgit").version("${grgit_version}")
id("com.replaymod.preprocess").version("${preprocessor_version}")
}

preprocess {
def mc1144 = createNode("1.14.4", 1_14_04, "mojang")
def mc1152 = createNode("1.15.2", 1_15_02, "mojang")
def mc1165 = createNode("1.16.5", 1_16_05, "mojang")
def mc1171 = createNode("1.17.1", 1_17_01, "mojang")
def mc1182 = createNode("1.18.2", 1_18_02, "mojang")
def mc1192 = createNode("1.19.2", 1_19_02, "mojang")
def mc1193 = createNode("1.19.3", 1_19_03, "mojang")
def mc1194 = createNode("1.19.4", 1_19_04, "mojang")
def mc1201 = createNode("1.20.1", 1_20_01, "mojang")
def mc1202 = createNode("1.20.2", 1_20_02, "mojang")
def mc1204 = createNode("1.20.4", 1_20_04, "mojang")
Node mc1144 = createNode("1.14.4", 1_14_04, "mojang")
Node mc1152 = createNode("1.15.2", 1_15_02, "mojang")
Node mc1165 = createNode("1.16.5", 1_16_05, "mojang")
Node mc1171 = createNode("1.17.1", 1_17_01, "mojang")
Node mc1182 = createNode("1.18.2", 1_18_02, "mojang")
Node mc1192 = createNode("1.19.2", 1_19_02, "mojang")
Node mc1193 = createNode("1.19.3", 1_19_03, "mojang")
Node mc1194 = createNode("1.19.4", 1_19_04, "mojang")
Node mc1201 = createNode("1.20.1", 1_20_01, "mojang")
Node mc1202 = createNode("1.20.2", 1_20_02, "mojang")
Node mc1204 = createNode("1.20.4", 1_20_04, "mojang")
Node mc1206 = createNode("1.20.6", 1_20_06, "mojang")

mc1144.link(mc1152, null)
mc1152.link(mc1165, file("versions/mapping-1.15.2-1.16.5.txt"))
Expand All @@ -28,6 +31,7 @@ preprocess {
mc1194.link(mc1201, null)
mc1201.link(mc1202, null)
mc1202.link(mc1204, null)
mc1204.link(mc1206, null)
}

ext {
Expand Down
2 changes: 1 addition & 1 deletion fabricWrapper/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"environment": "client",
"entrypoints": {
"modmenu": [
"com.plusls.MasaGadget.compat.modmenu.WrapperModMenuApiImpl"
"com.plusls.MasaGadget.impl.compat.modmenu.WrapperModMenuApiImpl"
]
},
"depends": {
Expand Down
18 changes: 11 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Gradle properties
org.gradle.cache.cleanup=false
org.gradle.jvmargs=-Xmx6G
org.gradle.parallel=true

# Mod Properties
mod_archives_base_name=MasaGadget
Expand All @@ -11,13 +9,19 @@ mod_maven_group=com.plusls
mod_name=Masa Gadget
mod_homepage=https://blog.plusls.com/
mod_sources=https://github.com/plusls/MasaGadget
mod_version=3.2
mod_version=4.0
mod_license=LGPL-3.0

# Required Libraries
# MagicLib - 0.7.398
magiclib_dependency=0.7.398
magiclib_version=0.7.398
# MagicLib - 0.8.562
magiclib_dependency=0.8.562
magiclib_version=0.8.562

# Annotation processor
lombok_version=1.18.30
lombok_version=1.18.30

# Gradle Plugins
fabric_loom_version=1.6-SNAPSHOT
grgit_version=5.2.2
preprocessor_version=ce1aeb2b
replace_token_version=1.1.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
43 changes: 18 additions & 25 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import groovy.json.JsonSlurper

pluginManagement {
repositories {
mavenLocal()
Expand All @@ -13,38 +15,29 @@ pluginManagement {
name("Jitpack")
url("https://jitpack.io")
}
}

maven {
name("Nyan Maven")
url("https://maven.hendrixshen.top")
}

maven {
name("Cotton")
url("https://server.bbkr.space/artifactory/libs-release")
resolutionStrategy {
eachPlugin {
switch (requested.id.id) {
case "com.replaymod.preprocess": {
useModule("com.github.Fallen-Breath:preprocessor:${requested.version}")
break
}
}
}
}
}

def versions = Arrays.asList(
"1.14.4",
"1.15.2",
"1.16.5",
"1.17.1",
"1.18.2",
"1.19.2",
"1.19.3",
"1.19.4",
"1.20.1",
"1.20.2",
"1.20.4",
)
Map<String, List<String>> settings = file("settings.json").withReader {
new JsonSlurper().parse(it) as Map<String, List<String>>
}

for (String version : versions) {
for (String version : settings.get("versions")) {
include(":$version")
def proj = project(":$version")
proj.projectDir = file("versions/$version")
proj.buildFileName = "../../common.gradle"
ProjectDescriptor proj = project(":$version")
proj.setProjectDir(file("versions/$version"))
proj.setBuildFileName("../${settings.versions.get(0)}/build.gradle")
}

include(":fabricWrapper")
16 changes: 16 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"versions": [
"1.14.4",
"1.15.2",
"1.16.5",
"1.17.1",
"1.18.2",
"1.19.2",
"1.19.3",
"1.19.4",
"1.20.1",
"1.20.2",
"1.20.4",
"1.20.6"
]
}
100 changes: 56 additions & 44 deletions src/main/java/com/plusls/MasaGadget/MasaGadgetMod.java
Original file line number Diff line number Diff line change
@@ -1,61 +1,73 @@
package com.plusls.MasaGadget;

import com.plusls.MasaGadget.config.Configs;
import com.plusls.MasaGadget.generic.entityInfo.EntityInfoRenderer;
import com.plusls.MasaGadget.generic.entityTrace.EntityTraceRenderer;
import com.plusls.MasaGadget.util.HitResultUtil;
import com.plusls.MasaGadget.tweakeroo.inventoryPreviewSupportSelect.MouseScrollInputHandler;
import com.plusls.MasaGadget.game.Configs;
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;
import com.plusls.MasaGadget.impl.mod_tweak.malilib.favoritesSupport.MalilibFavoritesData;
import com.plusls.MasaGadget.impl.generic.HitResultHandler;
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.dependency.api.annotation.Dependencies;
import top.hendrixshen.magiclib.dependency.api.annotation.Dependency;
import top.hendrixshen.magiclib.malilib.impl.ConfigHandler;
import top.hendrixshen.magiclib.malilib.impl.ConfigManager;
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 {
private static final int CONFIG_VERSION = 1;

@Dependencies(and = {
public class MasaGadgetMod implements ClientModInitializer, MinecraftListener {
@Dependencies(require = {
//#if MC > 11701
@Dependency(value = "itemscoller", versionPredicate = ">=0.16.0", optional = true),
@Dependency(value = "litematica", versionPredicate = ">=0.11.0", optional = true),
@Dependency(value = "minihud", versionPredicate = ">=0.22.0", optional = true),
@Dependency(value = "tweakeroo", versionPredicate = ">=0.13.1", optional = true)
@Dependency(value = "itemscroller", versionPredicates = ">=0.16.0", optional = true),
@Dependency(value = "litematica", versionPredicates = ">=0.11.0", optional = true),
@Dependency(value = "minihud", versionPredicates = ">=0.22.0", optional = true),
@Dependency(value = "tweakeroo", versionPredicates = ">=0.13.1", optional = true)
//#elseif MC > 11605
//$$ @Dependency(value = "itemscoller", versionPredicate = ">=0.15.0-dev.20211201.010054", optional = true),
//$$ @Dependency(value = "litematica", versionPredicate = ">=0.9.0", optional = true),
//$$ @Dependency(value = "minihud", versionPredicate = ">=0.20.0", optional = true),
//$$ @Dependency(value = "tweakeroo", versionPredicate = ">=0.11.0", optional = true)
//$$ @Dependency(value = "itemscroller", versionPredicates = ">=0.15.0-dev.20211201.010054", optional = true),
//$$ @Dependency(value = "litematica", versionPredicates = ">=0.9.0", optional = true),
//$$ @Dependency(value = "minihud", versionPredicates = ">=0.20.0", optional = true),
//$$ @Dependency(value = "tweakeroo", versionPredicates = ">=0.11.0", optional = true)
//#elseif MC > 11502
//$$ @Dependency(value = "itemscoller", versionPredicate = ">=0.15.0-dev.20210917.191808", optional = true),
//$$ @Dependency(value = "litematica", versionPredicate = ">=0.0.0-dev.20210917.192300", optional = true),
//$$ @Dependency(value = "minihud", versionPredicate = ">=0.19.0-dev.20210917.191825", optional = true),
//$$ @Dependency(value = "tweakeroo", versionPredicate = ">=0.10.0-dev.20210917.191839", optional = true)
//$$ @Dependency(value = "itemscroller", versionPredicates = ">=0.15.0-dev.20210917.191808", optional = true),
//$$ @Dependency(value = "litematica", versionPredicates = ">=0.0.0-dev.20210917.192300", optional = true),
//$$ @Dependency(value = "minihud", versionPredicates = ">=0.19.0-dev.20210917.191825", optional = true),
//$$ @Dependency(value = "tweakeroo", versionPredicates = ">=0.10.0-dev.20210917.191839", optional = true)
//#elseif MC > 11404
//$$ @Dependency(value = "itemscoller", versionPredicate = ">=0.15.0-dev.20200212.183513", optional = true),
//$$ @Dependency(value = "litematica", versionPredicate = ">=0.0.0-dev.20200515.184506", optional = true),
//$$ @Dependency(value = "minihud", versionPredicate = ">=0.19.0-dev.20200427.222110", optional = true),
//$$ @Dependency(value = "tweakeroo", versionPredicate = ">=0.10.0-dev.20200424.222527", optional = true)
//$$ @Dependency(value = "itemscroller", versionPredicates = ">=0.15.0-dev.20200212.183513", optional = true),
//$$ @Dependency(value = "litematica", versionPredicates = ">=0.0.0-dev.20200515.184506", optional = true),
//$$ @Dependency(value = "minihud", versionPredicates = ">=0.19.0-dev.20200427.222110", optional = true),
//$$ @Dependency(value = "tweakeroo", versionPredicates = ">=0.10.0-dev.20200424.222527", optional = true)
//#else
//$$ @Dependency(value = "itemscoller", versionPredicate = ">=0.15.0-dev.20190720.190250", optional = true),
//$$ @Dependency(value = "litematica", versionPredicate = ">=0.0.0-dev.20191222.014040", optional = true),
//$$ @Dependency(value = "minihud", versionPredicate = ">=0.19.0-dev.20191007.003640", optional = true),
//$$ @Dependency(value = "tweakeroo", versionPredicate = ">=0.10.0-dev.20190903.193019", optional = true)
//$$ @Dependency(value = "itemscroller", versionPredicates = ">=0.15.0-dev.20190720.190250", optional = true),
//$$ @Dependency(value = "litematica", versionPredicates = ">=0.0.0-dev.20191222.014040", optional = true),
//$$ @Dependency(value = "minihud", versionPredicates = ">=0.19.0-dev.20191007.003640", optional = true),
//$$ @Dependency(value = "tweakeroo", versionPredicates = ">=0.10.0-dev.20190903.193019", optional = true)
//#endif
})
@Override
public void onInitializeClient() {
ConfigManager cm = ConfigManager.get(ModInfo.MOD_ID);
cm.parseConfigClass(Configs.class);
ModInfo.configHandler = new ConfigHandler(ModInfo.MOD_ID, cm, CONFIG_VERSION);
ModInfo.configHandler.preDeserializeCallback = Configs::preDeserialize;
ModInfo.configHandler.postSerializeCallback = Configs::postSerialize;
ConfigHandler.register(ModInfo.configHandler);
Configs.init(cm);
InitializationHandler.getInstance().registerInitializationHandler(() ->
ConfigManager.getInstance().registerConfigHandler(SharedConstants.getModIdentifier(),
SharedConstants.getConfigHandler()));
Configs.init();
InputEventHandler.getKeybindManager().registerKeybindProvider(
(IKeybindProvider) SharedConstants.getConfigManager());
PcaSyncProtocol.init();
MouseScrollInputHandler.register();
EntityInfoRenderer.init();
EntityTraceRenderer.init();
HitResultUtil.init();
MouseScrollInputHandler.getInstance().init();
EntityInfoRenderer.getInstance().init();
EntityTraceRenderer.getInstance().init();
HitResultHandler.getInstance().init();
ComparatorInfo.getInstance().init();
MagicLib.getInstance().getEventManager().register(MinecraftListener.class, this);
}

@Override
public void postInit() {
FastMasaGuiSwitcher.getInstance().init();
SharedConstants.getConfigHandler().registerExternalData("malilib_favorites", MalilibFavoritesData.getInstance());
}
}
32 changes: 1 addition & 31 deletions src/main/java/com/plusls/MasaGadget/ModInfo.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
package com.plusls.MasaGadget;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.resources.ResourceLocation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi;
import top.hendrixshen.magiclib.malilib.impl.ConfigHandler;
import top.hendrixshen.magiclib.language.api.I18n;

//#if MC > 11502
import net.minecraft.network.chat.MutableComponent;
//#else
//$$ import net.minecraft.network.chat.BaseComponent;
//#endif

public class ModInfo {
public static final String ITEMSCROLLER_MOD_ID = "itemscroller";
Expand All @@ -23,28 +13,8 @@ public class ModInfo {
public static final String MODMENU_MOD_ID = "modmenu";
public static final String OMMC_MOD_ID = "ommc";
public static final String TWEAKEROO_MOD_ID = "tweakeroo";
public static String MOD_ID = "@MOD_IDENTIFIER@";
public static final String CURRENT_MOD_ID = "@MOD_IDENTIFIER@-@MINECRAFT_VERSION_IDENTIFY@";
public static final String MOD_NAME = FabricLoader.getInstance().getModContainer(CURRENT_MOD_ID)
.orElseThrow(RuntimeException::new).getMetadata().getName();
public static final String MOD_VERSION = FabricLoader.getInstance().getModContainer(CURRENT_MOD_ID)
.orElseThrow(RuntimeException::new).getMetadata().getVersion().getFriendlyString();
public static String MOD_ID = "masa_gadget_mod";
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
public static ConfigHandler configHandler;

public static String translate(String key, Object... objects) {
return I18n.get(ModInfo.MOD_ID + "." + key, objects);
}

public static @NotNull
//#if MC > 11502
MutableComponent
//#else
//$$ BaseComponent
//#endif
translatable(String key, Object... objects) {
return ComponentCompatApi.translatable(ModInfo.MOD_ID + "." + key, objects);
}

@Contract("_ -> new")
public static @NotNull ResourceLocation id(String path) {
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/plusls/MasaGadget/SharedConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.plusls.MasaGadget;

import lombok.Getter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager;
import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager;
import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler;
import top.hendrixshen.magiclib.util.VersionUtil;

public class SharedConstants {
@Getter
private static final String modIdentifier = "@MOD_IDENTIFIER@";
@Getter
private static final String modName = "@MOD_NAME@";
@Getter
private static final String modVersion = "@MOD_VERSION@";
@Getter
private static final String modVersionType = VersionUtil.getVersionType(SharedConstants.modVersion);
@Getter
private static final MagicConfigManager configManager = GlobalConfigManager
.getConfigManager(SharedConstants.getModIdentifier());
@Getter
private static final MagicConfigHandler configHandler = new MagicConfigHandler(configManager, 1);
@Getter
private static final Logger logger = LogManager.getLogger(SharedConstants.modIdentifier);

public static @NotNull String getTranslatedModVersionType() {
return VersionUtil.translateVersionType(SharedConstants.modVersion);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.plusls.MasaGadget.api.event;

import top.hendrixshen.magiclib.api.event.Listener;

public interface DisconnectListener extends Listener {
void onDisconnect();
}
Loading

0 comments on commit e3c09dd

Please sign in to comment.