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


Java PacketDispatcher.sendPacketToPlayer方法代碼示例

本文整理匯總了Java中cpw.mods.fml.common.network.PacketDispatcher.sendPacketToPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java PacketDispatcher.sendPacketToPlayer方法的具體用法?Java PacketDispatcher.sendPacketToPlayer怎麽用?Java PacketDispatcher.sendPacketToPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cpw.mods.fml.common.network.PacketDispatcher的用法示例。


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

示例1: LifePacketSender

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public static void LifePacketSender(double radiation, String name) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
    DataOutputStream outputStream = new DataOutputStream(bos);
    try {
        outputStream.writeDouble(radiation);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    Packet250CustomPayload packet_sender = new Packet250CustomPayload();
    packet_sender.channel = "Apocalyptic-rad";
    packet_sender.data = bos.toByteArray();
    packet_sender.length = bos.size();

    if (side == Side.SERVER) {
        PacketDispatcher.sendPacketToPlayer(packet_sender, getPlayer(name));
    }
}
 
開發者ID:kunik-ru,項目名稱:Apocalyptic,代碼行數:19,代碼來源:PacketHandler.java

示例2: sendCarvingData

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public void sendCarvingData(byte[] carvingData, Player player)
{
	try
	{
		ByteArrayOutputStream byteStream = new ByteArrayOutputStream(17);
		DataOutputStream dataStream = new DataOutputStream(byteStream);
		dataStream.writeByte(PacketHandler.CARVING_DATA);
		dataStream.writeInt(this.entityId);
		dataStream.writeInt(carvingData.length);
		dataStream.write(carvingData);

		Packet250CustomPayload packet = new Packet250CustomPayload();
		packet.channel = PacketHandler.CHANNEL_NAME;
		packet.data = byteStream.toByteArray();
		packet.length = packet.data.length;

		PacketDispatcher.sendPacketToPlayer(packet, player);
	}
	catch(Throwable tt)
	{
		tt.printStackTrace();
	}
}
 
開發者ID:VegasGoat,項目名稱:WoodworkingTFC,代碼行數:24,代碼來源:ContainerCarvingBase.java

示例3: processCommand

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void processCommand(final ICommandSender icommandsender,
		final String[] astring) {
	try {
		PacketCommandBase p = null;
		if (astring.length == 1) {
			p = createPacket(astring[0]);
		}
		if (p != null) {
			PacketDispatcher.sendPacketToPlayer(p.write(),
					(Player) getCommandSenderAsPlayer(icommandsender));
		}
	} catch (final Exception e) {
		FMLLog.log(VoiceChat.MOD_ID, Level.SEVERE, e, "");
	}
}
 
開發者ID:Nauja,項目名稱:Minecraft-VoiceChat,代碼行數:20,代碼來源:CommandVoiceBase.java

示例4: doSpellCasterEffect

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public void doSpellCasterEffect(EntityPlayer caster) 
{
	caster.worldObj.playSoundAtEntity(caster, "mob.enderdragon.wings", 1.0F, 1.0F);
	
	if (caster.onGround)
	{
		caster.motionY += 1.0D;
	}
	
	caster.fallDistance = 0;
	caster.capabilities.allowFlying = true;
	caster.capabilities.isFlying = true;
	
	SpellboundCore.getInstance().addActiveSpellToEntity(caster, this, 400);
	PacketDispatcher.sendPacketToPlayer(PacketHandler.createFlightPacket(true), (Player) caster);
}
 
開發者ID:WildBamaBoy,項目名稱:spellbound,代碼行數:18,代碼來源:SpellFlightLvl2.java

示例5: interactEvent

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
/**
 * For catching interactions with the Undertaker
 */
@ForgeSubscribe
public void interactEvent(EntityInteractEvent event)
{
    if (event.target instanceof EntityVillager && ((EntityVillager) event.target).getProfession() == BurialServices.getConfig().villagerID)
    {
        if (FMLCommonHandler.instance().getSide().isServer())
        {
            PacketDispatcher.sendPacketToPlayer(NetworkHelper.makeNBTPacket(BSConstants.CHANNEL_GRAVE_UPGRADE, MiscHelper.getPersistentDataTag(event.entityPlayer, BSConstants.NBT_PLAYER_GRAVE_DATA)), (Player) event.entityPlayer);
        }
        event.setCanceled(MinecraftServer.getServer().isSinglePlayer());
        FMLNetworkHandler.openGui(event.entityPlayer, BurialServices.instance, GuiHandler.undertakerID, event.entityPlayer.worldObj, 0, 0, 0);
    }
}
 
開發者ID:CCM-Modding,項目名稱:CcmBurialServicesInc,代碼行數:17,代碼來源:EventHandler.java

