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


Java PacketDispatcher类代码示例

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


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

示例1: drawGuiContainerBackgroundLayer

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
	GL11.glColor3f(1, 1, 1);
	Minecraft.getMinecraft().renderEngine.bindTexture(RivalRebels.guilaptopnuke);
	int x = (width - xSize) / 2;
	int y = (height - ySize) / 2;
	this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
	if (lt.hasChips()) this.drawTexturedModalRect(x + 135, y + 79, 248, 0, 8, 8);
	Minecraft.getMinecraft().fontRenderer.drawString(StatCollector.translateToLocal("RivalRebels.controller.B83"), x + 118, y + 11, 0xffffff);
	Minecraft.getMinecraft().fontRenderer.drawString(StatCollector.translateToLocal("RivalRebels.controller.b2spirit"), x + 25, y + 11, 0xffffff);
	Minecraft.getMinecraft().fontRenderer.drawString(StatCollector.translateToLocal("x" + lt.b2spirit), x + 154, y + 96, 0xffffff);
	Minecraft.getMinecraft().fontRenderer.drawString(StatCollector.translateToLocal("x" + lt.b2carpet), x + 154, y + 85, 0xffffff);
	if (button.mousePressed(mc, par2, par3) && Mouse.isButtonDown(0) && !prevButtonDown)
	{
		PacketDispatcher.packetsys.sendToServer(new LaptopButtonPacket(lt.xCoord, lt.yCoord, lt.zCoord));
	}
	prevButtonDown = Mouse.isButtonDown(0);
}
 
开发者ID:rodolphito,项目名称:Rival-Rebels-Mod,代码行数:20,代码来源:GuiLaptop.java

示例2: 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

示例3: requestCoinSumPackage

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
void requestCoinSumPackage(){
	Packet250CustomPayload packet = new Packet250CustomPayload();
	ByteArrayOutputStream stream = new ByteArrayOutputStream(16);
	DataOutputStream outputStream = new DataOutputStream(stream);
	try {
		outputStream.writeInt(xCoord);
		outputStream.writeInt(yCoord);
		outputStream.writeInt(zCoord);
		outputStream.writeInt(this.worldObj.getWorldInfo().getVanillaDimension());
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	packet.channel = "UCTS_TE_Request";
	packet.data = stream.toByteArray();
	packet.length = stream.size();
	PacketDispatcher.sendPacketToServer(packet);
}
 
开发者ID:TED-996,项目名称:UniversalCoinsMod,代码行数:18,代码来源:UCTileEntity.java

示例4: onBlockActivated

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
@Override
 public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2) 
 {
 	TileEntityAnvil tile = (TileEntityAnvil) world.getBlockTileEntity(x, y, z);
 	 if(tile == null)
      {
      	return super.onBlockActivated(world, x, y, z, player, i, f, f1, f2);
      }
 	 
 	if(world.isRemote)
{
 		int slot = tile.getSlotFor(f, f2);
         this.useInventory(world, x, y, z, tile, player, i, slot);
         
	Packet packet = PacketManagerMF.getPacketIntegerArray(tile, new int[]{1, player.entityId, i, slot});
	try
	{
		PacketDispatcher.sendPacketToServer(packet);
	} catch(NullPointerException e)
	{
		System.out.println("MineFantasy: Client connection lost");
	}
}
     
     return true;
 }
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:27,代码来源:BlockAnvilMF.java

示例5: onBlockActivated

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
@Override
 public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2)
 {
 	TileEntityTailor tile = (TileEntityTailor) world.getBlockTileEntity(x, y, z);
     if(tile == null)
     {
     	return super.onBlockActivated(world, x, y, z, player, i, f, f1, f2);
     }
     if(world.isRemote)
{
 		int slot = tile.getSlotFor(f, f2);
         this.useInventory(world, x, y, z, tile, player, i, slot);
         
	Packet packet = PacketManagerMF.getPacketIntegerArray(tile, new int[]{1, player.entityId, i, slot});
	try
	{
		PacketDispatcher.sendPacketToServer(packet);
	} catch(NullPointerException e)
	{
		System.out.println("MineFantasy: Client connection lost");
	}
}
     
     return true;
 }
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:26,代码来源:BlockTailor.java

示例6: onBlockActivated

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
@Override
  public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2) 
  {
  	TileEntityWeaponRack tile = (TileEntityWeaponRack)world.getBlockTileEntity(x, y, z);

if(world.isRemote)
	{
	int slot = tile.getSlotFor(f, f2);
	if(slot >= 0 && slot < 4)
	{
    	tryPlaceItem(slot, world, tile, player);
	}
	
		Packet packet = PacketManagerMF.getPacketIntegerArray(tile, new int[]{1, player.entityId, i, slot});
		try
		{
			PacketDispatcher.sendPacketToServer(packet);
		} catch(NullPointerException e)
		{
			System.out.println("MineFantasy: Client connection lost");
		}
	}

      return true;
  }
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:26,代码来源:BlockWeaponRack.java

