本文整理汇总了Java中net.minecraftforge.fml.common.network.FMLNetworkEvent类的典型用法代码示例。如果您正苦于以下问题:Java FMLNetworkEvent类的具体用法?Java FMLNetworkEvent怎么用?Java FMLNetworkEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FMLNetworkEvent类属于net.minecraftforge.fml.common.network包,在下文中一共展示了FMLNetworkEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: clientConnectedtoServer
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void clientConnectedtoServer(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
if (!CreeperHost.instance.active)
return;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server == null || server.isSinglePlayer() || discoverMode != Discoverability.PUBLIC)
return;
INetHandlerPlayServer handler = event.getHandler();
if (handler instanceof NetHandlerPlayServer)
{
EntityPlayerMP entity = ((NetHandlerPlayServer)handler).playerEntity;
playersJoined.add(entity.getUniqueID());
}
}
示例3: completeClientSideConnection
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
private void completeClientSideConnection(ConnectionType type)
{
this.connectionType = type;
FMLLog.info("[%s] Client side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
this.state = ConnectionState.CONNECTED;
MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientConnectedToServerEvent(manager, this.connectionType.name()));
}
示例4: onPlayerJoinServer
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent e)
{
if (e.isLocal())
{
singlePlayerGames++;
ConcurrentUtil.executor.execute(() ->
DiscordCE.client.getAccountManager().setGame("Minecraft [SP]"));
}
else
{
multiplayerGames++;
ConcurrentUtil.executor.execute(() ->
DiscordCE.client.getAccountManager().setGame("Minecraft [MP]"));
}
}
示例5: onConnectionCreated
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onConnectionCreated(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
JustEnoughDimensions.logInfo("FMLNetworkEvent.ServerConnectionFromClientEvent: Syncing dimension data to client");
DimensionSyncPacket packet = new DimensionSyncPacket();
packet.addDimensionData(DimensionConfig.instance().getRegisteredDimensions());
FMLEmbeddedChannel channel = JustEnoughDimensions.channels.get(Side.SERVER);
channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(event.getManager().channel().attr(NetworkDispatcher.FML_DISPATCHER).get());
channel.writeOutbound(packet);
}
示例6: onClientConnect
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
ProjectHelper.projectParts.clear();
ProjectHelper.projectTextureParts.clear();
for(ProjectInfo proj : ProjectHelper.projects.values())
{
proj.destroy();
}
for(Integer id : ProjectHelper.projectTextureIDs.values())
{
TextureUtil.deleteTexture(id);
}
ProjectHelper.projects.clear();
ProjectHelper.projectTextures.clear();
ProjectHelper.projectTextureIDs.clear();
}
示例7: onClientDisconnect
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
Hats.eventHandlerClient.hats.clear();
Hats.eventHandlerClient.mobHats.clear();
Hats.eventHandlerClient.playerWornHats.clear();
Hats.eventHandlerClient.requestedHats.clear();
if(Hats.eventHandlerClient.guiHatUnlocked != null)
{
Hats.eventHandlerClient.guiHatUnlocked.hatList.clear();
}
if(Hats.eventHandlerClient.guiNewTradeReq != null)
{
Hats.eventHandlerClient.guiNewTradeReq.hatList.clear();
}
Hats.eventHandlerClient.worldInstance = null;
}
示例8: fireNetRegistrationEvent
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@Override
public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side)
{
if (side == Side.CLIENT)
{
bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayClient>(manager, channelSet, channel, side, NetHandlerPlayClient.class));
}
else
{
bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayServer>(manager, channelSet, channel, side, NetHandlerPlayServer.class));
}
}
示例9: completeServerSideConnection
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
private synchronized void completeServerSideConnection(ConnectionType type)
{
this.connectionType = type;
FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
this.state = ConnectionState.CONNECTED;
MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
if (DEBUG_HANDSHAKE)
manager.closeChannel(new TextComponentString("Handshake Complete review log file for details."));
scm.initializeConnectionToPlayer(manager, player, serverHandler);
}
示例10: disconnect
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
{
if (side == Side.CLIENT)
{
MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager));
}
else
{
MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager));
}
cleanAttributes(ctx);
ctx.disconnect(promise);
}
示例11: close
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
{
if (side == Side.CLIENT)
{
MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager));
}
else
{
MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager));
}
cleanAttributes(ctx);
ctx.close(promise);
}
示例12: onDisconnect
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDisconnect(FMLNetworkEvent.ServerDisconnectionFromClientEvent event) {
INetHandlerPlayServer handlerServer = event.getHandler();
if(handlerServer instanceof NetHandlerPlayServer) {
purgeSelection(((NetHandlerPlayServer) handlerServer).player);
}
}
示例13: onClientConnection
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onClientConnection(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
exploTime.clear();
dismemberTimeout.clear();
explosionSources.clear();
}
示例14: clientConnectedToServer
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
/**
* Prints server connection info when the client connects to a server.
* <p>
* Test for this thread:
* http://www.minecraftforge.net/forum/index.php/topic,34546.0.html
*
* @param event The event
*/
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void clientConnectedToServer(FMLNetworkEvent.ClientConnectedToServerEvent event) {
final IThreadListener mainThread = Minecraft.getMinecraft();
mainThread.addScheduledTask(() -> {
final ServerData serverData = Minecraft.getMinecraft().getCurrentServerData();
Logger.info("Server Connected! Local? %s - Address: %s", event.isLocal(), serverData != null ? serverData.serverIP : "<No ServerData>");
});
}
示例15: onClientDisconnectFromServer
import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
@SuppressWarnings("unused")
public void onClientDisconnectFromServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
EntityPlayer player = ManeuverGear.proxy.getClientPlayer();
if(player == null) {
return;
}
unEquipGear(player);
}