本文整理汇总了Java中net.minecraft.network.PacketBuffer.writeItemStack方法的典型用法代码示例。如果您正苦于以下问题:Java PacketBuffer.writeItemStack方法的具体用法?Java PacketBuffer.writeItemStack怎么用?Java PacketBuffer.writeItemStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.network.PacketBuffer
的用法示例。
在下文中一共展示了PacketBuffer.writeItemStack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendBook
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
private void sendBook(ItemStack stack) {
NBTTagList pages = new NBTTagList(); // page tag list
// copy pages into NBT
for(int i = 0; i < MAX_PAGES && parser.hasNext(); i++) {
pages.appendTag(new NBTTagString(parser.next().trim()));
page++;
}
// set our client side book
if(stack.hasTagCompound())
stack.getTagCompound().setTag("pages", pages);
else
stack.setTagInfo("pages", pages);
// publish the book
stack.setTagInfo("author", new NBTTagString(getLocalPlayer().getName()));
stack.setTagInfo("title", new NBTTagString(parent.name.get().replaceAll(NUMBER_TOKEN, "" + getBook()).trim()));
PacketBuffer buff = new PacketBuffer(Unpooled.buffer());
buff.writeItemStack(stack);
MC.getConnection().sendPacket(new CPacketCustomPayload("MC|BSign", buff));
}
示例2: toBytes
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf)
{
PacketBuffer pbuf = new PacketBuffer(buf);
pbuf.writeInt(slot);
pbuf.writeCompoundTag(cap);
pbuf.writeItemStack(stack);
}