BlockStates code generation
emneo-dev opened this issue · 2 comments
emneo-dev commented
We need to generate some code to translate protocol ids to internal structures and vice versa, something like this :
#include <cstdint>
#include <unordered_map>
#include <string>
using namespace std;
enum class Blocks {
MINECRAFT_ACACIA_PRESSURE_PLATE,
};
struct Block {
Blocks type;
SomeMapType properties;
constexpr string toName() const {
switch (this->type) {
case Blocks::MINECRAFT_ACACIA_PRESSURE_PLATE:
return "minecraft:acacia_pressure_plate";
}
}
constexpr uint64_t toProtocol() const {
switch (this->type) {
case Blocks::MINECRAFT_ACACIA_PRESSURE_PLATE:
if constexpr (this->properties == SomeMapType({
{"powered", "true"}
}))
return 4186;
if constexpr (this->properties == SomeMapType({
{"powered", "false"}
}))
return 4187;
}
}
};
// "minecraft:acacia_pressure_plate": {
// "properties": {
// "powered": [
// "true",
// "false"
// ]
// },
// "states": [
// {
// "id": 4186,
// "properties": {
// "powered": "true"
// }
// },
// {
// "default": true,
// "id": 4187,
// "properties": {
// "powered": "false"
// }
// }
// ]
// },
Should be done next sprint
Trompettesib commented
We need to have a compile time thing to be more efficient.
For now, it cannot be build because of RAM usage.
Trompettesib commented
please refer to #108 PR for more info / code