本文整理汇总了Java中cpw.mods.fml.common.network.ByteBufUtils类的典型用法代码示例。如果您正苦于以下问题:Java ByteBufUtils类的具体用法?Java ByteBufUtils怎么用?Java ByteBufUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteBufUtils类属于cpw.mods.fml.common.network包,在下文中一共展示了ByteBufUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
void fromBytes(ByteBuf bytes)
{
int listSize = bytes.readInt();
for (int i = 0; i < listSize; i++) {
String fluidName = ByteBufUtils.readUTF8String(bytes);
int fluidId = bytes.readInt();
fluidIds.put(FluidRegistry.getFluid(fluidName), fluidId);
}
// do we have a defaults list?
if (bytes.isReadable())
{
for (int i = 0; i < listSize; i++)
{
defaultFluids.add(ByteBufUtils.readUTF8String(bytes));
}
}
else
{
FMLLog.getLogger().log(Level.INFO, "Legacy server message contains no default fluid list - there may be problems with fluids");
defaultFluids.clear();
}
}
示例2: 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);
}
}
}
示例3: decodePacket
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void decodePacket(ChannelHandlerContext context, ByteBuf buffer) {
int size = ByteBufUtils.readVarInt(buffer, 5);
entityIds = new HashMap<Integer, VRPlayerData>(size);
for (int i = 0; i < size; i++) {
VRPlayerData data = new VRPlayerData();
entityIds.put(ByteBufUtils.readVarInt(buffer, 5), data);
data.newAPI = buffer.readBoolean();
data.reverseHands = buffer.readBoolean();
data.worldScale = buffer.readFloat();
data.seated = buffer.readBoolean();
int size2 = buffer.readUnsignedByte();
for (int j = 0; j < size2; j++) {
data.entityIds.add(ByteBufUtils.readVarInt(buffer, 5));
}
}
}
示例4: toBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
ByteArrayOutputStream obj = new ByteArrayOutputStream();
try {
GZIPOutputStream gzip = new GZIPOutputStream(obj);
ObjectOutputStream objStream = new ObjectOutputStream(gzip);
objStream.writeObject(configValues);
objStream.close();
} catch (IOException e) {
Throwables.propagate(e);
}
buf.writeShort(obj.size());
buf.writeBytes(obj.toByteArray());
ByteBufUtils.writeUTF8String(buf, modid);
}
示例5: fromBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void fromBytes(ByteBuf buf) {
short len = buf.readShort();
byte[] compressedBody = new byte[len];
for (short i = 0; i < len; i++)
compressedBody[i] = buf.readByte();
try {
ObjectInputStream obj = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(compressedBody)));
configValues = (Map<String, Object>) obj.readObject();
obj.close();
} catch (Exception e) {
Throwables.propagate(e);
}
modid = ByteBufUtils.readUTF8String(buf);
}
示例6: 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());
}
}
示例7: fromBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buffer)
{
super.fromBytes(buffer);
int modCount = ByteBufUtils.readVarInt(buffer, 2);
for (int i = 0; i < modCount; i++)
{
modTags.put(ByteBufUtils.readUTF8String(buffer), ByteBufUtils.readUTF8String(buffer));
}
}
示例8: testMessageValidity
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
protected void testMessageValidity(FMLProxyPacket msg)
{
if (msg.payload().getByte(0) == 0 && msg.payload().readableBytes() > 2)
{
FMLLog.severe("The connection appears to have sent an invalid FML packet of type 0, this is likely because it think's it's talking to 1.6.4 FML");
FMLLog.info("Bad data :");
for (String l : Splitter.on('\n').split(ByteBufUtils.getContentDump(msg.payload()))) {
FMLLog.info("\t%s",l);
}
throw new FMLNetworkException("Invalid FML packet");
}
}
示例9: toBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
void toBytes(ByteBuf buf)
{
buf.writeInt(windowId);
ByteBufUtils.writeUTF8String(buf, modId);
buf.writeInt(modGuiId);
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
}
示例10: fromBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
void fromBytes(ByteBuf buf)
{
windowId = buf.readInt();
modId = ByteBufUtils.readUTF8String(buf);
modGuiId = buf.readInt();
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
}
示例11: fromBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf)
{
NBTTagCompound data = ByteBufUtils.readTag(buf);
x = data.getInteger("x");
y = data.getInteger("y");
z = data.getInteger("z");
once = data.getBoolean("once");
}
示例12: toBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void toBytes(ByteBuf buf)
{
NBTTagCompound data = new NBTTagCompound();
data.setInteger("x", x);
data.setInteger("y", y);
data.setInteger("z", z);
data.setBoolean("once", once);
ByteBufUtils.writeTag(buf, data);
}
示例13: fromBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf)
{
slotCount = (short) ByteBufUtils.readVarShort(buf);
itemStacks = new ItemStack[slotCount];
stackSizes = new int[slotCount];
for (int i = 0; i < slotCount; i++) {
itemStacks[i] = ByteBufUtils.readItemStack(buf);
stackSizes[i] = ByteBufUtils.readVarInt(buf, 5);
if (itemStacks[i] != null)
itemStacks[i].stackSize = stackSizes[i];
}
}
示例14: 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);
}
}
示例15: fromBytes
import cpw.mods.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(final ByteBuf buf)
{
windowId = ByteBufUtils.readVarInt(buf, 4);
slotNumber = ByteBufUtils.readVarShort(buf);
if (slotNumber < 0 || slotNumber > 279)
slotNumber = -999;
mouseButton = ByteBufUtils.readVarInt(buf, 4);
modifier = ByteBufUtils.readVarInt(buf, 4);
itemStack = ByteBufUtils.readItemStack(buf);
stackSize = ByteBufUtils.readVarInt(buf, 5);
if (itemStack != null)
itemStack.stackSize = stackSize;
transactionID = (short) ByteBufUtils.readVarShort(buf);
}