/*
 *    This file is a part of the SteamWar software.
 *
 *    Copyright (C) 2022  SteamWar.de-Serverteam
 *
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU Affero General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *    GNU Affero General Public License for more details.
 *
 *    You should have received a copy of the GNU Affero General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package de.steamwar.core;

import net.minecraft.network.chat.IChatMutableComponent;
import net.minecraft.network.chat.contents.LiteralContents;
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
import net.minecraft.network.syncher.DataWatcher;

import java.util.ArrayList;

public class ChatWrapper19 implements ChatWrapper {

    @Override
    public Object stringToChatComponent(String text) {
        return IChatMutableComponent.a(new LiteralContents(text));
    }

    @Override
    public Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues) {
        ArrayList<DataWatcher.b<?>> nativeWatchers = new ArrayList<>(1);
        for(int i = 0; i < dataWatcherKeyValues.length; i+=2) {
            nativeWatchers.add(((DataWatcher.Item<?>) BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])).e());
        }

        return new PacketPlayOutEntityMetadata(entityId, nativeWatchers);
    }
}
