Search in sources :

Example 91 with NBTTagCompound

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

the class NBTStackedEntityDataStorage method rebuild.

private NBTTagCompound rebuild(NBTTagCompound compoundTag) {
    NBTTagCompound merged = new NBTTagCompound();
    merged.a(this.base);
    merged.a(compoundTag);
    this.fillAttributeUuids(merged);
    return merged;
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound)

Example 92 with NBTTagCompound

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

the class NBTStackedEntityDataStorage method stripUnneeded.

private void stripUnneeded(NBTTagCompound compoundTag) {
    compoundTag.remove("UUID");
    compoundTag.remove("Pos");
    compoundTag.remove("Rotation");
    compoundTag.remove("WorldUUIDMost");
    compoundTag.remove("WorldUUIDLeast");
    compoundTag.remove("Motion");
    compoundTag.remove("OnGround");
    compoundTag.remove("FallDistance");
    compoundTag.remove("Leash");
    compoundTag.remove("Spigot.ticksLived");
    compoundTag.remove("Paper.OriginWorld");
    compoundTag.remove("Paper.Origin");
    NBTTagCompound bukkitValues = compoundTag.getCompound("BukkitValues");
    bukkitValues.remove("rosestacker:stacked_entity_data");
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound)

Example 93 with NBTTagCompound

use of net.minecraft.server.v1_16_R2.NBTTagCompound 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 94 with NBTTagCompound

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

the class NBTStackedEntityDataStorage method addAt.

private void addAt(int index, StackedEntityDataEntry<?> stackedEntityDataEntry) {
    NBTTagCompound compoundTag = (NBTTagCompound) stackedEntityDataEntry.get();
    this.stripUnneeded(compoundTag);
    this.stripAttributeUuids(compoundTag);
    this.removeDuplicates(compoundTag);
    this.data.add(index, compoundTag);
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound)

Example 95 with NBTTagCompound

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

the class NBTStackedEntityDataStorage method stripAttributeUuids.

private void stripAttributeUuids(NBTTagCompound compoundTag) {
    NBTTagList attributes = compoundTag.getList("Attributes", 10);
    for (int i = 0; i < attributes.size(); i++) {
        NBTTagCompound attribute = attributes.getCompound(i);
        attribute.remove("UUID");
        NBTTagList modifiers = attribute.getList("Modifiers", 10);
        for (int j = 0; j < modifiers.size(); j++) {
            NBTTagCompound modifier = modifiers.getCompound(j);
            if (modifier.getString("Name").equals("Random spawn bonus")) {
                modifiers.remove(j);
                j--;
            } else {
                modifier.remove("UUID");
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.server.v1_16_R3.NBTTagList) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound)

Aggregations

NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)70 ItemStack (org.bukkit.inventory.ItemStack)61 Map (java.util.Map)42 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)39 ArrayList (java.util.ArrayList)38 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)38 ItemMeta (org.bukkit.inventory.meta.ItemMeta)35 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)34 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)30 ListTag (com.wasteofplastic.org.jnbt.ListTag)30 StringTag (com.wasteofplastic.org.jnbt.StringTag)30 Tag (com.wasteofplastic.org.jnbt.Tag)30 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)24 Nullable (javax.annotation.Nullable)21 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)21 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)20 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)20 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)20 NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)19 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)18