當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteBufInputStream.readInt方法代碼示例

本文整理匯總了Java中io.netty.buffer.ByteBufInputStream.readInt方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteBufInputStream.readInt方法的具體用法?Java ByteBufInputStream.readInt怎麽用?Java ByteBufInputStream.readInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.netty.buffer.ByteBufInputStream的用法示例。


在下文中一共展示了ByteBufInputStream.readInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fromBytes

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void fromBytes(ByteBuf buf)
{
    ByteBufInputStream input = new ByteBufInputStream(buf);
    List<Frame> frames = new ArrayList<Frame>();

    try
    {
        this.filename = input.readUTF();
        int count = input.readInt();

        for (int i = 0; i < count; i++)
        {
            Frame frame = new Frame();

            frame.fromBytes(input);
            frames.add(frame);
        }
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    this.frames = frames;
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:27,代碼來源:PacketFrames.java

示例2: readData

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
protected void readData(ByteBufInputStream buffer) throws IOException {
    tileLocationX = buffer.readInt();
    tileLocationY = buffer.readInt();
    tileLocationZ = buffer.readInt();
    int numTexts = buffer.readInt();
    text = new String[numTexts];
    for (int i = 0; i < numTexts; i++) {
        int stringLength = buffer.readInt();
        char[] stringChars = new char[stringLength];
        for (int j = 0; j < stringLength; j++) {
            stringChars[j] = buffer.readChar();
        }
        text[i] = new String(stringChars);
    }
}
 
開發者ID:soultek101,項目名稱:projectzulu1.7.10-pre-1.3a,代碼行數:17,代碼來源:PacketTileText.java

示例3: processData

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void processData(EntityPlayer entityPlayer, ByteBufInputStream bbis) throws IOException
{
    super.processData(entityPlayer, bbis);

    ItemStack itemStack = entityPlayer.getHeldItem();
    side = bbis.readInt();

    boolean result = entityPlayer.worldObj.getBlock(x, y, z).onBlockActivated(entityPlayer.worldObj, x, y, z, entityPlayer, side, 1.0F, 1.0F, 1.0F);

    if (!result) {
        if (itemStack != null && itemStack.getItem() instanceof ItemBlock) {
            itemStack.tryPlaceItemIntoWorld(entityPlayer, entityPlayer.worldObj, x, y, z, side, 1.0F, 1.0F, 1.0F);
            EntityLivingUtil.decrementCurrentSlot(entityPlayer);
        }
    }
}
 
開發者ID:Mineshopper,項目名稱:carpentersblocks,代碼行數:18,代碼來源:PacketActivateBlock.java

示例4: processData

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void processData(EntityPlayer entityPlayer, ByteBufInputStream bbis) throws IOException
{
    super.processData(entityPlayer, bbis);
    World world = entityPlayer.worldObj;
    hexColor = bbis.readInt();

    TEBase TE = (TEBase) world.getTileEntity(x, y, z);

    if (TE != null) {
        if (hexColor != 16777215 && !TE.hasAttribute(TE.ATTR_FERTILIZER)) {
            TE.addAttribute(TE.ATTR_FERTILIZER, new ItemStack(Items.dye, 1, 15));
            EntityLivingUtil.decrementCurrentSlot(entityPlayer);
        }
    }
}
 
開發者ID:Mineshopper,項目名稱:carpentersblocks,代碼行數:17,代碼來源:PacketEnrichPlant.java

示例5: processData

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void processData(EntityPlayer entityPlayer, ByteBufInputStream bbis) throws IOException
{
    int slot = bbis.readInt();
    boolean incDmg = bbis.readBoolean();
    ItemStack itemStack = entityPlayer.inventory.getStackInSlot(slot);

    if (itemStack != null && BlockProperties.toBlock(itemStack).equals(BlockRegistry.blockCarpentersSlope)) {

        int maxDmg = BlockCarpentersSlope.slopeType.length - 1;
        int itemDmg = itemStack.getItemDamage();
        itemDmg += incDmg ? 1 : -1;

        if (itemDmg > maxDmg) {
            itemDmg = 0;
        } else if (itemDmg < 0) {
            itemDmg = maxDmg;
        }

        itemStack.setItemDamage(itemDmg);

    }
}
 
開發者ID:Mineshopper,項目名稱:carpentersblocks,代碼行數:24,代碼來源:PacketSlopeSelect.java

示例6: onServerPacket

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@SubscribeEvent
public void onServerPacket(ServerCustomPacketEvent event) throws IOException
{
    ByteBufInputStream bbis = new ByteBufInputStream(event.packet.payload());
    EntityPlayer entityPlayer = ((NetHandlerPlayServer) event.handler).playerEntity;
    int packetId = bbis.readInt();
    if (packetId < packetCarrier.size()) {
        try {
            ICarpentersPacket packetClass = (ICarpentersPacket) packetCarrier.get(packetId).newInstance();
            packetClass.processData(entityPlayer, bbis);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        ModLogger.log(Level.WARN, "Encountered out of range packet Id: " + packetId);
    }
    bbis.close();
}
 
開發者ID:Mineshopper,項目名稱:carpentersblocks,代碼行數:19,代碼來源:PacketHandler.java

示例7: readLargeUTF

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
/** Read a UTF8 string that could potentially be larger than 64k<br>
 * The ByteBufInputStream.readUTF() and writeUTF() calls use the first two bytes of the message
 * to encode the length of the string, which limits the string length to 64k.
 * This method gets around that limitation by using a four byte header.
 * @param bbis ByteBufInputStream we are reading from
 * @return the (potentially large) string we read
 * @throws IOException
 */
private String readLargeUTF(ByteBufInputStream bbis) throws IOException
{
    int length = bbis.readInt();
    if (length == 0)
        return "";

    byte[] data = new byte[length];
    int length_read = bbis.read(data, 0, length);
    if (length_read != length)
        throw new IOException("Failed to read whole message");

    return new String(data, "utf-8");
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:22,代碼來源:MalmoMod.java

示例8: read

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void read(ByteBufInputStream byteBuf) throws IOException {
	this.ok = byteBuf.readBoolean();
	this.minPort = byteBuf.readInt();
	this.maxPort = byteBuf.readInt();

	this.resources = byteBuf.readUTF();
}
 
開發者ID:MinecraftCloudSystem,項目名稱:MCS-Master,代碼行數:9,代碼來源:PacketAuthResponse.java

示例9: readData

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
protected void readData(ByteBufInputStream buffer) throws IOException {
    entityIdToBeNamed = buffer.readInt();
    int nameLength = buffer.readInt();
    char[] nameChars = new char[nameLength];
    for (int i = 0; i < nameLength; i++) {
        nameChars[i] = buffer.readChar();
    }
}
 
開發者ID:soultek101,項目名稱:projectzulu1.7.10-pre-1.3a,代碼行數:10,代碼來源:PacketNameSync.java

示例10: readData

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
protected void readData(ByteBufInputStream buffer) throws IOException {
    posX = buffer.readInt();
    posY = buffer.readInt();
    posZ = buffer.readInt();
    int soundLength = buffer.readInt();
    char[] soundChars = new char[soundLength];
    for (int i = 0; i < soundChars.length; i++) {
        soundChars[i] = buffer.readChar();
    }
    sound = new String(soundChars);
}
 
開發者ID:soultek101,項目名稱:projectzulu1.7.10-pre-1.3a,代碼行數:13,代碼來源:PacketStreamSound.java

示例11: decodeInto

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) throws IOException {
	ByteBufInputStream bis = new ByteBufInputStream(buffer);
	DataInputStream nbt = new DataInputStream(bis);
	entityID = bis.readInt();
	tag = NBTHelper.nbtRead(nbt);
}
 
開發者ID:DavidGoldman,項目名稱:NBTEdit,代碼行數:8,代碼來源:EntityNBTPacket.java

示例12: decodeInto

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) throws IOException {
	ByteBufInputStream bis = new ByteBufInputStream(buffer);
	DataInputStream nbt = new DataInputStream(bis);
	x = bis.readInt();
	y = bis.readInt();
	z = bis.readInt();
	tag = NBTHelper.nbtRead(nbt);
}
 
開發者ID:DavidGoldman,項目名稱:NBTEdit,代碼行數:10,代碼來源:TileNBTPacket.java

示例13: read

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void read(ByteBufInputStream in) throws IOException {
    x = in.readInt();
    y = in.readInt();
    z = in.readInt();
    if (payload != null) {
        payload.read(in);
    }
}
 
開發者ID:sk89q,項目名稱:playblock,代碼行數:10,代碼來源:TileEntityPayload.java

示例14: readData

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
protected void readData(ByteBufInputStream buffer) throws IOException {
    tileLocationX = buffer.readInt();
    tileLocationY = buffer.readInt();
    tileLocationZ = buffer.readInt();
    int numTexts = buffer.readInt();
    text = new String[numTexts];
    for (int i = 0; i < numTexts; i++) {
        int stringLength = buffer.readInt();
        char[] stringChars = new char[stringLength];
        for (int j = 0; j < stringLength; j++) {
            stringChars[j] = buffer.readChar();
        }
        text[i] = new String(stringChars);
    }
}
 
開發者ID:soultek101,項目名稱:projectzulu1.7.10,代碼行數:16,代碼來源:PZPacketTileText.java

示例15: readData

import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
protected void readData(ByteBufInputStream buffer) throws IOException {
    posX = buffer.readInt();
    posY = buffer.readInt();
    posZ = buffer.readInt();
    int soundLength = buffer.readInt();
    char[] soundChars = new char[soundLength];
    for (int i = 0; i < soundChars.length; i++) {
        soundChars[i] = buffer.readChar();
    }
    sound = new String(soundChars);
}
 
開發者ID:soultek101,項目名稱:projectzulu1.7.10,代碼行數:12,代碼來源:PZPacketPlaySound.java


注:本文中的io.netty.buffer.ByteBufInputStream.readInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。