use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.
the class BookEditScreenMixin method onInit.
@Inject(method = "init", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
addDrawableChild(new ButtonWidget(4, 4, 120, 20, new LiteralText("Copy"), button -> {
NbtList listTag = new NbtList();
pages.stream().map(NbtString::of).forEach(listTag::add);
NbtCompound tag = new NbtCompound();
tag.put("pages", listTag);
tag.putInt("currentPage", currentPage);
FastByteArrayOutputStream bytes = new FastByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(bytes);
try {
NbtIo.write(tag, out);
} catch (IOException e) {
e.printStackTrace();
}
try {
GLFW.glfwSetClipboardString(mc.getWindow().getHandle(), Base64.getEncoder().encodeToString(bytes.array));
} catch (OutOfMemoryError exception) {
GLFW.glfwSetClipboardString(mc.getWindow().getHandle(), exception.toString());
}
}));
addDrawableChild(new ButtonWidget(4, 4 + 20 + 2, 120, 20, new LiteralText("Paste"), button -> {
String clipboard = GLFW.glfwGetClipboardString(mc.getWindow().getHandle());
if (clipboard == null)
return;
byte[] bytes;
try {
bytes = Base64.getDecoder().decode(clipboard);
} catch (IllegalArgumentException ignored) {
return;
}
DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
try {
NbtCompound tag = NbtIo.read(in);
NbtList listTag = tag.getList("pages", 8).copy();
pages.clear();
for (int i = 0; i < listTag.size(); ++i) {
pages.add(listTag.getString(i));
}
if (pages.isEmpty()) {
pages.add("");
}
currentPage = tag.getInt("currentPage");
dirty = true;
updateButtons();
} catch (IOException e) {
e.printStackTrace();
}
}));
}
use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.
the class LocateCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("buried_treasure").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.FILLED_MAP) {
error("You need to hold a treasure map first");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 == null) {
error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
return SINGLE_SUCCESS;
}
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT == null) {
error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
BaseText text = new LiteralText("Buried Treasure located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("lodestone").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.COMPASS) {
error("You need to hold a lodestone compass");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
if (tag == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
NbtCompound nbt1 = tag.getCompound("LodestonePos");
if (nbt1 == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(nbt1.getDouble("X"), nbt1.getDouble("Y"), nbt1.getDouble("Z"));
BaseText text = new LiteralText("Lodestone located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("mansion").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.FILLED_MAP) {
error("You need to hold a woodland explorer map first");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 == null) {
error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
return SINGLE_SUCCESS;
}
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT == null) {
error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
BaseText text = new LiteralText("Mansion located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("stronghold").executes(s -> {
FindItemResult eye = InvUtils.findInHotbar(Items.ENDER_EYE);
if (eye.found()) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("follow entity minecraft:eye_of_ender");
firstStart = null;
firstEnd = null;
secondStart = null;
secondEnd = null;
MeteorClient.EVENT_BUS.subscribe(this);
info("Please throw the first Eye of Ender");
} else {
Vec3d coords = findByBlockList(strongholdBlocks);
if (coords == null) {
error("No stronghold found nearby. You can use (highlight)Ender Eyes(default) for more success.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Stronghold located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
}
return SINGLE_SUCCESS;
}));
builder.then(literal("nether_fortress").executes(s -> {
Vec3d coords = findByBlockList(netherFortressBlocks);
if (coords == null) {
error("No nether fortress found.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Fortress located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("monument").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() == Items.FILLED_MAP) {
NbtCompound tag = stack.getNbt();
if (tag != null) {
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 != null) {
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT != null) {
Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
BaseText text = new LiteralText("Monument located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}
}
}
}
Vec3d coords = findByBlockList(monumentBlocks);
if (coords == null) {
error("No monument found. You can try using a (highlight)Ocean explorer map(default) for more success.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Monument located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("cancel").executes(s -> {
cancel();
return SINGLE_SUCCESS;
}));
}
use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.
the class Modules method toTag.
@Override
public NbtCompound toTag() {
NbtCompound tag = new NbtCompound();
NbtList modulesTag = new NbtList();
for (Module module : getAll()) {
NbtCompound moduleTag = module.toTag();
if (moduleTag != null)
modulesTag.add(moduleTag);
}
tag.put("modules", modulesTag);
return tag;
}
use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.
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.NbtList in project meteor-client by MeteorDevelopment.
the class Friends method toTag.
@Override
public NbtCompound toTag() {
NbtCompound tag = new NbtCompound();
NbtList friendsTag = new NbtList();
for (Friend friend : friends) friendsTag.add(friend.toTag());
tag.put("friends", friendsTag);
tag.put("color", color.toTag());
tag.putBoolean("attack", attack);
return tag;
}
Aggregations