Skip to content

Commit

Permalink
Merge pull request #31 from SmokeyStack/refactor
Browse files Browse the repository at this point in the history
Updated queries and fixed GlobalRegistry
  • Loading branch information
SmokeyStack authored Oct 5, 2023
2 parents 86d94ce + 69150b6 commit ff23f7f
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 52 deletions.
2 changes: 1 addition & 1 deletion adk/data/GlobalRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ std::vector<std::string> vanillaRegistry{
"minecraft:zombie_villager_spawn_egg"};

std::vector<std::string> getIds() {
std::string key;
std::vector<std::string> key;

for (auto const entry : globalregistry) {
std::map<std::string, std::variant<Block*, Item*>> registry_check;
Expand Down
6 changes: 3 additions & 3 deletions adk/data/include/AxisBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class AxisBlock : public Block {

// Permutations
json::object_t temp = {
{"condition", "q.block_property('" + mod_id + ":rotation') == 0"}};
{"condition", "q.block_state('" + mod_id + ":rotation') == 0"}};
temp["components"].update(helper.rotation(std::vector<int>(0, 0, 0)));
j["minecraft:block"]["permutations"].push_back(temp);
temp = {
{"condition", "q.block_property('" + mod_id + ":rotation') == 1"}};
{"condition", "q.block_state('" + mod_id + ":rotation') == 1"}};
temp["components"].update(helper.rotation(std::vector<int>(90, 0, 0)));
j["minecraft:block"]["permutations"].push_back(temp);
temp = {
{"condition", "q.block_property('" + mod_id + ":rotation') == 2"}};
{"condition", "q.block_state('" + mod_id + ":rotation') == 2"}};
temp["components"].update(helper.rotation(std::vector<int>(0, 0, 90)));
j["minecraft:block"]["permutations"].push_back(temp);

Expand Down
20 changes: 10 additions & 10 deletions adk/data/include/CandleBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,27 @@ class CandleBlock : public Block {
"geometry.candle";
j["minecraft:block"]["components"]["minecraft:geometry"]
["bone_visibility"] = {
{"one", "q.block_property('" + mod_id + ":count') == 1"},
{"two", "q.block_property('" + mod_id + ":count') == 2"},
{"three", "q.block_property('" + mod_id + ":count') == 3"},
{"four", "q.block_property('" + mod_id + ":count') == 4"}};
{"one", "q.block_state('" + mod_id + ":count') == 1"},
{"two", "q.block_state('" + mod_id + ":count') == 2"},
{"three", "q.block_state('" + mod_id + ":count') == 3"},
{"four", "q.block_state('" + mod_id + ":count') == 4"}};
j["minecraft:block"]["components"]["minecraft:on_interact"]
["condition"] = "q.is_item_name_any('slot.weapon.mainhand', '" + id +
"') && q.block_property('" + mod_id + ":count') != 4";
"') && q.block_state('" + mod_id + ":count') != 4";
j["minecraft:block"]["components"]["minecraft:on_interact"]["event"] =
mod_id + ":add_candle";

// Events
j["minecraft:block"]["events"][mod_id + ":add_candle"]
["set_block_property"][mod_id + ":count"] =
"(q.block_property('" + mod_id +
":count') < 4) ? q.block_property('" + mod_id + ":count') + 1 : 4";
"(q.block_state('" + mod_id +
":count') < 4) ? q.block_state('" + mod_id + ":count') + 1 : 4";
j["minecraft:block"]["events"][mod_id + ":add_candle"]
["decrement_stack"] = json::object();

