Search in sources :

Example 81 with NbtList

use of net.minecraft.nbt.NbtList in project frame-fabric by moddingplayground.

the class ClientBannerBlockEntityMixin method frame_getBannerPatterns.

@Override
public List<FrameBannerPatternData> frame_getBannerPatterns() {
    if (this.patterns == null) {
        NbtList nbt = ((FrameBannerPatternAccess.Internal) this).frame_getBannerPatternNbt();
        frame_bannerPatterns = FrameBannerPatternConversions.makeData(nbt);
    }
    return Collections.unmodifiableList(frame_bannerPatterns);
}
Also used : NbtList(net.minecraft.nbt.NbtList)

Example 82 with NbtList

use of net.minecraft.nbt.NbtList in project KahzerxMod by otakucraft.

the class SolExtension method createFirework.

private static ItemStack createFirework(FireworkHelper... fireworksConfigs) {
    ItemStack firework = new ItemStack(Items.FIREWORK_ROCKET, 1);
    ItemStack star = new ItemStack(Items.FIREWORK_STAR);
    NbtList explosions = new NbtList();
    for (FireworkHelper config : fireworksConfigs) {
        NbtCompound explosion = star.getOrCreateSubNbt(FireworkRocketItem.EXPLOSION_KEY).copy();
        explosion.putIntArray(FireworkRocketItem.COLORS_KEY, config.getColors());
        explosion.putByte(FireworkRocketItem.TYPE_KEY, (byte) config.getType());
        explosion.putByte(FireworkRocketItem.FLICKER_KEY, (byte) config.getFlicker());
        explosion.putByte(FireworkRocketItem.TRAIL_KEY, (byte) config.getTrail());
        if (config.getFadeColors().length != 0) {
            explosion.putIntArray(FireworkRocketItem.FADE_COLORS_KEY, config.getFadeColors());
        }
        explosions.add(explosion);
    }
    NbtCompound fireworks = firework.getOrCreateSubNbt(FireworkRocketItem.FIREWORKS_KEY);
    fireworks.putByte(FireworkRocketItem.FLIGHT_KEY, (byte) 1);
    fireworks.put(FireworkRocketItem.EXPLOSIONS_KEY, explosions);
    firework.getOrCreateNbt().putBoolean("Sol", true);
    return firework;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) ItemStack(net.minecraft.item.ItemStack)

Example 83 with NbtList

use of net.minecraft.nbt.NbtList in project KiwiClient by TangyKiwi.

the class Utils method removeEnchantment.

public static void removeEnchantment(ItemStack itemStack, Enchantment enchantment) {
    NbtCompound nbt = itemStack.getNbt();
    if (nbt == null)
        return;
    if (!nbt.contains("Enchantments", 9))
        return;
    NbtList list = nbt.getList("Enchantments", 10);
    String enchId = Registry.ENCHANTMENT.getId(enchantment).toString();
    for (Iterator<NbtElement> it = list.iterator(); it.hasNext(); ) {
        NbtCompound ench = (NbtCompound) it.next();
        if (ench.getString("id").equals(enchId)) {
            it.remove();
            break;
        }
    }
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Example 84 with NbtList

use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.

the class SoundEventListSetting method load.

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

Example 85 with NbtList

use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.

the class SettingGroup method fromTag.

@Override
public SettingGroup fromTag(NbtCompound tag) {
    sectionExpanded = tag.getBoolean("sectionExpanded");
    NbtList settingsTag = tag.getList("settings", 10);
    for (NbtElement t : settingsTag) {
        NbtCompound settingTag = (NbtCompound) t;
        Setting<?> setting = get(settingTag.getString("name"));
        if (setting != null)
            setting.fromTag(settingTag);
    }
    return this;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Aggregations

NbtList (net.minecraft.nbt.NbtList)161 NbtCompound (net.minecraft.nbt.NbtCompound)92 NbtElement (net.minecraft.nbt.NbtElement)46 Identifier (net.minecraft.util.Identifier)38 ItemStack (net.minecraft.item.ItemStack)28 NbtString (net.minecraft.nbt.NbtString)17 LiteralText (net.minecraft.text.LiteralText)12 BlockPos (net.minecraft.util.math.BlockPos)11 Block (net.minecraft.block.Block)9 IOException (java.io.IOException)8 List (java.util.List)8 Item (net.minecraft.item.Item)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 Items (net.minecraft.item.Items)6 NbtIo (net.minecraft.nbt.NbtIo)6 StatusEffect (net.minecraft.entity.effect.StatusEffect)5 Text (net.minecraft.text.Text)5 ArrayList (java.util.ArrayList)4 Comparator (java.util.Comparator)4 Blocks (net.minecraft.block.Blocks)4