mirror of
https://github.com/System-End/Discord-MC-Chat.git
synced 2026-04-19 18:35:15 +00:00
client
This commit is contained in:
parent
ec0d8d53e6
commit
ea7faa0d8a
26 changed files with 15 additions and 435 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -28,10 +28,6 @@ bin/
|
||||||
|
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
|
|
||||||
# Fabric
|
|
||||||
|
|
||||||
run/
|
|
||||||
|
|
||||||
# Java
|
# Java
|
||||||
|
|
||||||
hs_err_*.log
|
hs_err_*.log
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ apply plugin: "net.neoforged.moddev"
|
||||||
version = mod_version
|
version = mod_version
|
||||||
|
|
||||||
base {
|
base {
|
||||||
archivesName = "Discord-MC-Chat-neoforge"
|
archivesName = "Discord-MC-Chat-client"
|
||||||
}
|
}
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.xujiayao.discord_mc_chat.neoforge;
|
package com.xujiayao.discord_mc_chat.client;
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.DMCC;
|
import com.xujiayao.discord_mc_chat.common.DMCC;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.xujiayao.discord_mc_chat.fabric.mixins;
|
package com.xujiayao.discord_mc_chat.client.mixins;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.xujiayao.discord_mc_chat.fabric.mixins;
|
package com.xujiayao.discord_mc_chat.client.mixins;
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.xujiayao.discord_mc_chat.fabric.mixins;
|
package com.xujiayao.discord_mc_chat.client.mixins;
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.xujiayao.discord_mc_chat.fabric.mixins;
|
package com.xujiayao.discord_mc_chat.client.mixins;
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.xujiayao.discord_mc_chat.neoforge.mixins;
|
package com.xujiayao.discord_mc_chat.client.mixins;
|
||||||
|
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.xujiayao.discord_mc_chat.fabric.mixins;
|
package com.xujiayao.discord_mc_chat.client.mixins;
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.xujiayao.discord_mc_chat.fabric.mixins;
|
package com.xujiayao.discord_mc_chat.client.mixins;
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.xujiayao.discord_mc_chat.neoforge.mixins;
|
package com.xujiayao.discord_mc_chat.client.mixins;
|
||||||
|
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
||||||
|
|
@ -21,7 +21,7 @@ config = "neoforge.dmcc.mixins.json"
|
||||||
|
|
||||||
#[[dependencies.discord_mc_chat]]
|
#[[dependencies.discord_mc_chat]]
|
||||||
|
|
||||||
#modId = "neoforge"
|
#modId = "client"
|
||||||
#type = "required"
|
#type = "required"
|
||||||
#versionRange = "[${neo_version},)"
|
#versionRange = "[${neo_version},)"
|
||||||
#ordering = "NONE"
|
#ordering = "NONE"
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "com.xujiayao.discord_mc_chat.neoforge.mixins",
|
"package": "com.xujiayao.discord_mc_chat.client.mixins",
|
||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinCommands",
|
"MixinCommands",
|
||||||
|
|
@ -98,8 +98,8 @@ shadowJar {
|
||||||
def otherSubprojects = rootProject.subprojects.findAll { it.name != project.name }
|
def otherSubprojects = rootProject.subprojects.findAll { it.name != project.name }
|
||||||
|
|
||||||
tasks.register("mergeJars") {
|
tasks.register("mergeJars") {
|
||||||
dependsOn ":neoforge:jar"
|
//dependsOn ":server:jar"
|
||||||
dependsOn ":fabric:remapJar"
|
dependsOn ":client:jar"
|
||||||
dependsOn shadowJar
|
dependsOn shadowJar
|
||||||
|
|
||||||
def shadowJarFile = tasks.shadowJar.archiveFile.get().asFile
|
def shadowJarFile = tasks.shadowJar.archiveFile.get().asFile
|
||||||
|
|
@ -109,7 +109,7 @@ tasks.register("mergeJars") {
|
||||||
tempDir.mkdirs()
|
tempDir.mkdirs()
|
||||||
def addedFiles = [:]
|
def addedFiles = [:]
|
||||||
otherSubprojects.each { subproj ->
|
otherSubprojects.each { subproj ->
|
||||||
def jarTask = subproj.tasks.names.contains("remapJar") ? subproj.tasks.named("remapJar").get() : subproj.tasks.named("jar").get()
|
def jarTask = subproj.tasks.named("jar").get()
|
||||||
def jarFile = jarTask.archiveFile.get().asFile
|
def jarFile = jarTask.archiveFile.get().asFile
|
||||||
copy {
|
copy {
|
||||||
from zipTree(jarFile)
|
from zipTree(jarFile)
|
||||||
|
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
apply plugin: "fabric-loom"
|
|
||||||
|
|
||||||
version = mod_version
|
|
||||||
|
|
||||||
base {
|
|
||||||
archivesName = "Discord-MC-Chat-fabric"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation project(":common")
|
|
||||||
|
|
||||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
|
||||||
mappings loom.officialMojangMappings()
|
|
||||||
modImplementation "net.fabricmc:fabric-loader:${loader_version}"
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
var replaceProperties = [
|
|
||||||
mod_version: mod_version
|
|
||||||
]
|
|
||||||
inputs.properties replaceProperties
|
|
||||||
filesMatching("fabric.mod.json") {
|
|
||||||
expand replaceProperties
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
|
||||||
options.release = 21
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_21
|
|
||||||
targetCompatibility = JavaVersion.VERSION_21
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
inputs.property "archivesName", base.archivesName
|
|
||||||
}
|
|
||||||
|
|
||||||
loom {
|
|
||||||
mixin {
|
|
||||||
defaultRefmapName = "fabric.dmcc.refmap.json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
package com.xujiayao.discord_mc_chat.fabric;
|
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.DMCC;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Xujiayao
|
|
||||||
*/
|
|
||||||
public class FabricDMCC implements ModInitializer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInitialize() {
|
|
||||||
String version = FabricLoader.getInstance().getModContainer("discord_mc_chat").orElseThrow().getMetadata().getVersion().getFriendlyString();
|
|
||||||
DMCC.init("Fabric", version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package com.xujiayao.discord_mc_chat.fabric.mixins;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.network.chat.PlayerChatMessage;
|
|
||||||
import net.minecraft.server.commands.SayCommand;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Xujiayao
|
|
||||||
*/
|
|
||||||
@Mixin(SayCommand.class)
|
|
||||||
public class MixinSayCommand {
|
|
||||||
|
|
||||||
@Inject(method = "method_43657", at = @At("HEAD"))
|
|
||||||
private static void method_43657(CommandContext<CommandSourceStack> commandContext, PlayerChatMessage playerChatMessage, CallbackInfo ci) {
|
|
||||||
// SourceSay Event
|
|
||||||
EventManager.post(new MinecraftEvents.SourceSay(
|
|
||||||
commandContext,
|
|
||||||
playerChatMessage,
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package com.xujiayao.discord_mc_chat.fabric.mixins;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.server.commands.TellRawCommand;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Xujiayao
|
|
||||||
*/
|
|
||||||
@Mixin(TellRawCommand.class)
|
|
||||||
public class MixinTellRawCommand {
|
|
||||||
|
|
||||||
@Inject(method = "method_13777", at = @At("HEAD"))
|
|
||||||
private static void method_13777(CommandContext<CommandSourceStack> commandContext, CallbackInfoReturnable<Integer> cir) {
|
|
||||||
// SourceTellRaw Event
|
|
||||||
EventManager.post(new MinecraftEvents.SourceTellRaw(
|
|
||||||
commandContext,
|
|
||||||
cir
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"package": "com.xujiayao.discord_mc_chat.fabric.mixins",
|
|
||||||
"compatibilityLevel": "JAVA_21",
|
|
||||||
"mixins": [
|
|
||||||
"MixinCommands",
|
|
||||||
"MixinMinecraftServer",
|
|
||||||
"MixinPlayerAdvancements",
|
|
||||||
"MixinPlayerList",
|
|
||||||
"MixinSayCommand",
|
|
||||||
"MixinServerGamePacketListenerImpl",
|
|
||||||
"MixinServerPlayer",
|
|
||||||
"MixinTellRawCommand"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
},
|
|
||||||
"overwrites": {
|
|
||||||
"requireAnnotations": true
|
|
||||||
},
|
|
||||||
"refmap": "fabric.dmcc.refmap.json"
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"id": "discord_mc_chat",
|
|
||||||
"version": "${mod_version}",
|
|
||||||
"name": "Discord-MC-Chat",
|
|
||||||
"description": "Discord-MC-Chat (DMCC), formerly known as MC-Discord-Chat and MCDiscordChat (MCDC), is a practical and powerful Fabric and NeoForge Minecraft <> Discord chat bridge inspired by BRForgers/DisFabric",
|
|
||||||
"authors": [
|
|
||||||
"Xujiayao"
|
|
||||||
],
|
|
||||||
"contact": {
|
|
||||||
"homepage": "https://blog.xujiayao.com/posts/4ba0a17a/",
|
|
||||||
"sources": "https://github.com/Xujiayao/Discord-MC-Chat",
|
|
||||||
"issues": "https://github.com/Xujiayao/Discord-MC-Chat/issues"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"icon": "icon/icon.png",
|
|
||||||
"environment": "*",
|
|
||||||
"entrypoints": {
|
|
||||||
"main": [
|
|
||||||
"com.xujiayao.discord_mc_chat.fabric.FabricDMCC"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"mixins": [
|
|
||||||
"fabric.dmcc.mixins.json"
|
|
||||||
],
|
|
||||||
"depends": {
|
|
||||||
"fabricloader": ">=0.17.3",
|
|
||||||
"minecraft": "~1.21.10",
|
|
||||||
"java": ">=21"
|
|
||||||
},
|
|
||||||
"suggests": {
|
|
||||||
"another-mod": "*"
|
|
||||||
},
|
|
||||||
"custom": {
|
|
||||||
"modmenu": {
|
|
||||||
"links": {
|
|
||||||
"modmenu.wiki": "https://dmcc.xujiayao.com/",
|
|
||||||
"modmenu.discord": "https://discord.gg/kbXkV6k2XU",
|
|
||||||
"modmenu.modrinth": "https://modrinth.com/mod/discord-mc-chat",
|
|
||||||
"modmenu.curseforge": "https://www.curseforge.com/minecraft/mc-mods/discord-mc-chat"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
package com.xujiayao.discord_mc_chat.neoforge.mixins;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
|
||||||
import net.minecraft.commands.CommandBuildContext;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.commands.Commands;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Xujiayao
|
|
||||||
*/
|
|
||||||
@Mixin(Commands.class)
|
|
||||||
public class MixinCommands {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
@Final
|
|
||||||
private CommandDispatcher<CommandSourceStack> dispatcher;
|
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
|
||||||
private void init(Commands.CommandSelection commandSelection, CommandBuildContext commandBuildContext, CallbackInfo ci) {
|
|
||||||
// CommandRegister Event
|
|
||||||
EventManager.post(new MinecraftEvents.CommandRegister(
|
|
||||||
dispatcher,
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
package com.xujiayao.discord_mc_chat.neoforge.mixins;
|
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Xujiayao
|
|
||||||
*/
|
|
||||||
@Mixin(MinecraftServer.class)
|
|
||||||
public class MixinMinecraftServer {
|
|
||||||
|
|
||||||
@Inject(method = "runServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;getNanos()J", ordinal = 0))
|
|
||||||
private void serverStarted(CallbackInfo ci) {
|
|
||||||
// ServerStarted Event
|
|
||||||
EventManager.post(new MinecraftEvents.ServerStarted(
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "runServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;stopServer()V"))
|
|
||||||
private void serverStopping(CallbackInfo ci) {
|
|
||||||
// ServerStopping Event
|
|
||||||
EventManager.post(new MinecraftEvents.ServerStopping(
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "runServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;onServerExit()V"))
|
|
||||||
private void serverStopped(CallbackInfo ci) {
|
|
||||||
// ServerStopped Event
|
|
||||||
EventManager.post(new MinecraftEvents.ServerStopped(
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
package com.xujiayao.discord_mc_chat.neoforge.mixins;
|
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
|
||||||
import net.minecraft.advancements.AdvancementHolder;
|
|
||||||
import net.minecraft.advancements.AdvancementProgress;
|
|
||||||
import net.minecraft.server.PlayerAdvancements;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Xujiayao
|
|
||||||
*/
|
|
||||||
@Mixin(PlayerAdvancements.class)
|
|
||||||
public abstract class MixinPlayerAdvancements {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
private ServerPlayer player;
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract AdvancementProgress getOrStartProgress(AdvancementHolder advancementHolder);
|
|
||||||
|
|
||||||
@Inject(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/advancements/AdvancementRewards;grant(Lnet/minecraft/server/level/ServerPlayer;)V", shift = At.Shift.AFTER))
|
|
||||||
private void award(AdvancementHolder advancementHolder, String string, CallbackInfoReturnable<Boolean> cir) {
|
|
||||||
// PlayerAdvancement Event
|
|
||||||
EventManager.post(new MinecraftEvents.PlayerAdvancement(
|
|
||||||
advancementHolder,
|
|
||||||
string,
|
|
||||||
player,
|
|
||||||
getOrStartProgress(advancementHolder),
|
|
||||||
cir
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
package com.xujiayao.discord_mc_chat.neoforge.mixins;
|
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
|
||||||
import net.minecraft.network.Connection;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.server.network.CommonListenerCookie;
|
|
||||||
import net.minecraft.server.players.PlayerList;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Xujiayao
|
|
||||||
*/
|
|
||||||
@Mixin(PlayerList.class)
|
|
||||||
public class MixinPlayerList {
|
|
||||||
|
|
||||||
@Inject(method = "placeNewPlayer", at = @At("RETURN"))
|
|
||||||
private void placeNewPlayer(Connection connection, ServerPlayer serverPlayer, CommonListenerCookie commonListenerCookie, CallbackInfo ci) {
|
|
||||||
// PlayerJoin Event
|
|
||||||
EventManager.post(new MinecraftEvents.PlayerJoin(
|
|
||||||
connection,
|
|
||||||
serverPlayer,
|
|
||||||
commonListenerCookie,
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "remove", at = @At("HEAD"))
|
|
||||||
private void remove(ServerPlayer serverPlayer, CallbackInfo ci) {
|
|
||||||
// PlayerQuit Event
|
|
||||||
EventManager.post(new MinecraftEvents.PlayerQuit(
|
|
||||||
serverPlayer,
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
package com.xujiayao.discord_mc_chat.neoforge.mixins;
|
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
|
||||||
import net.minecraft.network.chat.LastSeenMessages;
|
|
||||||
import net.minecraft.network.chat.PlayerChatMessage;
|
|
||||||
import net.minecraft.network.protocol.game.ServerboundChatCommandSignedPacket;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Xujiayao
|
|
||||||
*/
|
|
||||||
@Mixin(ServerGamePacketListenerImpl.class)
|
|
||||||
public class MixinServerGamePacketListenerImpl {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public ServerPlayer player;
|
|
||||||
|
|
||||||
@Inject(method = "broadcastChatMessage", at = @At("HEAD"))
|
|
||||||
private void broadcastChatMessage(PlayerChatMessage playerChatMessage, CallbackInfo ci) {
|
|
||||||
// PlayerChat Event
|
|
||||||
EventManager.post(new MinecraftEvents.PlayerChat(
|
|
||||||
playerChatMessage,
|
|
||||||
player,
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "performUnsignedChatCommand", at = @At("HEAD"))
|
|
||||||
private void performUnsignedChatCommand(String string, CallbackInfo ci) {
|
|
||||||
// PlayerCommand Event
|
|
||||||
EventManager.post(new MinecraftEvents.PlayerCommand(
|
|
||||||
string,
|
|
||||||
player,
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "performSignedChatCommand", at = @At("HEAD"))
|
|
||||||
private void performSignedChatCommand(ServerboundChatCommandSignedPacket serverboundChatCommandSignedPacket, LastSeenMessages lastSeenMessages, CallbackInfo ci) {
|
|
||||||
// PlayerCommand Event
|
|
||||||
EventManager.post(new MinecraftEvents.PlayerCommand(
|
|
||||||
serverboundChatCommandSignedPacket.command(),
|
|
||||||
player,
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package com.xujiayao.discord_mc_chat.neoforge.mixins;
|
|
||||||
|
|
||||||
import com.xujiayao.discord_mc_chat.common.minecraft.MinecraftEvents;
|
|
||||||
import com.xujiayao.discord_mc_chat.common.utils.events.EventManager;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Xujiayao
|
|
||||||
*/
|
|
||||||
@Mixin(ServerPlayer.class)
|
|
||||||
public class MixinServerPlayer {
|
|
||||||
|
|
||||||
@Inject(method = "die", at = @At("HEAD"))
|
|
||||||
private void die(DamageSource damageSource, CallbackInfo ci) {
|
|
||||||
// PlayerDie Event
|
|
||||||
EventManager.post(new MinecraftEvents.PlayerDie(
|
|
||||||
damageSource,
|
|
||||||
(ServerPlayer) (Object) this,
|
|
||||||
ci
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue