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


Java ByteBufUtils类代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.network.ByteBufUtils的典型用法代码示例。如果您正苦于以下问题:Java ByteBufUtils类的具体用法?Java ByteBufUtils怎么用?Java ByteBufUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: fromBytes

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf) {
    healingCfg = new FirstAidConfig.ExternalHealing();
    healingCfg.allowNaturalRegeneration = buf.readBoolean();
    healingCfg.allowOtherHealingItems = buf.readBoolean();
    healingCfg.sleepHealing = buf.readFloat();
    healingCfg.otherRegenMultiplier = buf.readDouble();
    healingCfg.naturalRegenMultiplier = buf.readDouble();

    damageCfg = new FirstAidConfig.DamageSystem();
    damageCfg.maxHealthHead = buf.readByte();
    damageCfg.maxHealthLeftArm = buf.readByte();
    damageCfg.maxHealthLeftLeg = buf.readByte();
    damageCfg.maxHealthLeftFoot = buf.readByte();
    damageCfg.maxHealthBody = buf.readByte();
    damageCfg.maxHealthRightArm = buf.readByte();
    damageCfg.maxHealthRightLeg = buf.readByte();
    damageCfg.maxHealthRightFoot = buf.readByte();

    scaleMaxHealth = buf.readBoolean();

    playerDamageModel = ByteBufUtils.readTag(buf);
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:24,代码来源:MessageReceiveConfiguration.java

示例2: toBytes

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void toBytes(ByteBuf buf)
{
	buf.writeInt(pos.getX());
	buf.writeInt(pos.getY());
	buf.writeInt(pos.getZ());

	if (fluidStack != null)
	{
		buf.writeInt(fluidStack.amount);
		ByteBufUtils.writeUTF8String(buf, fluidStack.getFluid().getName());
	}
	else
	{
		buf.writeInt(0);
		buf.writeBytes(("").getBytes());
	}
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:19,代码来源:PacketNetherBrickOvenFuelLevel.java

示例3: writeToBuf

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
public void writeToBuf(ByteBuf buf) {
    ByteBufUtils.writeUTF8String(buf, offeringPlayerName);
    ByteBufUtils.writeUTF8String(buf, offeringPlayerId);
    if (providingPosition != null) {
        buf.writeBoolean(true);
        buf.writeInt(providingPosition.getX());
        buf.writeInt(providingPosition.getY());
        buf.writeInt(providingPosition.getZ());
        buf.writeInt(providingDimensionId);
    } else {
        buf.writeBoolean(false);
    }
    if (returningPosition != null) {
        buf.writeBoolean(true);
        buf.writeInt(returningPosition.getX());
        buf.writeInt(returningPosition.getY());
        buf.writeInt(returningPosition.getZ());
        buf.writeInt(returningDimensionId);
    } else {
        buf.writeBoolean(false);
    }
    buf.writeInt(inStock);
    buf.writeInt(maxTrades);
    buf.writeInt(pendingPayments);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:AmadronOfferCustom.java

示例4: fromBytes

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf)
{
    pos = ByteBufTools.readBlockPos(buf);
    int rows = buf.readInt();
    int columns = buf.readInt();
    boolean[][] bools = new boolean[rows][columns];
    for(int r = 0; r < rows; r++)
    {
        for(int c = 0; c < columns; c++)
        {
            bools[r][c] = buf.readBoolean();
        }
    }
    data = bools;
    entryName = ByteBufUtils.readUTF8String(buf);
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:18,代码来源:SPacketCheckMicroscopeResearch.java

示例5: fromBytes

import net.minecraftforge.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();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:ForgeMessage.java

示例6: fromBytes

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf)
{
	pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());

	int level = buf.readInt();
	String fluidId = ByteBufUtils.readUTF8String(buf);

	if (level != 0)
	{
		fluidStack = new FluidStack(FluidRegistry.getFluid(fluidId), level);
	}
	else
	{
		fluidStack = null;
	}
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:18,代码来源:PacketNetherBrickOvenFuelLevel.java

示例7: fromBytes

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
public void fromBytes(ByteBuf buf) {
	String s = ByteBufUtils.readUTF8String(buf);
	if (s == null) {
		return;
	}
	String[] split = s.split(";");
	if (split.length != 6) {
		return;
	}
	try {
		energy = Integer.parseInt(split[0]);
		maxEnergy = Integer.parseInt(split[1]);
		working = Boolean.parseBoolean(split[2]);
		bpo = Integer.parseInt(split[3]);
		fortune = Integer.parseInt(split[4]);
		silk = Boolean.parseBoolean(split[5]);
	} catch(Exception e) {
		LogUtils.info("Failed to convert client packet info: \"" + s + "\"");
	}
}
 
开发者ID:cjburkey01,项目名称:MiningWells,代码行数:21,代码来源:PacketWellToClient.java

示例8: toBytes

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
	ByteBufUtils.writeUTF8String(buf, this.playerId);
	RezolveByteBufUtils.writeBlockPos(buf, this.entityPos);
	ByteBufUtils.writeUTF8String(buf, this.ruleId);
	ByteBufUtils.writeUTF8String(buf, this.ruleName);
	buf.writeInt(this.mode);
}
 
开发者ID:astronautlabs,项目名称:rezolve,代码行数:9,代码来源:RuleModificationMessage.java

示例9: fromBytes

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf)
{
    text = ByteBufUtils.readUTF8String(buf);
    code = ByteBufUtils.readUTF8String(buf);
    pos = ByteBufTools.readBlockPos(buf);
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:8,代码来源:SPacketLock.java

示例10: fromBytes

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf){
	this.x=buf.readInt();
	this.y=buf.readInt();
	this.z=buf.readInt();
	this.tag=ByteBufUtils.readTag(buf);
}
 