// Permutations
json::object_t temp = {
{"condition", "q.block_property('" + mod_id + ":count') == 2"}};
{"condition", "q.block_state('" + mod_id + ":count') == 2"}};
temp["components"].update(
helper.collision(std::make_pair(std::vector<int>{-3, 0, -1},
std::vector<int>{5, 6, 3}),
Expand All @@ -82,7 +82,7 @@ class CandleBlock : public Block {
std::vector<int>{5, 6, 3}),
id));
j["minecraft:block"]["permutations"].push_back(temp);
temp = {{"condition", "q.block_property('" + mod_id + ":count') == 3"}};
temp = {{"condition", "q.block_state('" + mod_id + ":count') == 3"}};
temp["components"].update(
helper.collision(std::make_pair(std::vector<int>{-2, 0, -2},
std::vector<int>{5, 6, 5}),
Expand All @@ -92,7 +92,7 @@ class CandleBlock : public Block {
std::vector<int>{5, 6, 5}),
id));
j["minecraft:block"]["permutations"].push_back(temp);
temp = {{"condition", "q.block_property('" + mod_id + ":count') == 4"}};
temp = {{"condition", "q.block_state('" + mod_id + ":count') == 4"}};
temp["components"].update(
helper.collision(std::make_pair(std::vector<int>{-3, 0, -3},
std::vector<int>{6, 6, 5}),
Expand Down
52 changes: 26 additions & 26 deletions adk/data/include/HeadBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,49 +58,49 @@ class HeadBlock : public Block {
"geometry.head";
j["minecraft:block"]["components"]["minecraft:geometry"]
["bone_visibility"] = {
{"0", "(q.block_property('" + mod_id +
{"0", "(q.block_state('" + mod_id +
":rotation') == 0 || "
"q.block_property('" +
"q.block_state('" +
mod_id +
":rotation') == 4 || "
"q.block_property('" +
"q.block_state('" +
mod_id +
":rotation') == 8 || "
"q.block_property('" +
"q.block_state('" +
mod_id +
":rotation') == 12) && "
"q.block_property('minecraft:block_face') == 'up'"},
{"22_5", "q.block_property('" + mod_id +
"q.block_state('minecraft:block_face') == 'up'"},
{"22_5", "q.block_state('" + mod_id +
":rotation') == 1 || "
"q.block_property('" +
"q.block_state('" +
mod_id +
":rotation') == 5 || "
"q.block_property('" +
"q.block_state('" +
mod_id +
":rotation') == 9 || "
"q.block_property('" +
"q.block_state('" +
mod_id + ":rotation') == 13"},
{"45", "q.block_property('" + mod_id +
{"45", "q.block_state('" + mod_id +
":rotation') == 2 || "
"q.block_property('" +
"q.block_state('" +
mod_id +
":rotation') == 6 || "
"q.block_property('" +
"q.block_state('" +
mod_id +
":rotation') == 10 || "
"q.block_property('" +
"q.block_state('" +
mod_id + ":rotation') == 14"},
{"67_5", "q.block_property('" + mod_id +
{"67_5", "q.block_state('" + mod_id +
":rotation') == 3 || "
"q.block_property('" +
"q.block_state('" +
mod_id +
":rotation') == 7 || "
"q.block_property('" +
"q.block_state('" +
mod_id +
":rotation') == 11 || "
"q.block_property('" +
"q.block_state('" +
mod_id + ":rotation') == 15"},
{"wall", "q.block_property('minecraft:block_face') != 'up'"}};
{"wall", "q.block_state('minecraft:block_face') != 'up'"}};

// Events
j["minecraft:block"]["events"][mod_id + ":set_rotation"]
Expand All @@ -114,30 +114,30 @@ class HeadBlock : public Block {
// Permutations
json::object_t temp = {
{"condition",
"q.block_property('" + mod_id +
"q.block_state('" + mod_id +
":rotation') >= 4 || "
"q.block_property('minecraft:block_face') == 'east'"}};
"q.block_state('minecraft:block_face') == 'east'"}};
temp["components"].update(
helper.rotation(std::vector<int>{0, -90, 0}, id));
j["minecraft:block"]["permutations"].push_back(temp);
temp = {{"condition",
"q.block_property('" + mod_id +
"q.block_state('" + mod_id +
":rotation') >= 4 || "
"q.block_property('minecraft:block_face') == 'east'"}};
"q.block_state('minecraft:block_face') == 'east'"}};
temp["components"].update(
helper.rotation(std::vector<int>{0, -90, 0}, id));
j["minecraft:block"]["permutations"].push_back(temp);
temp = {{"condition",
"q.block_property('" + mod_id +
"q.block_state('" + mod_id +
":rotation') >= 8 || "
"q.block_property('minecraft:block_face') == 'south'"}};
"q.block_state('minecraft:block_face') == 'south'"}};
temp["components"].update(
helper.rotation(std::vector<int>{0, 180, 0}, id));
j["minecraft:block"]["permutations"].push_back(temp);
temp = {{"condition",
"q.block_property('" + mod_id +
"q.block_state('" + mod_id +
":rotation') >= 12 || "
"q.block_property('minecraft:block_face') == 'west'"}};
"q.block_state('minecraft:block_face') == 'west'"}};
temp["components"].update(
helper.rotation(std::vector<int>{0, 90, 0}, id));
j["minecraft:block"]["permutations"].push_back(temp);
Expand Down
67 changes: 67 additions & 0 deletions adk/data/include/ItemComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef ITEMCOMPONENT_H
#define ITEMCOMPONENT_H

