package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities;

import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;

public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
    private final int WALL_BANNER_START = 7110; // 4 each
    private final int WALL_BANNER_STOP = 7173;

    private final int BANNER_START = 6854; // 16 each
    private final int BANNER_STOP = 7109;

    @Override
    public int transform(UserConnection user, CompoundTag tag) {
        BlockStorage storage = user.get(BlockStorage.class);
        Position position = new Position(getLong(tag.get("x")), getLong(tag.get("y")), getLong(tag.get("z")));

        if (!storage.contains(position)) {
            System.out.println("Received an banner color update packet, but there is no banner! O_o " + tag);
            return -1;
        }

        int blockId = storage.get(position).getOriginal();

        int color = (int) tag.get("Base").getValue();
        // Standing banner
        if (blockId >= BANNER_START && blockId <= BANNER_STOP)
            blockId += ((15 - color) * 16);
            // Wall banner
        else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP)
            blockId += ((15 - color) * 4);
        else
            System.out.println("Why does this block have the banner block entity? :(" + tag);

        return blockId;
    }

    private long getLong(Tag tag) {
        return ((Integer) tag.getValue()).longValue();
    }
}
@@ -136,24 +136,139 @@
 ompoundTag;%0A
+import com.github.steveice10.opennbt.tag.builtin.IntTag;%0Aimport com.github.steveice10.opennbt.tag.builtin.ListTag;%0A
 import com.g
@@ -1803,24 +1803,378 @@
 (%22 + tag);%0A%0A
+        if (tag.get(%22Patterns%22) instanceof ListTag) %7B%0A            for (Tag pattern : (ListTag) tag.get(%22Patterns%22)) %7B%0A                if (pattern instanceof CompoundTag) %7B%0A                    IntTag c = ((CompoundTag) pattern).get(%22Color%22);%0A                    c.setValue(15 - c.getValue()); // Invert color id%0A                %7D%0A            %7D%0A        %7D%0A%0A
         retu

Fix patterns