当前位置: 首页>>代码示例>>Java>>正文


Java PacketBuffer类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:26,代码来源:S26PacketMapChunkBulk.java

示例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);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:CPacketUseEntity.java

示例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);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:21,代码来源:CPacketUseEntity.java

示例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);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:29,代码来源:SPacketExplosion.java

示例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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:SPacketChunkData.java

示例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);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:C0CPacketInput.java

示例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);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:29,代码来源:S27PacketExplosion.java

示例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);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:S3EPacketTeams.java

示例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));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:12,代码来源:EntityPlayerMP.java

示例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();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:28,代码来源:S27PacketExplosion.java

示例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);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:S26PacketMapChunkBulk.java

示例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));
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:S3EPacketTeams.java

示例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());
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:23,代码来源:MerchantRecipeList.java

示例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);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:SPacketUpdateScore.java

示例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();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:8,代码来源:S14PacketEntity.java


注:本文中的net.minecraft.network.PacketBuffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。