开发者ID:DonBruce64,项目名称:OpenFlexiTrack,代码行数:8,代码来源:TileEntitySyncPacket.java

示例11: toBytes

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
	if (!this.messageValid)
		return;
	buf.writeInt(this.cooldown);
	buf.writeInt(this.maxCooldown);
	ByteBufUtils.writeUTF8String(buf, this.className);
	ByteBufUtils.writeUTF8String(buf, this.cooldownFieldName);
	ByteBufUtils.writeUTF8String(buf, this.maxCooldownFieldName);
}
 
开发者ID:IvanSteklow,项目名称:VanillaExtras,代码行数:11,代码来源:PacketReturnWorker.java

示例12: onMessage

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data) 
{
    String bufstring = data.get("message");
    ByteBuf buf = Unpooled.copiedBuffer(DatatypeConverter.parseBase64Binary(bufstring));
    ItemStack itemStack = ByteBufUtils.readItemStack(buf);
    if (itemStack != null && itemStack.getItem() != null)
    {
        accumulateReward(this.params.getDimension(), itemStack);
    }
    else
    {
        System.out.println("Error - couldn't understand the itemstack we received.");
    }
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:16,代码来源:RewardForDiscardingItemImplementation.java

示例13: writeSpawnData

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void writeSpawnData(ByteBuf additionalData) 
{
	ByteBufUtils.writeItemStack(additionalData, knife);
	additionalData.writeFloat(baseDamage);
	additionalData.writeFloat(force);
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:8,代码来源:EntityThrownKnife.java

示例14: loadFromBuf

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
public static AmadronOfferCustom loadFromBuf(ByteBuf buf) {
    AmadronOfferCustom offer = new AmadronOfferCustom(PacketSyncAmadronOffers.getFluidOrItemStack(buf), PacketSyncAmadronOffers.getFluidOrItemStack(buf), ByteBufUtils.readUTF8String(buf), ByteBufUtils.readUTF8String(buf));
    if (buf.readBoolean()) {
        offer.setProvidingPosition(new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()), buf.readInt());
    }
    if (buf.readBoolean()) {
        offer.setReturningPosition(new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()), buf.readInt());
    }
    offer.inStock = buf.readInt();
    offer.maxTrades = buf.readInt();
    offer.pendingPayments = buf.readInt();
    return offer;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:14,代码来源:AmadronOfferCustom.java

示例15: readFrom

import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void readFrom(ByteBuf buf)
{
    PacketBuffer buff = new PacketBuffer(buf);
    tracks = new Track[buf.readInt()];
    for(int i = 0; i < tracks.length; i++)
    {
        String id = ByteBufUtils.readUTF8String(buf);
        String band = ByteBufUtils.readUTF8String(buf);
        String md5 = ByteBufUtils.readUTF8String(buf);
        TrackFile file = AbcLibrary.getTrack(md5);
        tracks[i] = new Track(id, band, md5, file != null ? file.track : null, true);
        tracks[i].playing = buf.readBoolean();
        tracks[i].playProg = buf.readInt();
        int playerCount = buf.readInt();
        for(int x = 0; x < playerCount; x++)
        {
            tracks[i].addPlayer(ByteBufUtils.readUTF8String(buf));
        }
        playerCount = buf.readInt();
        for(int x = 0; x < playerCount; x++)
        {
            int key = buf.readInt();
            int count = buf.readInt();
            HashSet<BlockPos> poses = new HashSet<>();
            for(int k = 0; k < count; k++)
            {
                poses.add(buff.readBlockPos());
            }
            tracks[i].instrumentPlayers.put(key, poses);
        }
        playerCount = buf.readInt();
        for(int x = 0; x < playerCount; x++)
        {
            tracks[i].zombies.add(buf.readInt());
        }
    }
}
 
开发者ID:iChun,项目名称:Clef,代码行数:39,代码来源:PacketPlayingTracks.java


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