package us.myles.ViaVersion.api.data;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import java.util.Arrays;

public class Mappings {
    protected final short[] oldToNew;

    /**
     * Maps old identifiers to the new ones.
     * If an old value cannot be found in the new mappings, the diffmapping will be checked for the given entry.
     *
     * @param size set size of the underlying short array
     * @param oldMapping mappings to map from
     * @param newMapping mappings to map to
     * @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
     */
    public Mappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
        oldToNew = new short[size];
        Arrays.fill(oldToNew, (short) -1);
        MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping);
    }

    public Mappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
        this(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping);
    }

    /**
     * Maps old identifiers to the new ones.
     *
     * @param size set size of the underlying short array
     * @param oldMapping mappings to map from
     * @param newMapping mappings to map to
     */
    public Mappings(int size, JsonObject oldMapping, JsonObject newMapping) {
        oldToNew = new short[size];
        Arrays.fill(oldToNew, (short) -1);
        MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping);
    }

    public Mappings(JsonObject oldMapping, JsonObject newMapping) {
        this(oldMapping.entrySet().size(), oldMapping, newMapping);
    }

    /**
     * Maps old identifiers to the new ones.
     *
     * @param size set size of the underlying short array
     * @param oldMapping mappings to map from
     * @param newMapping mappings to map to
     */
    public Mappings(int size, JsonArray oldMapping, JsonArray newMapping) {
        oldToNew = new short[size];
        Arrays.fill(oldToNew, (short) -1);
        MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping);
    }

    public Mappings(JsonArray oldMapping, JsonArray newMapping) {
        this(oldMapping.size(), oldMapping, newMapping);
    }

    public int getNewId(int old) {
        return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
    }
}

@@ -191,24 +191,108 @@
 ToNew;%0A%0A
+    protected Mappings(short%5B%5D oldToNew) %7B%0A        this.oldToNew = oldToNew;%0A    %7D%0A%0A
     /**%0A
      * M
@@ -275,32 +275,32 @@
 %0A    %7D%0A%0A    /**%0A
-
      * Maps old 
@@ -459,32 +459,39 @@
   * @param size 
+       
 set size of the 
@@ -530,32 +530,33 @@
 aram oldMapping 
+ 
 mappings to map 
@@ -577,32 +577,33 @@
 aram newMapping 
+ 
 mappings to map 
@@ -1238,32 +1238,38 @@
   * @param size 
+      
 set size of the 
@@ -1824,32 +1824,32 @@
 ew ones.%0A     *%0A
-
      * @param si
@@ -1851,16 +1851,22 @@
 am size 
+      
 set size

Add extra mappings constructor for VB