Search in sources :

Example 1 with NBTBase

use of net.minecraft.server.v1_16_R2.NBTBase in project MechanicsMain by WeaponMechanics.

the class NBT_1_10_R1 method visit.

private StringBuilder visit(NBTTagCompound nbt, int indents, int colorOffset) {
    String braceColor = "&" + BRACE_COLORS.charAt(indents % BRACE_COLORS.length());
    StringBuilder builder = new StringBuilder(braceColor).append('{');
    List<String> keys = new ArrayList<>(nbt.c());
    Collections.sort(keys);
    for (int i = 0; i < keys.size(); i++) {
        String key = keys.get(i);
        NBTBase value = Objects.requireNonNull(nbt.get(key), "This is impossible");
        if (i != 0)
            builder.append('\n');
        builder.append(StringUtil.repeat("  ", indents));
        String color = "&" + VALUE_COLORS.charAt((i + colorOffset) % VALUE_COLORS.length());
        builder.append(color).append(key).append("&f&l: ").append(color);
        if (value instanceof NBTTagCompound)
            builder.append(visit((NBTTagCompound) value, indents + 1, colorOffset + i));
        else
            builder.append(value);
    }
    return builder.append(braceColor).append("}\n");
}
Also used : NBTBase(net.minecraft.server.v1_10_R1.NBTBase) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.server.v1_10_R1.NBTTagCompound)

Example 2 with NBTBase

use of net.minecraft.server.v1_16_R2.NBTBase in project MechanicsMain by WeaponMechanics.

the class NBT_1_11_R1 method visit.

private StringBuilder visit(NBTTagCompound nbt, int indents, int colorOffset) {
    String braceColor = "&" + BRACE_COLORS.charAt(indents % BRACE_COLORS.length());
    StringBuilder builder = new StringBuilder(braceColor).append('{');
    List<String> keys = new ArrayList<>(nbt.c());
    Collections.sort(keys);
    for (int i = 0; i < keys.size(); i++) {
        String key = keys.get(i);
        NBTBase value = Objects.requireNonNull(nbt.get(key), "This is impossible");
        if (i != 0)
            builder.append('\n');
        builder.append(StringUtil.repeat("  ", indents));
        String color = "&" + VALUE_COLORS.charAt((i + colorOffset) % VALUE_COLORS.length());
        builder.append(color).append(key).append("&f&l: ").append(color);
        if (value instanceof NBTTagCompound)
            builder.append(visit((NBTTagCompound) value, indents + 1, colorOffset + i));
        else
            builder.append(value);
    }
    return builder.append(braceColor).append("}\n");
}
Also used : NBTBase(net.minecraft.server.v1_11_R1.NBTBase) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.server.v1_11_R1.NBTTagCompound)

Example 3 with NBTBase

use of net.minecraft.server.v1_16_R2.NBTBase in project MechanicsMain by WeaponMechanics.

the class NBT_1_12_R1 method visit.

private StringBuilder visit(NBTTagCompound nbt, int indents, int colorOffset) {
    String braceColor = "&" + BRACE_COLORS.charAt(indents % BRACE_COLORS.length());
    StringBuilder builder = new StringBuilder(braceColor).append('{');
    List<String> keys = new ArrayList<>(nbt.c());
    Collections.sort(keys);
    for (int i = 0; i < keys.size(); i++) {
        String key = keys.get(i);
        NBTBase value = Objects.requireNonNull(nbt.get(key), "This is impossible");
        if (i != 0)
            builder.append('\n');
        builder.append(StringUtil.repeat("  ", indents));
        String color = "&" + VALUE_COLORS.charAt((i + colorOffset) % VALUE_COLORS.length());
        builder.append(color).append(key).append("&f&l: ").append(color);
        if (value instanceof NBTTagCompound)
            builder.append(visit((NBTTagCompound) value, indents + 1, colorOffset + i));
        else
            builder.append(value);
    }
    return builder.append(braceColor).append("}\n");
}
Also used : NBTBase(net.minecraft.server.v1_12_R1.NBTBase) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound)

Example 4 with NBTBase

use of net.minecraft.server.v1_16_R2.NBTBase in project RoseStacker by Rosewood-Development.

the class NBTStackedEntityDataStorage method removeDuplicates.

private void removeDuplicates(NBTTagCompound compoundTag) {
    for (String key : new ArrayList<>(compoundTag.getKeys())) {
        NBTBase baseValue = this.base.get(key);
        NBTBase thisValue = compoundTag.get(key);
        if (baseValue != null && baseValue.equals(thisValue))
            compoundTag.remove(key);
    }
}
Also used : NBTBase(net.minecraft.server.v1_16_R2.NBTBase) ArrayList(java.util.ArrayList)

Example 5 with NBTBase

use of net.minecraft.server.v1_16_R2.NBTBase in project RoseStacker by Rosewood-Development.

the class NBTStackedEntityDataStorage method removeDuplicates.

private void removeDuplicates(NBTTagCompound compoundTag) {
    for (String key : new ArrayList<>(compoundTag.getKeys())) {
        NBTBase baseValue = this.base.get(key);
        NBTBase thisValue = compoundTag.get(key);
        if (baseValue != null && baseValue.equals(thisValue))
            compoundTag.remove(key);
    }
}
Also used : NBTBase(net.minecraft.server.v1_16_R3.NBTBase) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)11 NBTBase (net.minecraft.server.v1_12_R1.NBTBase)2 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)2 NBTBase (net.minecraft.server.v1_16_R3.NBTBase)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 NBTBase (net.minecraft.server.v1_10_R1.NBTBase)1 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)1 NBTBase (net.minecraft.server.v1_11_R1.NBTBase)1 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)1 NBTTagString (net.minecraft.server.v1_12_R1.NBTTagString)1 NBTBase (net.minecraft.server.v1_13_R2.NBTBase)1 NBTTagCompound (net.minecraft.server.v1_13_R2.NBTTagCompound)1 NBTBase (net.minecraft.server.v1_14_R1.NBTBase)1 NBTTagCompound (net.minecraft.server.v1_14_R1.NBTTagCompound)1