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


Java Packet类代码示例

本文整理汇总了Java中net.minecraft.network.packet.Packet的典型用法代码示例。如果您正苦于以下问题:Java Packet类的具体用法?Java Packet怎么用?Java Packet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Packet类属于net.minecraft.network.packet包,在下文中一共展示了Packet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDescriptionPacket

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public Packet getDescriptionPacket()
{
    NBTTagCompound root = new NBTTagCompound();

    NBTTagList nbttaglist = root.getTagList("contents");
    for (ItemStack itemStack : contents)
    {
        nbttaglist.appendTag(itemStack == null ? new NBTTagCompound() : itemStack.writeToNBT(new NBTTagCompound()));
    }
    root.setTag("contents", nbttaglist);
    root.setString("username", username);
    root.setCompoundTag("holding", holding == null ? new NBTTagCompound() : holding.writeToNBT(new NBTTagCompound()));
    root.setString("text", BSConstants.TEXT_JOINER.join(text));
    root.setInteger("age", age);

    return new Packet132TileEntityData(xCoord, yCoord, zCoord, 15, root);
}
 
开发者ID:CCM-Modding,项目名称:CcmBurialServicesInc,代码行数:18,代码来源:GraveTE.java

示例2: syncItems

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
private void syncItems() 
   {
	if(!worldObj.isRemote)
	{
		for(int a = 0; a < armour.length; a ++)
		{
			Packet packet = PacketManagerMF.getPacketItemStackArray(this, a, armour[a]);
			try
			{
				FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet);
			} catch(NullPointerException e)
			{
				System.out.println("MineFantasy: Client connection lost");
				return;
			}
		}
	}
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:19,代码来源:EntityHound.java

示例3: func_96546_g

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public void func_96546_g(ScoreObjective par1ScoreObjective)
{
    List list = this.func_96548_f(par1ScoreObjective);
    Iterator iterator = this.field_96555_a.getConfigurationManager().playerEntityList.iterator();

    while (iterator.hasNext())
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next();
        Iterator iterator1 = list.iterator();

        while (iterator1.hasNext())
        {
            Packet packet = (Packet)iterator1.next();
            entityplayermp.playerNetServerHandler.sendPacketToPlayer(packet);
        }
    }

    this.field_96553_b.remove(par1ScoreObjective);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:20,代码来源:ServerScoreboard.java

