Proxy.java
4.98 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package com.mumfrey.liteloader.core;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
import net.minecraft.network.play.client.C0APacketAnimation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.ItemInWorldManager;
import net.minecraft.server.management.ServerConfigurationManager;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
public abstract class Proxy
{
private static LiteLoaderEventBroker<?, ?> broker;
protected Proxy() {}
protected static void onStartupComplete()
{
Proxy.broker = LiteLoaderEventBroker.broker;
if (Proxy.broker == null)
{
throw new RuntimeException("LiteLoader failed to start up properly."
+ " The game is in an unstable state and must shut down now. Check the developer log for startup errors");
}
}
public static void onInitializePlayerConnection(ServerConfigurationManager source, NetworkManager netManager, EntityPlayerMP player)
{
Proxy.broker.onInitializePlayerConnection(source, netManager, player);
}
public static void onPlayerLogin(ServerConfigurationManager source, EntityPlayerMP player)
{
Proxy.broker.onPlayerLogin(source, player);
}
public static void onPlayerLogout(ServerConfigurationManager source, EntityPlayerMP player)
{
Proxy.broker.onPlayerLogout(source, player);
}
public static void onSpawnPlayer(CallbackInfoReturnable<EntityPlayerMP> cir, ServerConfigurationManager source, GameProfile profile)
{
Proxy.broker.onSpawnPlayer(source, cir.getReturnValue(), profile);
}
public static void onRespawnPlayer(CallbackInfoReturnable<EntityPlayerMP> cir, ServerConfigurationManager source, EntityPlayerMP oldPlayer,
int dimension, boolean won)
{
Proxy.broker.onRespawnPlayer(source, cir.getReturnValue(), oldPlayer, dimension, won);
}
public static void onServerTick(MinecraftServer mcServer)
{
Proxy.broker.onServerTick(mcServer);
}
public static void onPlaceBlock(CallbackInfo ci, NetHandlerPlayServer netHandler, C08PacketPlayerBlockPlacement packet)
{
if (!Proxy.broker.onPlaceBlock(netHandler, netHandler.playerEntity, packet.getPosition(),
EnumFacing.getFront(packet.getPlacedBlockDirection())))
{
ci.cancel();
}
}
public static void onClickedAir(CallbackInfo ci, NetHandlerPlayServer netHandler, C0APacketAnimation packet)
{
if (!Proxy.broker.onClickedAir(netHandler))
{
ci.cancel();
}
}
public static void onPlayerDigging(CallbackInfo ci, NetHandlerPlayServer netHandler, C07PacketPlayerDigging packet)
{
if (packet.getStatus() == C07PacketPlayerDigging.Action.START_DESTROY_BLOCK)
{
if (!Proxy.broker.onPlayerDigging(netHandler, packet.getPosition(), netHandler.playerEntity))
{
ci.cancel();
}
}
}
public static void onUseItem(CallbackInfoReturnable<Boolean> ci, EntityPlayer player, World world, ItemStack itemStack, BlockPos pos,
EnumFacing side, float par8, float par9, float par10)
{
if (!(player instanceof EntityPlayerMP))
{
return;
}
if (!Proxy.broker.onUseItem(pos, side, (EntityPlayerMP)player))
{
ci.setReturnValue(false);
}
}
public static void onBlockClicked(CallbackInfo ci, ItemInWorldManager manager, BlockPos pos, EnumFacing side)
{
if (!Proxy.broker.onBlockClicked(pos, side, manager))
{
ci.cancel();
}
}
public static void onPlayerMoved(CallbackInfo ci, NetHandlerPlayServer netHandler, C03PacketPlayer packet, WorldServer world, double oldPosX,
double oldPosY, double oldPosZ)
{
if (!Proxy.broker.onPlayerMove(netHandler, packet, netHandler.playerEntity, world))
{
ci.cancel();
}
}
public static void onPlayerMoved(CallbackInfo ci, NetHandlerPlayServer netHandler, C03PacketPlayer packet, WorldServer world, double oldPosX,
double oldPosY, double oldPosZ, double deltaMoveSq, double deltaX, double deltaY, double deltaZ)
{
if (!Proxy.broker.onPlayerMove(netHandler, packet, netHandler.playerEntity, world))
{
ci.cancel();
}
}
}