use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.
the class SoundEventListSetting method save.
@Override
public NbtCompound save(NbtCompound tag) {
NbtList valueTag = new NbtList();
for (SoundEvent sound : get()) {
Identifier id = Registry.SOUND_EVENT.getId(sound);
if (id != null)
valueTag.add(NbtString.of(id.toString()));
}
tag.put("value", valueTag);
return tag;
}
use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.
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.NbtList in project meteor-client by MeteorDevelopment.
the class StatusEffectListSetting method save.
@Override
public NbtCompound save(NbtCompound tag) {
NbtList valueTag = new NbtList();
for (StatusEffect effect : get()) {
Identifier id = Registry.STATUS_EFFECT.getId(effect);
if (id != null)
valueTag.add(NbtString.of(id.toString()));
}
tag.put("value", valueTag);
return tag;
}
use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.
the class BookBot method writeBook.
private void writeBook(PrimitiveIterator.OfInt chars) {
ArrayList<String> pages = new ArrayList<>();
for (int pageI = 0; pageI < (mode.get() == Mode.File ? 100 : this.pages.get()); pageI++) {
// Check if the stream is empty before creating a new page
if (!chars.hasNext())
break;
StringBuilder page = new StringBuilder();
for (int lineI = 0; lineI < 13; lineI++) {
// Check if the stream is empty before creating a new line
if (!chars.hasNext())
break;
double lineWidth = 0;
StringBuilder line = new StringBuilder();
while (true) {
// Check if the stream is empty
if (!chars.hasNext())
break;
// Get the next character
int nextChar = chars.nextInt();
// Ignore newline chars when writing lines, should already be organised
if (nextChar == '\r' || nextChar == '\n')
break;
// Make sure the character will fit on the line
double charWidth = ((TextHandlerAccessor) mc.textRenderer.getTextHandler()).getWidthRetriever().getWidth(nextChar, Style.EMPTY);
if (lineWidth + charWidth > 114)
break;
// Append it to the line
line.appendCodePoint(nextChar);
lineWidth += charWidth;
}
// Append the line to the page
page.append(line).append('\n');
}
// Append page to the page list
pages.add(page.toString());
}
// Get the title with count
String title = name.get();
if (count.get() && bookCount != 0)
title += " #" + bookCount;
// Write data to book
mc.player.getMainHandStack().setSubNbt("title", NbtString.of(title));
mc.player.getMainHandStack().setSubNbt("author", NbtString.of(mc.player.getGameProfile().getName()));
// Write pages NBT
NbtList pageNbt = new NbtList();
pages.stream().map(NbtString::of).forEach(pageNbt::add);
if (!pages.isEmpty())
mc.player.getMainHandStack().setSubNbt("pages", pageNbt);
// Send book update to server
mc.player.networkHandler.sendPacket(new BookUpdateC2SPacket(mc.player.getInventory().selectedSlot, pages, Optional.of(title)));
bookCount++;
}
use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.
the class Profile method toTag.
@Override
public NbtCompound toTag() {
NbtCompound tag = new NbtCompound();
tag.putString("name", name);
tag.putBoolean("onLaunch", onLaunch);
tag.putBoolean("accounts", accounts);
tag.putBoolean("config", config);
tag.putBoolean("friends", friends);
tag.putBoolean("macros", macros);
tag.putBoolean("modules", modules);
tag.putBoolean("waypoints", waypoints);
tag.putBoolean("hud", hud);
loadOnJoinIps.removeIf(String::isEmpty);
NbtList ipsTag = new NbtList();
for (String ip : loadOnJoinIps) ipsTag.add(NbtString.of(ip));
tag.put("loadOnJoinIps", ipsTag);
return tag;
}
Aggregations