本文整理汇总了Java中net.minecraft.network.PacketBuffer类的典型用法代码示例。如果您正苦于以下问题:Java PacketBuffer类的具体用法?Java PacketBuffer怎么用?Java PacketBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PacketBuffer类属于net.minecraft.network包,在下文中一共展示了PacketBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readPacketData
import net.minecraft.network.PacketBuffer; //导入依赖的package包/类
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.isOverworld = buf.readBoolean();
int i = buf.readVarIntFromBuffer();
this.xPositions = new int[i];
this.zPositions = new int[i];
this.chunksData = new S21PacketChunkData.Extracted[i];
for (int j = 0; j < i; ++j)
{
this.xPositions[j] = buf.readInt();
this.zPositions[j] = buf.readInt();
this.chunksData[j] = new S21PacketChunkData.Extracted();
this.chunksData[j].dataSize = buf.readShort() & 65535;
this.chunksData[j].data = new byte[S21PacketChunkData.func_180737_a(Integer.bitCount(this.chunksData[j].dataSize), this.isOverworld, true)];
}
for (int k = 0; k < i; ++k)
{
buf.readBytes(this.chunksData[k].data);
}
}
示例2: readPacketData
import net.minecraft.network.PacketBuffer; //导入依赖的package包/类
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.entityId = buf.readVarIntFromBuffer();
this.action = (CPacketUseEntity.Action)buf.readEnumValue(CPacketUseEntity.Action.class);
if (this.action == CPacketUseEntity.Action.INTERACT_AT)
{
this.hitVec = new Vec3d((double)buf.readFloat(), (double)buf.readFloat(), (double)buf.readFloat());
}
if (this.action == CPacketUseEntity.Action.INTERACT || this.action == CPacketUseEntity.Action.INTERACT_AT)
{
this.hand = (EnumHand)buf.readEnumValue(EnumHand.class);
}
}
示例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.writeVarIntToBuffer(this.entityId);
buf.writeEnumValue(this.action);
if (this.action == CPacketUseEntity.Action.INTERACT_AT)
{
buf.writeFloat((float)this.hitVec.xCoord);
buf.writeFloat((float)this.hitVec.yCoord);
buf.writeFloat((float)this.hitVec.zCoord);
}
if (this.action == CPacketUseEntity.Action.INTERACT || this.action == CPacketUseEntity.Action.INTERACT_AT)
{
buf.writeEnumValue(this.hand);
}
}
示例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.writeFloat((float)this.posX);
buf.writeFloat((float)this.posY);
buf.writeFloat((float)this.posZ);
buf.writeFloat(this.strength);
buf.writeInt(this.affectedBlockPositions.size());
int i = (int)this.posX;
int j = (int)this.posY;
int k = (int)this.posZ;
for (BlockPos blockpos : this.affectedBlockPositions)
{
int l = blockpos.getX() - i;
int i1 = blockpos.getY() - j;
int j1 = blockpos.getZ() - k;
buf.writeByte(l);
buf.writeByte(i1);
buf.writeByte(j1);
}
buf.writeFloat(this.motionX);
buf.writeFloat(this.motionY);
buf.writeFloat(this.motionZ);
}
示例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.writeInt(this.chunkX);
buf.writeInt(this.chunkZ);
buf.writeBoolean(this.loadChunk);
buf.writeVarIntToBuffer(this.availableSections);
buf.writeVarIntToBuffer(this.buffer.length);
buf.writeBytes(this.buffer);
buf.writeVarIntToBuffer(this.tileEntityTags.size());
for (NBTTagCompound nbttagcompound : this.tileEntityTags)
{
buf.writeNBTTagCompoundToBuffer(nbttagcompound);
}
}
示例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.writeFloat(this.strafeSpeed);
buf.writeFloat(this.forwardSpeed);
byte b0 = 0;
if (this.jumping)
{
b0 = (byte)(b0 | 1);
}
if (this.sneaking)
{
b0 = (byte)(b0 | 2);
}
buf.writeByte(b0);
}
示例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.writeFloat((float)this.posX);
buf.writeFloat((float)this.posY);
buf.writeFloat((float)this.posZ);
buf.writeFloat(this.strength);
buf.writeInt(this.affectedBlockPositions.size());
int i = (int)this.posX;
int j = (int)this.posY;
int k = (int)this.posZ;
for (BlockPos blockpos : this.affectedBlockPositions)
{
int l = blockpos.getX() - i;
int i1 = blockpos.getY() - j;
int j1 = blockpos.getZ() - k;
buf.writeByte(l);
buf.writeByte(i1);
buf.writeByte(j1);
}
buf.writeFloat(this.field_149152_f);
buf.writeFloat(this.field_149153_g);
buf.writeFloat(this.field_149159_h);
}
示例8: writePacketData
import net.minecraft.network.PacketBuffer; //导入依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeString(this.field_149320_a);
buf.writeByte(this.field_149314_f);
if (this.field_149314_f == 0 || this.field_149314_f == 2)
{
buf.writeString(this.field_149318_b);
buf.writeString(this.field_149319_c);
buf.writeString(this.field_149316_d);
buf.writeByte(this.field_149315_g);
buf.writeString(this.field_179816_e);
buf.writeByte(this.field_179815_f);
}
if (this.field_149314_f == 0 || this.field_149314_f == 3 || this.field_149314_f == 4)
{
buf.writeVarIntToBuffer(this.field_149317_e.size());
for (String s : this.field_149317_e)
{
buf.writeString(s);
}
}
}
示例9: openBook
import net.minecraft.network.PacketBuffer; //导入依赖的package包/类
public void openBook(ItemStack stack, EnumHand hand)
{
Item item = stack.getItem();
if (item == Items.WRITTEN_BOOK)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeEnumValue(hand);
this.connection.sendPacket(new SPacketCustomPayload("MC|BOpen", packetbuffer));
}
}
示例10: readPacketData
import net.minecraft.network.PacketBuffer; //导入依赖的package包/类
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.posX = (double)buf.readFloat();
this.posY = (double)buf.readFloat();
this.posZ = (double)buf.readFloat();
this.strength = buf.readFloat();
int i = buf.readInt();
this.affectedBlockPositions = Lists.<BlockPos>newArrayListWithCapacity(i);
int j = (int)this.posX;
int k = (int)this.posY;
int l = (int)this.posZ;
for (int i1 = 0; i1 < i; ++i1)
{
int j1 = buf.readByte() + j;
int k1 = buf.readByte() + k;
int l1 = buf.readByte() + l;
this.affectedBlockPositions.add(new BlockPos(j1, k1, l1));
}
this.field_149152_f = buf.readFloat();
this.field_149153_g = buf.readFloat();
this.field_149159_h = buf.readFloat();
}
示例11: writePacketData
import net.minecraft.network.PacketBuffer; //导入依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeBoolean(this.isOverworld);
buf.writeVarIntToBuffer(this.chunksData.length);
for (int i = 0; i < this.xPositions.length; ++i)
{
buf.writeInt(this.xPositions[i]);
buf.writeInt(this.zPositions[i]);
buf.writeShort((short)(this.chunksData[i].dataSize & 65535));
}
for (int j = 0; j < this.xPositions.length; ++j)
{
buf.writeBytes(this.chunksData[j].data);
}
}
示例12: readPacketData
import net.minecraft.network.PacketBuffer; //导入依赖的package包/类
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.field_149320_a = buf.readStringFromBuffer(16);
this.field_149314_f = buf.readByte();
if (this.field_149314_f == 0 || this.field_149314_f == 2)
{
this.field_149318_b = buf.readStringFromBuffer(32);
this.field_149319_c = buf.readStringFromBuffer(16);
this.field_149316_d = buf.readStringFromBuffer(16);
this.field_149315_g = buf.readByte();
this.field_179816_e = buf.readStringFromBuffer(32);
this.field_179815_f = buf.readByte();
}
if (this.field_149314_f == 0 || this.field_149314_f == 3 || this.field_149314_f == 4)
{
int i = buf.readVarIntFromBuffer();
for (int j = 0; j < i; ++j)
{
this.field_149317_e.add(buf.readStringFromBuffer(40));
}
}
}
示例13: 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());
}
}
示例14: writePacketData
import net.minecraft.network.PacketBuffer; //导入依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeString(this.name);
buf.writeEnumValue(this.action);
buf.writeString(this.objective);
if (this.action != SPacketUpdateScore.Action.REMOVE)
{
buf.writeVarIntToBuffer(this.value);
}
}
示例15: readPacketData
import net.minecraft.network.PacketBuffer; //导入依赖的package包/类
public void readPacketData(PacketBuffer buf) throws IOException
{
super.readPacketData(buf);
this.yaw = buf.readByte();
this.pitch = buf.readByte();
this.onGround = buf.readBoolean();
}