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


Java ByteBufUtils.writeVarInt方法代码示例

本文整理汇总了Java中cpw.mods.fml.common.network.ByteBufUtils.writeVarInt方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBufUtils.writeVarInt方法的具体用法?Java ByteBufUtils.writeVarInt怎么用?Java ByteBufUtils.writeVarInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cpw.mods.fml.common.network.ByteBufUtils的用法示例。


在下文中一共展示了ByteBufUtils.writeVarInt方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodePacket

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void encodePacket(ChannelHandlerContext context, ByteBuf buffer) {
	ByteBufUtils.writeVarInt(buffer, entityIds.size(), 5);
	for (Map.Entry<Integer, VRPlayerData> entry : entityIds.entrySet()) {
		VRPlayerData data = entry.getValue();
		ByteBufUtils.writeVarInt(buffer, entry.getKey(), 5);
		buffer.writeBoolean(data.newAPI);
		buffer.writeBoolean(data.reverseHands);
		buffer.writeFloat(data.worldScale);
		buffer.writeBoolean(data.seated);
		buffer.writeByte(data.entityIds.size());
		for (int id : data.entityIds) {
			ByteBufUtils.writeVarInt(buffer, id, 5);
		}
	}
}
 
开发者ID:Techjar,项目名称:VivecraftForgeExtensions,代码行数:17,代码来源:PacketVRPlayerList.java

示例2: toBytes

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buffer)
{
    super.toBytes(buffer);
    ByteBufUtils.writeVarInt(buffer, modTags.size(), 2);
    for (Map.Entry<String,String> modTag: modTags.entrySet())
    {
        ByteBufUtils.writeUTF8String(buffer, modTag.getKey());
        ByteBufUtils.writeUTF8String(buffer, modTag.getValue());
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:12,代码来源:FMLHandshakeMessage.java

示例3: toBytes

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void toBytes(final ByteBuf buf)
{
	ByteBufUtils.writeVarShort(buf, slotCount);
	for (int i = 0; i < slotCount; i++) {
		ByteBufUtils.writeItemStack(buf, itemStacks[i]);
		ByteBufUtils.writeVarInt(buf, stackSizes[i], 5);
	}
}
 
开发者ID:WanionCane,项目名称:Avaritiaddons,代码行数:10,代码来源:InfinityChestSyncAllSlots.java

示例4: toBytes

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void toBytes(final ByteBuf buf)
{
	ByteBufUtils.writeVarInt(buf, windowId, 4);
	ByteBufUtils.writeVarShort(buf, slotNumber);
	ByteBufUtils.writeVarInt(buf, mouseButton, 4);
	ByteBufUtils.writeVarInt(buf, modifier, 4);
	ByteBufUtils.writeItemStack(buf, itemStack);
	ByteBufUtils.writeVarInt(buf, stackSize, 5);
	ByteBufUtils.writeVarShort(buf, transactionID);
}
 
开发者ID:WanionCane,项目名称:Avaritiaddons,代码行数:12,代码来源:InfinityChestClick.java

示例5: toBytes

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void toBytes(final ByteBuf buf)
{
	ByteBufUtils.writeItemStack(buf, itemStack);
	ByteBufUtils.writeVarShort(buf, slot);
	ByteBufUtils.writeVarInt(buf, stackSize, 5);
}
 
开发者ID:WanionCane,项目名称:Avaritiaddons,代码行数:8,代码来源:InfinityChestSlotSync.java

示例6: toBytes

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void toBytes(final ByteBuf buf)
{
	ByteBufUtils.writeVarInt(buf, windowID, 4);
	ByteBufUtils.writeVarShort(buf, transactionID);
	ByteBufUtils.writeVarShort(buf, confirmed ? 1 : 0);
}
 
开发者ID:WanionCane,项目名称:Avaritiaddons,代码行数:8,代码来源:InfinityChestConfirmation.java

示例7: toBytes

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf) 
{
 ByteBufUtils.writeVarInt(buf, entityId, 4);
 ByteBufUtils.writeTag(buf, entitySyncDataCompound);
    // DEBUG
    System.out.println("toBytes encoded");
}
 
开发者ID:jtrent238,项目名称:PopularMMOS-EpicProportions-Mod,代码行数:9,代码来源:MessageSyncEntityToServer.java

示例8: testByteBufUtilsByteArrays

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Test
public void testByteBufUtilsByteArrays()
{
    ByteBuf buf = Unpooled.buffer(5, 5);
    ByteBufUtils.writeVarInt(buf, 1, 1);
    assertArrayEquals("1 as byte[] is [1]", new byte[] { 1, 0, 0, 0, 0 }, buf.array());

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 127, 1);
    assertArrayEquals("127 as byte[] is [127]", new byte[] { 127, 0, 0, 0, 0 }, buf.array());

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 128, 2);
    assertArrayEquals("128 as byte[] is [-128, 1]", new byte[] { -128, 1, 0, 0, 0 }, buf.array());

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 16383, 2);
    assertArrayEquals("16383 as byte[] is [-1, 127]", new byte[] { -1, 127, 0, 0, 0 }, buf.array());

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 16384, 3);
    assertArrayEquals("16384 as byte[] is [-1, -128, 1]", new byte[] { -128, -128, 1, 0, 0 }, buf.array());

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 2097151, 3);
    assertArrayEquals("2097151 as byte[] is [-1, -1, 127]", new byte[] { -1, -1, 127, 0, 0 }, buf.array());

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 2097152, 4);
    assertArrayEquals("16384 as byte[] is [-128, -128, 1]", new byte[] { -128, -128, -128, 1, 0 }, buf.array());

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 268435455, 4);
    assertArrayEquals("268435455 as byte[] is [-1, -1, -1, 127]", new byte[] { -1, -1, -1, 127, 0 }, buf.array());

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 268435456, 5);
    assertArrayEquals("268435456 as byte[] is [-1, -128, 1]", new byte[] { -128, -128, -128, -128, 1 }, buf.array());
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:40,代码来源:TestNetStuff.java

