當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。