Java 类net.minecraft.network.PacketBuffer 实例源码

项目:DecompiledMinecraft    文件:S26PacketMapChunkBulk.java   
/**
 * 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);
    }
}
项目:Backmemed    文件:CPacketUseEntity.java   
/**
 * 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);
    }
}
项目:Backmemed    文件:CPacketUseEntity.java   
/**
 * 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);
    }
}
项目:Backmemed    文件:SPacketExplosion.java   
/**
 * 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);
}
项目:CustomWorldGen    文件:SPacketChunkData.java   
/**
 * 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);
    }
}
项目:BaseClient    文件:C0CPacketInput.java   
/**
 * 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);
}
项目:BaseClient    文件:S27PacketExplosion.java   
/**
 * 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);
}
项目:DecompiledMinecraft    文件:S3EPacketTeams.java   
/**
 * 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);
        }
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
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));
    }
}
项目:BaseClient    文件:S27PacketExplosion.java   
/**
 * 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();
}
项目:BaseClient    文件:S26PacketMapChunkBulk.java   
/**
 * 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);
    }
}
项目:DecompiledMinecraft    文件:S3EPacketTeams.java   
/**
 * 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));
        }
    }
}
项目:BaseClient    文件:MerchantRecipeList.java   
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());
    }
}
项目:Backmemed    文件:SPacketUpdateScore.java   
/**
 * 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);
    }
}
项目:BaseClient    文件:S14PacketEntity.java   
public void readPacketData(PacketBuffer buf) throws IOException
{
    super.readPacketData(buf);
    this.yaw = buf.readByte();
    this.pitch = buf.readByte();
    this.onGround = buf.readBoolean();
}
项目:BaseClient    文件:S14PacketEntity.java   
public void writePacketData(PacketBuffer buf) throws IOException
{
    super.writePacketData(buf);
    buf.writeByte(this.posX);
    buf.writeByte(this.posY);
    buf.writeByte(this.posZ);
    buf.writeBoolean(this.onGround);
}
项目:Backmemed    文件:SPacketLoginSuccess.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    UUID uuid = this.profile.getId();
    buf.writeString(uuid == null ? "" : uuid.toString());
    buf.writeString(this.profile.getName());
}
项目:Scripty    文件:ScriptyPacketContent.java   
@Override
public void toBytes(ByteBuf buf) {
    PacketBuffer buffer = new PacketBuffer(buf);
    buffer.writeVarInt(pos.getX());
    buffer.writeVarInt(pos.getY());
    buffer.writeVarInt(pos.getZ());
    buffer.writeVarInt(content.length());
    buffer.writeString(content);
    buffer.writeByte(language.ordinal());
    buffer.writeBoolean(parsing);
}
项目:Backmemed    文件:CPacketUpdateSign.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeBlockPos(this.pos);

    for (int i = 0; i < 4; ++i)
    {
        buf.writeString(this.lines[i]);
    }
}
项目:BaseClient    文件:S12PacketEntityVelocity.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeVarIntToBuffer(this.entityID);
    buf.writeShort(this.motionX);
    buf.writeShort(this.motionY);
    buf.writeShort(this.motionZ);
}
项目:CustomWorldGen    文件:SPacketWindowItems.java   
/**
 * 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);
    }
}
项目:DecompiledMinecraft    文件:S31PacketWindowProperty.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeByte(this.windowId);
    buf.writeShort(this.varIndex);
    buf.writeShort(this.varValue);
}
项目:CustomWorldGen    文件:SPacketEntityTeleport.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeVarIntToBuffer(this.entityId);
    buf.writeDouble(this.posX);
    buf.writeDouble(this.posY);
    buf.writeDouble(this.posZ);
    buf.writeByte(this.yaw);
    buf.writeByte(this.pitch);
    buf.writeBoolean(this.onGround);
}
项目:Backmemed    文件:SPacketTeams.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeString(this.name);
    buf.writeByte(this.action);

    if (this.action == 0 || this.action == 2)
    {
        buf.writeString(this.displayName);
        buf.writeString(this.prefix);
        buf.writeString(this.suffix);
        buf.writeByte(this.friendlyFlags);
        buf.writeString(this.nameTagVisibility);
        buf.writeString(this.collisionRule);
        buf.writeByte(this.color);
    }

    if (this.action == 0 || this.action == 3 || this.action == 4)
    {
        buf.writeVarIntToBuffer(this.players.size());

        for (String s : this.players)
        {
            buf.writeString(s);
        }
    }
}
项目:BaseClient    文件:C13PacketPlayerAbilities.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    byte b0 = 0;

    if (this.isInvulnerable())
    {
        b0 = (byte)(b0 | 1);
    }

    if (this.isFlying())
    {
        b0 = (byte)(b0 | 2);
    }

    if (this.isAllowFlying())
    {
        b0 = (byte)(b0 | 4);
    }

    if (this.isCreativeMode())
    {
        b0 = (byte)(b0 | 8);
    }

    buf.writeByte(b0);
    buf.writeFloat(this.flySpeed);
    buf.writeFloat(this.walkSpeed);
}
项目:CustomWorldGen    文件:SPacketEntity.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    super.readPacketData(buf);
    this.posX = buf.readShort();
    this.posY = buf.readShort();
    this.posZ = buf.readShort();
    this.onGround = buf.readBoolean();
}
项目:DecompiledMinecraft    文件:S14PacketEntity.java   
public void readPacketData(PacketBuffer buf) throws IOException
{
    super.readPacketData(buf);
    this.posX = buf.readByte();
    this.posY = buf.readByte();
    this.posZ = buf.readByte();
    this.onGround = buf.readBoolean();
}
项目:Backmemed    文件:SPacketEntityTeleport.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.entityId = buf.readVarIntFromBuffer();
    this.posX = buf.readDouble();
    this.posY = buf.readDouble();
    this.posZ = buf.readDouble();
    this.yaw = buf.readByte();
    this.pitch = buf.readByte();
    this.onGround = buf.readBoolean();
}
项目:CustomWorldGen    文件:SPacketScoreboardObjective.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.objectiveName = buf.readStringFromBuffer(16);
    this.action = buf.readByte();

    if (this.action == 0 || this.action == 2)
    {
        this.objectiveValue = buf.readStringFromBuffer(32);
        this.type = IScoreCriteria.EnumRenderType.getByName(buf.readStringFromBuffer(16));
    }
}
项目:BaseClient    文件:S29PacketSoundEffect.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeString(this.soundName);
    buf.writeInt(this.posX);
    buf.writeInt(this.posY);
    buf.writeInt(this.posZ);
    buf.writeFloat(this.soundVolume);
    buf.writeByte(this.soundPitch);
}
项目:Backmemed    文件:SPacketUpdateTileEntity.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.blockPos = buf.readBlockPos();
    this.metadata = buf.readUnsignedByte();
    this.nbt = buf.readNBTTagCompoundFromBuffer();
}
项目:Backmemed    文件:SPacketWindowItems.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeByte(this.windowId);
    buf.writeShort(this.itemStacks.size());

    for (ItemStack itemstack : this.itemStacks)
    {
        buf.writeItemStackToBuffer(itemstack);
    }
}
项目:Backmemed    文件:CPacketClientSettings.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeString(this.lang);
    buf.writeByte(this.view);
    buf.writeEnumValue(this.chatVisibility);
    buf.writeBoolean(this.enableColors);
    buf.writeByte(this.modelPartFlags);
    buf.writeEnumValue(this.mainHand);
}
项目:DecompiledMinecraft    文件:S25PacketBlockBreakAnim.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeVarIntToBuffer(this.breakerId);
    buf.writeBlockPos(this.position);
    buf.writeByte(this.progress);
}
项目:CustomWorldGen    文件:SPacketSoundEffect.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.sound = (SoundEvent)SoundEvent.REGISTRY.getObjectById(buf.readVarIntFromBuffer());
    this.category = (SoundCategory)buf.readEnumValue(SoundCategory.class);
    this.posX = buf.readInt();
    this.posY = buf.readInt();
    this.posZ = buf.readInt();
    this.soundVolume = buf.readFloat();
    this.soundPitch = buf.readFloat();
}
项目:BaseClient    文件:S18PacketEntityTeleport.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.entityId = buf.readVarIntFromBuffer();
    this.posX = buf.readInt();
    this.posY = buf.readInt();
    this.posZ = buf.readInt();
    this.yaw = buf.readByte();
    this.pitch = buf.readByte();
    this.onGround = buf.readBoolean();
}
项目:BaseClient    文件:C03PacketPlayer.java   
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeDouble(this.x);
    buf.writeDouble(this.y);
    buf.writeDouble(this.z);
    super.writePacketData(buf);
}
项目:Backmemed    文件:BlockStatePaletteHashMap.java   
public void write(PacketBuffer buf)
{
    int i = this.statePaletteMap.size();
    buf.writeVarIntToBuffer(i);

    for (int j = 0; j < i; ++j)
    {
        buf.writeVarIntToBuffer(Block.BLOCK_STATE_IDS.get(this.statePaletteMap.get(j)));
    }
}
项目:Backmemed    文件:CPacketInput.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.strafeSpeed = buf.readFloat();
    this.forwardSpeed = buf.readFloat();
    byte b0 = buf.readByte();
    this.jumping = (b0 & 1) > 0;
    this.sneaking = (b0 & 2) > 0;
}
项目:Backmemed    文件:GuiRepair.java   
private void renameItem()
{
    String s = this.nameField.getText();
    Slot slot = this.anvil.getSlot(0);

    if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
    {
        s = "";
    }

    this.anvil.updateItemName(s);
    this.mc.player.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}