示例9: testByteBufUtilsByteReversals

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Test
public void testByteBufUtilsByteReversals()
{
    ByteBuf buf = Unpooled.buffer(5, 5);
    ByteBufUtils.writeVarInt(buf, 1, 1);
    assertEquals("1 is 1", 1, ByteBufUtils.readVarInt(buf, 1));

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 127, 1);
    assertEquals("127 is 127", 127, ByteBufUtils.readVarInt(buf, 1));

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 128, 2);
    assertEquals("128 is 128", 128, ByteBufUtils.readVarInt(buf, 2));

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 16383, 2);
    assertEquals("16383 is 16383", 16383, ByteBufUtils.readVarInt(buf, 2));

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 16384, 3);
    assertEquals("16384 is 16384", 16384, ByteBufUtils.readVarInt(buf, 3));

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 2097151, 3);
    assertEquals("2097151 is 2097151", 2097151, ByteBufUtils.readVarInt(buf, 3));

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 2097152, 4);
    assertEquals("2097152 is 2097152", 2097152, ByteBufUtils.readVarInt(buf, 4));

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 268435455, 4);
    assertEquals("268435455 is 268435455", 268435455, ByteBufUtils.readVarInt(buf, 4));

    buf.clear();
    ByteBufUtils.writeVarInt(buf, 268435456, 5);
    assertEquals("268435456 is 268435456", 268435456, ByteBufUtils.readVarInt(buf, 5));
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:40,代码来源:TestNetStuff.java

示例10: toBytes

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf)
{
    for (int i=0;i<3;i++)
    {
        ByteBufUtils.writeVarInt(buf,location[i],5);
    }

    ByteBufUtils.writeTag(buf,tagCompound);
}
 
开发者ID:M4thG33k,项目名称:M4thThings,代码行数:11,代码来源:PacketNBT.java

示例11: toBytes

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf)
{
    ByteBufUtils.writeVarInt(buf,x,5);
    ByteBufUtils.writeVarInt(buf,y,5);
    ByteBufUtils.writeVarInt(buf,z,5);
    ByteBufUtils.writeVarInt(buf,direction,1);
    ByteBufUtils.writeVarInt(buf,isFilling,1);
    ByteBufUtils.writeUTF8String(buf,fluidName);
    ByteBufUtils.writeVarInt(buf,amount,5);
    ByteBufUtils.writeVarInt(buf,size,1);
}
 
开发者ID:M4thG33k,项目名称:M4thThings,代码行数:13,代码来源:PacketFilling.java

示例12: createPayload

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
public ByteBuf createPayload(boolean fullPacket) throws IOException {
    ByteBuf output = Unpooled.buffer();

    HandlerType type = getHandlerType();
    ByteBufUtils.writeVarInt(output, type.ordinal(), 5);

    DataOutputStream dataOutput = new DataOutputStream(new ByteBufOutputStream(output));
    type.writeHandlerInfo(handler, dataOutput);
    writeToStream(dataOutput, fullPacket);

    return output.copy();
}
 
开发者ID:awesommist,项目名称:DynamicLib,代码行数:13,代码来源:SyncMap.java

示例13: writeToPacket

import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void writeToPacket(ByteBuf buf) {
	ByteBufUtils.writeVarInt(buf, charge, 4);
}
 
开发者ID:nikita488,项目名称:RainbowElectricity,代码行数:5,代码来源:TileEntityRainbowBatteryBox.java


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