当前位置: 首页>>代码示例>>Java>>正文


Java FMLNetworkEvent.ServerCustomPacketEvent方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:26,代码来源:FlatNet.java

示例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);
            }
        });
    }
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:13,代码来源:BattlegearPacketHandeler.java

示例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);
}
 
开发者ID:worldwidewoogie,项目名称:demomod,代码行数:6,代码来源:DemoPacketHandler.java

示例4: onServerPacket

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onServerPacket(FMLNetworkEvent.ServerCustomPacketEvent event){

}
 
开发者ID:tjkenmate,项目名称:TeslaEssentials,代码行数:5,代码来源:ServerProxy.java


注:本文中的net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。