本文整理汇总了Java中net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent方法的典型用法代码示例。如果您正苦于以下问题:Java FMLNetworkEvent.ServerCustomPacketEvent方法的具体用法?Java FMLNetworkEvent.ServerCustomPacketEvent怎么用?Java FMLNetworkEvent.ServerCustomPacketEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fml.common.network.FMLNetworkEvent
的用法示例。
在下文中一共展示了FMLNetworkEvent.ServerCustomPacketEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: packetToServer
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void packetToServer(FMLNetworkEvent.ServerCustomPacketEvent event) {
ByteBuf buf = event.packet.payload();
byte kind = buf.readByte();
NetHandlerPlayServer handler = (NetHandlerPlayServer) event.handler;
EntityPlayerMP player = handler.playerEntity;
if (kind == INTERACT_HIT || kind == INTERACT_USE) {
Coord at = readCoord(buf, player);
EnumFacing side = readSide(buf);
if (!at.blockExists()) return;
double reachSq = 6 * 6; // FIXME: There's no way to get this properly on the server?
if (at.distanceSq(player) > reachSq) {
log("Ignoring distant interaction packet for " + at + " from " + player);
return;
}
FlatFace face = Flat.get(at, side);
if (kind == INTERACT_HIT) {
face.onHit(at, side, player);
} else {
face.onActivate(at, side, player);
}
} else {
log("Invalid packet ID " + kind + " from " + player);
}
}
示例2: onServerPacket
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onServerPacket(final FMLNetworkEvent.ServerCustomPacketEvent event) {
final AbstractMBPacket packet = map.get(event.getPacket().channel());
if (packet != null) {
Battlegear.proxy.getThreadListener().addScheduledTask(new Runnable() {
@Override
public void run() {
packet.process(event.getPacket().payload(), ((NetHandlerPlayServer) event.getHandler()).player);
}
});
}
}
示例3: onPacketDataServer
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPacketDataServer(FMLNetworkEvent.ServerCustomPacketEvent event) {
FMLProxyPacket pkt = event.packet;
onPacketData(event.manager, pkt, ((NetHandlerPlayServer) event.handler).playerEntity);
}
示例4: onServerPacket
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onServerPacket(FMLNetworkEvent.ServerCustomPacketEvent event){
}