當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。