當前位置: 首頁>>代碼示例>>Java>>正文


Java NetHandlerPlayServer類代碼示例

本文整理匯總了Java中net.minecraft.network.NetHandlerPlayServer的典型用法代碼示例。如果您正苦於以下問題:Java NetHandlerPlayServer類的具體用法?Java NetHandlerPlayServer怎麽用?Java NetHandlerPlayServer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NetHandlerPlayServer類屬於net.minecraft.network包,在下文中一共展示了NetHandlerPlayServer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: serverPacket

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@SubscribeEvent
public void serverPacket(
		final ServerCustomPacketEvent ev )
{
	// find player
	final NetHandlerPlayServer srv = (NetHandlerPlayServer) ev.getPacket().handler();

	try
	{
		if ( serverPacketHandler != null )
		{
			serverPacketHandler.onPacketData( ev.getPacket(), ev.getHandler(), srv.playerEntity );
		}
	}
	catch ( final ThreadQuickExitException ext )
	{
		;
	}
}
 
開發者ID:AlgorithmX2,項目名稱:Ambidextrous,代碼行數:20,代碼來源:NetworkRouter.java

示例2: packetToServer

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的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

示例3: onClientPacket

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
/**
 * Invoked when the server receives a packet from the client
 */
@SubscribeEvent
public void onClientPacket(final ServerCustomPacketEvent event) {
	if (!event.getPacket().channel().equals(Reference.CHANNEL)) return;
	
	((NetHandlerPlayServer) event.getHandler()).player.getServerWorld().addScheduledTask(new Runnable() {
		@Override
		public void run() {
			try {handleClientPacket(event.getPacket(), ((NetHandlerPlayServer) event.getHandler()).player);}
			catch (Exception ex) {
				ex.printStackTrace(); 
				MoreCommands.INSTANCE.getLogger().warn("Error handling Packet");
			}
		}
	});
}
 
開發者ID:MrNobody98,項目名稱:morecommands,代碼行數:19,代碼來源:PacketDispatcher.java

示例4: clientConnectedtoServer

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的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.handler;
    if (handler instanceof NetHandlerPlayServer)
    {
        EntityPlayerMP entity = ((NetHandlerPlayServer) handler).playerEntity;
        playersJoined.add(entity.getUniqueID());
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:17,代碼來源:CreeperHostServer.java

示例5: clientConnectedtoServer

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的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());
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:17,代碼來源:CreeperHostServer.java

