Skip to content

Commit

Permalink
+ fix MixinPlayerList
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlimiter committed Nov 11, 2023
1 parent 2a5377d commit 86c4d4f
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cn.evole.mods.mcbot.init.mixins;


import cn.evole.mods.mcbot.init.callbacks.IEvents;
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 cnlimiter
* CreateTime 2023/5/19 0:51
* Name MixinPlayerList
* Description
*/

@Mixin(value = PlayerList.class, priority = 1001)
public abstract class MixinPlayerList {
@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);
}

@Inject(method = "remove", at = @At(value = "HEAD"))
public void PlayerList_remove(ServerPlayer player, CallbackInfo ci) {
IEvents.PLAYER_LOGGED_OUT.invoker().onPlayerLoggedOut(player.getCommandSenderWorld(), player);
}
}

0 comments on commit 86c4d4f

Please sign in to comment.