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


Java PacketDispatcher.sendPacketToAllPlayers方法代碼示例

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


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

示例1: dispatchPackage

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public void dispatchPackage() { //packet server-to-player
	Packet250CustomPayload packet = new Packet250CustomPayload();
	ByteArrayOutputStream stream = new ByteArrayOutputStream(21);
	DataOutputStream outputStream = new DataOutputStream(stream);
	try {
		outputStream.writeInt(coinSum);
		outputStream.writeInt(xCoord);
		outputStream.writeInt(yCoord);
		outputStream.writeInt(zCoord);
		outputStream.writeInt(this.worldObj.getWorldInfo().getVanillaDimension());
		outputStream.writeBoolean(bypassActive);
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	packet.channel = "UCTS_TileEntity";
	packet.data = stream.toByteArray();
	packet.length = stream.size();
	PacketDispatcher.sendPacketToAllPlayers(packet);
}
 
開發者ID:TED-996,項目名稱:UniversalCoinsMod,代碼行數:20,代碼來源:UCTileEntity.java

示例2: BlockVisibilitySender

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public static void BlockVisibilitySender(boolean result) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
    DataOutputStream outputStream = new DataOutputStream(bos);
    try {
        outputStream.writeBoolean(result);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    Packet250CustomPayload packet_sender = new Packet250CustomPayload();
    packet_sender.channel = "Apocalyptic-bv";
    packet_sender.data = bos.toByteArray();
    packet_sender.length = bos.size();
    if (side == Side.SERVER) {
        PacketDispatcher.sendPacketToAllPlayers(packet_sender);
    }
}
 
開發者ID:kunik-ru,項目名稱:Apocalyptic,代碼行數:18,代碼來源:PacketHandler.java

示例3: onNetworkPatternChange

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@ForgeSubscribe
public void onNetworkPatternChange(GridPatternUpdateEvent e)
{
	if (grid != null)
	{
		IMEInventoryHandler inventoryHandler = grid.getCraftableArray();
		if (inventoryHandler != null)
		{
			craftableFluidsInNetwork = new ArrayList<Fluid>();
			for (IAEItemStack stack : inventoryHandler.getAvailableItems())
			{
				if (stack.getItem() == FLUIDDISPLAY.getItemInstance())
				{
					craftableFluidsInNetwork.add(FluidRegistry.getFluid(stack.getItemDamage()));
				}
			}
		}
	}
	PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:21,代碼來源:TileEntityTerminalFluid.java

示例4: onItemRightClick

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
	MinecraftForge.EVENT_BUS.post(new UseItemEvent(player, this));
	itemStack.stackSize--;
	EntityStats stats = Dota2Items.stats.getOrCreateEntityStats(player);
	long startTime = world.getTotalWorldTime();
	long endTime = startTime + (long) (duration * MCConstants.TICKS_PER_SECOND);
	BuffInstance buffInst = new BuffInstance(Buff.clarity, player, startTime, endTime, true);
	boolean buffAdded = stats.addBuff(buffInst);
	PacketDispatcher.sendPacketToAllPlayers(new BuffForcePacket(buffInst).makePacket());
	player.playSound(Sound.CLARITY.getName(), 0.7f, 1);
	if (!player.worldObj.isRemote && buffAdded) {
		EffectClarity effect = new EffectClarity(player);
		player.worldObj.spawnEntityInWorld(effect);
	}
	return itemStack;
}
 
開發者ID:Hunternif,項目名稱:Dota2Items,代碼行數:18,代碼來源:Clarity.java

示例5: doSpellTargetEffect

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public void doSpellTargetEffect(World worldObj, int posX, int posY, int posZ, EntityLivingBase entityHit) 
{
	for (int i = 0; i < 3; i++)
	{
		final double nextX = SpellboundCore.modRandom.nextBoolean() ? SpellboundCore.modRandom.nextInt(15) + 10 : SpellboundCore.modRandom.nextInt(15) + 10 * -1;
		final double nextZ = SpellboundCore.modRandom.nextBoolean() ? SpellboundCore.modRandom.nextInt(15) + 10 : SpellboundCore.modRandom.nextInt(15) + 10 * -1;
		
		worldObj.spawnEntityInWorld(new EntityLightningBolt(worldObj, posX + nextX, posY, posZ + nextZ));
		PacketDispatcher.sendPacketToAllPlayers(PacketHandler.createLightningPacket(posX + nextX, posY, posZ + nextZ));
	}
	
	final EntityMeteor meteor = new EntityMeteor(caster, this);
	meteor.setPosition(posX + SpellboundCore.modRandom.nextGaussian(), 255, posZ + SpellboundCore.modRandom.nextGaussian());
	worldObj.spawnEntityInWorld(meteor);
}
 
開發者ID:WildBamaBoy,項目名稱:spellbound,代碼行數:17,代碼來源:SpellMeteor.java

示例6: onNeighborBlockChange

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID)
{
	super.onNeighborBlockChange(world, x, y, z, neighborID);
	if (!world.isRemote)
	{
		if (world.getBlockTileEntity(x, y, z) instanceof TileEntityBusFluidExport)
			PacketDispatcher.sendPacketToAllPlayers(world.getBlockTileEntity(x, y, z).getDescriptionPacket());
		((TileEntityBusFluidExport) world.getBlockTileEntity(x, y, z)).setRedstoneStatus(world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z));
	}
	ForgeDirection blockOrientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
	TileEntity blockTE = world.getBlockTileEntity(x, y, z);
	if (blockTE instanceof TileEntityBusFluidExport)
	{
		TileEntity fluidHandler = world.getBlockTileEntity(x + blockOrientation.offsetX, y + blockOrientation.offsetY, z + blockOrientation.offsetZ);
		((TileEntityBusFluidExport) blockTE).setFluidHandler(fluidHandler instanceof IFluidHandler ? (IFluidHandler) fluidHandler : null);
	}
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:19,代碼來源:BlockBusFluidExport.java

