本文整理汇总了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());
}
}
示例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);
}
}
示例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();
}
}
}
}