Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
refactor: ServerPlayerEntitySendMessageEvent use mixin instead of fml…
Browse files Browse the repository at this point in the history
…coremod
  • Loading branch information
WakelessSloth56 committed Oct 1, 2021
1 parent 6ad4699 commit d2b852f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.auioc.mods.ahutils.mixin.server;

import java.util.UUID;
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;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;

@Mixin(value = ServerPlayerEntity.class)
public abstract class MixinServerPlayerEntity {

// @org.spongepowered.asm.mixin.Debug(export = true, print = true)
@Inject(
method = "Lnet/minecraft/entity/player/ServerPlayerEntity;sendMessage(Lnet/minecraft/util/text/ITextComponent;Lnet/minecraft/util/text/ChatType;Ljava/util/UUID;)V",
at = @At(value = "HEAD"),
require = 1,
cancellable = true,
remap = false
)
private void onSendMessage(ITextComponent p_241151_1_, ChatType p_241151_2_, UUID p_241151_3_, CallbackInfo ci) {
if (org.auioc.mods.ahutils.server.event.ServerEventRegistry.postServerPlayerEntitySendMessageEvent(p_241151_1_, p_241151_2_, p_241151_3_)) {
ci.cancel();
return;
}
}

}
3 changes: 1 addition & 2 deletions src/main/resources/META-INF/coremods.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"ahutils.CheckPushableEvent": "coremods/ahutils/CheckPushableEvent.js",
"ahutils.ServerPlayerSendMessageEvent": "coremods/ahutils/ServerPlayerSendMessageEvent.js"
"ahutils.CheckPushableEvent": "coremods/ahutils/CheckPushableEvent.js"
}
2 changes: 1 addition & 1 deletion src/main/resources/ahutils.mixin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"package": "org.auioc.mods.ahutils.mixin",
"compatibilityLevel": "JAVA_16",
"mixins": ["server.MixinLootContext"],
"mixins": ["server.MixinLootContext", "server.MixinServerPlayerEntity"],
"client": [],
"server": ["server.MixinServerLifecycleHooks"],
"injectors": {
Expand Down

0 comments on commit d2b852f

Please sign in to comment.