示例7: updateAmount

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
private void updateAmount() {
	int amount = item == null ? 0 : item.stackSize;
	if (prevAmount != amount || prevMaxSize != maxSize) {
		World world = turtle.getWorld();
		Vec3 pos = turtle.getPosition();
		int x = (int)Math.floor(pos.xCoord);
		int y = (int)Math.floor(pos.yCoord);
		int z = (int)Math.floor(pos.zCoord);
		
		ByteArrayDataOutput os = ByteStreams.newDataOutput();
		os.writeInt(x);
		os.writeInt(y);
		os.writeInt(z);
		os.writeInt(amount);
		os.writeInt(maxSize);
		PacketDispatcher.sendPacketToAllAround(pos.xCoord + 0.5D, pos.yCoord + 0.5D, pos.zCoord + 0.5D, 64.0D, world.provider.dimensionId, PacketDispatcher.getTinyPacket(MiscPeripherals.instance, (short)5, os.toByteArray()));
	}
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:19,代码来源:PeripheralBarrel.java

示例8: mousePressed

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
@Override
public boolean mousePressed(Minecraft minecraft, int par2, int par3)
{
	if (renderID != 0)
		return super.mousePressed(minecraft, par2, par3);

	this.enabled = !super.mousePressed(minecraft, par2, par3);
	if (!this.enabled && this.renderID == 0)
	{
		Packet250CustomPayload packet = new Packet250CustomPayload();
		packet.length = 1;
		packet.data = new byte[] { 0 };
		packet.channel = Reference.CHANNEL;
		PacketDispatcher.sendPacketToServer(packet);
	}
	return !this.enabled;
}
 
开发者ID:tterrag1098,项目名称:RecipeIGE,代码行数:18,代码来源:SmallButton.java

示例9: order

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
private void order()
{
	if( !m_ordered )
	{
		// Send our orders to the server
		for( int i=0; i<NUM_SETS; ++i )
		{
			if( m_orders[i] )
			{
				BillundPacket packet = new BillundPacket();
				packet.packetType = BillundPacket.OrderSet;
				packet.dataInt = new int[] { i };
				PacketDispatcher.sendPacketToServer( packet.toPacket() );
			}
		}
		
		// Ensure we don't order again
		m_ordered = true;
	}
}
 
开发者ID:dan200,项目名称:Billund,代码行数:21,代码来源:GuiOrderForm.java

示例10: overlayRecipe

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift)
{
    List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);

    NBTTagCompound root = new NBTTagCompound();
    for (PositionedStack stack : ingredients)
    {
        int x = (stack.relx - 25) / 18;
        int y = (stack.rely - 6) / 18;
        root.setCompoundTag(String.valueOf((x + y * 3)), stack.item.writeToNBT(new NBTTagCompound()));
    }
    PacketDispatcher.sendPacketToServer(NetworkHelper.makeNBTPacket(CHANNEL_NEI, root));

    ((AutoCrafterGui) firstGui).inventorySlots.getSlot(0).putStack(recipe.getResultStack(recipeIndex).item);
}
 
开发者ID:CCM-Modding,项目名称:AutoCrafter2000,代码行数:17,代码来源:AutoCrafterOverlayHandler.java

示例11: 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

示例12: 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

示例13: onMouseClick

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
@Subscribe
public void onMouseClick(MouseClickEvent event)
{
    if (event.getComponent().getAction().equals(btnSit.getAction()))
    {
        bot.setSitting(!bot.isSitting());
        PacketDispatcher.sendPacketToServer(new PacketBuddyBotSit(bot.entityId).makePacket());
        btnSit.setText(bot.isSitting() ? LangHelper.translate("gui", "button.stand") : LangHelper.translate("gui", "button.sit"));
    }

    if (event.getComponent().getAction().equals(btnNext.getAction()))
    {
        if (currentPage < pages.size() - 1)
            setCurrentPage(currentPage + 1);
    }

    if (event.getComponent().getAction().equals(btnPrev.getAction()))
    {
        if (currentPage > 0)
            setCurrentPage(currentPage - 1);
    }
}
 
开发者ID:PaleoCrafter,项目名称:R0b0ts,代码行数:23,代码来源:WindowIngameManual.java

示例14: setGrid

import cpw.mods.fml.common.network.PacketDispatcher; //导入依赖的package包/类
@Override
public void setGrid(IGridInterface gi)
{
	if (!worldObj.isRemote)
	{
		grid = gi;
		if (gi != null)
		{
			IMEInventoryHandler cellArray = gi.getCellArray();
			if (cellArray != null)
				updateFluids(cellArray.getAvailableItems());
		} else
		{
			setPowerStatus(false);
		}
		PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
	}
}
 
开发者ID:ExtraCells,项目名称:ExtraCells1,代码行数:19,代码来源:TileEntityTerminalFluid.java

示例15: 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


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