Lodestone.Minecraft.Common
Loading...
Searching...
No Matches
ObjectIOs.h
Go to the documentation of this file.
1//
2// Created by DexrnZacAttack on 2/14/26 using zPc-i2.
3//
4#ifndef LODESTONE_MINECRAFT_COMMON_OBJECTIOS_H
5#define LODESTONE_MINECRAFT_COMMON_OBJECTIOS_H
6#include <type_traits>
7
14
18#include <libnbt++/io/stream_writer.h>
19
24
25namespace nbt {
26 class tag_compound;
27}
28
30 template <const lodestone::common::registry::Identifier *I, typename RO, typename WO, typename WR = void>
33 public lodestone::conversion::io::AbstractObjectIO<I, std::unique_ptr<world::data::LevelData>, world::data::LevelData *, RO, WO, WR> {};
34
35 template <const lodestone::common::registry::Identifier *I, typename RO, typename WO, typename WR = void>
38 public lodestone::conversion::io::AbstractObjectIO<I, std::unique_ptr<region::Region>, level::Level *, RO, WO, WR> {};
39
40 template <const lodestone::common::registry::Identifier *I, typename R, typename W, typename RO, typename WO>
43 class NbtIO : public lodestone::conversion::io::AbstractObjectIO<I, R, W, RO, const options::OptionPresets::NbtOutputWriteOptions<WO>, void> {
44 public:
45
46 nbt::tag_compound tagFromWritten(W obj, WO &options) const {
47 nbt::tag_compound c;
48
50 options,
52 c
53 }
54 };
55
56 this->write(obj, h);
57
58 return c;
59 };
60
61 void writeToNbtStreamWriter(W obj, const std::string& key, nbt::io::stream_writer &writer, WO &options) const {
62 writer.write_tag(key, this->tagFromWritten(obj, options));
63 }
64 };
65
66 template <const lodestone::common::registry::Identifier *I, typename RO, typename WO>
69 public NbtIO<I, std::unique_ptr<level::entity::Player>, level::entity::Player *, RO, WO> {};
70
71 template <const lodestone::common::registry::Identifier *I, typename RO, typename WO>
74 public NbtIO<I, std::unique_ptr<level::Level>, level::Level *, RO, WO> {};
75
76 template <const lodestone::common::registry::Identifier *I, typename RO, typename WO>
79 public NbtIO<I, std::unique_ptr<world::data::LevelData>, world::data::LevelData *, RO, WO> {};
80
81 template <const lodestone::common::registry::Identifier *I, typename RO, typename WO>
84 public NbtIO<I, std::unique_ptr<level::chunk::Chunk>, level::chunk::Chunk *, RO, WO> {};
85}
86
87#endif // LODESTONE_OBJECTIOS_H
virtual WR write(W obj, WO &options) const =0
void writeToNbtStreamWriter(W obj, const std::string &key, nbt::io::stream_writer &writer, WO &options) const
Definition ObjectIOs.h:61
nbt::tag_compound tagFromWritten(W obj, WO &options) const
Definition ObjectIOs.h:46
lodestone::conversion::io::options::OptionsBuilder< WO, NbtOutputOptions > NbtOutputWriteOptions
Definition OptionPresets.h:45
Definition ObjectIOs.h:25