#include <spdlog/spdlog.h>

#include "json.hpp"

class ItemComponent {
public:
/**
* @brief
*
* @param value
* @return nlohmann::json::object_t
*/
nlohmann::json::object_t armor(int value) {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}

nlohmann::json::object_t blockPlacer() {}
};

#endif
6 changes: 3 additions & 3 deletions adk/data/include/SaplingBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class SaplingBlock : public BushBlock {

j["minecraft:block"]["events"][mod_id + ":random_tick"]
["set_block_property"][mod_id + ":growth_stage"] =
"(q.block_property('" + mod_id + ":growth_stage') < " +
"(q.block_state('" + mod_id + ":growth_stage') < " +
std::to_string(_number_of_properties - 1) +
") ? "
"q.block_property('" +
"q.block_state('" +
mod_id + ":growth_stage') + 1 : " +
std::to_string(_number_of_properties - 1);

Expand All @@ -75,7 +75,7 @@ class SaplingBlock : public BushBlock {
{{"components",
{{"minecraft:random_ticking",
{{"on_tick", {{"event", mod_id + ":final_growth"}}}}}}},
{"condition", "q.block_property('" + mod_id +
{"condition", "q.block_state('" + mod_id +
":growth_stage') == " +
std::to_string(_number_of_properties - 1)}},
};
Expand Down
18 changes: 9 additions & 9 deletions adk/data/include/SlabBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class SlabBlock : public Block {
j["minecraft:block"]["components"]["minecraft:geometry"]
["bone_visibility"] = {
{"upper",
"q.block_property('minecraft:vertical_half') == 'top' || "
"q.block_property('" +
"q.block_state('minecraft:vertical_half') == 'top' || "
"q.block_state('" +
mod_id + ":is_double')"},
{"lower",
"q.block_property('minecraft:vertical_half') == 'bottom' || "
"q.block_property('" +
"q.block_state('minecraft:vertical_half') == 'bottom' || "
"q.block_state('" +
mod_id + ":is_double')"}};

// Events
Expand All @@ -60,8 +60,8 @@ class SlabBlock : public Block {
// Permutations
json::object_t temp = {
{"condition",
"q.block_property('minecraft:vertical_half') == 'top' && "
"!q.block_property('" +
"q.block_state('minecraft:vertical_half') == 'top' && "
"!q.block_state('" +
mod_id + ":is_double')"}};
temp["components"].update(
helper.collision(std::make_pair(std::vector<int>{-8, 8, -8},
Expand All @@ -80,8 +80,8 @@ class SlabBlock : public Block {
mod_id + ":" + id + "')"}}}});
j["minecraft:block"]["permutations"].push_back(temp);
temp = {{"condition",
"q.block_property('minecraft:vertical_half') == 'bottom' && "
"!q.block_property('" +
"q.block_state('minecraft:vertical_half') == 'bottom' && "
"!q.block_state('" +
mod_id + ":is_double')"}};
temp["components"].update(
helper.collision(std::make_pair(std::vector<int>{-8, 0, -8},
Expand All @@ -99,7 +99,7 @@ class SlabBlock : public Block {
"mainhand','" +
mod_id + ":" + id + "')"}}}});
j["minecraft:block"]["permutations"].push_back(temp);
temp = {{"condition", "q.block_property('" + mod_id + ":is_double')"}};
temp = {{"condition", "q.block_state('" + mod_id + ":is_double')"}};
temp["components"].update(
{{"minecraft:on_player_destroyed",
{{"event", "" + mod_id + ":drop_double"}}}});
Expand Down

0 comments on commit ff23f7f

Please sign in to comment.