本文整理汇总了Java中net.minecraft.network.PacketBuffer.writeItemStackToBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java PacketBuffer.writeItemStackToBuffer方法的具体用法?Java PacketBuffer.writeItemStackToBuffer怎么用?Java PacketBuffer.writeItemStackToBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.network.PacketBuffer
的用法示例。
在下文中一共展示了PacketBuffer.writeItemStackToBuffer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeToBuf
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
public void writeToBuf(PacketBuffer buffer)
{
buffer.writeByte((byte)(this.size() & 255));
for (int i = 0; i < this.size(); ++i)
{
MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(i);
buffer.writeItemStackToBuffer(merchantrecipe.getItemToBuy());
buffer.writeItemStackToBuffer(merchantrecipe.getItemToSell());
ItemStack itemstack = merchantrecipe.getSecondItemToBuy();
buffer.writeBoolean(itemstack != null);
if (itemstack != null)
{
buffer.writeItemStackToBuffer(itemstack);
}
buffer.writeBoolean(merchantrecipe.isRecipeDisabled());
buffer.writeInt(merchantrecipe.getToolUses());
buffer.writeInt(merchantrecipe.getMaxTradeUses());
}
}
示例2: writeToBuf
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
public void writeToBuf(PacketBuffer buffer)
{
buffer.writeByte((byte)(this.size() & 255));
for (int i = 0; i < this.size(); ++i)
{
MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(i);
buffer.writeItemStackToBuffer(merchantrecipe.getItemToBuy());
buffer.writeItemStackToBuffer(merchantrecipe.getItemToSell());
ItemStack itemstack = merchantrecipe.getSecondItemToBuy();
buffer.writeBoolean(!itemstack.func_190926_b());
if (!itemstack.func_190926_b())
{
buffer.writeItemStackToBuffer(itemstack);
}
buffer.writeBoolean(merchantrecipe.isRecipeDisabled());
buffer.writeInt(merchantrecipe.getToolUses());
buffer.writeInt(merchantrecipe.getMaxTradeUses());
}
}
示例3: writePacketData
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeByte(this.windowId);
buf.writeShort(this.slot);
buf.writeItemStackToBuffer(this.item);
}
示例4: writePacketData
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeByte(this.windowId);
buf.writeShort(this.slotId);
buf.writeByte(this.usedButton);
buf.writeShort(this.actionNumber);
buf.writeEnumValue(this.mode);
buf.writeItemStackToBuffer(this.clickedItem);
}
示例5: writePacketData
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeByte(this.windowId);
buf.writeShort(this.slotId);
buf.writeByte(this.usedButton);
buf.writeShort(this.actionNumber);
buf.writeByte(this.mode);
buf.writeItemStackToBuffer(this.clickedItem);
}
示例6: writePacketData
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeVarIntToBuffer(this.entityID);
buf.writeShort(this.equipmentSlot);
buf.writeItemStackToBuffer(this.itemStack);
}
示例7: writePacketData
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeByte(this.windowId);
buf.writeShort(this.itemStacks.length);
for (ItemStack itemstack : this.itemStacks)
{
buf.writeItemStackToBuffer(itemstack);
}
}
示例8: sendBookToServer
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
private void sendBookToServer(boolean publish) throws IOException
{
if (this.bookIsUnsigned && this.bookIsModified)
{
if (this.bookPages != null)
{
while (this.bookPages.tagCount() > 1)
{
String s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1);
if (s.length() != 0)
{
break;
}
this.bookPages.removeTag(this.bookPages.tagCount() - 1);
}
if (this.bookObj.hasTagCompound())
{
NBTTagCompound nbttagcompound = this.bookObj.getTagCompound();
nbttagcompound.setTag("pages", this.bookPages);
}
else
{
this.bookObj.setTagInfo("pages", this.bookPages);
}
String s2 = "MC|BEdit";
if (publish)
{
s2 = "MC|BSign";
this.bookObj.setTagInfo("author", new NBTTagString(this.editingPlayer.getName()));
this.bookObj.setTagInfo("title", new NBTTagString(this.bookTitle.trim()));
for (int i = 0; i < this.bookPages.tagCount(); ++i)
{
String s1 = this.bookPages.getStringTagAt(i);
IChatComponent ichatcomponent = new ChatComponentText(s1);
s1 = IChatComponent.Serializer.componentToJson(ichatcomponent);
this.bookPages.set(i, new NBTTagString(s1));
}
this.bookObj.setItem(Items.written_book);
}
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeItemStackToBuffer(this.bookObj);
this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload(s2, packetbuffer));
}
}
}
示例9: writePacketData
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeShort(this.slotId);
buf.writeItemStackToBuffer(this.stack);
}
示例10: writeWatchableObjectToPacketBuffer
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Writes a watchable object (entity attribute of type {byte, short, int, float, string, ItemStack,
* ChunkCoordinates}) to the specified PacketBuffer
*/
private static void writeWatchableObjectToPacketBuffer(PacketBuffer buffer, DataWatcher.WatchableObject object) throws IOException
{
int i = (object.getObjectType() << 5 | object.getDataValueId() & 31) & 255;
buffer.writeByte(i);
switch (object.getObjectType())
{
case 0:
buffer.writeByte(((Byte)object.getObject()).byteValue());
break;
case 1:
buffer.writeShort(((Short)object.getObject()).shortValue());
break;
case 2:
buffer.writeInt(((Integer)object.getObject()).intValue());
break;
case 3:
buffer.writeFloat(((Float)object.getObject()).floatValue());
break;
case 4:
buffer.writeString((String)object.getObject());
break;
case 5:
ItemStack itemstack = (ItemStack)object.getObject();
buffer.writeItemStackToBuffer(itemstack);
break;
case 6:
BlockPos blockpos = (BlockPos)object.getObject();
buffer.writeInt(blockpos.getX());
buffer.writeInt(blockpos.getY());
buffer.writeInt(blockpos.getZ());
break;
case 7:
Rotations rotations = (Rotations)object.getObject();
buffer.writeFloat(rotations.getX());
buffer.writeFloat(rotations.getY());
buffer.writeFloat(rotations.getZ());
}
}
示例11: writeItemStack
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Write an {@link ItemStack} using minecraft compatible encoding.
*
* @param to The buffer to write to
* @param stack The itemstack to write
*/
public static void writeItemStack(ByteBuf to, ItemStack stack)
{
PacketBuffer pb = new PacketBuffer(to);
pb.writeItemStackToBuffer(stack);
}