示例6: serverSendPacket

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Deprecated
public static void serverSendPacket(NetServerHandler handler, Packet packet)
{
    if (handler != null)
    {
        PacketDispatcher.sendPacketToPlayer(packet, (Player)handler.getPlayer());
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:9,代碼來源:ModLoader.java

示例7: playerLoggedIn

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
{
    Packet250CustomPayload[] fluidPackets = ForgePacket.makePacketSet(new FluidIdMapPacket());
    for (int i = 0; i < fluidPackets.length; i++) {
        PacketDispatcher.sendPacketToPlayer(fluidPackets[i], player);
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:9,代碼來源:ForgeConnectionHandler.java

示例8: onBlockActivated

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float offsetX, float offsetY, float offsetZ)
{
	if (!world.isRemote)
	{
		if (world.getBlockTileEntity(x, y, z) == null || player.isSneaking())
		{
			return false;
		}
		PacketDispatcher.sendPacketToPlayer(world.getBlockTileEntity(x, y, z).getDescriptionPacket(), (Player) player);
		player.openGui(Extracells.instance, 6, world, x, y, z);
	}
	return true;
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:15,代碼來源:BlockLevelEmitterFluid.java

示例9: onPlayerLogin

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public void onPlayerLogin(EntityPlayer player) 
{
	try
	{
		//Setup a stream for the new packet
		ByteArrayOutputStream streambyte = new ByteArrayOutputStream();
		DataOutputStream stream = new DataOutputStream(streambyte);
		try
       	{
			//add the serverKey to validate
       		stream.writeUTF("VALIDATE");
       	}
       	finally
       	{
       		//close our streams
       		stream.close();
       		streambyte.close();
       	}
		//send the packet
		PacketDispatcher.sendPacketToPlayer(new Packet250CustomPayload(Strings.packetChannel, streambyte.toByteArray()), (Player)player);
	}
	//catch ALL exceptions
	catch (Exception e)
	{
		e.printStackTrace();
	}
}
 
開發者ID:KitKat31337,項目名稱:ServerKey,代碼行數:29,代碼來源:PlayerTracker.java

示例10: sendBarsPacket

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public static void sendBarsPacket(EntityPlayer player)
{
    float[] essenceValues = EssenceBar.bars().ratios.get(player.username);
    float[] essenceDefaults = EssenceBar.bars().defaultRatios.get(player.username);
    float essenceLevel = EssenceBar.bars().levels.get(player.username);

    ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
    DataOutputStream outputStream = new DataOutputStream(bos);
    try 
    {
        outputStream.writeUTF(player.username);
        for(int i = 0; i < 5; i++)
            outputStream.writeFloat(essenceValues[i]);
        for(int i = 0; i < 5; i++)
            outputStream.writeFloat(essenceDefaults[i]);
        outputStream.writeFloat(essenceLevel);
    } 
    catch (Exception ex) 
    {
        ex.printStackTrace();
    }

    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "Essence";
    packet.data = bos.toByteArray();
    packet.length = bos.size();

    PacketDispatcher.sendPacketToPlayer(packet, (Player)player);
}
 
開發者ID:Hologuardian,項目名稱:Sojourn,代碼行數:30,代碼來源:PacketHandler.java

示例11: updateGuiTile

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public void updateGuiTile(String playername)
{
	Player player = (Player) worldObj.getPlayerEntityByName(playername);

	if (!worldObj.isRemote)
		PacketDispatcher.sendPacketToPlayer(getDescriptionPacket(), player);
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:8,代碼來源:TileEntityMEBattery.java

示例12: sendGrenadePacket

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public void sendGrenadePacket(World world, EntityGrenade grenade,
        String var, Object arg) {
    try {
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(baout);
        out.writeByte(grenadePacketID);
        out.writeInt(world.provider.dimensionId);
        out.writeInt(grenade.entityId);
        out.writeUTF(var);
        if (var.equals("parent")) {
            out.writeInt(((Entity) arg).entityId);
        } else if (var.equals("homing")) {
            out.writeBoolean((Boolean) arg);
        }
        out.close();
        Packet250CustomPayload packet = new Packet250CustomPayload();
        packet.channel = "bl2";
        packet.isChunkDataPacket = false;
        packet.data = baout.toByteArray();
        packet.length = baout.size();

        @SuppressWarnings("unchecked")
        Iterator<EntityPlayer> players = world.playerEntities.iterator();

        while (players.hasNext()) {
            EntityPlayer player = players.next();

            if (player.getDistanceSqToEntity(grenade) < 64.0D) {
                PacketDispatcher
                        .sendPacketToPlayer(packet, (Player) player);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:lombax5832,項目名稱:BL2,代碼行數:37,代碼來源:NetworkHandler.java

示例13: sendJoinUpdate

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public static void sendJoinUpdate(EntityPlayer player) {
    List<Object> tempList = new ArrayList<Object>();

    tempList.add(0, (byte) capes.size());

    for (String playerName : capes.keySet()) {
        tempList.add(playerName);
        tempList.add(capes.get(playerName));
    }

    PacketDispatcher.sendPacketToPlayer(PacketWrapper.createPacket(HexxitGear.modNetworkChannel, Packets.CapeJoin, tempList.toArray()), (Player) player);
}
 
開發者ID:sct,項目名稱:HexxitGear,代碼行數:13,代碼來源:CapeHandler.java

示例14: sync

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public final void sync()
{
	byte[] whichBytetoSend = {PacketHandler.EXTENDED_PROPERTIES, PacketHandler.EXTENDED_SPEC, PacketHandler.EXTENDED_STATS, PacketHandler.EXTENDED_CHAIN};
	float currentStats[] = this.getStats();

	for(int i=0; i<whichBytetoSend.length;i++){
		ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
		DataOutputStream outputStream = new DataOutputStream(bos);

		try {
			switch(i){
			case 0:
				outputStream.writeByte(whichBytetoSend[i]);
				outputStream.writeInt(this.currentJob);
				break;
			case 1:
				outputStream.writeByte(whichBytetoSend[i]);
				outputStream.writeInt(this.currentSpecialization);
				break;
			case 2:
				outputStream.writeByte(whichBytetoSend[i]);
				for(int j=0;j<4;j++){
					outputStream.writeFloat(currentStats[j]);
				}
				outputStream.writeInt(this.levelUpPoints);
				outputStream.writeInt(this.level);
				outputStream.writeInt(this.level);
				outputStream.writeInt(this.currentMateriaSelected);	
				break;
			case 3:
				outputStream.writeByte(whichBytetoSend[i]);
				outputStream.writeInt(this.chainLevel);
				outputStream.writeChars(this.lastEntityKilled);
				break;
			default: break;
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		Packet250CustomPayload packet = new Packet250CustomPayload("GenericClass", bos.toByteArray());

		// We only want to send from the server to the client
		if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
			EntityPlayerMP player1 = (EntityPlayerMP) player;
			PacketDispatcher.sendPacketToPlayer(packet, (Player) player1);
		}
	}
}
 
開發者ID:Unrelentless,項目名稱:FantasyCraft-Mod,代碼行數:49,代碼來源:FCraftJobCore.java

示例15: updateEntity

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public void updateEntity()
{
    super.updateEntity();
    if (worldObj.isRemote) return;
    debug(this);

    // Initialize code
    if (craftSlot == null)
    {
        internalPlayer = new InternalPlayer();
        craftSlot = new SlotCrafting(internalPlayer, inventoryIn, inventoryOut, xCoord, yCoord, zCoord);
    }

    boolean willCraft = true;
    // Lower tick rate
    tick++;
    if (AutoCrafter2000.getConfig().craftDelay != 0 && tick % AutoCrafter2000.getConfig().craftDelay != 0) willCraft = false;
    else tick = 0;
    debug("tickDelay", willCraft);

    // Redstone things
    boolean powered = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
    if (redstoneMode == 0 && powered) willCraft = false;
    if (redstoneMode == 1 && !powered) willCraft = false;
    debug("powered", powered);

    // Deal with overflow. If we couldn't empty, don't make new stuff.
    emptyOverflow();
    if (!overflow.isEmpty()) willCraft = false;
    debug("overflow.isEmpty", overflow.isEmpty());
    debug("recipe", recipe);

    ItemStack result = null;
    if (willCraft && recipe == null) willCraft = false;
    if (willCraft && !recipe.matches(inventoryIn, worldObj)) willCraft = false;
    debug("matches", willCraft);
    if (willCraft && (result = recipe.getCraftingResult(inventoryIn)) == null) willCraft = false;
    debug("result", result);
    if (willCraft && !InventoryHelper.hasSpaceFor(inventoryOut, result)) willCraft = false;
    debug("spacefor", willCraft);
    if (willCraft)
    {
        crafts++;
        result = result.copy(); // Won't be null cause then willCraft would have been false.
        if (AutoCrafter2000.getConfig().updateCraftCountLive) for (EntityPlayer player : players)
            PacketDispatcher.sendPacketToPlayer(PacketDispatcher.getPacket(CHANNEL_RMU, Joiner.on(";").join(this.xCoord, this.yCoord, this.zCoord, this.redstoneMode, this.crafts).getBytes()), (cpw.mods.fml.common.network.Player) player);

        // Craft!
        craftSlot.onPickupFromSlot(internalPlayer, result);

        // Overflow handling
        ItemStack stack = InventoryHelper.addToInventory(inventoryOut, result);
        if (stack != null) overflow.add(stack);
        debug("overflowFromCrafting", stack);
        for (int i = 0; i < internalPlayer.inventory.getSizeInventory(); i++)
        {
            stack = InventoryHelper.addToInventory(inventoryOut, internalPlayer.inventory.getStackInSlotOnClosing(i));
            if (stack != null) overflow.add(stack);
        }
        debug("overflow.size", overflow.size());
    }
    else reBalanceSlots(); // If we can't / won't craft, we rebalanced 1 slot.

    if (debugTicks > 0) debugTicks --;
    debug("debugTicks", debugTicks);
}
 
開發者ID:CCM-Modding,項目名稱:AutoCrafter2000,代碼行數:68,代碼來源:AutoCrafterTile.java


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