Search in sources :

Example 46 with NbtElement

use of net.minecraft.nbt.NbtElement in project Client by MatHax.

the class ParticleTypeListSetting method load.

@Override
public List<ParticleType<?>> load(NbtCompound tag) {
    get().clear();
    NbtList valueTag = tag.getList("value", 8);
    for (NbtElement tagI : valueTag) {
        ParticleType<?> particleType = Registry.PARTICLE_TYPE.get(new Identifier(tagI.asString()));
        if (particleType != null)
            get().add(particleType);
    }
    return get();
}
Also used : Identifier(net.minecraft.util.Identifier) NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Example 47 with NbtElement

use of net.minecraft.nbt.NbtElement in project Client by MatHax.

the class StatusEffectListSetting method load.

@Override
public List<StatusEffect> load(NbtCompound tag) {
    get().clear();
    NbtList valueTag = tag.getList("value", 8);
    for (NbtElement tagI : valueTag) {
        StatusEffect effect = Registry.STATUS_EFFECT.get(new Identifier(tagI.asString()));
        if (effect != null)
            get().add(effect);
    }
    return get();
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect) Identifier(net.minecraft.util.Identifier) NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Example 48 with NbtElement

use of net.minecraft.nbt.NbtElement in project Client by MatHax.

the class Module method fromTag.

@Override
public Module fromTag(NbtCompound tag) {
    if (tag.contains("key"))
        keybind.set(true, tag.getInt("key"));
    else
        keybind.fromTag(tag.getCompound("keybind"));
    toggleOnBindRelease = tag.getBoolean("toggleOnKeyRelease");
    NbtElement settingsTag = tag.get("settings");
    if (settingsTag instanceof NbtCompound)
        settings.fromTag((NbtCompound) settingsTag);
    toggleMessage = tag.getBoolean("toggleMessage");
    toggleToast = tag.getBoolean("toggleToast");
    favorite = tag.getBoolean("favorite");
    boolean active = tag.getBoolean("active");
    if (active != isActive())
        toggle();
    visible = tag.getBoolean("visible");
    return this;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtElement(net.minecraft.nbt.NbtElement)

Example 49 with NbtElement

use of net.minecraft.nbt.NbtElement in project Client by MatHax.

the class Modules method fromTag.

@Override
public Modules fromTag(NbtCompound tag) {
    disableAll();
    NbtList modulesTag = tag.getList("modules", 10);
    for (NbtElement moduleTagI : modulesTag) {
        NbtCompound moduleTag = (NbtCompound) moduleTagI;
        Module module = get(moduleTag.getString("name"));
        if (module != null)
            module.fromTag(moduleTag);
    }
    return this;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Example 50 with NbtElement

use of net.minecraft.nbt.NbtElement in project Hypnotic-Client by Hypnotic-Development.

the class Enchant method addEnchantment.

public static void addEnchantment(ItemStack itemStack, Enchantment enchantment, int level) {
    NbtCompound tag = itemStack.getOrCreateNbt();
    NbtList listTag;
    // Get list tag
    if (!tag.contains("Enchantments", 9)) {
        listTag = new NbtList();
        tag.put("Enchantments", listTag);
    } else {
        listTag = tag.getList("Enchantments", 10);
    }
    // Check if item already has the enchantment and modify the level
    String enchId = Registry.ENCHANTMENT.getId(enchantment).toString();
    for (NbtElement _t : listTag) {
        NbtCompound t = (NbtCompound) _t;
        if (t.getString("id").equals(enchId)) {
            t.putShort("lvl", (short) level);
            return;
        }
    }
    // Add the enchantment if it doesn't already have it
    NbtCompound enchTag = new NbtCompound();
    enchTag.putString("id", enchId);
    enchTag.putShort("lvl", (short) level);
    listTag.add(enchTag);
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Aggregations

NbtElement (net.minecraft.nbt.NbtElement)51 NbtList (net.minecraft.nbt.NbtList)44 NbtCompound (net.minecraft.nbt.NbtCompound)22 Identifier (net.minecraft.util.Identifier)20 ItemStack (net.minecraft.item.ItemStack)6 Field (java.lang.reflect.Field)2 Block (net.minecraft.block.Block)2 Enchantment (net.minecraft.enchantment.Enchantment)2 StatusEffect (net.minecraft.entity.effect.StatusEffect)2 Item (net.minecraft.item.Item)2 SoundEvent (net.minecraft.sound.SoundEvent)2 DyeColor (net.minecraft.util.DyeColor)2 RecipePair (top.theillusivec4.polymorph.api.common.base.RecipePair)2 RecipePairImpl (top.theillusivec4.polymorph.common.impl.RecipePairImpl)2 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Module (mathax.client.systems.modules.Module)1 Module (meteordevelopment.meteorclient.systems.modules.Module)1