示例4: func_77204_a

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public static MerchantRecipeList func_77204_a(DataInputStream p_77204_0_) throws IOException {
   MerchantRecipeList var1 = new MerchantRecipeList();
   int var2 = p_77204_0_.readByte() & 255;

   for(int var3 = 0; var3 < var2; ++var3) {
      ItemStack var4 = Packet.func_73276_c(p_77204_0_);
      ItemStack var5 = Packet.func_73276_c(p_77204_0_);
      ItemStack var6 = null;
      if(p_77204_0_.readBoolean()) {
         var6 = Packet.func_73276_c(p_77204_0_);
      }

      boolean var7 = p_77204_0_.readBoolean();
      MerchantRecipe var8 = new MerchantRecipe(var4, var6, var5);
      if(var7) {
         var8.func_82785_h();
      }

      var1.add(var8);
   }

   return var1;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:25,代码来源:MerchantRecipeList.java

示例5: syncItems

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
private void syncItems()
{
	recipe = getNewRecipe();
	maxProgress = this.getMaxTime();
	
	if(!worldObj.isRemote)
	{
		for(int a = 0; a < inv.length; a ++)
		{
			Packet packet = PacketManagerMF.getPacketItemStackArray(this, a, inv[a]);
			try
			{
				FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet);
			} catch(NullPointerException e)
			{
				System.out.println("MineFantasy: Client connection lost");
				return;
			}
		}
	}
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:22,代码来源:TileEntitySpinningWheel.java

示例6: writeRecipiesToStream

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public void writeRecipiesToStream(DataOutputStream par1DataOutputStream) throws IOException
{
    par1DataOutputStream.writeByte((byte)(this.size() & 255));

    for (int i = 0; i < this.size(); ++i)
    {
        MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(i);
        Packet.writeItemStack(merchantrecipe.getItemToBuy(), par1DataOutputStream);
        Packet.writeItemStack(merchantrecipe.getItemToSell(), par1DataOutputStream);
        ItemStack itemstack = merchantrecipe.getSecondItemToBuy();
        par1DataOutputStream.writeBoolean(itemstack != null);

        if (itemstack != null)
        {
            Packet.writeItemStack(itemstack, par1DataOutputStream);
        }

        par1DataOutputStream.writeBoolean(merchantrecipe.func_82784_g());
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:21,代码来源:MerchantRecipeList.java

示例7: sendPacketToClients

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
private void sendPacketToClients() {
	if (!worldObj.isRemote) {
		try 
		{
			Packet packet = PacketManagerMF.getPacketIntegerArray(this, new int[]
			{ 
					(int)fuel, progress, direction, isBurning() ? 1 : 0, doorAngle
			});
			
			
			FMLCommonHandler.instance().getMinecraftServerInstance()
					.getConfigurationManager()
					.sendPacketToAllPlayers(packet);
		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:20,代码来源:TileEntityOven.java

示例8: syncItems

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public void syncItems() 
   {
	if(!worldObj.isRemote)
	{
		for(int a = 0; a < items.length; a ++)
		{
			Packet packet = PacketManagerMF.getPacketItemStackArray(this, a, items[a]);
			try
			{
				FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet);
			} catch(NullPointerException e)
			{
				System.out.println("MineFantasy: Client connection lost");
				return;
			}
		}
	}
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:19,代码来源:TileEntityOven.java

示例9: func_77200_a

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public void func_77200_a(DataOutputStream p_77200_1_) throws IOException {
   p_77200_1_.writeByte((byte)(this.size() & 255));

   for(int var2 = 0; var2 < this.size(); ++var2) {
      MerchantRecipe var3 = (MerchantRecipe)this.get(var2);
      Packet.func_73270_a(var3.func_77394_a(), p_77200_1_);
      Packet.func_73270_a(var3.func_77397_d(), p_77200_1_);
      ItemStack var4 = var3.func_77396_b();
      p_77200_1_.writeBoolean(var4 != null);
      if(var4 != null) {
         Packet.func_73270_a(var4, p_77200_1_);
      }

      p_77200_1_.writeBoolean(var3.func_82784_g());
   }

}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:18,代码来源:MerchantRecipeList.java

示例10: func_96546_g

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public void func_96546_g(ScoreObjective p_96546_1_) {
   List var2 = this.func_96548_f(p_96546_1_);
   Iterator var3 = this.field_96555_a.func_71203_ab().field_72404_b.iterator();

   while(var3.hasNext()) {
      EntityPlayerMP var4 = (EntityPlayerMP)var3.next();
      Iterator var5 = var2.iterator();

      while(var5.hasNext()) {
         Packet var6 = (Packet)var5.next();
         var4.field_71135_a.func_72567_b(var6);
      }
   }

   this.field_96553_b.remove(p_96546_1_);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:17,代码来源:ServerScoreboard.java

示例11: splashWater

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public void splashWater()
{
	if(!isBurning())return;
	heat -= 100;
	if(heat < 0)heat = 0;
	
	worldObj.playSound(xCoord+0.5F, yCoord+0.4F, zCoord+0.5F, "random.fizz", 1.0F, 1.0F, true);
	worldObj.spawnParticle("smoke", xCoord+0.5F, yCoord+0.4F, zCoord+0.5F, 0, 0.05F, 0);
	
	
	
	if (!worldObj.isRemote) {
		try {
			Packet packet = PacketManagerMF.getPacketIntegerArray(this,
					new int[] {1, 0});
			FMLCommonHandler.instance().getMinecraftServerInstance()
					.getConfigurationManager()
					.sendPacketToAllPlayers(packet);
		} catch (NullPointerException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:24,代码来源:TileEntityForge.java

示例12: sendToAllNearExcept

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
/**
 * params: srcPlayer,x,y,z,d,dimension. The packet is not sent to the srcPlayer, but all other players where
 * dx*dx+dy*dy+dz*dz<d*d
 */
public void sendToAllNearExcept(EntityPlayer par1EntityPlayer, double par2, double par4, double par6, double par8, int par10, Packet par11Packet)
{
    for (int j = 0; j < this.playerEntityList.size(); ++j)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j);

        if (entityplayermp != par1EntityPlayer && entityplayermp.dimension == par10)
        {
            double d4 = par2 - entityplayermp.posX;
            double d5 = par4 - entityplayermp.posY;
            double d6 = par6 - entityplayermp.posZ;

            if (d4 * d4 + d5 * d5 + d6 * d6 < par8 * par8)
            {
                entityplayermp.playerNetServerHandler.sendPacketToPlayer(par11Packet);
            }
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:24,代码来源:ServerConfigurationManager.java

示例13: getEntityPacketInteger

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public static Packet getEntityPacketInteger(Entity entity, int dat)
{
	ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
	DataOutputStream dos = new DataOutputStream(bos);
	int id = entity.entityId;
	try {
		dos.writeInt(1);
		dos.writeInt(id);
		dos.writeInt(dat);
	} catch (IOException e) {
		System.out.println("Failed to send Entity packet");
	}
	Packet250CustomPayload pkt = new Packet250CustomPayload();
	pkt.channel = "MineFantasy";
	pkt.data = bos.toByteArray();
	pkt.length = bos.size();
	pkt.isChunkDataPacket = true;
	return pkt;
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:20,代码来源:PacketManagerMF.java

示例14: getEntityPacketIntegerArray

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public static Packet getEntityPacketIntegerArray(Entity entity, int[] dat)
{
	ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
	DataOutputStream dos = new DataOutputStream(bos);
	int id = entity.entityId;
	try {
		dos.writeInt(1);
		dos.writeInt(id);
		for(int a = 0; a < dat.length; a ++)
		dos.writeInt(dat[a]);
	} catch (IOException e) {
		System.out.println("Failed to send Entity packet");
	}
	Packet250CustomPayload pkt = new Packet250CustomPayload();
	pkt.channel = "MineFantasy";
	pkt.data = bos.toByteArray();
	pkt.length = bos.size();
	pkt.isChunkDataPacket = true;
	return pkt;
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:21,代码来源:PacketManagerMF.java

示例15: getEntityPacketMotionArray

import net.minecraft.network.packet.Packet; //导入依赖的package包/类
public static Packet getEntityPacketMotionArray(Entity entity, int moveID, double[] dat)
{
	ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
	DataOutputStream dos = new DataOutputStream(bos);
	int id = entity.entityId;
	try {
		dos.writeInt(1);
		dos.writeInt(id);
		dos.writeInt(moveID);
		for(int a = 0; a < dat.length; a ++)
		dos.writeDouble(dat[a]);
	} catch (IOException e) {
		System.out.println("Failed to send Entity packet");
	}
	Packet250CustomPayload pkt = new Packet250CustomPayload();
	pkt.channel = "MineFantasy";
	pkt.data = bos.toByteArray();
	pkt.length = bos.size();
	pkt.isChunkDataPacket = true;
	return pkt;
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:22,代码来源:PacketManagerMF.java


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