示例7: syncSpear

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public void syncSpear() 
   {
   	if(!worldObj.isRemote)
   	{
   		try
   		{
   			Packet packet = PacketManagerMF.getPacketItemStackArray(this, 0, getSpear());
   			PacketDispatcher.sendPacketToAllPlayers(packet);
   		}catch(Exception e){}
   	}
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:12,代碼來源:EntityThrownSpear.java

示例8: syncItems

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public void syncItems() 
   {
   	if(!worldObj.isRemote)
   	{
   		try
   		{
   			for(int a = 0; a < this.getSizeInventory(); a ++)
   			{
   				Packet packet = PacketManagerMF.getPacketItemStackArray(this, a, getStackInSlot(a));
   				PacketDispatcher.sendPacketToAllPlayers(packet);
   			}
   						
   		}catch(Exception e){}
   	}
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:16,代碼來源:TileEntityWeaponRack.java

示例9: onNeighborBlockChange

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID)
{
	if (!world.isRemote)
	{
		PacketDispatcher.sendPacketToAllPlayers(world.getBlockTileEntity(x, y, z).getDescriptionPacket());
	}
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:9,代碼來源:BlockCertusTank.java

示例10: setPowerStatus

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public void setPowerStatus(boolean hasPower)
{
	powerStatus = hasPower;
	PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
	worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:8,代碼來源:TileEntityMonitorStorageFluid.java

示例11: playerLoggedIn

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
//SERVER SIDE
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {
	PacketDispatcher.sendPacketToPlayer(getSkillAllUpdatePacket(), player);
	PacketDispatcher.sendPacketToAllPlayers(getAllSkillsUpdatePacket(netHandler.getPlayer().username));
	SCLog.info("Send all skills to " + netHandler.getPlayer().username);
}
 
開發者ID:ElConquistador,項目名稱:SkillCraft,代碼行數:8,代碼來源:SCPacketHandler.java

示例12: drain

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
	if (from == ForgeDirection.UNKNOWN)
		return null;
	FluidStack drained = tanks[from.ordinal()].drain(maxDrain, doDrain);
	if (drained != null)
		PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
	return drained;
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:11,代碼來源:TileEntityInterfaceFluid.java

示例13: fill

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
	if (from == ForgeDirection.UNKNOWN || resource == null)
		return 0;

	int filled = 0;
	filled += fillToNetwork(resource, doFill);

	if (filled < resource.amount)
		filled += tanks[from.ordinal()].fill(new FluidStack(resource.fluidID, resource.amount - filled), doFill);
	if (filled > 0)
		PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
	return filled;
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:16,代碼來源:TileEntityInterfaceFluid.java

示例14: sendCapeUpdate

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
public static void sendCapeUpdate(String player, String capeUrl) {
    if (capeUrl == null) {
        capeUrl = "";
    }
    Object[] data = new Object[] { player, capeUrl };

    PacketDispatcher.sendPacketToAllPlayers(PacketWrapper.createPacket(HexxitGear.modNetworkChannel, Packets.CapeChange, data));
}
 
開發者ID:sct,項目名稱:HexxitGear,代碼行數:9,代碼來源:CapeHandler.java

示例15: doSpellTargetEffect

import cpw.mods.fml.common.network.PacketDispatcher; //導入方法依賴的package包/類
@Override
public void doSpellTargetEffect(World worldObj, int posX, int posY, int posZ, EntityLivingBase entityHit) 
{
	if (entityHit != null)
	{
		PacketDispatcher.sendPacketToAllPlayers(PacketHandler.createColdGFXPacket(2, 0, entityHit.posX, entityHit.posY, entityHit.posZ));
		
		for (final Point3D point : Logic.getNearbyBlocks(worldObj, (int)entityHit.posX, (int)entityHit.posY, (int)entityHit.posZ, 3, Constants.SNOW_SUPPORTERS))
		{
			if (worldObj.getBlockId(point.posX, point.posY + 1, point.posZ) == 0)
			{
				worldObj.setBlock(point.posX, point.posY + 1, point.posZ, Block.snow.blockID);
			}
		}

		if (entityHit instanceof EntityPlayer)
		{
			if (!SpellboundCore.getInstance().entityHasActiveSpell((EntityPlayer)entityHit, SpellShieldOfInvulnerability.class) && !SpellboundCore.getInstance().entityHasActiveSpell((EntityPlayer)entityHit, SpellColdShield.class))
			{							
				entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
				entityHit.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1200));
				entityHit.extinguish();
			}
		}

		else
		{
			entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
			entityHit.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1200));
			entityHit.extinguish();
		}
	}
}
 
開發者ID:WildBamaBoy,項目名稱:spellbound,代碼行數:34,代碼來源:SpellColdLvl2.java


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