package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage;

import com.google.common.collect.Sets;
import lombok.AllArgsConstructor;
import lombok.Data;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class BlockStorage extends StoredObject {
    // This BlockStorage is very exclusive (;
    private static final Set<Integer> whitelist = Sets.newConcurrentHashSet();

    static {
        // Flower pots
        whitelist.add(5247);

        // Add those red beds
        for (int i = 0; i < 16; i++)
            whitelist.add(954 + i);

        // Add the white banners
        for (int i = 0; i < 20; i++)
            whitelist.add(6836 + i);

        // Add the white wall banners
        for (int i = 0; i < 4; i++) {
            whitelist.add(7092 + i);
        }

        // Skeleton skulls
        for (int i = 0; i < 5; i++)
            whitelist.add(5429 + i);
    }

    private Map<Position, ReplacementData> blocks = new ConcurrentHashMap<>();

    public BlockStorage(UserConnection user) {
        super(user);
    }

    public void store(Position position, int block) {
        store(position, block, -1);
    }

    public void store(Position position, int block, int replacementId) {
        if (!whitelist.contains(block))
            return;

        blocks.put(position, new ReplacementData(block, replacementId));
    }

    public boolean isWelcome(int block) {
        return whitelist.contains(block);
    }

    public boolean contains(Position position) {
        return blocks.containsKey(position);
    }

    public ReplacementData get(Position position) {
        return blocks.get(position);
    }

    public ReplacementData remove(Position position) {
        return blocks.remove(position);
    }

    @Data
    @AllArgsConstructor
    public class ReplacementData {
        private int original;
        private int replacement;
    }

}

@@ -644,10 +644,10 @@
 d(52
-47
+66
 );%0A%0A
@@ -740,18 +740,18 @@
 st.add(9
-54
+72
  + i);%0A%0A
@@ -852,10 +852,10 @@
 d(68
-36
+54
  + i
@@ -965,11 +965,11 @@
 dd(7
-092
+110
  + i
@@ -1077,10 +1077,10 @@
 d(54
-29
+47
  + i

Update BlockStorage