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


Java Packet.writeItemStack方法代碼示例

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


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

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

示例2: writeWatchableObject

import net.minecraft.network.packet.Packet; //導入方法依賴的package包/類
private static void writeWatchableObject(DataOutput par0DataOutput, WatchableObject par1WatchableObject) throws IOException
{
    int i = (par1WatchableObject.getObjectType() << 5 | par1WatchableObject.getDataValueId() & 31) & 255;
    par0DataOutput.writeByte(i);

    switch (par1WatchableObject.getObjectType())
    {
        case 0:
            par0DataOutput.writeByte(((Byte)par1WatchableObject.getObject()).byteValue());
            break;
        case 1:
            par0DataOutput.writeShort(((Short)par1WatchableObject.getObject()).shortValue());
            break;
        case 2:
            par0DataOutput.writeInt(((Integer)par1WatchableObject.getObject()).intValue());
            break;
        case 3:
            par0DataOutput.writeFloat(((Float)par1WatchableObject.getObject()).floatValue());
            break;
        case 4:
            Packet.writeString((String)par1WatchableObject.getObject(), par0DataOutput);
            break;
        case 5:
            ItemStack itemstack = (ItemStack)par1WatchableObject.getObject();
            Packet.writeItemStack(itemstack, par0DataOutput);
            break;
        case 6:
            ChunkCoordinates chunkcoordinates = (ChunkCoordinates)par1WatchableObject.getObject();
            par0DataOutput.writeInt(chunkcoordinates.posX);
            par0DataOutput.writeInt(chunkcoordinates.posY);
            par0DataOutput.writeInt(chunkcoordinates.posZ);
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:34,代碼來源:DataWatcher.java

示例3: sendBookToServer

import net.minecraft.network.packet.Packet; //導入方法依賴的package包/類
private void sendBookToServer(boolean par1)
{
    if (this.bookIsUnsigned && this.bookModified)
    {
        if (this.bookPages != null)
        {
            while (this.bookPages.tagCount() > 1)
            {
                NBTTagString nbttagstring = (NBTTagString)this.bookPages.tagAt(this.bookPages.tagCount() - 1);

                if (nbttagstring.data != null && nbttagstring.data.length() != 0)
                {
                    break;
                }

                this.bookPages.removeTag(this.bookPages.tagCount() - 1);
            }

            if (this.itemstackBook.hasTagCompound())
            {
                NBTTagCompound nbttagcompound = this.itemstackBook.getTagCompound();
                nbttagcompound.setTag("pages", this.bookPages);
            }
            else
            {
                this.itemstackBook.setTagInfo("pages", this.bookPages);
            }

            String s = "MC|BEdit";

            if (par1)
            {
                s = "MC|BSign";
                this.itemstackBook.setTagInfo("author", new NBTTagString("author", this.editingPlayer.getCommandSenderName()));
                this.itemstackBook.setTagInfo("title", new NBTTagString("title", this.bookTitle.trim()));
                this.itemstackBook.itemID = Item.writtenBook.itemID;
            }

            ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
            DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);

            try
            {
                Packet.writeItemStack(this.itemstackBook, dataoutputstream);
                this.mc.getNetHandler().addToSendQueue(new Packet250CustomPayload(s, bytearrayoutputstream.toByteArray()));
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
        }
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:54,代碼來源:GuiScreenBook.java


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