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();
}
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();
}
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;
}
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;
}
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);
}
Aggregations