Skip to content

Commit

Permalink
build(fabric): fix remap
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlimiter committed Feb 20, 2024
1 parent 16ccf52 commit 3a51a81
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 58 deletions.
6 changes: 3 additions & 3 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "fabric-loom" version "1.3-SNAPSHOT" apply false
id 'dev.architectury.loom' version '1.5-SNAPSHOT' apply false
id "com.replaymod.preprocess" version "SNAPSHOT"
}

Expand All @@ -10,12 +10,12 @@ preprocess {
def mc1193 = createNode("1.19.3", 1_19_03, "yarn")
def mc1194 = createNode("1.19.4", 1_19_04, "yarn")
def mc1201 = createNode("1.20.1", 1_20_01, "yarn")
def mc1202 = createNode("1.20.2", 1_20_02, "yarn")
def mc1204 = createNode("1.20.4", 1_20_04, "yarn")

mc1165.link(mc1182, null)
mc1182.link(mc1192, null)
mc1192.link(mc1193, null)
mc1193.link(mc1194, null)
mc1194.link(mc1201, null)
mc1201.link(mc1202, null)
mc1201.link(mc1204, null)
}
35 changes: 22 additions & 13 deletions fabric/common.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: "fabric-loom"
apply plugin: "com.replaymod.preprocess"
apply(plugin: "dev.architectury.loom")
apply(plugin: "com.replaymod.preprocess")

int mcVersion = 1

