MixinPlayerList.java
3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* This file is part of LiteLoader.
* Copyright (C) 2012-16 Adam Mummery-Smith
* All Rights Reserved.
*/
package com.mumfrey.liteloader.common.mixin;
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.Surrogate;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile;
import com.mumfrey.liteloader.core.LiteLoaderEventBroker;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.NetworkManager;
import net.minecraft.server.management.PlayerList;
@Mixin(value = PlayerList.class, priority = 2000)
public abstract class MixinPlayerList
{
@Inject(
method = "initializeConnectionToPlayer(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;)V",
at = @At("RETURN")
)
private void onInitializePlayerConnection(NetworkManager netManager, EntityPlayerMP player, CallbackInfo ci)
{
LiteLoaderEventBroker.getCommonBroker().onInitializePlayerConnection((PlayerList)(Object)this, netManager, player);
}
// Because, forge
@Surrogate
private void onInitializePlayerConnection(NetworkManager netManager, EntityPlayerMP player, NetHandlerPlayServer nhps, CallbackInfo ci)
{
LiteLoaderEventBroker.getCommonBroker().onInitializePlayerConnection((PlayerList)(Object)this, netManager, player);
}
@Inject(method = "playerLoggedIn(Lnet/minecraft/entity/player/EntityPlayerMP;)V", at = @At("RETURN"))
private void onPlayerLogin(EntityPlayerMP player, CallbackInfo ci)
{
LiteLoaderEventBroker.getCommonBroker().onPlayerLogin((PlayerList)(Object)this, player);
}
@Inject(method = "playerLoggedOut(Lnet/minecraft/entity/player/EntityPlayerMP;)V", at = @At("RETURN"))
private void onPlayerLogout(EntityPlayerMP player, CallbackInfo ci)
{
LiteLoaderEventBroker.getCommonBroker().onPlayerLogout((PlayerList)(Object)this, player);
}
@Inject(
method = "createPlayerForUser(Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/entity/player/EntityPlayerMP;",
cancellable = true,
at = @At("RETURN")
)
private void onSpawnPlayer(GameProfile profile, CallbackInfoReturnable<EntityPlayerMP> cir)
{
LiteLoaderEventBroker.getCommonBroker().onSpawnPlayer((PlayerList)(Object)this, cir.getReturnValue(), profile);
}
@Inject(
method = "recreatePlayerEntity(Lnet/minecraft/entity/player/EntityPlayerMP;IZ)Lnet/minecraft/entity/player/EntityPlayerMP;",
cancellable = true,
at = @At("RETURN")
)
private void onRespawnPlayer(EntityPlayerMP player, int dimension, boolean conqueredEnd, CallbackInfoReturnable<EntityPlayerMP> cir)
{
LiteLoaderEventBroker.getCommonBroker().onRespawnPlayer((PlayerList)(Object)this, cir.getReturnValue(), player, dimension, conqueredEnd);
}
}