示例6: make

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@Override
FMLNetworkEvent.CustomPacketEvent<?> make(FMLProxyPacket msg)
{
    FMLNetworkEvent.CustomPacketEvent<?> event = null;
    if (msg.handler() instanceof NetHandlerPlayClient)
    {
        NetHandlerPlayClient client = (NetHandlerPlayClient) msg.handler();
        event = new FMLNetworkEvent.ClientCustomPacketEvent(client.getNetworkManager(), msg);
    }
    else if (msg.handler() instanceof NetHandlerPlayServer)
    {
        NetHandlerPlayServer server = (NetHandlerPlayServer) msg.handler();
        event = new FMLNetworkEvent.ServerCustomPacketEvent(server.getNetworkManager(), msg);
    }
    return event;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:FMLEventChannel.java

示例7: onMessage

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@Override
public IMessage onMessage(final MessageCreateDimension message, final MessageContext ctx)
{
	FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(new Runnable()
	{
		@Override
		public void run()
		{
			NetHandlerPlayServer netHandler = (NetHandlerPlayServer) ctx.netHandler;

			if (netHandler.player.canUseCommand(3, "simpledimensions"))
			{
				DimensionHandler.getInstance().createDimension(((NetHandlerPlayServer) ctx.netHandler).player, message.getWorldInfo());
			}
		}
	});

	return null;
}
 
開發者ID:lumien231,項目名稱:Simple-Dimensions,代碼行數:20,代碼來源:HandlerCreateDimension.java

示例8: handleServerSafe

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@Override
public void handleServerSafe(NetHandlerPlayServer netHandler) {
	EntityPlayer player = netHandler.playerEntity;
	World world = netHandler.playerEntity.getEntityWorld();
	if(world == null){
		return;
	}
	IEnhancement enhancement = EnhancementManager.getEnhancement(new ResourceLocation(id));
	
	TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
	if(tile !=null){
		if(tile instanceof TileEnhancementTable){
			TileEnhancementTable table = (TileEnhancementTable)tile;
			if(type == 0){
				table.applyEnhancement(player, enhancement);
			} else if(type == 1){
				table.removeEnhancement(player, enhancement);
			}
		}
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:22,代碼來源:PacketEnhancementTable.java

示例9: make

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@Override
FMLNetworkEvent.CustomPacketEvent<?> make(FMLProxyPacket msg)
{
    FMLNetworkEvent.CustomPacketEvent<?> event = null;
    if (msg.handler() instanceof NetHandlerPlayClient)
    {
        NetHandlerPlayClient client = (NetHandlerPlayClient) msg.handler();
        event = new FMLNetworkEvent.ClientCustomPacketEvent(client.func_147298_b(), msg);
    }
    else if (msg.handler() instanceof NetHandlerPlayServer)
    {
        NetHandlerPlayServer server = (NetHandlerPlayServer) msg.handler();
        event = new FMLNetworkEvent.ServerCustomPacketEvent(server.func_147362_b(), msg);
    }
    return event;
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:17,代碼來源:FMLEventChannel.java

示例10: serverInitiateHandshake

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
int serverInitiateHandshake()
{
    // Send mod salutation to the client
    // This will be ignored by vanilla clients
    this.state = ConnectionState.AWAITING_HANDSHAKE;
    this.manager.channel().pipeline().addFirst("fml:vanilla_detector", new VanillaTimeoutWaiter());
    // Need to start the handler here, so we can send custompayload packets
    serverHandler = new NetHandlerPlayServer(scm.func_72365_p(), manager, player);
    this.netHandler = serverHandler;
    // NULL the play server here - we restore it further on. If not, there are packets sent before the login
    player.field_71135_a = null;
    // manually for the manager into the PLAY state, so we can send packets later
    this.manager.func_150723_a(EnumConnectionState.PLAY);

    // Return the dimension the player is in, so it can be pre-sent to the client in the ServerHello v2 packet
    // Requires some hackery to the serverconfigmanager and stuff for this to work
    NBTTagCompound playerNBT = scm.getPlayerNBT(player);
    if (playerNBT!=null)
    {
        return playerNBT.func_74762_e("Dimension");
    }
    else
    {
        return 0;
    }
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:27,代碼來源:NetworkDispatcher.java

示例11: processEntityAction

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@Hook("net.minecraft.network.NetHandlerPlayServer#func_147357_a")
public static Hook.Result processEntityAction(NetHandlerPlayServer handler, CPacketEntityAction action) {
	if (action.getAction() == Action.START_FALL_FLYING) {
		PacketThreadUtil.checkThreadAndEnqueue(action, handler, handler.player.getServerWorld());
		handler.player.markPlayerActive();
		if (!handler.player.onGround && handler.player.motionY < 0.0D &&
				!handler.player.isElytraFlying() && !handler.player.isInWater()) {
			ItemStack item = getFormLiving0(handler.player);
			if (item.getItem() == Items.ELYTRA && ItemElytra.isUsable(item))
				handler.player.setElytraFlying();
		} else
			handler.player.clearElytraFlying();
		return Hook.Result.NULL;
	}
	return Hook.Result.VOID;
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:17,代碼來源:ExItemElytra.java

示例12: handle

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@Override
public void handle(NetworkManager origin) {
	FairyFactions.LOGGER.info("PacketSetFairyName.handle");
	
	final EntityPlayerMP player = ((NetHandlerPlayServer)origin.getNetHandler()).playerEntity;
	if( player != null ) {
		final EntityFairy fairy = FairyFactions.getFairy(this.fairyID);
		if( fairy == null ) {
			FairyFactions.LOGGER.warn("Unable to find fairy "+this.fairyID+" to rename.");
			return;
		}
		
		final String username = player.getGameProfile().getName();
		final String rulername = fairy.rulerName();
		if( fairy.nameEnabled() && rulername.equals(username) ) {
			fairy.setCustomName(this.name);
		} else {
			FairyFactions.LOGGER.warn("Attempt by '"+username+"' to rename fairy owned by '"+rulername+"'");
		}
		fairy.setNameEnabled(false);
	}
}
 
開發者ID:allaryin,項目名稱:FairyFactions,代碼行數:23,代碼來源:PacketSetFairyName.java

示例13: onPacket

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@SubscribeEvent
public void onPacket(final ServerCustomPacketEvent event) {
    WorldServer world = ((NetHandlerPlayServer) event.handler).playerEntity.getServerForPlayer();
    if (!world.isCallingFromMinecraftThread()) {
        world.addScheduledTask(new Runnable() {
            public void run() {
                handlePacket(event, true, ((NetHandlerPlayServer) event.handler).playerEntity);
            }
        });
    } else {
        handlePacket(event, true, ((NetHandlerPlayServer) event.handler).playerEntity);
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:14,代碼來源:FzNetEventHandler.java

示例14: onMessage

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@Override
public IMessage onMessage(PacketWarpButton message, MessageContext ctx)
{
	EntityPlayer player = ((NetHandlerPlayServer)ctx.netHandler).playerEntity;
	
	
	int cost = (int)ConfigSettings.expCostPerTeleport;
	
	
	if(cost != 0 && UtilExperience.getExpTotal(player) < cost )
	{
		player.addChatMessage(new TextComponentTranslation(I18n.translateToLocal("gui.chatexp")));
	}
	else
	{ 
		ItemEnderBook.teleport(player, message.slot);
	}
	
	return null;
}
 
開發者ID:LothrazarMinecraftMods,項目名稱:EnderBook,代碼行數:21,代碼來源:PacketWarpButton.java

示例15: onMessage

import net.minecraft.network.NetHandlerPlayServer; //導入依賴的package包/類
@Override
public IMessage onMessage(PacketNewButton message, MessageContext ctx)
{
	//since we are on the server right now:
	EntityPlayer player = ((NetHandlerPlayServer)ctx.netHandler).playerEntity;
	//otherwise, on the client we would use  Minecraft.getMinecraft().thePlayer;
/*
	//this shouldnt happen anyway but just in case
	if(player.getHeldItem() == null || 
			!(player.getHeldItem().getItem() instanceof ItemEnderBook))
	{
		//then cancel
		return null;
	}
	*/
	//it now passes the stack, in case the players hand becomes null/empty at some point during process
	
	
	ItemEnderBook.saveCurrentLocation(player,message.name);
	
	
	return null;
}
 
開發者ID:LothrazarMinecraftMods,項目名稱:EnderBook,代碼行數:24,代碼來源:PacketNewButton.java


注:本文中的net.minecraft.network.NetHandlerPlayServer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。