Expand All @@ -11,22 +11,22 @@ preprocess {

repositories {
mavenCentral()
maven {
url = 'https://maven.nova-committee.cn/releases'
}
maven { url = "https://maven.nova-committee.cn/releases" }
maven { url = "https://api.modrinth.com/maven" }
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
minecraft ("com.mojang:minecraft:${project.minecraft_version}")
mappings loom.officialMojangMappings()

modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
api include("cn.evole.bot:OneBot-Client:${project.onebot_client_version}")
api include("cn.evole.config:AtomConfig-Toml:${project.toml_version}")

compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor "org.projectlombok:lombok:1.18.24"
modImplementation ("net.fabricmc:fabric-loader:${project.loader_version}")
modImplementation ("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
api include ("cn.evole.bot:OneBot-Client:${project.onebot_client_version}")
api include ("cn.evole.config:AtomConfig-Toml:${project.toml_version}")
if (mcVersion == 11605) include ("org.slf4j:slf4j-api:2.0.7")
if (mcVersion == 12101) modCompileOnly ("maven.modrinth:vanish:1.5.2")
compileOnly ("org.projectlombok:lombok:1.18.24")
annotationProcessor ("org.projectlombok:lombok:1.18.24")

}

Expand All @@ -37,6 +37,15 @@ loom {
}
}



loom {
silentMojangMappingsLicense()
mixin {
useLegacyMixinAp = false
}
}

remapJar {
remapperIsolation = true
}
Expand Down
9 changes: 8 additions & 1 deletion fabric/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ pluginManagement {
name = "Fabric"
url = "https://maven.fabricmc.net/"
}
maven {
name = 'Architectury'
url "https://maven.architectury.dev/"
}
maven {
name = "Jitpack"
url = "https://jitpack.io"
Expand All @@ -15,6 +19,9 @@ pluginManagement {
maven {
url = 'https://maven.nova-committee.cn/releases'
}
maven { url 'https://maven.minecraftforge.net' }
maven { url 'https://repo.spongepowered.org/repository/maven-public' }
maven { url 'https://maven.parchmentmc.org' }
mavenCentral()
gradlePluginPortal()
}
Expand All @@ -27,7 +34,7 @@ def versions = Arrays.asList(
"1.19.3",
"1.19.4",
"1.20.1",
"1.20.2",
"1.20.4",
)
for (String version : versions) {
include(":$version")
Expand Down
13 changes: 3 additions & 10 deletions fabric/src/main/java/cn/evole/mods/mcbot/cmds/BotCmdRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import cn.evole.mods.mcbot.McBot;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
Expand All @@ -14,16 +13,10 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
//#if MC >= 11900
import net.minecraft.network.chat.Component;
//#else
//$$ import net.minecraft.network.chat.TextComponent;
//$$ import net.minecraft.network.chat.Component;
//#endif

//#if MC < 11600
//$$ import net.minecraft.world.level.dimension.DimensionType;
import java.util.function.Supplier;
//#if MC < 11900
import net.minecraft.network.chat.TextComponent;
//#endif


Expand Down
17 changes: 9 additions & 8 deletions fabric/src/main/java/cn/evole/mods/mcbot/data/UserBindApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

public class UserBindApi {
public static String BIND_NAME = "bind.csv";
private static final String BIND_NAME = "bind.csv";
private static final EasyCsv easyCsv = new EasyCsv();
public static Map<String, UserBind> users;

Expand All @@ -27,11 +27,12 @@ public static void load(Path folder){
if (!bindFile.toFile().isFile()) Files.createFile(bindFile);
userBinds = easyCsv.readAll(bindFile.toFile().getAbsolutePath()
, UserBind.class);
for (UserBind userBind : userBinds){
userBindMap.put(userBind.getQqId(), userBind);
}
} catch (IOException ignored) {
}
for (UserBind userBind : userBinds){
userBindMap.put(userBind.getQqId(), userBind);
}

users = userBindMap;
}

Expand All @@ -45,15 +46,15 @@ public static void save(Path folder){
}
}

public static boolean exist(String qq_id){
public static boolean has(String qq_id){
return users.containsKey(qq_id);
}

public static void add(String group_name, String qq_id, String game_name){
if (!exist(qq_id)) users.put(qq_id, new UserBind(System.currentTimeMillis(), qq_id, group_name, game_name));
if (!has(qq_id)) users.put(qq_id, new UserBind(System.currentTimeMillis(), qq_id, group_name, game_name));
}

public static void delete(String qq_id){
if (exist(qq_id)) users.remove(qq_id);
public static void del(String qq_id){
if (has(qq_id)) users.remove(qq_id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ public static void advancement(Player player, Advancement advancement) {
//$$ DisplayInfo display = advancement.display().get();
//#endif

//#if MC > 12001
//$$ String message = I18n.get("mcbot.chat.type.advancement." + display.getType().getSerializedName(), player.getDisplayName().getString(), I18n.get(display.getTitle().getString()));
//#else
String message = I18n.get("mcbot.chat.type.advancement." + display.getFrame().getName(), player.getDisplayName().getString(), I18n.get(display.getTitle().getString()));
//#endif

val msg = String.format(message, player.getDisplayName().getString());
send(msg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@

@Mixin(value = PlayerList.class, priority = 1001)
public abstract class MixinPlayerList {
//#if MC < 12002
@Inject(method = "placeNewPlayer", at = @At(value = "TAIL"))
public void PlayerList_placeNewPlayer(Connection connection, ServerPlayer player, CallbackInfo ci) {
IEvents.PLAYER_LOGGED_IN.invoker().onPlayerLoggedIn(player.getCommandSenderWorld(), player);
}
@Inject(method = "remove", at = @At(value = "HEAD"))
public void PlayerList_remove(ServerPlayer player, CallbackInfo ci) {
IEvents.PLAYER_LOGGED_OUT.invoker().onPlayerLoggedOut(player.getCommandSenderWorld(), player);
}
//#else
//#if MC >= 12002
//$$ @Inject(method = "placeNewPlayer", at = @At(value = "TAIL"))
//$$ public void PlayerList_placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie commonListenerCookie, CallbackInfo ci) {
//$$ IEvents.PLAYER_LOGGED_IN.invoker().onPlayerLoggedIn(player.getCommandSenderWorld(), player);
Expand All @@ -40,5 +31,14 @@ public void PlayerList_remove(ServerPlayer player, CallbackInfo ci) {
//$$ public void PlayerList_remove(ServerPlayer player, CallbackInfo ci) {
//$$ IEvents.PLAYER_LOGGED_OUT.invoker().onPlayerLoggedOut(player.getCommandSenderWorld(), player);
//$$ }
//#else
@Inject(method = "placeNewPlayer", at = @At(value = "TAIL"))
public void PlayerList_placeNewPlayer(Connection connection, ServerPlayer player, CallbackInfo ci) {
IEvents.PLAYER_LOGGED_IN.invoker().onPlayerLoggedIn(player.getCommandSenderWorld(), player);
}
@Inject(method = "remove", at = @At(value = "HEAD"))
public void PlayerList_remove(ServerPlayer player, CallbackInfo ci) {
IEvents.PLAYER_LOGGED_OUT.invoker().onPlayerLoggedOut(player.getCommandSenderWorld(), player);
}
//#endif
}
6 changes: 3 additions & 3 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"cnlimiter"
],
"contact": {
"issues": "https://github.com/cnlimiter/Bot-Connect/issues",
"sources": "https://github.com/cnlimiter/Bot-Connect"
"issues": "https://github.com/cnlimiter/McBot/issues",
"sources": "https://github.com/cnlimiter/McBot"
},
"license": "AGPL-3.0",
"icon": "assets/mcbot/icon.png",
Expand All @@ -23,7 +23,7 @@
"mcbot.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.21",
"fabricloader": ">=0.14.0",
"fabric": "*",
"minecraft": "${minecraft_dependency}",
"java": ">=8"
Expand Down
3 changes: 2 additions & 1 deletion fabric/versions/1.16.5/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# check these on https://fabricmc.net/develop
minecraft_version=1.16.5
loader_version=0.14.21
loom.platform=fabric

# Fabric Mod Metadata
minecraft_dependency=1.16.x
minecraft_dependency=1.16.5

# Dependencies
fabric_version=0.42.0+1.16
1 change: 1 addition & 0 deletions fabric/versions/1.18.2/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# check these on https://fabricmc.net/develop
minecraft_version=1.18.2
loader_version=0.14.21
loom.platform=fabric

# Fabric Mod Metadata
minecraft_dependency=1.18.2
Expand Down
1 change: 1 addition & 0 deletions fabric/versions/1.19.2/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# check these on https://fabricmc.net/develop
minecraft_version=1.19.2
loader_version=0.14.21
loom.platform=fabric

# Fabric Mod Metadata
minecraft_dependency=1.19.2
Expand Down
1 change: 1 addition & 0 deletions fabric/versions/1.19.3/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# check these on https://fabricmc.net/develop
minecraft_version=1.19.3
loader_version=0.14.21
loom.platform=fabric

# Fabric Mod Metadata
minecraft_dependency=1.19.3
Expand Down
1 change: 1 addition & 0 deletions fabric/versions/1.19.4/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# check these on https://fabricmc.net/develop
minecraft_version=1.19.4
loader_version=0.14.21
loom.platform=fabric

# Fabric Mod Metadata
minecraft_dependency=1.19.4
Expand Down
1 change: 1 addition & 0 deletions fabric/versions/1.20.1/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
loader_version=0.14.21
loom.platform=fabric

# Fabric Mod Metadata
minecraft_dependency=1.20.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.2
minecraft_version=1.20.4
loader_version=0.14.21
loom.platform=fabric

# Fabric Mod Metadata
minecraft_dependency=1.20.x
minecraft_dependency=1.20.4

# Dependencies
fabric_version=0.90.7+1.20.2
fabric_version=0.96.3+1.20.4
8 changes: 4 additions & 4 deletions fabric/wrapper/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: "fabric-loom"
apply(plugin: "dev.architectury.loom")

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand All @@ -23,7 +23,7 @@ dependencies {
api("cn.evole.bot:OneBot-Client:${project.onebot_client_version}")
api("cn.evole.config:AtomConfig-Toml:${project.toml_version}")

compileOnly 'org.projectlombok:lombok:1.18.24'
compileOnly "org.projectlombok:lombok:1.18.24"
annotationProcessor "org.projectlombok:lombok:1.18.24"
}

Expand Down
4 changes: 2 additions & 2 deletions fabric/wrapper/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"environment": "server",
"jars": [
{
"file": "META-INF/jars/McBot-fabric-1.16.x-${version}.jar"
"file": "META-INF/jars/McBot-fabric-1.16.5-${version}.jar"
},
{
"file": "META-INF/jars/McBot-fabric-1.18.2-${version}.jar"
Expand All @@ -34,7 +34,7 @@
"file": "META-INF/jars/McBot-fabric-1.20.1-${version}.jar"
},
{
"file": "META-INF/jars/McBot-fabric-1.20.x-${version}.jar"
"file": "META-INF/jars/McBot-fabric-1.20.4-${version}.jar"
}
]
}

0 comments on commit 3a51a81

Please sign in to comment.