本文整理汇总了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);
}
}
}
示例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());
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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());
}
示例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));
}
示例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);
}
示例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);
}
示例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();
}
示例13: writeToPacket
import cpw.mods.fml.common.network.ByteBufUtils; //导入方法依赖的package包/类
@Override
public void writeToPacket(ByteBuf buf) {
ByteBufUtils.writeVarInt(buf, charge, 4);
}