Java 类net.minecraftforge.fml.common.network.ByteBufUtils 实例源码

项目:FirstAid    文件:MessageReceiveConfiguration.java   
@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);
}
项目:BetterBeginningsReborn    文件:PacketNetherBrickOvenFuelLevel.java   
@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());
    }
}
项目:pnc-repressurized    文件:AmadronOfferCustom.java   
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);
}
项目:PurificatiMagicae    文件:SPacketCheckMicroscopeResearch.java   
@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);
}
项目:CustomWorldGen    文件:ForgeMessage.java   
@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();
    }
}
项目:BetterBeginningsReborn    文件:PacketNetherBrickOvenFuelLevel.java   
@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;
    }
}
项目:MiningWells    文件:PacketWellToClient.java   
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 + "\"");
    }
}
项目:rezolve    文件:RuleModificationMessage.java   
@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);
}
项目:PurificatiMagicae    文件:SPacketLock.java   
@Override
public void fromBytes(ByteBuf buf)
{
    text = ByteBufUtils.readUTF8String(buf);
    code = ByteBufUtils.readUTF8String(buf);
    pos = ByteBufTools.readBlockPos(buf);
}
项目:OpenFlexiTrack    文件:TileEntitySyncPacket.java   
@Override
public void fromBytes(ByteBuf buf){
    this.x=buf.readInt();
    this.y=buf.readInt();
    this.z=buf.readInt();
    this.tag=ByteBufUtils.readTag(buf);
}
项目:VanillaExtras    文件:PacketReturnWorker.java   
@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);
}
项目:Proyecto-DASI    文件:RewardForDiscardingItemImplementation.java   
@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.");
    }
}
项目:BetterBeginningsReborn    文件:EntityThrownKnife.java   
@Override
public void writeSpawnData(ByteBuf additionalData) 
{
    ByteBufUtils.writeItemStack(additionalData, knife);
    additionalData.writeFloat(baseDamage);
    additionalData.writeFloat(force);
}
项目:pnc-repressurized    文件:AmadronOfferCustom.java   
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;
}
项目:Clef    文件:PacketPlayingTracks.java   
@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());
        }
    }
}
项目:pnc-repressurized    文件:PacketDescription.java   
@Override
public void fromBytes(ByteBuf buf) {
    super.fromBytes(buf);
    type = IDescSynced.Type.values()[buf.readByte()];
    int dataAmount = buf.readInt();
    types = new byte[dataAmount];
    values = new Object[dataAmount];
    for (int i = 0; i < dataAmount; i++) {
        types[i] = buf.readByte();
        values[i] = PacketUpdateGui.readField(buf, types[i]);
    }
    extraData = ByteBufUtils.readTag(buf);
}
项目:PurificatiMagicae    文件:CPacketSpawnSipParticle.java   
@Override
public void fromBytes(ByteBuf buf)
{
    pos = ByteBufTools.readVector3d(buf);
    posTo = ByteBufTools.readVector3d(buf);
    speed = buf.readFloat();
    sipType = ByteBufUtils.readUTF8String(buf);
    amount = buf.readInt();
}
项目:CustomWorldGen    文件:FMLRuntimeCodec.java   
@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");
    }
}
项目:PurificatiMagicae    文件:CPacketSpawnMultiblockParticles.java   
@Override
public void toBytes(ByteBuf buf)
{
    ByteBufTools.writeBlockPos(buf, pos);
    ByteBufUtils.writeUTF8String(buf, multiblockId.toString());
    buf.writeInt(rot.ordinal());
}
项目:NemesisSystem    文件:MessageOpenNemesisGui.java   
@Override
public void toBytes(ByteBuf buf) {
    NBTTagCompound c = new NBTTagCompound();
    NemesisRegistry.writeNemesesToNBT(c, nemeses);
    ByteBufUtils.writeTag(buf, c);
    ByteBufUtils.writeTag(buf, PlayerKnowledgeBase.save(knowledgeBase));
}
项目:Clef    文件:PacketPlayABC.java   
@Override
public void readFrom(ByteBuf buf)
{
    abc_md5 = ByteBufUtils.readUTF8String(buf);
    bandName = ByteBufUtils.readUTF8String(buf);
    syncPlay = buf.readBoolean();
    syncTrack = buf.readBoolean();
}
项目:pnc-repressurized    文件:PacketAphorismTileUpdate.java   
@Override
public void fromBytes(ByteBuf buffer) {
    super.fromBytes(buffer);
    int lines = buffer.readInt();
    text = new String[lines];
    for (int i = 0; i < lines; i++) {
        text[i] = ByteBufUtils.readUTF8String(buffer);
    }
}
项目:Never-Enough-Currency    文件:MessageSyncCart.java   
@Override
public void fromBytes(ByteBuf buf) {
    this.entityId = buf.readInt();
    int size = buf.readInt();
    NonNullList<ItemStack> list = NonNullList.withSize(size, ItemStack.EMPTY);
    for (int i = 0; i < list.size(); i++) {
        list.set(i, ByteBufUtils.readItemStack(buf));
    }
    this.cart = list;
}
项目:Melodium    文件:MessageCompositionUpdate.java   
@Override
public void toBytes(ByteBuf buf) {
    buf.writeLong(id.getMostSignificantBits());
    buf.writeLong(id.getLeastSignificantBits());
    ByteBufUtils.writeTag(buf, tag);
    buf.writeBoolean(mainHand);
}
项目:pnc-repressurized    文件:PacketSetGlobalVariable.java   
@Override
public void toBytes(ByteBuf buf) {
    ByteBufUtils.writeUTF8String(buf, varName);
    buf.writeInt(value.getX());
    buf.writeInt(value.getY());
    buf.writeInt(value.getZ());
}
项目:SimpleTubes    文件:PacketItemAdd.java   
@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(this.tile.getWorld().provider.getDimension());
    buf.writeLong(this.tile.getPos().toLong());

    buf.writeInt(this.id);
    ByteBufUtils.writeItemStack(buf, this.stack);
    buf.writeFloat(this.progress);
    buf.writeByte(this.direction);
    buf.writeInt(this.color);
}
项目:LagGoggles    文件:ScanResult.java   
@Override
public void fromBytes(ByteBuf buf) {
    worldID = buf.readInt();
    nanos = buf.readLong();
    name = ByteBufUtils.readUTF8String(buf);
    className = ByteBufUtils.readUTF8String(buf);
    isTileEntity = buf.readBoolean();
    if(isTileEntity){
        x = buf.readInt();
        y = buf.readInt();
        z = buf.readInt();
    }else {
        id = UUID.fromString(ByteBufUtils.readUTF8String(buf));
    }
}
项目:pnc-repressurized    文件:PacketSyncAmadronOffers.java   
public static Object getFluidOrItemStack(ByteBuf buf) {
    if (buf.readByte() == 0) {
        return ByteBufUtils.readItemStack(buf);
    } else {
        return new FluidStack(FluidRegistry.getFluid(ByteBufUtils.readUTF8String(buf)), buf.readInt(), ByteBufUtils.readTag(buf));
    }
}
项目:BetterBeginningsReborn    文件:EntityThrownKnife.java   
@Override
public void readSpawnData(ByteBuf additionalData) 
{
    knife = ByteBufUtils.readItemStack(additionalData);
    baseDamage = additionalData.readFloat();
    force = additionalData.readFloat();
}
项目:pnc-repressurized    文件:PacketPlaySound.java   
@Override
public void fromBytes(ByteBuf buffer) {
    super.fromBytes(buffer);
    soundEvent = new SoundEvent(new ResourceLocation(ByteBufUtils.readUTF8String(buffer)));
    category = SoundCategory.values()[buffer.readInt()];
    volume = buffer.readFloat();
    pitch = buffer.readFloat();
    bool = buffer.readBoolean();
}
项目:Never-Enough-Currency    文件:MessageSyncCart.java   
@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(this.entityId);
    buf.writeInt(cart.size());
    for (int i = 0; i < cart.size(); i++) {
        ByteBufUtils.writeItemStack(buf, cart.get(i));
    }
}
项目:VanillaExtras    文件:PacketReturnWorker.java   
@Override
public void fromBytes(ByteBuf buf) {
    try {
        this.cooldown = buf.readInt();
        this.maxCooldown = buf.readInt();
        this.className = ByteBufUtils.readUTF8String(buf);
        this.cooldownFieldName = ByteBufUtils.readUTF8String(buf);
        this.maxCooldownFieldName = ByteBufUtils.readUTF8String(buf);
    } catch (IndexOutOfBoundsException ioe) {
        Utils.getLogger(Refs.NAME).catching(ioe);
        return;
    }
    this.messageValid = true;
}
项目:Clef    文件:PacketPlayABC.java   
@Override
public void writeTo(ByteBuf buf)
{
    ByteBufUtils.writeUTF8String(buf, abc_md5);
    ByteBufUtils.writeUTF8String(buf, bandName);
    buf.writeBoolean(syncPlay);
    buf.writeBoolean(syncTrack);
}
项目:Clef    文件:PacketPlayingTracks.java   
@Override
public void writeTo(ByteBuf buf)
{
    PacketBuffer buff = new PacketBuffer(buf);
    buf.writeInt(tracks.length);
    for(Track track : tracks)
    {
        ByteBufUtils.writeUTF8String(buf, track.getId());
        ByteBufUtils.writeUTF8String(buf, track.getBandName());
        ByteBufUtils.writeUTF8String(buf, track.getMd5());
        buf.writeBoolean(track.playing);
        buf.writeInt(track.playProg);
        buf.writeInt(track.players.size());
        for(EntityPlayer player : track.players.keySet())
        {
            ByteBufUtils.writeUTF8String(buf, player.getName());
        }
        buf.writeInt(track.instrumentPlayers.size());
        for(Map.Entry<Integer, HashSet<BlockPos>> e : track.instrumentPlayers.entrySet())
        {
            buf.writeInt(e.getKey());
            buf.writeInt(e.getValue().size());
            for(BlockPos pos : e.getValue())
            {
                buff.writeBlockPos(pos);
            }
        }
        buf.writeInt(track.zombies.size());
        for(Integer i : track.zombies)
        {
            buf.writeInt(i);
        }
    }
}
项目:pnc-repressurized    文件:PacketAddChatMessage.java   
@Override
public void toBytes(ByteBuf buffer) {
    ByteBufUtils.writeUTF8String(buffer, message);
    if (replacements != null) {
        buffer.writeInt(replacements.length);
        for (String replacement : replacements) {
            ByteBufUtils.writeUTF8String(buffer, replacement);
        }
    } else {
        buffer.writeInt(0);
    }
}
项目:Proyecto-DASI    文件:RewardForDiscardingItemImplementation.java   
@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.");
    }
}
项目:ProgressiveDifficulty    文件:ChatUtil.java   
@Override
public void fromBytes(ByteBuf buf)
{
    chatLines = new ITextComponent[buf.readInt()];
    for (int i = 0; i < chatLines.length; i++)
    {
        chatLines[i] = ITextComponent.Serializer.jsonToComponent(ByteBufUtils.readUTF8String(buf));
    }
}
项目:CustomWorldGen    文件:FMLMessage.java   
@Override
void fromBytes(ByteBuf dat)
{
    super.fromBytes(dat);
    modId = ByteBufUtils.readUTF8String(dat);
    modEntityTypeId = dat.readInt();
    entityUUID = new UUID(dat.readLong(), dat.readLong());
    rawX = dat.readDouble();
    rawY = dat.readDouble();
    rawZ = dat.readDouble();
    scaledYaw = dat.readByte() * 360F / 256F;
    scaledPitch = dat.readByte() * 360F / 256F;
    scaledHeadYaw = dat.readByte() * 360F / 256F;
    try
    {
        dataWatcherList = EntityDataManager.readEntries(new PacketBuffer(dat));
    } catch (IOException e)
    {
        FMLLog.log(Level.FATAL, e, "There was a critical error decoding the datawatcher stream for a mod entity.");
        throw Throwables.propagate(e);
    }

    throwerId = dat.readInt();
    if (throwerId != 0)
    {
        speedScaledX = dat.readInt() / 8000D;
        speedScaledY = dat.readInt() / 8000D;
        speedScaledZ = dat.readInt() / 8000D;
    }
    this.dataStream = dat;
}
项目:CustomWorldGen    文件:FMLHandshakeMessage.java   
@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());
    }
}
项目:harshencastle    文件:BaseMessagePacketSendPackage.java   
@Override
public void toBytes(ByteBuf buf) {
    NBTTagCompound compound = new NBTTagCompound();
    compound.setInteger("size", objects.length);
    for(int i = 0; i < objects.length; i++) compound.setByteArray("byte" + i, HarshenUtils.serialize(objects[i]));
    ByteBufUtils.writeTag(buf, compound);

}