From 3055499ae15513d4b3556e6118618d4ae626f59d Mon Sep 17 00:00:00 2001 From: Artemis Rosman <73006620+rozukke@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:20:13 +1000 Subject: [PATCH] Format all code to prepare for CI actions --- .clang-format | 3 + CMakeLists.txt | 2 + include/mcpp/block.h | 947 +++++++++++++++++++------------------- include/mcpp/connection.h | 111 ++--- include/mcpp/entity.h | 184 ++++---- include/mcpp/mcpp.h | 241 +++++----- include/mcpp/util.h | 35 +- src/block.cpp | 26 +- src/connection.cpp | 140 +++--- src/mcpp.cpp | 297 ++++++------ src/util.cpp | 88 ++-- test/local_tests.cpp | 20 +- test/minecraft_tests.cpp | 89 ++-- 13 files changed, 1069 insertions(+), 1114 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..abdf0a24 --- /dev/null +++ b/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +PointerAlignment: Left diff --git a/CMakeLists.txt b/CMakeLists.txt index 95123a9c..416d7048 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ set(MCPP_PUBLIC_INCLUDE_DIRECTORIES include/ ) # Testing enable_testing() add_subdirectory(test) +add_test(NAME local COMMAND local_tests) +add_test(NAME full COMMAND test_suite) # Source files file(GLOB_RECURSE MCPP_INCLUDE_FILES "include/*.h") diff --git a/include/mcpp/block.h b/include/mcpp/block.h index 1c32b8df..e04cd8e3 100644 --- a/include/mcpp/block.h +++ b/include/mcpp/block.h @@ -3,482 +3,485 @@ #include namespace mcpp { - class BlockType { - public: - int id; - int mod; +class BlockType { + public: + int id; + int mod; - BlockType() = default; - constexpr BlockType(int id, int modifier = 0) : id(id), mod(modifier) {}; - - /** - * Watch out as this also compares the BlockType.mod element of the block, so some equalities may behave in - * unexpected ways e.g. rotated stairs - */ - bool operator==(const BlockType& other) const; - - bool operator!=(const BlockType& other) const; - - friend std::ostream& operator<< (std::ostream& out, const BlockType& block); - - /** - * Returns a new BlockType with the same id and specified modifier, useful for rotations etc. - * @param modifier New modifier for the BlockType - * @return New BlockType object with the specified modifier - */ - [[nodiscard]] BlockType withMod(int modifier) const; - }; + BlockType() = default; + constexpr BlockType(int id, int modifier = 0) : id(id), mod(modifier){}; + /** + * Watch out as this also compares the BlockType.mod element of the block, + * so some equalities may behave in unexpected ways e.g. rotated stairs + */ + bool operator==(const BlockType& other) const; + bool operator!=(const BlockType& other) const; - // Using script to extract ids from https://minecraft-ids.grahamedgecombe.com/ + friend std::ostream& operator<<(std::ostream& out, const BlockType& block); /** - * Struct of static block objects that allows for a "search" of sorts, callable using Blocks::TYPE - * after importing + * Returns a new BlockType with the same id and specified modifier, useful + * for rotations etc. + * @param modifier New modifier for the BlockType + * @return New BlockType object with the specified modifier */ - struct Blocks { - static constexpr BlockType AIR = BlockType(0); - static constexpr BlockType STONE = BlockType(1); - static constexpr BlockType GRANITE = BlockType(1, 1); - static constexpr BlockType POLISHED_GRANITE = BlockType(1, 2); - static constexpr BlockType DIORITE = BlockType(1, 3); - static constexpr BlockType POLISHED_DIORITE = BlockType(1, 4); - static constexpr BlockType ANDESITE = BlockType(1, 5); - static constexpr BlockType POLISHED_ANDESITE = BlockType(1, 6); - static constexpr BlockType GRASS = BlockType(2); - static constexpr BlockType DIRT = BlockType(3); - static constexpr BlockType COARSE_DIRT = BlockType(3, 1); - static constexpr BlockType PODZOL = BlockType(3, 2); - static constexpr BlockType COBBLESTONE = BlockType(4); - static constexpr BlockType OAK_WOOD_PLANK = BlockType(5); - static constexpr BlockType SPRUCE_WOOD_PLANK = BlockType(5, 1); - static constexpr BlockType BIRCH_WOOD_PLANK = BlockType(5, 2); - static constexpr BlockType JUNGLE_WOOD_PLANK = BlockType(5, 3); - static constexpr BlockType ACACIA_WOOD_PLANK = BlockType(5, 4); - static constexpr BlockType DARK_OAK_WOOD_PLANK = BlockType(5, 5); - static constexpr BlockType OAK_SAPLING = BlockType(6); - static constexpr BlockType SPRUCE_SAPLING = BlockType(6, 1); - static constexpr BlockType BIRCH_SAPLING = BlockType(6, 2); - static constexpr BlockType JUNGLE_SAPLING = BlockType(6, 3); - static constexpr BlockType ACACIA_SAPLING = BlockType(6, 4); - static constexpr BlockType DARK_OAK_SAPLING = BlockType(6, 5); - static constexpr BlockType BEDROCK = BlockType(7); - static constexpr BlockType FLOWING_WATER = BlockType(8); - static constexpr BlockType STILL_WATER = BlockType(9); - static constexpr BlockType FLOWING_LAVA = BlockType(10); - static constexpr BlockType STILL_LAVA = BlockType(11); - static constexpr BlockType SAND = BlockType(12); - static constexpr BlockType RED_SAND = BlockType(12, 1); - static constexpr BlockType GRAVEL = BlockType(13); - static constexpr BlockType GOLD_ORE = BlockType(14); - static constexpr BlockType IRON_ORE = BlockType(15); - static constexpr BlockType COAL_ORE = BlockType(16); - static constexpr BlockType OAK_WOOD = BlockType(17); - static constexpr BlockType SPRUCE_WOOD = BlockType(17, 1); - static constexpr BlockType BIRCH_WOOD = BlockType(17, 2); - static constexpr BlockType JUNGLE_WOOD = BlockType(17, 3); - static constexpr BlockType OAK_LEAVES = BlockType(18); - static constexpr BlockType SPRUCE_LEAVES = BlockType(18, 1); - static constexpr BlockType BIRCH_LEAVES = BlockType(18, 2); - static constexpr BlockType JUNGLE_LEAVES = BlockType(18, 3); - static constexpr BlockType SPONGE = BlockType(19); - static constexpr BlockType WET_SPONGE = BlockType(19, 1); - static constexpr BlockType GLASS = BlockType(20); - static constexpr BlockType LAPIS_LAZULI_ORE = BlockType(21); - static constexpr BlockType LAPIS_LAZULI_BLOCK = BlockType(22); - static constexpr BlockType DISPENSER = BlockType(23); - static constexpr BlockType SANDSTONE = BlockType(24); - static constexpr BlockType CHISELED_SANDSTONE = BlockType(24, 1); - static constexpr BlockType SMOOTH_SANDSTONE = BlockType(24, 2); - static constexpr BlockType NOTE_BLOCK = BlockType(25); - static constexpr BlockType BED = BlockType(26); - static constexpr BlockType POWERED_RAIL = BlockType(27); - static constexpr BlockType DETECTOR_RAIL = BlockType(28); - static constexpr BlockType STICKY_PISTON = BlockType(29); - static constexpr BlockType COBWEB = BlockType(30); - static constexpr BlockType DEAD_SHRUB = BlockType(31); - static constexpr BlockType TALL_GRASS = BlockType(31, 1); - static constexpr BlockType FERN = BlockType(31, 2); - static constexpr BlockType DEAD_BUSH = BlockType(32); - static constexpr BlockType PISTON = BlockType(33); - static constexpr BlockType PISTON_HEAD = BlockType(34); - static constexpr BlockType WHITE_WOOL = BlockType(35); - static constexpr BlockType ORANGE_WOOL = BlockType(35, 1); - static constexpr BlockType MAGENTA_WOOL = BlockType(35, 2); - static constexpr BlockType LIGHT_BLUE_WOOL = BlockType(35, 3); - static constexpr BlockType YELLOW_WOOL = BlockType(35, 4); - static constexpr BlockType LIME_WOOL = BlockType(35, 5); - static constexpr BlockType PINK_WOOL = BlockType(35, 6); - static constexpr BlockType GRAY_WOOL = BlockType(35, 7); - static constexpr BlockType LIGHT_GRAY_WOOL = BlockType(35, 8); - static constexpr BlockType CYAN_WOOL = BlockType(35, 9); - static constexpr BlockType PURPLE_WOOL = BlockType(35, 10); - static constexpr BlockType BLUE_WOOL = BlockType(35, 11); - static constexpr BlockType BROWN_WOOL = BlockType(35, 12); - static constexpr BlockType GREEN_WOOL = BlockType(35, 13); - static constexpr BlockType RED_WOOL = BlockType(35, 14); - static constexpr BlockType BLACK_WOOL = BlockType(35, 15); - static constexpr BlockType DANDELION = BlockType(37); - static constexpr BlockType POPPY = BlockType(38); - static constexpr BlockType BLUE_ORCHID = BlockType(38, 1); - static constexpr BlockType ALLIUM = BlockType(38, 2); - static constexpr BlockType AZURE_BLUET = BlockType(38, 3); - static constexpr BlockType RED_TULIP = BlockType(38, 4); - static constexpr BlockType ORANGE_TULIP = BlockType(38, 5); - static constexpr BlockType WHITE_TULIP = BlockType(38, 6); - static constexpr BlockType PINK_TULIP = BlockType(38, 7); - static constexpr BlockType OXEYE_DAISY = BlockType(38, 8); - static constexpr BlockType BROWN_MUSHROOM = BlockType(39); - static constexpr BlockType RED_MUSHROOM = BlockType(40); - static constexpr BlockType GOLD_BLOCK = BlockType(41); - static constexpr BlockType IRON_BLOCK = BlockType(42); - static constexpr BlockType DOUBLE_STONE_SLAB = BlockType(43); - static constexpr BlockType DOUBLE_SANDSTONE_SLAB = BlockType(43, 1); - static constexpr BlockType DOUBLE_WOODEN_SLAB = BlockType(43, 2); - static constexpr BlockType DOUBLE_COBBLESTONE_SLAB = BlockType(43, 3); - static constexpr BlockType DOUBLE_BRICK_SLAB = BlockType(43, 4); - static constexpr BlockType DOUBLE_STONE_BRICK_SLAB = BlockType(43, 5); - static constexpr BlockType DOUBLE_NETHER_BRICK_SLAB = BlockType(43, 6); - static constexpr BlockType DOUBLE_QUARTZ_SLAB = BlockType(43, 7); - static constexpr BlockType STONE_SLAB = BlockType(44); - static constexpr BlockType SANDSTONE_SLAB = BlockType(44, 1); - static constexpr BlockType WOODEN_SLAB = BlockType(44, 2); - static constexpr BlockType COBBLESTONE_SLAB = BlockType(44, 3); - static constexpr BlockType BRICK_SLAB = BlockType(44, 4); - static constexpr BlockType STONE_BRICK_SLAB = BlockType(44, 5); - static constexpr BlockType NETHER_BRICK_SLAB = BlockType(44, 6); - static constexpr BlockType QUARTZ_SLAB = BlockType(44, 7); - static constexpr BlockType BRICKS = BlockType(45); - static constexpr BlockType TNT = BlockType(46); - static constexpr BlockType BOOKSHELF = BlockType(47); - static constexpr BlockType MOSS_STONE = BlockType(48); - static constexpr BlockType OBSIDIAN = BlockType(49); - static constexpr BlockType TORCH = BlockType(50); - static constexpr BlockType FIRE = BlockType(51); - static constexpr BlockType MONSTER_SPAWNER = BlockType(52); - static constexpr BlockType OAK_WOOD_STAIRS = BlockType(53); - static constexpr BlockType CHEST = BlockType(54); - static constexpr BlockType REDSTONE_WIRE = BlockType(55); - static constexpr BlockType DIAMOND_ORE = BlockType(56); - static constexpr BlockType DIAMOND_BLOCK = BlockType(57); - static constexpr BlockType CRAFTING_TABLE = BlockType(58); - static constexpr BlockType WHEAT_CROPS = BlockType(59); - static constexpr BlockType FARMLAND = BlockType(60); - static constexpr BlockType FURNACE = BlockType(61); - static constexpr BlockType BURNING_FURNACE = BlockType(62); - static constexpr BlockType STANDING_SIGN_BLOCK = BlockType(63); - static constexpr BlockType OAK_DOOR_BLOCK = BlockType(64); - static constexpr BlockType LADDER = BlockType(65); - static constexpr BlockType RAIL = BlockType(66); - static constexpr BlockType COBBLESTONE_STAIRS = BlockType(67); - static constexpr BlockType WALLMOUNTED_SIGN_BLOCK = BlockType(68); - static constexpr BlockType LEVER = BlockType(69); - static constexpr BlockType STONE_PRESSURE_PLATE = BlockType(70); - static constexpr BlockType IRON_DOOR_BLOCK = BlockType(71); - static constexpr BlockType WOODEN_PRESSURE_PLATE = BlockType(72); - static constexpr BlockType REDSTONE_ORE = BlockType(73); - static constexpr BlockType GLOWING_REDSTONE_ORE = BlockType(74); - static constexpr BlockType REDSTONE_TORCH_OFF = BlockType(75); - static constexpr BlockType REDSTONE_TORCH_ON = BlockType(76); - static constexpr BlockType STONE_BUTTON = BlockType(77); - static constexpr BlockType SNOW = BlockType(78); - static constexpr BlockType ICE = BlockType(79); - static constexpr BlockType SNOW_BLOCK = BlockType(80); - static constexpr BlockType CACTUS = BlockType(81); - static constexpr BlockType CLAY = BlockType(82); - static constexpr BlockType SUGAR_CANES = BlockType(83); - static constexpr BlockType JUKEBOX = BlockType(84); - static constexpr BlockType OAK_FENCE = BlockType(85); - static constexpr BlockType PUMPKIN = BlockType(86); - static constexpr BlockType NETHERRACK = BlockType(87); - static constexpr BlockType SOUL_SAND = BlockType(88); - static constexpr BlockType GLOWSTONE = BlockType(89); - static constexpr BlockType NETHER_PORTAL = BlockType(90); - static constexpr BlockType JACK_OLANTERN = BlockType(91); - static constexpr BlockType CAKE_BLOCK = BlockType(92); - static constexpr BlockType REDSTONE_REPEATER_BLOCK_OFF = BlockType(93); - static constexpr BlockType REDSTONE_REPEATER_BLOCK_ON = BlockType(94); - static constexpr BlockType WHITE_STAINED_GLASS = BlockType(95); - static constexpr BlockType ORANGE_STAINED_GLASS = BlockType(95, 1); - static constexpr BlockType MAGENTA_STAINED_GLASS = BlockType(95, 2); - static constexpr BlockType LIGHT_BLUE_STAINED_GLASS = BlockType(95, 3); - static constexpr BlockType YELLOW_STAINED_GLASS = BlockType(95, 4); - static constexpr BlockType LIME_STAINED_GLASS = BlockType(95, 5); - static constexpr BlockType PINK_STAINED_GLASS = BlockType(95, 6); - static constexpr BlockType GRAY_STAINED_GLASS = BlockType(95, 7); - static constexpr BlockType LIGHT_GRAY_STAINED_GLASS = BlockType(95, 8); - static constexpr BlockType CYAN_STAINED_GLASS = BlockType(95, 9); - static constexpr BlockType PURPLE_STAINED_GLASS = BlockType(95, 10); - static constexpr BlockType BLUE_STAINED_GLASS = BlockType(95, 11); - static constexpr BlockType BROWN_STAINED_GLASS = BlockType(95, 12); - static constexpr BlockType GREEN_STAINED_GLASS = BlockType(95, 13); - static constexpr BlockType RED_STAINED_GLASS = BlockType(95, 14); - static constexpr BlockType BLACK_STAINED_GLASS = BlockType(95, 15); - static constexpr BlockType WOODEN_TRAPDOOR = BlockType(96); - static constexpr BlockType STONE_MONSTER_EGG = BlockType(97); - static constexpr BlockType COBBLESTONE_MONSTER_EGG = BlockType(97, 1); - static constexpr BlockType STONE_BRICK_MONSTER_EGG = BlockType(97, 2); - static constexpr BlockType MOSSY_STONE_BRICK_MONSTER_EGG = BlockType(97, 3); - static constexpr BlockType CRACKED_STONE_BRICK_MONSTER_EGG = BlockType(97, 4); - static constexpr BlockType CHISELED_STONE_BRICK_MONSTER_EGG = BlockType(97, 5); - static constexpr BlockType STONE_BRICKS = BlockType(98); - static constexpr BlockType MOSSY_STONE_BRICKS = BlockType(98, 1); - static constexpr BlockType CRACKED_STONE_BRICKS = BlockType(98, 2); - static constexpr BlockType CHISELED_STONE_BRICKS = BlockType(98, 3); - static constexpr BlockType BROWN_MUSHROOM_BLOCK = BlockType(99); - static constexpr BlockType RED_MUSHROOM_BLOCK = BlockType(100); - static constexpr BlockType IRON_BARS = BlockType(101); - static constexpr BlockType GLASS_PANE = BlockType(102); - static constexpr BlockType MELON_BLOCK = BlockType(103); - static constexpr BlockType PUMPKIN_STEM = BlockType(104); - static constexpr BlockType MELON_STEM = BlockType(105); - static constexpr BlockType VINES = BlockType(106); - static constexpr BlockType OAK_FENCE_GATE = BlockType(107); - static constexpr BlockType BRICK_STAIRS = BlockType(108); - static constexpr BlockType STONE_BRICK_STAIRS = BlockType(109); - static constexpr BlockType MYCELIUM = BlockType(110); - static constexpr BlockType LILY_PAD = BlockType(111); - static constexpr BlockType NETHER_BRICK = BlockType(112); - static constexpr BlockType NETHER_BRICK_FENCE = BlockType(113); - static constexpr BlockType NETHER_BRICK_STAIRS = BlockType(114); - static constexpr BlockType NETHER_WART = BlockType(115); - static constexpr BlockType ENCHANTMENT_TABLE = BlockType(116); - static constexpr BlockType BREWING_STAND = BlockType(117); - static constexpr BlockType CAULDRON = BlockType(118); - static constexpr BlockType END_PORTAL = BlockType(119); - static constexpr BlockType END_PORTAL_FRAME = BlockType(120); - static constexpr BlockType END_STONE = BlockType(121); - static constexpr BlockType DRAGON_EGG = BlockType(122); - static constexpr BlockType REDSTONE_LAMP_INACTIVE = BlockType(123); - static constexpr BlockType REDSTONE_LAMP_ACTIVE = BlockType(124); - static constexpr BlockType DOUBLE_OAK_WOOD_SLAB = BlockType(125); - static constexpr BlockType DOUBLE_SPRUCE_WOOD_SLAB = BlockType(125, 1); - static constexpr BlockType DOUBLE_BIRCH_WOOD_SLAB = BlockType(125, 2); - static constexpr BlockType DOUBLE_JUNGLE_WOOD_SLAB = BlockType(125, 3); - static constexpr BlockType DOUBLE_ACACIA_WOOD_SLAB = BlockType(125, 4); - static constexpr BlockType DOUBLE_DARK_OAK_WOOD_SLAB = BlockType(125, 5); - static constexpr BlockType OAK_WOOD_SLAB = BlockType(126); - static constexpr BlockType SPRUCE_WOOD_SLAB = BlockType(126, 1); - static constexpr BlockType BIRCH_WOOD_SLAB = BlockType(126, 2); - static constexpr BlockType JUNGLE_WOOD_SLAB = BlockType(126, 3); - static constexpr BlockType ACACIA_WOOD_SLAB = BlockType(126, 4); - static constexpr BlockType DARK_OAK_WOOD_SLAB = BlockType(126, 5); - static constexpr BlockType COCOA = BlockType(127); - static constexpr BlockType SANDSTONE_STAIRS = BlockType(128); - static constexpr BlockType EMERALD_ORE = BlockType(129); - static constexpr BlockType ENDER_CHEST = BlockType(130); - static constexpr BlockType TRIPWIRE_HOOK = BlockType(131); - static constexpr BlockType TRIPWIRE = BlockType(132); - static constexpr BlockType EMERALD_BLOCK = BlockType(133); - static constexpr BlockType SPRUCE_WOOD_STAIRS = BlockType(134); - static constexpr BlockType BIRCH_WOOD_STAIRS = BlockType(135); - static constexpr BlockType JUNGLE_WOOD_STAIRS = BlockType(136); - static constexpr BlockType COMMAND_BLOCK = BlockType(137); - static constexpr BlockType BEACON = BlockType(138); - static constexpr BlockType COBBLESTONE_WALL = BlockType(139); - static constexpr BlockType MOSSY_COBBLESTONE_WALL = BlockType(139, 1); - static constexpr BlockType FLOWER_POT = BlockType(140); - static constexpr BlockType CARROTS = BlockType(141); - static constexpr BlockType POTATOES = BlockType(142); - static constexpr BlockType WOODEN_BUTTON = BlockType(143); - static constexpr BlockType MOB_HEAD = BlockType(144); - static constexpr BlockType ANVIL = BlockType(145); - static constexpr BlockType TRAPPED_CHEST = BlockType(146); - static constexpr BlockType WEIGHTED_PRESSURE_PLATE_LIGHT = BlockType(147); - static constexpr BlockType WEIGHTED_PRESSURE_PLATE_HEAVY = BlockType(148); - static constexpr BlockType REDSTONE_COMPARATOR_INACTIVE = BlockType(149); - static constexpr BlockType REDSTONE_COMPARATOR_ACTIVE = BlockType(150); - static constexpr BlockType DAYLIGHT_SENSOR = BlockType(151); - static constexpr BlockType REDSTONE_BLOCK = BlockType(152); - static constexpr BlockType NETHER_QUARTZ_ORE = BlockType(153); - static constexpr BlockType HOPPER = BlockType(154); - static constexpr BlockType QUARTZ_BLOCK = BlockType(155); - static constexpr BlockType CHISELED_QUARTZ_BLOCK = BlockType(155, 1); - static constexpr BlockType PILLAR_QUARTZ_BLOCK = BlockType(155, 2); - static constexpr BlockType QUARTZ_STAIRS = BlockType(156); - static constexpr BlockType ACTIVATOR_RAIL = BlockType(157); - static constexpr BlockType DROPPER = BlockType(158); - static constexpr BlockType WHITE_HARDENED_CLAY = BlockType(159); - static constexpr BlockType ORANGE_HARDENED_CLAY = BlockType(159, 1); - static constexpr BlockType MAGENTA_HARDENED_CLAY = BlockType(159, 2); - static constexpr BlockType LIGHT_BLUE_HARDENED_CLAY = BlockType(159, 3); - static constexpr BlockType YELLOW_HARDENED_CLAY = BlockType(159, 4); - static constexpr BlockType LIME_HARDENED_CLAY = BlockType(159, 5); - static constexpr BlockType PINK_HARDENED_CLAY = BlockType(159, 6); - static constexpr BlockType GRAY_HARDENED_CLAY = BlockType(159, 7); - static constexpr BlockType LIGHT_GRAY_HARDENED_CLAY = BlockType(159, 8); - static constexpr BlockType CYAN_HARDENED_CLAY = BlockType(159, 9); - static constexpr BlockType PURPLE_HARDENED_CLAY = BlockType(159, 10); - static constexpr BlockType BLUE_HARDENED_CLAY = BlockType(159, 11); - static constexpr BlockType BROWN_HARDENED_CLAY = BlockType(159, 12); - static constexpr BlockType GREEN_HARDENED_CLAY = BlockType(159, 13); - static constexpr BlockType RED_HARDENED_CLAY = BlockType(159, 14); - static constexpr BlockType BLACK_HARDENED_CLAY = BlockType(159, 15); - static constexpr BlockType WHITE_STAINED_GLASS_PANE = BlockType(160); - static constexpr BlockType ORANGE_STAINED_GLASS_PANE = BlockType(160, 1); - static constexpr BlockType MAGENTA_STAINED_GLASS_PANE = BlockType(160, 2); - static constexpr BlockType LIGHT_BLUE_STAINED_GLASS_PANE = BlockType(160, 3); - static constexpr BlockType YELLOW_STAINED_GLASS_PANE = BlockType(160, 4); - static constexpr BlockType LIME_STAINED_GLASS_PANE = BlockType(160, 5); - static constexpr BlockType PINK_STAINED_GLASS_PANE = BlockType(160, 6); - static constexpr BlockType GRAY_STAINED_GLASS_PANE = BlockType(160, 7); - static constexpr BlockType LIGHT_GRAY_STAINED_GLASS_PANE = BlockType(160, 8); - static constexpr BlockType CYAN_STAINED_GLASS_PANE = BlockType(160, 9); - static constexpr BlockType PURPLE_STAINED_GLASS_PANE = BlockType(160, 10); - static constexpr BlockType BLUE_STAINED_GLASS_PANE = BlockType(160, 11); - static constexpr BlockType BROWN_STAINED_GLASS_PANE = BlockType(160, 12); - static constexpr BlockType GREEN_STAINED_GLASS_PANE = BlockType(160, 13); - static constexpr BlockType RED_STAINED_GLASS_PANE = BlockType(160, 14); - static constexpr BlockType BLACK_STAINED_GLASS_PANE = BlockType(160, 15); - static constexpr BlockType ACACIA_LEAVES = BlockType(161); - static constexpr BlockType DARK_OAK_LEAVES = BlockType(161, 1); - static constexpr BlockType ACACIA_WOOD = BlockType(162); - static constexpr BlockType DARK_OAK_WOOD = BlockType(162, 1); - static constexpr BlockType ACACIA_WOOD_STAIRS = BlockType(163); - static constexpr BlockType DARK_OAK_WOOD_STAIRS = BlockType(164); - static constexpr BlockType SLIME_BLOCK = BlockType(165); - static constexpr BlockType BARRIER = BlockType(166); - static constexpr BlockType IRON_TRAPDOOR = BlockType(167); - static constexpr BlockType PRISMARINE = BlockType(168); - static constexpr BlockType PRISMARINE_BRICKS = BlockType(168, 1); - static constexpr BlockType DARK_PRISMARINE = BlockType(168, 2); - static constexpr BlockType SEA_LANTERN = BlockType(169); - static constexpr BlockType HAY_BALE = BlockType(170); - static constexpr BlockType WHITE_CARPET = BlockType(171); - static constexpr BlockType ORANGE_CARPET = BlockType(171, 1); - static constexpr BlockType MAGENTA_CARPET = BlockType(171, 2); - static constexpr BlockType LIGHT_BLUE_CARPET = BlockType(171, 3); - static constexpr BlockType YELLOW_CARPET = BlockType(171, 4); - static constexpr BlockType LIME_CARPET = BlockType(171, 5); - static constexpr BlockType PINK_CARPET = BlockType(171, 6); - static constexpr BlockType GRAY_CARPET = BlockType(171, 7); - static constexpr BlockType LIGHT_GRAY_CARPET = BlockType(171, 8); - static constexpr BlockType CYAN_CARPET = BlockType(171, 9); - static constexpr BlockType PURPLE_CARPET = BlockType(171, 10); - static constexpr BlockType BLUE_CARPET = BlockType(171, 11); - static constexpr BlockType BROWN_CARPET = BlockType(171, 12); - static constexpr BlockType GREEN_CARPET = BlockType(171, 13); - static constexpr BlockType RED_CARPET = BlockType(171, 14); - static constexpr BlockType BLACK_CARPET = BlockType(171, 15); - static constexpr BlockType HARDENED_CLAY = BlockType(172); - static constexpr BlockType BLOCK_OF_COAL = BlockType(173); - static constexpr BlockType PACKED_ICE = BlockType(174); - static constexpr BlockType SUNFLOWER = BlockType(175); - static constexpr BlockType LILAC = BlockType(175, 1); - static constexpr BlockType DOUBLE_TALLGRASS = BlockType(175, 2); - static constexpr BlockType LARGE_FERN = BlockType(175, 3); - static constexpr BlockType ROSE_BUSH = BlockType(175, 4); - static constexpr BlockType PEONY = BlockType(175, 5); - static constexpr BlockType FREESTANDING_BANNER = BlockType(176); - static constexpr BlockType WALLMOUNTED_BANNER = BlockType(177); - static constexpr BlockType INVERTED_DAYLIGHT_SENSOR = BlockType(178); - static constexpr BlockType RED_SANDSTONE = BlockType(179); - static constexpr BlockType CHISELED_RED_SANDSTONE = BlockType(179, 1); - static constexpr BlockType SMOOTH_RED_SANDSTONE = BlockType(179, 2); - static constexpr BlockType RED_SANDSTONE_STAIRS = BlockType(180); - static constexpr BlockType DOUBLE_RED_SANDSTONE_SLAB = BlockType(181); - static constexpr BlockType RED_SANDSTONE_SLAB = BlockType(182); - static constexpr BlockType SPRUCE_FENCE_GATE = BlockType(183); - static constexpr BlockType BIRCH_FENCE_GATE = BlockType(184); - static constexpr BlockType JUNGLE_FENCE_GATE = BlockType(185); - static constexpr BlockType DARK_OAK_FENCE_GATE = BlockType(186); - static constexpr BlockType ACACIA_FENCE_GATE = BlockType(187); - static constexpr BlockType SPRUCE_FENCE = BlockType(188); - static constexpr BlockType BIRCH_FENCE = BlockType(189); - static constexpr BlockType JUNGLE_FENCE = BlockType(190); - static constexpr BlockType DARK_OAK_FENCE = BlockType(191); - static constexpr BlockType ACACIA_FENCE = BlockType(192); - static constexpr BlockType SPRUCE_DOOR_BLOCK = BlockType(193); - static constexpr BlockType BIRCH_DOOR_BLOCK = BlockType(194); - static constexpr BlockType JUNGLE_DOOR_BLOCK = BlockType(195); - static constexpr BlockType ACACIA_DOOR_BLOCK = BlockType(196); - static constexpr BlockType DARK_OAK_DOOR_BLOCK = BlockType(197); - static constexpr BlockType END_ROD = BlockType(198); - static constexpr BlockType CHORUS_PLANT = BlockType(199); - static constexpr BlockType CHORUS_FLOWER = BlockType(200); - static constexpr BlockType PURPUR_BLOCK = BlockType(201); - static constexpr BlockType PURPUR_PILLAR = BlockType(202); - static constexpr BlockType PURPUR_STAIRS = BlockType(203); - static constexpr BlockType PURPUR_DOUBLE_SLAB = BlockType(204); - static constexpr BlockType PURPUR_SLAB = BlockType(205); - static constexpr BlockType END_STONE_BRICKS = BlockType(206); - static constexpr BlockType BEETROOT_BLOCK = BlockType(207); - static constexpr BlockType GRASS_PATH = BlockType(208); - static constexpr BlockType END_GATEWAY = BlockType(209); - static constexpr BlockType REPEATING_COMMAND_BLOCK = BlockType(210); - static constexpr BlockType CHAIN_COMMAND_BLOCK = BlockType(211); - static constexpr BlockType FROSTED_ICE = BlockType(212); - static constexpr BlockType MAGMA_BLOCK = BlockType(213); - static constexpr BlockType NETHER_WART_BLOCK = BlockType(214); - static constexpr BlockType RED_NETHER_BRICK = BlockType(215); - static constexpr BlockType BONE_BLOCK = BlockType(216); - static constexpr BlockType STRUCTURE_VOID = BlockType(217); - static constexpr BlockType OBSERVER = BlockType(218); - static constexpr BlockType WHITE_SHULKER_BOX = BlockType(219); - static constexpr BlockType ORANGE_SHULKER_BOX = BlockType(220); - static constexpr BlockType MAGENTA_SHULKER_BOX = BlockType(221); - static constexpr BlockType LIGHT_BLUE_SHULKER_BOX = BlockType(222); - static constexpr BlockType YELLOW_SHULKER_BOX = BlockType(223); - static constexpr BlockType LIME_SHULKER_BOX = BlockType(224); - static constexpr BlockType PINK_SHULKER_BOX = BlockType(225); - static constexpr BlockType GRAY_SHULKER_BOX = BlockType(226); - static constexpr BlockType LIGHT_GRAY_SHULKER_BOX = BlockType(227); - static constexpr BlockType CYAN_SHULKER_BOX = BlockType(228); - static constexpr BlockType PURPLE_SHULKER_BOX = BlockType(229); - static constexpr BlockType BLUE_SHULKER_BOX = BlockType(230); - static constexpr BlockType BROWN_SHULKER_BOX = BlockType(231); - static constexpr BlockType GREEN_SHULKER_BOX = BlockType(232); - static constexpr BlockType RED_SHULKER_BOX = BlockType(233); - static constexpr BlockType BLACK_SHULKER_BOX = BlockType(234); - static constexpr BlockType WHITE_GLAZED_TERRACOTTA = BlockType(235); - static constexpr BlockType ORANGE_GLAZED_TERRACOTTA = BlockType(236); - static constexpr BlockType MAGENTA_GLAZED_TERRACOTTA = BlockType(237); - static constexpr BlockType LIGHT_BLUE_GLAZED_TERRACOTTA = BlockType(238); - static constexpr BlockType YELLOW_GLAZED_TERRACOTTA = BlockType(239); - static constexpr BlockType LIME_GLAZED_TERRACOTTA = BlockType(240); - static constexpr BlockType PINK_GLAZED_TERRACOTTA = BlockType(241); - static constexpr BlockType GRAY_GLAZED_TERRACOTTA = BlockType(242); - static constexpr BlockType LIGHT_GRAY_GLAZED_TERRACOTTA = BlockType(243); - static constexpr BlockType CYAN_GLAZED_TERRACOTTA = BlockType(244); - static constexpr BlockType PURPLE_GLAZED_TERRACOTTA = BlockType(245); - static constexpr BlockType BLUE_GLAZED_TERRACOTTA = BlockType(246); - static constexpr BlockType BROWN_GLAZED_TERRACOTTA = BlockType(247); - static constexpr BlockType GREEN_GLAZED_TERRACOTTA = BlockType(248); - static constexpr BlockType RED_GLAZED_TERRACOTTA = BlockType(249); - static constexpr BlockType BLACK_GLAZED_TERRACOTTA = BlockType(250); - static constexpr BlockType WHITE_CONCRETE = BlockType(251); - static constexpr BlockType ORANGE_CONCRETE = BlockType(251, 1); - static constexpr BlockType MAGENTA_CONCRETE = BlockType(251, 2); - static constexpr BlockType LIGHT_BLUE_CONCRETE = BlockType(251, 3); - static constexpr BlockType YELLOW_CONCRETE = BlockType(251, 4); - static constexpr BlockType LIME_CONCRETE = BlockType(251, 5); - static constexpr BlockType PINK_CONCRETE = BlockType(251, 6); - static constexpr BlockType GRAY_CONCRETE = BlockType(251, 7); - static constexpr BlockType LIGHT_GRAY_CONCRETE = BlockType(251, 8); - static constexpr BlockType CYAN_CONCRETE = BlockType(251, 9); - static constexpr BlockType PURPLE_CONCRETE = BlockType(251, 10); - static constexpr BlockType BLUE_CONCRETE = BlockType(251, 11); - static constexpr BlockType BROWN_CONCRETE = BlockType(251, 12); - static constexpr BlockType GREEN_CONCRETE = BlockType(251, 13); - static constexpr BlockType RED_CONCRETE = BlockType(251, 14); - static constexpr BlockType BLACK_CONCRETE = BlockType(251, 15); - static constexpr BlockType WHITE_CONCRETE_POWDER = BlockType(252); - static constexpr BlockType ORANGE_CONCRETE_POWDER = BlockType(252, 1); - static constexpr BlockType MAGENTA_CONCRETE_POWDER = BlockType(252, 2); - static constexpr BlockType LIGHT_BLUE_CONCRETE_POWDER = BlockType(252, 3); - static constexpr BlockType YELLOW_CONCRETE_POWDER = BlockType(252, 4); - static constexpr BlockType LIME_CONCRETE_POWDER = BlockType(252, 5); - static constexpr BlockType PINK_CONCRETE_POWDER = BlockType(252, 6); - static constexpr BlockType GRAY_CONCRETE_POWDER = BlockType(252, 7); - static constexpr BlockType LIGHT_GRAY_CONCRETE_POWDER = BlockType(252, 8); - static constexpr BlockType CYAN_CONCRETE_POWDER = BlockType(252, 9); - static constexpr BlockType PURPLE_CONCRETE_POWDER = BlockType(252, 10); - static constexpr BlockType BLUE_CONCRETE_POWDER = BlockType(252, 11); - static constexpr BlockType BROWN_CONCRETE_POWDER = BlockType(252, 12); - static constexpr BlockType GREEN_CONCRETE_POWDER = BlockType(252, 13); - static constexpr BlockType RED_CONCRETE_POWDER = BlockType(252, 14); - static constexpr BlockType BLACK_CONCRETE_POWDER = BlockType(252, 15); - static constexpr BlockType STRUCTURE_BLOCK = BlockType(255); - }; -} + [[nodiscard]] BlockType withMod(int modifier) const; +}; + +// Using script to extract ids from https://minecraft-ids.grahamedgecombe.com/ + +/** + * Struct of static block objects that allows for a "search" of sorts, callable + * using Blocks::TYPE after importing + */ +struct Blocks { + static constexpr BlockType AIR = BlockType(0); + static constexpr BlockType STONE = BlockType(1); + static constexpr BlockType GRANITE = BlockType(1, 1); + static constexpr BlockType POLISHED_GRANITE = BlockType(1, 2); + static constexpr BlockType DIORITE = BlockType(1, 3); + static constexpr BlockType POLISHED_DIORITE = BlockType(1, 4); + static constexpr BlockType ANDESITE = BlockType(1, 5); + static constexpr BlockType POLISHED_ANDESITE = BlockType(1, 6); + static constexpr BlockType GRASS = BlockType(2); + static constexpr BlockType DIRT = BlockType(3); + static constexpr BlockType COARSE_DIRT = BlockType(3, 1); + static constexpr BlockType PODZOL = BlockType(3, 2); + static constexpr BlockType COBBLESTONE = BlockType(4); + static constexpr BlockType OAK_WOOD_PLANK = BlockType(5); + static constexpr BlockType SPRUCE_WOOD_PLANK = BlockType(5, 1); + static constexpr BlockType BIRCH_WOOD_PLANK = BlockType(5, 2); + static constexpr BlockType JUNGLE_WOOD_PLANK = BlockType(5, 3); + static constexpr BlockType ACACIA_WOOD_PLANK = BlockType(5, 4); + static constexpr BlockType DARK_OAK_WOOD_PLANK = BlockType(5, 5); + static constexpr BlockType OAK_SAPLING = BlockType(6); + static constexpr BlockType SPRUCE_SAPLING = BlockType(6, 1); + static constexpr BlockType BIRCH_SAPLING = BlockType(6, 2); + static constexpr BlockType JUNGLE_SAPLING = BlockType(6, 3); + static constexpr BlockType ACACIA_SAPLING = BlockType(6, 4); + static constexpr BlockType DARK_OAK_SAPLING = BlockType(6, 5); + static constexpr BlockType BEDROCK = BlockType(7); + static constexpr BlockType FLOWING_WATER = BlockType(8); + static constexpr BlockType STILL_WATER = BlockType(9); + static constexpr BlockType FLOWING_LAVA = BlockType(10); + static constexpr BlockType STILL_LAVA = BlockType(11); + static constexpr BlockType SAND = BlockType(12); + static constexpr BlockType RED_SAND = BlockType(12, 1); + static constexpr BlockType GRAVEL = BlockType(13); + static constexpr BlockType GOLD_ORE = BlockType(14); + static constexpr BlockType IRON_ORE = BlockType(15); + static constexpr BlockType COAL_ORE = BlockType(16); + static constexpr BlockType OAK_WOOD = BlockType(17); + static constexpr BlockType SPRUCE_WOOD = BlockType(17, 1); + static constexpr BlockType BIRCH_WOOD = BlockType(17, 2); + static constexpr BlockType JUNGLE_WOOD = BlockType(17, 3); + static constexpr BlockType OAK_LEAVES = BlockType(18); + static constexpr BlockType SPRUCE_LEAVES = BlockType(18, 1); + static constexpr BlockType BIRCH_LEAVES = BlockType(18, 2); + static constexpr BlockType JUNGLE_LEAVES = BlockType(18, 3); + static constexpr BlockType SPONGE = BlockType(19); + static constexpr BlockType WET_SPONGE = BlockType(19, 1); + static constexpr BlockType GLASS = BlockType(20); + static constexpr BlockType LAPIS_LAZULI_ORE = BlockType(21); + static constexpr BlockType LAPIS_LAZULI_BLOCK = BlockType(22); + static constexpr BlockType DISPENSER = BlockType(23); + static constexpr BlockType SANDSTONE = BlockType(24); + static constexpr BlockType CHISELED_SANDSTONE = BlockType(24, 1); + static constexpr BlockType SMOOTH_SANDSTONE = BlockType(24, 2); + static constexpr BlockType NOTE_BLOCK = BlockType(25); + static constexpr BlockType BED = BlockType(26); + static constexpr BlockType POWERED_RAIL = BlockType(27); + static constexpr BlockType DETECTOR_RAIL = BlockType(28); + static constexpr BlockType STICKY_PISTON = BlockType(29); + static constexpr BlockType COBWEB = BlockType(30); + static constexpr BlockType DEAD_SHRUB = BlockType(31); + static constexpr BlockType TALL_GRASS = BlockType(31, 1); + static constexpr BlockType FERN = BlockType(31, 2); + static constexpr BlockType DEAD_BUSH = BlockType(32); + static constexpr BlockType PISTON = BlockType(33); + static constexpr BlockType PISTON_HEAD = BlockType(34); + static constexpr BlockType WHITE_WOOL = BlockType(35); + static constexpr BlockType ORANGE_WOOL = BlockType(35, 1); + static constexpr BlockType MAGENTA_WOOL = BlockType(35, 2); + static constexpr BlockType LIGHT_BLUE_WOOL = BlockType(35, 3); + static constexpr BlockType YELLOW_WOOL = BlockType(35, 4); + static constexpr BlockType LIME_WOOL = BlockType(35, 5); + static constexpr BlockType PINK_WOOL = BlockType(35, 6); + static constexpr BlockType GRAY_WOOL = BlockType(35, 7); + static constexpr BlockType LIGHT_GRAY_WOOL = BlockType(35, 8); + static constexpr BlockType CYAN_WOOL = BlockType(35, 9); + static constexpr BlockType PURPLE_WOOL = BlockType(35, 10); + static constexpr BlockType BLUE_WOOL = BlockType(35, 11); + static constexpr BlockType BROWN_WOOL = BlockType(35, 12); + static constexpr BlockType GREEN_WOOL = BlockType(35, 13); + static constexpr BlockType RED_WOOL = BlockType(35, 14); + static constexpr BlockType BLACK_WOOL = BlockType(35, 15); + static constexpr BlockType DANDELION = BlockType(37); + static constexpr BlockType POPPY = BlockType(38); + static constexpr BlockType BLUE_ORCHID = BlockType(38, 1); + static constexpr BlockType ALLIUM = BlockType(38, 2); + static constexpr BlockType AZURE_BLUET = BlockType(38, 3); + static constexpr BlockType RED_TULIP = BlockType(38, 4); + static constexpr BlockType ORANGE_TULIP = BlockType(38, 5); + static constexpr BlockType WHITE_TULIP = BlockType(38, 6); + static constexpr BlockType PINK_TULIP = BlockType(38, 7); + static constexpr BlockType OXEYE_DAISY = BlockType(38, 8); + static constexpr BlockType BROWN_MUSHROOM = BlockType(39); + static constexpr BlockType RED_MUSHROOM = BlockType(40); + static constexpr BlockType GOLD_BLOCK = BlockType(41); + static constexpr BlockType IRON_BLOCK = BlockType(42); + static constexpr BlockType DOUBLE_STONE_SLAB = BlockType(43); + static constexpr BlockType DOUBLE_SANDSTONE_SLAB = BlockType(43, 1); + static constexpr BlockType DOUBLE_WOODEN_SLAB = BlockType(43, 2); + static constexpr BlockType DOUBLE_COBBLESTONE_SLAB = BlockType(43, 3); + static constexpr BlockType DOUBLE_BRICK_SLAB = BlockType(43, 4); + static constexpr BlockType DOUBLE_STONE_BRICK_SLAB = BlockType(43, 5); + static constexpr BlockType DOUBLE_NETHER_BRICK_SLAB = BlockType(43, 6); + static constexpr BlockType DOUBLE_QUARTZ_SLAB = BlockType(43, 7); + static constexpr BlockType STONE_SLAB = BlockType(44); + static constexpr BlockType SANDSTONE_SLAB = BlockType(44, 1); + static constexpr BlockType WOODEN_SLAB = BlockType(44, 2); + static constexpr BlockType COBBLESTONE_SLAB = BlockType(44, 3); + static constexpr BlockType BRICK_SLAB = BlockType(44, 4); + static constexpr BlockType STONE_BRICK_SLAB = BlockType(44, 5); + static constexpr BlockType NETHER_BRICK_SLAB = BlockType(44, 6); + static constexpr BlockType QUARTZ_SLAB = BlockType(44, 7); + static constexpr BlockType BRICKS = BlockType(45); + static constexpr BlockType TNT = BlockType(46); + static constexpr BlockType BOOKSHELF = BlockType(47); + static constexpr BlockType MOSS_STONE = BlockType(48); + static constexpr BlockType OBSIDIAN = BlockType(49); + static constexpr BlockType TORCH = BlockType(50); + static constexpr BlockType FIRE = BlockType(51); + static constexpr BlockType MONSTER_SPAWNER = BlockType(52); + static constexpr BlockType OAK_WOOD_STAIRS = BlockType(53); + static constexpr BlockType CHEST = BlockType(54); + static constexpr BlockType REDSTONE_WIRE = BlockType(55); + static constexpr BlockType DIAMOND_ORE = BlockType(56); + static constexpr BlockType DIAMOND_BLOCK = BlockType(57); + static constexpr BlockType CRAFTING_TABLE = BlockType(58); + static constexpr BlockType WHEAT_CROPS = BlockType(59); + static constexpr BlockType FARMLAND = BlockType(60); + static constexpr BlockType FURNACE = BlockType(61); + static constexpr BlockType BURNING_FURNACE = BlockType(62); + static constexpr BlockType STANDING_SIGN_BLOCK = BlockType(63); + static constexpr BlockType OAK_DOOR_BLOCK = BlockType(64); + static constexpr BlockType LADDER = BlockType(65); + static constexpr BlockType RAIL = BlockType(66); + static constexpr BlockType COBBLESTONE_STAIRS = BlockType(67); + static constexpr BlockType WALLMOUNTED_SIGN_BLOCK = BlockType(68); + static constexpr BlockType LEVER = BlockType(69); + static constexpr BlockType STONE_PRESSURE_PLATE = BlockType(70); + static constexpr BlockType IRON_DOOR_BLOCK = BlockType(71); + static constexpr BlockType WOODEN_PRESSURE_PLATE = BlockType(72); + static constexpr BlockType REDSTONE_ORE = BlockType(73); + static constexpr BlockType GLOWING_REDSTONE_ORE = BlockType(74); + static constexpr BlockType REDSTONE_TORCH_OFF = BlockType(75); + static constexpr BlockType REDSTONE_TORCH_ON = BlockType(76); + static constexpr BlockType STONE_BUTTON = BlockType(77); + static constexpr BlockType SNOW = BlockType(78); + static constexpr BlockType ICE = BlockType(79); + static constexpr BlockType SNOW_BLOCK = BlockType(80); + static constexpr BlockType CACTUS = BlockType(81); + static constexpr BlockType CLAY = BlockType(82); + static constexpr BlockType SUGAR_CANES = BlockType(83); + static constexpr BlockType JUKEBOX = BlockType(84); + static constexpr BlockType OAK_FENCE = BlockType(85); + static constexpr BlockType PUMPKIN = BlockType(86); + static constexpr BlockType NETHERRACK = BlockType(87); + static constexpr BlockType SOUL_SAND = BlockType(88); + static constexpr BlockType GLOWSTONE = BlockType(89); + static constexpr BlockType NETHER_PORTAL = BlockType(90); + static constexpr BlockType JACK_OLANTERN = BlockType(91); + static constexpr BlockType CAKE_BLOCK = BlockType(92); + static constexpr BlockType REDSTONE_REPEATER_BLOCK_OFF = BlockType(93); + static constexpr BlockType REDSTONE_REPEATER_BLOCK_ON = BlockType(94); + static constexpr BlockType WHITE_STAINED_GLASS = BlockType(95); + static constexpr BlockType ORANGE_STAINED_GLASS = BlockType(95, 1); + static constexpr BlockType MAGENTA_STAINED_GLASS = BlockType(95, 2); + static constexpr BlockType LIGHT_BLUE_STAINED_GLASS = BlockType(95, 3); + static constexpr BlockType YELLOW_STAINED_GLASS = BlockType(95, 4); + static constexpr BlockType LIME_STAINED_GLASS = BlockType(95, 5); + static constexpr BlockType PINK_STAINED_GLASS = BlockType(95, 6); + static constexpr BlockType GRAY_STAINED_GLASS = BlockType(95, 7); + static constexpr BlockType LIGHT_GRAY_STAINED_GLASS = BlockType(95, 8); + static constexpr BlockType CYAN_STAINED_GLASS = BlockType(95, 9); + static constexpr BlockType PURPLE_STAINED_GLASS = BlockType(95, 10); + static constexpr BlockType BLUE_STAINED_GLASS = BlockType(95, 11); + static constexpr BlockType BROWN_STAINED_GLASS = BlockType(95, 12); + static constexpr BlockType GREEN_STAINED_GLASS = BlockType(95, 13); + static constexpr BlockType RED_STAINED_GLASS = BlockType(95, 14); + static constexpr BlockType BLACK_STAINED_GLASS = BlockType(95, 15); + static constexpr BlockType WOODEN_TRAPDOOR = BlockType(96); + static constexpr BlockType STONE_MONSTER_EGG = BlockType(97); + static constexpr BlockType COBBLESTONE_MONSTER_EGG = BlockType(97, 1); + static constexpr BlockType STONE_BRICK_MONSTER_EGG = BlockType(97, 2); + static constexpr BlockType MOSSY_STONE_BRICK_MONSTER_EGG = BlockType(97, 3); + static constexpr BlockType CRACKED_STONE_BRICK_MONSTER_EGG = + BlockType(97, 4); + static constexpr BlockType CHISELED_STONE_BRICK_MONSTER_EGG = + BlockType(97, 5); + static constexpr BlockType STONE_BRICKS = BlockType(98); + static constexpr BlockType MOSSY_STONE_BRICKS = BlockType(98, 1); + static constexpr BlockType CRACKED_STONE_BRICKS = BlockType(98, 2); + static constexpr BlockType CHISELED_STONE_BRICKS = BlockType(98, 3); + static constexpr BlockType BROWN_MUSHROOM_BLOCK = BlockType(99); + static constexpr BlockType RED_MUSHROOM_BLOCK = BlockType(100); + static constexpr BlockType IRON_BARS = BlockType(101); + static constexpr BlockType GLASS_PANE = BlockType(102); + static constexpr BlockType MELON_BLOCK = BlockType(103); + static constexpr BlockType PUMPKIN_STEM = BlockType(104); + static constexpr BlockType MELON_STEM = BlockType(105); + static constexpr BlockType VINES = BlockType(106); + static constexpr BlockType OAK_FENCE_GATE = BlockType(107); + static constexpr BlockType BRICK_STAIRS = BlockType(108); + static constexpr BlockType STONE_BRICK_STAIRS = BlockType(109); + static constexpr BlockType MYCELIUM = BlockType(110); + static constexpr BlockType LILY_PAD = BlockType(111); + static constexpr BlockType NETHER_BRICK = BlockType(112); + static constexpr BlockType NETHER_BRICK_FENCE = BlockType(113); + static constexpr BlockType NETHER_BRICK_STAIRS = BlockType(114); + static constexpr BlockType NETHER_WART = BlockType(115); + static constexpr BlockType ENCHANTMENT_TABLE = BlockType(116); + static constexpr BlockType BREWING_STAND = BlockType(117); + static constexpr BlockType CAULDRON = BlockType(118); + static constexpr BlockType END_PORTAL = BlockType(119); + static constexpr BlockType END_PORTAL_FRAME = BlockType(120); + static constexpr BlockType END_STONE = BlockType(121); + static constexpr BlockType DRAGON_EGG = BlockType(122); + static constexpr BlockType REDSTONE_LAMP_INACTIVE = BlockType(123); + static constexpr BlockType REDSTONE_LAMP_ACTIVE = BlockType(124); + static constexpr BlockType DOUBLE_OAK_WOOD_SLAB = BlockType(125); + static constexpr BlockType DOUBLE_SPRUCE_WOOD_SLAB = BlockType(125, 1); + static constexpr BlockType DOUBLE_BIRCH_WOOD_SLAB = BlockType(125, 2); + static constexpr BlockType DOUBLE_JUNGLE_WOOD_SLAB = BlockType(125, 3); + static constexpr BlockType DOUBLE_ACACIA_WOOD_SLAB = BlockType(125, 4); + static constexpr BlockType DOUBLE_DARK_OAK_WOOD_SLAB = BlockType(125, 5); + static constexpr BlockType OAK_WOOD_SLAB = BlockType(126); + static constexpr BlockType SPRUCE_WOOD_SLAB = BlockType(126, 1); + static constexpr BlockType BIRCH_WOOD_SLAB = BlockType(126, 2); + static constexpr BlockType JUNGLE_WOOD_SLAB = BlockType(126, 3); + static constexpr BlockType ACACIA_WOOD_SLAB = BlockType(126, 4); + static constexpr BlockType DARK_OAK_WOOD_SLAB = BlockType(126, 5); + static constexpr BlockType COCOA = BlockType(127); + static constexpr BlockType SANDSTONE_STAIRS = BlockType(128); + static constexpr BlockType EMERALD_ORE = BlockType(129); + static constexpr BlockType ENDER_CHEST = BlockType(130); + static constexpr BlockType TRIPWIRE_HOOK = BlockType(131); + static constexpr BlockType TRIPWIRE = BlockType(132); + static constexpr BlockType EMERALD_BLOCK = BlockType(133); + static constexpr BlockType SPRUCE_WOOD_STAIRS = BlockType(134); + static constexpr BlockType BIRCH_WOOD_STAIRS = BlockType(135); + static constexpr BlockType JUNGLE_WOOD_STAIRS = BlockType(136); + static constexpr BlockType COMMAND_BLOCK = BlockType(137); + static constexpr BlockType BEACON = BlockType(138); + static constexpr BlockType COBBLESTONE_WALL = BlockType(139); + static constexpr BlockType MOSSY_COBBLESTONE_WALL = BlockType(139, 1); + static constexpr BlockType FLOWER_POT = BlockType(140); + static constexpr BlockType CARROTS = BlockType(141); + static constexpr BlockType POTATOES = BlockType(142); + static constexpr BlockType WOODEN_BUTTON = BlockType(143); + static constexpr BlockType MOB_HEAD = BlockType(144); + static constexpr BlockType ANVIL = BlockType(145); + static constexpr BlockType TRAPPED_CHEST = BlockType(146); + static constexpr BlockType WEIGHTED_PRESSURE_PLATE_LIGHT = BlockType(147); + static constexpr BlockType WEIGHTED_PRESSURE_PLATE_HEAVY = BlockType(148); + static constexpr BlockType REDSTONE_COMPARATOR_INACTIVE = BlockType(149); + static constexpr BlockType REDSTONE_COMPARATOR_ACTIVE = BlockType(150); + static constexpr BlockType DAYLIGHT_SENSOR = BlockType(151); + static constexpr BlockType REDSTONE_BLOCK = BlockType(152); + static constexpr BlockType NETHER_QUARTZ_ORE = BlockType(153); + static constexpr BlockType HOPPER = BlockType(154); + static constexpr BlockType QUARTZ_BLOCK = BlockType(155); + static constexpr BlockType CHISELED_QUARTZ_BLOCK = BlockType(155, 1); + static constexpr BlockType PILLAR_QUARTZ_BLOCK = BlockType(155, 2); + static constexpr BlockType QUARTZ_STAIRS = BlockType(156); + static constexpr BlockType ACTIVATOR_RAIL = BlockType(157); + static constexpr BlockType DROPPER = BlockType(158); + static constexpr BlockType WHITE_HARDENED_CLAY = BlockType(159); + static constexpr BlockType ORANGE_HARDENED_CLAY = BlockType(159, 1); + static constexpr BlockType MAGENTA_HARDENED_CLAY = BlockType(159, 2); + static constexpr BlockType LIGHT_BLUE_HARDENED_CLAY = BlockType(159, 3); + static constexpr BlockType YELLOW_HARDENED_CLAY = BlockType(159, 4); + static constexpr BlockType LIME_HARDENED_CLAY = BlockType(159, 5); + static constexpr BlockType PINK_HARDENED_CLAY = BlockType(159, 6); + static constexpr BlockType GRAY_HARDENED_CLAY = BlockType(159, 7); + static constexpr BlockType LIGHT_GRAY_HARDENED_CLAY = BlockType(159, 8); + static constexpr BlockType CYAN_HARDENED_CLAY = BlockType(159, 9); + static constexpr BlockType PURPLE_HARDENED_CLAY = BlockType(159, 10); + static constexpr BlockType BLUE_HARDENED_CLAY = BlockType(159, 11); + static constexpr BlockType BROWN_HARDENED_CLAY = BlockType(159, 12); + static constexpr BlockType GREEN_HARDENED_CLAY = BlockType(159, 13); + static constexpr BlockType RED_HARDENED_CLAY = BlockType(159, 14); + static constexpr BlockType BLACK_HARDENED_CLAY = BlockType(159, 15); + static constexpr BlockType WHITE_STAINED_GLASS_PANE = BlockType(160); + static constexpr BlockType ORANGE_STAINED_GLASS_PANE = BlockType(160, 1); + static constexpr BlockType MAGENTA_STAINED_GLASS_PANE = BlockType(160, 2); + static constexpr BlockType LIGHT_BLUE_STAINED_GLASS_PANE = + BlockType(160, 3); + static constexpr BlockType YELLOW_STAINED_GLASS_PANE = BlockType(160, 4); + static constexpr BlockType LIME_STAINED_GLASS_PANE = BlockType(160, 5); + static constexpr BlockType PINK_STAINED_GLASS_PANE = BlockType(160, 6); + static constexpr BlockType GRAY_STAINED_GLASS_PANE = BlockType(160, 7); + static constexpr BlockType LIGHT_GRAY_STAINED_GLASS_PANE = + BlockType(160, 8); + static constexpr BlockType CYAN_STAINED_GLASS_PANE = BlockType(160, 9); + static constexpr BlockType PURPLE_STAINED_GLASS_PANE = BlockType(160, 10); + static constexpr BlockType BLUE_STAINED_GLASS_PANE = BlockType(160, 11); + static constexpr BlockType BROWN_STAINED_GLASS_PANE = BlockType(160, 12); + static constexpr BlockType GREEN_STAINED_GLASS_PANE = BlockType(160, 13); + static constexpr BlockType RED_STAINED_GLASS_PANE = BlockType(160, 14); + static constexpr BlockType BLACK_STAINED_GLASS_PANE = BlockType(160, 15); + static constexpr BlockType ACACIA_LEAVES = BlockType(161); + static constexpr BlockType DARK_OAK_LEAVES = BlockType(161, 1); + static constexpr BlockType ACACIA_WOOD = BlockType(162); + static constexpr BlockType DARK_OAK_WOOD = BlockType(162, 1); + static constexpr BlockType ACACIA_WOOD_STAIRS = BlockType(163); + static constexpr BlockType DARK_OAK_WOOD_STAIRS = BlockType(164); + static constexpr BlockType SLIME_BLOCK = BlockType(165); + static constexpr BlockType BARRIER = BlockType(166); + static constexpr BlockType IRON_TRAPDOOR = BlockType(167); + static constexpr BlockType PRISMARINE = BlockType(168); + static constexpr BlockType PRISMARINE_BRICKS = BlockType(168, 1); + static constexpr BlockType DARK_PRISMARINE = BlockType(168, 2); + static constexpr BlockType SEA_LANTERN = BlockType(169); + static constexpr BlockType HAY_BALE = BlockType(170); + static constexpr BlockType WHITE_CARPET = BlockType(171); + static constexpr BlockType ORANGE_CARPET = BlockType(171, 1); + static constexpr BlockType MAGENTA_CARPET = BlockType(171, 2); + static constexpr BlockType LIGHT_BLUE_CARPET = BlockType(171, 3); + static constexpr BlockType YELLOW_CARPET = BlockType(171, 4); + static constexpr BlockType LIME_CARPET = BlockType(171, 5); + static constexpr BlockType PINK_CARPET = BlockType(171, 6); + static constexpr BlockType GRAY_CARPET = BlockType(171, 7); + static constexpr BlockType LIGHT_GRAY_CARPET = BlockType(171, 8); + static constexpr BlockType CYAN_CARPET = BlockType(171, 9); + static constexpr BlockType PURPLE_CARPET = BlockType(171, 10); + static constexpr BlockType BLUE_CARPET = BlockType(171, 11); + static constexpr BlockType BROWN_CARPET = BlockType(171, 12); + static constexpr BlockType GREEN_CARPET = BlockType(171, 13); + static constexpr BlockType RED_CARPET = BlockType(171, 14); + static constexpr BlockType BLACK_CARPET = BlockType(171, 15); + static constexpr BlockType HARDENED_CLAY = BlockType(172); + static constexpr BlockType BLOCK_OF_COAL = BlockType(173); + static constexpr BlockType PACKED_ICE = BlockType(174); + static constexpr BlockType SUNFLOWER = BlockType(175); + static constexpr BlockType LILAC = BlockType(175, 1); + static constexpr BlockType DOUBLE_TALLGRASS = BlockType(175, 2); + static constexpr BlockType LARGE_FERN = BlockType(175, 3); + static constexpr BlockType ROSE_BUSH = BlockType(175, 4); + static constexpr BlockType PEONY = BlockType(175, 5); + static constexpr BlockType FREESTANDING_BANNER = BlockType(176); + static constexpr BlockType WALLMOUNTED_BANNER = BlockType(177); + static constexpr BlockType INVERTED_DAYLIGHT_SENSOR = BlockType(178); + static constexpr BlockType RED_SANDSTONE = BlockType(179); + static constexpr BlockType CHISELED_RED_SANDSTONE = BlockType(179, 1); + static constexpr BlockType SMOOTH_RED_SANDSTONE = BlockType(179, 2); + static constexpr BlockType RED_SANDSTONE_STAIRS = BlockType(180); + static constexpr BlockType DOUBLE_RED_SANDSTONE_SLAB = BlockType(181); + static constexpr BlockType RED_SANDSTONE_SLAB = BlockType(182); + static constexpr BlockType SPRUCE_FENCE_GATE = BlockType(183); + static constexpr BlockType BIRCH_FENCE_GATE = BlockType(184); + static constexpr BlockType JUNGLE_FENCE_GATE = BlockType(185); + static constexpr BlockType DARK_OAK_FENCE_GATE = BlockType(186); + static constexpr BlockType ACACIA_FENCE_GATE = BlockType(187); + static constexpr BlockType SPRUCE_FENCE = BlockType(188); + static constexpr BlockType BIRCH_FENCE = BlockType(189); + static constexpr BlockType JUNGLE_FENCE = BlockType(190); + static constexpr BlockType DARK_OAK_FENCE = BlockType(191); + static constexpr BlockType ACACIA_FENCE = BlockType(192); + static constexpr BlockType SPRUCE_DOOR_BLOCK = BlockType(193); + static constexpr BlockType BIRCH_DOOR_BLOCK = BlockType(194); + static constexpr BlockType JUNGLE_DOOR_BLOCK = BlockType(195); + static constexpr BlockType ACACIA_DOOR_BLOCK = BlockType(196); + static constexpr BlockType DARK_OAK_DOOR_BLOCK = BlockType(197); + static constexpr BlockType END_ROD = BlockType(198); + static constexpr BlockType CHORUS_PLANT = BlockType(199); + static constexpr BlockType CHORUS_FLOWER = BlockType(200); + static constexpr BlockType PURPUR_BLOCK = BlockType(201); + static constexpr BlockType PURPUR_PILLAR = BlockType(202); + static constexpr BlockType PURPUR_STAIRS = BlockType(203); + static constexpr BlockType PURPUR_DOUBLE_SLAB = BlockType(204); + static constexpr BlockType PURPUR_SLAB = BlockType(205); + static constexpr BlockType END_STONE_BRICKS = BlockType(206); + static constexpr BlockType BEETROOT_BLOCK = BlockType(207); + static constexpr BlockType GRASS_PATH = BlockType(208); + static constexpr BlockType END_GATEWAY = BlockType(209); + static constexpr BlockType REPEATING_COMMAND_BLOCK = BlockType(210); + static constexpr BlockType CHAIN_COMMAND_BLOCK = BlockType(211); + static constexpr BlockType FROSTED_ICE = BlockType(212); + static constexpr BlockType MAGMA_BLOCK = BlockType(213); + static constexpr BlockType NETHER_WART_BLOCK = BlockType(214); + static constexpr BlockType RED_NETHER_BRICK = BlockType(215); + static constexpr BlockType BONE_BLOCK = BlockType(216); + static constexpr BlockType STRUCTURE_VOID = BlockType(217); + static constexpr BlockType OBSERVER = BlockType(218); + static constexpr BlockType WHITE_SHULKER_BOX = BlockType(219); + static constexpr BlockType ORANGE_SHULKER_BOX = BlockType(220); + static constexpr BlockType MAGENTA_SHULKER_BOX = BlockType(221); + static constexpr BlockType LIGHT_BLUE_SHULKER_BOX = BlockType(222); + static constexpr BlockType YELLOW_SHULKER_BOX = BlockType(223); + static constexpr BlockType LIME_SHULKER_BOX = BlockType(224); + static constexpr BlockType PINK_SHULKER_BOX = BlockType(225); + static constexpr BlockType GRAY_SHULKER_BOX = BlockType(226); + static constexpr BlockType LIGHT_GRAY_SHULKER_BOX = BlockType(227); + static constexpr BlockType CYAN_SHULKER_BOX = BlockType(228); + static constexpr BlockType PURPLE_SHULKER_BOX = BlockType(229); + static constexpr BlockType BLUE_SHULKER_BOX = BlockType(230); + static constexpr BlockType BROWN_SHULKER_BOX = BlockType(231); + static constexpr BlockType GREEN_SHULKER_BOX = BlockType(232); + static constexpr BlockType RED_SHULKER_BOX = BlockType(233); + static constexpr BlockType BLACK_SHULKER_BOX = BlockType(234); + static constexpr BlockType WHITE_GLAZED_TERRACOTTA = BlockType(235); + static constexpr BlockType ORANGE_GLAZED_TERRACOTTA = BlockType(236); + static constexpr BlockType MAGENTA_GLAZED_TERRACOTTA = BlockType(237); + static constexpr BlockType LIGHT_BLUE_GLAZED_TERRACOTTA = BlockType(238); + static constexpr BlockType YELLOW_GLAZED_TERRACOTTA = BlockType(239); + static constexpr BlockType LIME_GLAZED_TERRACOTTA = BlockType(240); + static constexpr BlockType PINK_GLAZED_TERRACOTTA = BlockType(241); + static constexpr BlockType GRAY_GLAZED_TERRACOTTA = BlockType(242); + static constexpr BlockType LIGHT_GRAY_GLAZED_TERRACOTTA = BlockType(243); + static constexpr BlockType CYAN_GLAZED_TERRACOTTA = BlockType(244); + static constexpr BlockType PURPLE_GLAZED_TERRACOTTA = BlockType(245); + static constexpr BlockType BLUE_GLAZED_TERRACOTTA = BlockType(246); + static constexpr BlockType BROWN_GLAZED_TERRACOTTA = BlockType(247); + static constexpr BlockType GREEN_GLAZED_TERRACOTTA = BlockType(248); + static constexpr BlockType RED_GLAZED_TERRACOTTA = BlockType(249); + static constexpr BlockType BLACK_GLAZED_TERRACOTTA = BlockType(250); + static constexpr BlockType WHITE_CONCRETE = BlockType(251); + static constexpr BlockType ORANGE_CONCRETE = BlockType(251, 1); + static constexpr BlockType MAGENTA_CONCRETE = BlockType(251, 2); + static constexpr BlockType LIGHT_BLUE_CONCRETE = BlockType(251, 3); + static constexpr BlockType YELLOW_CONCRETE = BlockType(251, 4); + static constexpr BlockType LIME_CONCRETE = BlockType(251, 5); + static constexpr BlockType PINK_CONCRETE = BlockType(251, 6); + static constexpr BlockType GRAY_CONCRETE = BlockType(251, 7); + static constexpr BlockType LIGHT_GRAY_CONCRETE = BlockType(251, 8); + static constexpr BlockType CYAN_CONCRETE = BlockType(251, 9); + static constexpr BlockType PURPLE_CONCRETE = BlockType(251, 10); + static constexpr BlockType BLUE_CONCRETE = BlockType(251, 11); + static constexpr BlockType BROWN_CONCRETE = BlockType(251, 12); + static constexpr BlockType GREEN_CONCRETE = BlockType(251, 13); + static constexpr BlockType RED_CONCRETE = BlockType(251, 14); + static constexpr BlockType BLACK_CONCRETE = BlockType(251, 15); + static constexpr BlockType WHITE_CONCRETE_POWDER = BlockType(252); + static constexpr BlockType ORANGE_CONCRETE_POWDER = BlockType(252, 1); + static constexpr BlockType MAGENTA_CONCRETE_POWDER = BlockType(252, 2); + static constexpr BlockType LIGHT_BLUE_CONCRETE_POWDER = BlockType(252, 3); + static constexpr BlockType YELLOW_CONCRETE_POWDER = BlockType(252, 4); + static constexpr BlockType LIME_CONCRETE_POWDER = BlockType(252, 5); + static constexpr BlockType PINK_CONCRETE_POWDER = BlockType(252, 6); + static constexpr BlockType GRAY_CONCRETE_POWDER = BlockType(252, 7); + static constexpr BlockType LIGHT_GRAY_CONCRETE_POWDER = BlockType(252, 8); + static constexpr BlockType CYAN_CONCRETE_POWDER = BlockType(252, 9); + static constexpr BlockType PURPLE_CONCRETE_POWDER = BlockType(252, 10); + static constexpr BlockType BLUE_CONCRETE_POWDER = BlockType(252, 11); + static constexpr BlockType BROWN_CONCRETE_POWDER = BlockType(252, 12); + static constexpr BlockType GREEN_CONCRETE_POWDER = BlockType(252, 13); + static constexpr BlockType RED_CONCRETE_POWDER = BlockType(252, 14); + static constexpr BlockType BLACK_CONCRETE_POWDER = BlockType(252, 15); + static constexpr BlockType STRUCTURE_BLOCK = BlockType(255); +}; +} // namespace mcpp diff --git a/include/mcpp/connection.h b/include/mcpp/connection.h index c49ad313..56bd1d2e 100644 --- a/include/mcpp/connection.h +++ b/include/mcpp/connection.h @@ -1,61 +1,62 @@ -#include +#include #include #include -#include +#include #define FAIL_RESPONSE "Fail" namespace mcpp { - class SocketConnection { - private: - int socketHandle; - std::string lastSent; - - static std::string resolveHostname(const std::string& hostname); - - public: - SocketConnection(const std::string& address_str, uint16_t port); - - void send(const std::string& dataString); - - /** - * Takes in parameters supporting std::stringstream conversion and a string prefix and transforms them into - * format "prefix(arg1,arg2,arg3)\n" (e.g. "chat.post(test)\n") and sends command to the server. - * @tparam Types - * @param prefix - * @param args - */ - template - void sendCommand(const std::string& prefix, const Types& ...args) { - std::stringstream ss; - - ss << prefix << "("; - - // Iterate over args pack - ((ss << args << ','), ...); - // Remove trailing comma - ss.seekp(-1, std::ios_base::end); - - ss << ")\n"; - - send(ss.str()); - } - - /** - * Sends via sendCommand() and returns the result from endpoint - * @tparam T - * @tparam Types - * @param prefix - * @param args - * @return - */ - template - std::string sendReceiveCommand(const T& prefix, const Types& ...args) { - sendCommand(prefix, args...); - auto result = recv(); - return result; - } - - [[nodiscard]] std::string recv() const; - }; -} +class SocketConnection { + private: + int socketHandle; + std::string lastSent; + + static std::string resolveHostname(const std::string& hostname); + + public: + SocketConnection(const std::string& address_str, uint16_t port); + + void send(const std::string& dataString); + + /** + * Takes in parameters supporting std::stringstream conversion and a string + * prefix and transforms them into format "prefix(arg1,arg2,arg3)\n" (e.g. + * "chat.post(test)\n") and sends command to the server. + * @tparam Types + * @param prefix + * @param args + */ + template + void sendCommand(const std::string& prefix, const Types&... args) { + std::stringstream ss; + + ss << prefix << "("; + + // Iterate over args pack + ((ss << args << ','), ...); + // Remove trailing comma + ss.seekp(-1, std::ios_base::end); + + ss << ")\n"; + + send(ss.str()); + } + + /** + * Sends via sendCommand() and returns the result from endpoint + * @tparam T + * @tparam Types + * @param prefix + * @param args + * @return + */ + template + std::string sendReceiveCommand(const T& prefix, const Types&... args) { + sendCommand(prefix, args...); + auto result = recv(); + return result; + } + + [[nodiscard]] std::string recv() const; +}; +} // namespace mcpp diff --git a/include/mcpp/entity.h b/include/mcpp/entity.h index 54b0e7a1..bfbc944b 100644 --- a/include/mcpp/entity.h +++ b/include/mcpp/entity.h @@ -3,99 +3,97 @@ #include namespace mcpp { - class Entity { - public: - constexpr Entity(int id, const char *name = nullptr) : id(id), name(name) {}; +class Entity { + public: + constexpr Entity(int id, const char* name = nullptr) : id(id), name(name){}; - bool operator==(Entity& other) const { - return this->id == other.id; - } + bool operator==(Entity& other) const { return this->id == other.id; } - private: - int id; - const char *name; - }; + private: + int id; + const char* name; +}; - - struct Entities { - static constexpr Entity EXPERIENCE_ORB = Entity(2, "EXPERIENCE_ORB"); - static constexpr Entity AREA_EFFECT_CLOUD = Entity(3, "AREA_EFFECT_CLOUD"); - static constexpr Entity ELDER_GUARDIAN = Entity(4, "ELDER_GUARDIAN"); - static constexpr Entity WITHER_SKELETON = Entity(5, "WITHER_SKELETON"); - static constexpr Entity STRAY = Entity(6, "STRAY"); - static constexpr Entity EGG = Entity(7, "EGG"); - static constexpr Entity LEASH_HITCH = Entity(8, "LEASH_HITCH"); - static constexpr Entity PAINTING = Entity(9, "PAINTING"); - static constexpr Entity ARROW = Entity(10, "ARROW"); - static constexpr Entity SNOWBALL = Entity(11, "SNOWBALL"); - static constexpr Entity FIREBALL = Entity(12, "FIREBALL"); - static constexpr Entity SMALL_FIREBALL = Entity(13, "SMALL_FIREBALL"); - static constexpr Entity ENDER_PEARL = Entity(14, "ENDER_PEARL"); - static constexpr Entity ENDER_SIGNAL = Entity(15, "ENDER_SIGNAL"); - static constexpr Entity THROWN_EXP_BOTTLE = Entity(17, "THROWN_EXP_BOTTLE"); - static constexpr Entity ITEM_FRAME = Entity(18, "ITEM_FRAME"); - static constexpr Entity WITHER_SKULL = Entity(19, "WITHER_SKULL"); - static constexpr Entity PRIMED_TNT = Entity(20, "PRIMED_TNT"); - static constexpr Entity HUSK = Entity(23, "HUSK"); - static constexpr Entity SPECTRAL_ARROW = Entity(24, "SPECTRAL_ARROW"); - static constexpr Entity SHULKER_BULLET = Entity(25, "SHULKER_BULLET"); - static constexpr Entity DRAGON_FIREBALL = Entity(26, "DRAGON_FIREBALL"); - static constexpr Entity ZOMBIE_VILLAGER = Entity(27, "ZOMBIE_VILLAGER"); - static constexpr Entity SKELETON_HORSE = Entity(28, "SKELETON_HORSE"); - static constexpr Entity ZOMBIE_HORSE = Entity(29, "ZOMBIE_HORSE"); - static constexpr Entity ARMOR_STAND = Entity(30, "ARMOR_STAND"); - static constexpr Entity DONKEY = Entity(31, "DONKEY"); - static constexpr Entity MULE = Entity(32, "MULE"); - static constexpr Entity EVOKER_FANGS = Entity(33, "EVOKER_FANGS"); - static constexpr Entity EVOKER = Entity(34, "EVOKER"); - static constexpr Entity VEX = Entity(35, "VEX"); - static constexpr Entity VINDICATOR = Entity(36, "VINDICATOR"); - static constexpr Entity ILLUSIONER = Entity(37, "ILLUSIONER"); - static constexpr Entity MINECART_COMMAND = Entity(40, "MINECART_COMMAND"); - static constexpr Entity BOAT = Entity(41, "BOAT"); - static constexpr Entity MINECART = Entity(42, "MINECART"); - static constexpr Entity MINECART_CHEST = Entity(43, "MINECART_CHEST"); - static constexpr Entity MINECART_FURNACE = Entity(44, "MINECART_FURNACE"); - static constexpr Entity MINECART_TNT = Entity(45, "MINECART_TNT"); - static constexpr Entity MINECART_HOPPER = Entity(46, "MINECART_HOPPER"); - static constexpr Entity MINECART_MOB_SPAWNER = Entity(47, "MINECART_MOB_SPAWNER"); - static constexpr Entity CREEPER = Entity(50, "CREEPER"); - static constexpr Entity SKELETON = Entity(51, "SKELETON"); - static constexpr Entity SPIDER = Entity(52, "SPIDER"); - static constexpr Entity GIANT = Entity(53, "GIANT"); - static constexpr Entity ZOMBIE = Entity(54, "ZOMBIE"); - static constexpr Entity SLIME = Entity(55, "SLIME"); - static constexpr Entity GHAST = Entity(56, "GHAST"); - static constexpr Entity PIG_ZOMBIE = Entity(57, "PIG_ZOMBIE"); - static constexpr Entity ENDERMAN = Entity(58, "ENDERMAN"); - static constexpr Entity CAVE_SPIDER = Entity(59, "CAVE_SPIDER"); - static constexpr Entity SILVERFISH = Entity(60, "SILVERFISH"); - static constexpr Entity BLAZE = Entity(61, "BLAZE"); - static constexpr Entity MAGMA_CUBE = Entity(62, "MAGMA_CUBE"); - static constexpr Entity ENDER_DRAGON = Entity(63, "ENDER_DRAGON"); - static constexpr Entity WITHER = Entity(64, "WITHER"); - static constexpr Entity BAT = Entity(65, "BAT"); - static constexpr Entity WITCH = Entity(66, "WITCH"); - static constexpr Entity ENDERMITE = Entity(67, "ENDERMITE"); - static constexpr Entity GUARDIAN = Entity(68, "GUARDIAN"); - static constexpr Entity SHULKER = Entity(69, "SHULKER"); - static constexpr Entity PIG = Entity(90, "PIG"); - static constexpr Entity SHEEP = Entity(91, "SHEEP"); - static constexpr Entity COW = Entity(92, "COW"); - static constexpr Entity CHICKEN = Entity(93, "CHICKEN"); - static constexpr Entity SQUID = Entity(94, "SQUID"); - static constexpr Entity WOLF = Entity(95, "WOLF"); - static constexpr Entity MUSHROOM_COW = Entity(96, "MUSHROOM_COW"); - static constexpr Entity SNOWMAN = Entity(97, "SNOWMAN"); - static constexpr Entity OCELOT = Entity(98, "OCELOT"); - static constexpr Entity IRON_GOLEM = Entity(99, "IRON_GOLEM"); - static constexpr Entity HORSE = Entity(100, "HORSE"); - static constexpr Entity RABBIT = Entity(101, "RABBIT"); - static constexpr Entity POLAR_BEAR = Entity(102, "POLAR_BEAR"); - static constexpr Entity LLAMA = Entity(103, "LLAMA"); - static constexpr Entity LLAMA_SPIT = Entity(104, "LLAMA_SPIT"); - static constexpr Entity PARROT = Entity(105, "PARROT"); - static constexpr Entity VILLAGER = Entity(120, "VILLAGER"); - static constexpr Entity ENDER_CRYSTAL = Entity(200, "ENDER_CRYSTAL"); - }; -} \ No newline at end of file +struct Entities { + static constexpr Entity EXPERIENCE_ORB = Entity(2, "EXPERIENCE_ORB"); + static constexpr Entity AREA_EFFECT_CLOUD = Entity(3, "AREA_EFFECT_CLOUD"); + static constexpr Entity ELDER_GUARDIAN = Entity(4, "ELDER_GUARDIAN"); + static constexpr Entity WITHER_SKELETON = Entity(5, "WITHER_SKELETON"); + static constexpr Entity STRAY = Entity(6, "STRAY"); + static constexpr Entity EGG = Entity(7, "EGG"); + static constexpr Entity LEASH_HITCH = Entity(8, "LEASH_HITCH"); + static constexpr Entity PAINTING = Entity(9, "PAINTING"); + static constexpr Entity ARROW = Entity(10, "ARROW"); + static constexpr Entity SNOWBALL = Entity(11, "SNOWBALL"); + static constexpr Entity FIREBALL = Entity(12, "FIREBALL"); + static constexpr Entity SMALL_FIREBALL = Entity(13, "SMALL_FIREBALL"); + static constexpr Entity ENDER_PEARL = Entity(14, "ENDER_PEARL"); + static constexpr Entity ENDER_SIGNAL = Entity(15, "ENDER_SIGNAL"); + static constexpr Entity THROWN_EXP_BOTTLE = Entity(17, "THROWN_EXP_BOTTLE"); + static constexpr Entity ITEM_FRAME = Entity(18, "ITEM_FRAME"); + static constexpr Entity WITHER_SKULL = Entity(19, "WITHER_SKULL"); + static constexpr Entity PRIMED_TNT = Entity(20, "PRIMED_TNT"); + static constexpr Entity HUSK = Entity(23, "HUSK"); + static constexpr Entity SPECTRAL_ARROW = Entity(24, "SPECTRAL_ARROW"); + static constexpr Entity SHULKER_BULLET = Entity(25, "SHULKER_BULLET"); + static constexpr Entity DRAGON_FIREBALL = Entity(26, "DRAGON_FIREBALL"); + static constexpr Entity ZOMBIE_VILLAGER = Entity(27, "ZOMBIE_VILLAGER"); + static constexpr Entity SKELETON_HORSE = Entity(28, "SKELETON_HORSE"); + static constexpr Entity ZOMBIE_HORSE = Entity(29, "ZOMBIE_HORSE"); + static constexpr Entity ARMOR_STAND = Entity(30, "ARMOR_STAND"); + static constexpr Entity DONKEY = Entity(31, "DONKEY"); + static constexpr Entity MULE = Entity(32, "MULE"); + static constexpr Entity EVOKER_FANGS = Entity(33, "EVOKER_FANGS"); + static constexpr Entity EVOKER = Entity(34, "EVOKER"); + static constexpr Entity VEX = Entity(35, "VEX"); + static constexpr Entity VINDICATOR = Entity(36, "VINDICATOR"); + static constexpr Entity ILLUSIONER = Entity(37, "ILLUSIONER"); + static constexpr Entity MINECART_COMMAND = Entity(40, "MINECART_COMMAND"); + static constexpr Entity BOAT = Entity(41, "BOAT"); + static constexpr Entity MINECART = Entity(42, "MINECART"); + static constexpr Entity MINECART_CHEST = Entity(43, "MINECART_CHEST"); + static constexpr Entity MINECART_FURNACE = Entity(44, "MINECART_FURNACE"); + static constexpr Entity MINECART_TNT = Entity(45, "MINECART_TNT"); + static constexpr Entity MINECART_HOPPER = Entity(46, "MINECART_HOPPER"); + static constexpr Entity MINECART_MOB_SPAWNER = + Entity(47, "MINECART_MOB_SPAWNER"); + static constexpr Entity CREEPER = Entity(50, "CREEPER"); + static constexpr Entity SKELETON = Entity(51, "SKELETON"); + static constexpr Entity SPIDER = Entity(52, "SPIDER"); + static constexpr Entity GIANT = Entity(53, "GIANT"); + static constexpr Entity ZOMBIE = Entity(54, "ZOMBIE"); + static constexpr Entity SLIME = Entity(55, "SLIME"); + static constexpr Entity GHAST = Entity(56, "GHAST"); + static constexpr Entity PIG_ZOMBIE = Entity(57, "PIG_ZOMBIE"); + static constexpr Entity ENDERMAN = Entity(58, "ENDERMAN"); + static constexpr Entity CAVE_SPIDER = Entity(59, "CAVE_SPIDER"); + static constexpr Entity SILVERFISH = Entity(60, "SILVERFISH"); + static constexpr Entity BLAZE = Entity(61, "BLAZE"); + static constexpr Entity MAGMA_CUBE = Entity(62, "MAGMA_CUBE"); + static constexpr Entity ENDER_DRAGON = Entity(63, "ENDER_DRAGON"); + static constexpr Entity WITHER = Entity(64, "WITHER"); + static constexpr Entity BAT = Entity(65, "BAT"); + static constexpr Entity WITCH = Entity(66, "WITCH"); + static constexpr Entity ENDERMITE = Entity(67, "ENDERMITE"); + static constexpr Entity GUARDIAN = Entity(68, "GUARDIAN"); + static constexpr Entity SHULKER = Entity(69, "SHULKER"); + static constexpr Entity PIG = Entity(90, "PIG"); + static constexpr Entity SHEEP = Entity(91, "SHEEP"); + static constexpr Entity COW = Entity(92, "COW"); + static constexpr Entity CHICKEN = Entity(93, "CHICKEN"); + static constexpr Entity SQUID = Entity(94, "SQUID"); + static constexpr Entity WOLF = Entity(95, "WOLF"); + static constexpr Entity MUSHROOM_COW = Entity(96, "MUSHROOM_COW"); + static constexpr Entity SNOWMAN = Entity(97, "SNOWMAN"); + static constexpr Entity OCELOT = Entity(98, "OCELOT"); + static constexpr Entity IRON_GOLEM = Entity(99, "IRON_GOLEM"); + static constexpr Entity HORSE = Entity(100, "HORSE"); + static constexpr Entity RABBIT = Entity(101, "RABBIT"); + static constexpr Entity POLAR_BEAR = Entity(102, "POLAR_BEAR"); + static constexpr Entity LLAMA = Entity(103, "LLAMA"); + static constexpr Entity LLAMA_SPIT = Entity(104, "LLAMA_SPIT"); + static constexpr Entity PARROT = Entity(105, "PARROT"); + static constexpr Entity VILLAGER = Entity(120, "VILLAGER"); + static constexpr Entity ENDER_CRYSTAL = Entity(200, "ENDER_CRYSTAL"); +}; +} // namespace mcpp \ No newline at end of file diff --git a/include/mcpp/mcpp.h b/include/mcpp/mcpp.h index c455448d..9dd42472 100644 --- a/include/mcpp/mcpp.h +++ b/include/mcpp/mcpp.h @@ -1,125 +1,128 @@ #pragma once -#include -#include -#include -#include "connection.h" #include "block.h" +#include "connection.h" #include "util.h" +#include +#include +#include namespace mcpp { - class MinecraftConnection { - private: - std::unique_ptr conn; - - static std::vector>> - unflattenBlocksArray(const Coordinate& loc1, - const Coordinate& loc2, - const std::vector& inVector); - - static std::vector> - unflattenHeightsArray(const Coordinate& loc1, - const Coordinate& loc2, - const std::vector& inVector); - - public: - /** - * Represents the main endpoint for interaction with the minecraft world. - * @param address String address in IPV4 format, defaults to "localhost" - * @param port Integer port to run on, defaults to 4711 as that is the port for ELCI - */ - explicit MinecraftConnection(const std::string& address = "localhost", - int port = 4711); - - /** - * Sends a message to the in-game chat, does not require a joined player - * @param message - */ - void postToChat(const std::string& message); - - /** - * Performs an in-game minecraft command. Players have to exist on the server and - * should be server operators (default with ELCI) - * @param command Command string in the in-game format (e.g. "time set day") - */ - void doCommand(const std::string& command); - - /** - * Sets player pos (block pos of lower half of playermodel) to specified Coordinate - * @param pos Coordinate to set - */ - void setPlayerPosition(const Coordinate& pos); - - /** - * Returns a coordinate representing player position (block pos of lower half of playermodel) - * @return Coordinate of location - */ - Coordinate getPlayerPosition(); - - /** - * Sets player position to be one above specified tile (i.e. tile = block player is standing on) - * @param tile Coordinate to set - */ - void setPlayerTilePosition(const Coordinate& tile); - - /** - * Returns the coordinate location of the block the player is standing on - * @return Coordinate of location - */ - Coordinate getPlayerTilePosition(); - - /** - * Sets block at Coordinate loc to the BlockType specified by blockType - * @param loc - * @param blockType - */ - void setBlock(const Coordinate& loc, const BlockType& blockType); - - /** - * Sets a cuboid of blocks to the specified BlockType blockType, with the corners of the cuboid - * provided by the Coordinate loc1 and loc2 - * @param loc1 - * @param loc2 - * @param blockType - */ - void setBlocks(const Coordinate& loc1, const Coordinate& loc2, - const BlockType& blockType); - - /** - * Returns BlockType object from the specified Coordinate loc with modifier - * @param loc - * @return BlockType of the requested block - */ - BlockType getBlock(const Coordinate& loc); - - /** - * Returns a 3D vector of the BlockTypes of the requested cuboid with modifiers - * @param loc1 1st corner of the cuboid - * @param loc2 2nd corner of the cuboid - * @return 3D vector of BlockType in the specified cuboid. - */ - std::vector>> - getBlocks(const Coordinate& loc1, const Coordinate& loc2); - - /** - * IMPORTANT: DO NOT USE FOR LARGE AREAS, IT WILL BE VERY SLOW - * USE getHeights() INSTEAD - * Gets the y-value of the highest non-air block at the specified (x, z) coordinate. - * @param x - * @param z - * @return Returns the integer y-height at the requested coordinate. - */ - int getHeight(int x, int z); - - /** - * Provides a scaled option of the getHeight call to allow for considerable performance gains. USE THIS - * instead of getHeight in a for loop. - * @param loc1 - * @param loc2 - * @return Returns a vector of integers representing the 2D area of heights. - */ - std::vector> - getHeights(const Coordinate& loc1, const Coordinate& loc2); - - }; -} +class MinecraftConnection { + private: + std::unique_ptr conn; + + static std::vector>> + unflattenBlocksArray(const Coordinate& loc1, const Coordinate& loc2, + const std::vector& inVector); + + static std::vector> + unflattenHeightsArray(const Coordinate& loc1, const Coordinate& loc2, + const std::vector& inVector); + + public: + /** + * Represents the main endpoint for interaction with the minecraft world. + * @param address String address in IPV4 format, defaults to "localhost" + * @param port Integer port to run on, defaults to 4711 as that is the port + * for ELCI + */ + explicit MinecraftConnection(const std::string& address = "localhost", + int port = 4711); + + /** + * Sends a message to the in-game chat, does not require a joined player + * @param message + */ + void postToChat(const std::string& message); + + /** + * Performs an in-game minecraft command. Players have to exist on the + * server and should be server operators (default with ELCI) + * @param command Command string in the in-game format (e.g. "time set day") + */ + void doCommand(const std::string& command); + + /** + * Sets player pos (block pos of lower half of playermodel) to specified + * Coordinate + * @param pos Coordinate to set + */ + void setPlayerPosition(const Coordinate& pos); + + /** + * Returns a coordinate representing player position (block pos of lower + * half of playermodel) + * @return Coordinate of location + */ + Coordinate getPlayerPosition(); + + /** + * Sets player position to be one above specified tile (i.e. tile = block + * player is standing on) + * @param tile Coordinate to set + */ + void setPlayerTilePosition(const Coordinate& tile); + + /** + * Returns the coordinate location of the block the player is standing on + * @return Coordinate of location + */ + Coordinate getPlayerTilePosition(); + + /** + * Sets block at Coordinate loc to the BlockType specified by blockType + * @param loc + * @param blockType + */ + void setBlock(const Coordinate& loc, const BlockType& blockType); + + /** + * Sets a cuboid of blocks to the specified BlockType blockType, with the + * corners of the cuboid provided by the Coordinate loc1 and loc2 + * @param loc1 + * @param loc2 + * @param blockType + */ + void setBlocks(const Coordinate& loc1, const Coordinate& loc2, + const BlockType& blockType); + + /** + * Returns BlockType object from the specified Coordinate loc with modifier + * @param loc + * @return BlockType of the requested block + */ + BlockType getBlock(const Coordinate& loc); + + /** + * Returns a 3D vector of the BlockTypes of the requested cuboid with + * modifiers + * @param loc1 1st corner of the cuboid + * @param loc2 2nd corner of the cuboid + * @return 3D vector of BlockType in the specified cuboid. + */ + std::vector>> + getBlocks(const Coordinate& loc1, const Coordinate& loc2); + + /** + * IMPORTANT: DO NOT USE FOR LARGE AREAS, IT WILL BE VERY SLOW + * USE getHeights() INSTEAD + * Gets the y-value of the highest non-air block at the specified (x, z) + * coordinate. + * @param x + * @param z + * @return Returns the integer y-height at the requested coordinate. + */ + int getHeight(int x, int z); + + /** + * Provides a scaled option of the getHeight call to allow for considerable + * performance gains. USE THIS instead of getHeight in a for loop. + * @param loc1 + * @param loc2 + * @return Returns a vector of integers representing the 2D area of heights. + */ + std::vector> getHeights(const Coordinate& loc1, + const Coordinate& loc2); +}; +} // namespace mcpp diff --git a/include/mcpp/util.h b/include/mcpp/util.h index a7819239..c25ba954 100644 --- a/include/mcpp/util.h +++ b/include/mcpp/util.h @@ -4,30 +4,29 @@ namespace mcpp { /** - * Represented using integers since sub-unit coordinates are not of particular relevance. Allows for - * operations such as addition between coordinates. + * Represented using integers since sub-unit coordinates are not of particular + * relevance. Allows for operations such as addition between coordinates. */ - class Coordinate { - public: - explicit Coordinate(int x = 0, int y = 0, int z = 0); +class Coordinate { + public: + explicit Coordinate(int x = 0, int y = 0, int z = 0); - Coordinate(double x, double y, double z); + Coordinate(double x, double y, double z); - Coordinate operator+(const Coordinate& obj) const; + Coordinate operator+(const Coordinate& obj) const; - bool operator==(const Coordinate& obj) const; + bool operator==(const Coordinate& obj) const; - bool operator!=(const Coordinate& obj) const; + bool operator!=(const Coordinate& obj) const; - Coordinate operator-(const Coordinate& obj) const; + Coordinate operator-(const Coordinate& obj) const; - [[nodiscard]] Coordinate clone() const; + [[nodiscard]] Coordinate clone() const; - friend std::ostream& operator<< (std::ostream& out, const Coordinate& coord); - - int x; - int y; - int z; - }; -} + friend std::ostream& operator<<(std::ostream& out, const Coordinate& coord); + int x; + int y; + int z; +}; +} // namespace mcpp diff --git a/src/block.cpp b/src/block.cpp index 9f7c0f59..7e0eb5e7 100644 --- a/src/block.cpp +++ b/src/block.cpp @@ -1,20 +1,20 @@ #include "../include/mcpp/block.h" namespace mcpp { - bool BlockType::operator==(const BlockType& other) const { - return this->id == other.id && this->mod == other.mod; - } +bool BlockType::operator==(const BlockType& other) const { + return this->id == other.id && this->mod == other.mod; +} - bool BlockType::operator!=(const BlockType& other) const { - return !(*this == other); - } +bool BlockType::operator!=(const BlockType& other) const { + return !(*this == other); +} - BlockType BlockType::withMod(int modifier) const { - return {this->id, modifier}; - } +BlockType BlockType::withMod(int modifier) const { + return {this->id, modifier}; +} - std::ostream& operator<< (std::ostream& out, const BlockType& block) { - out << "[" << block.id << ", " << block.mod << "]"; - return out; - } +std::ostream& operator<<(std::ostream& out, const BlockType& block) { + out << "[" << block.id << ", " << block.mod << "]"; + return out; } +} // namespace mcpp diff --git a/src/connection.cpp b/src/connection.cpp index 506b2d51..2bc8879b 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -1,93 +1,95 @@ #include "../include/mcpp/connection.h" -#include -#include -#include + #include -#include #include +#include +#include + +#include +#include namespace mcpp { - SocketConnection::SocketConnection(const std::string& address_str, - uint16_t port) { - std::string ipAddress = resolveHostname(address_str); - - // Using std libs only to avoid dependency on socket lib - socketHandle = socket(AF_INET, SOCK_STREAM, 0); - if (socketHandle == -1) { - throw std::runtime_error("Failed to create socket."); - } +SocketConnection::SocketConnection(const std::string& address_str, + uint16_t port) { + std::string ipAddress = resolveHostname(address_str); + + // Using std libs only to avoid dependency on socket lib + socketHandle = socket(AF_INET, SOCK_STREAM, 0); + if (socketHandle == -1) { + throw std::runtime_error("Failed to create socket."); + } - sockaddr_in serverAddress{}; - serverAddress.sin_family = AF_INET; - serverAddress.sin_port = htons(port); + sockaddr_in serverAddress{}; + serverAddress.sin_family = AF_INET; + serverAddress.sin_port = htons(port); - if (inet_pton(AF_INET, ipAddress.c_str(), &(serverAddress.sin_addr)) <= - 0) { - throw std::runtime_error("Invalid address."); - } + if (inet_pton(AF_INET, ipAddress.c_str(), &(serverAddress.sin_addr)) <= 0) { + throw std::runtime_error("Invalid address."); + } - if (connect(socketHandle, (struct sockaddr *) &serverAddress, - sizeof(serverAddress)) < 0) { - throw std::runtime_error("Failed to connect to the server. Check if the server is running."); - } + if (connect(socketHandle, (struct sockaddr*)&serverAddress, + sizeof(serverAddress)) < 0) { + throw std::runtime_error( + "Failed to connect to the server. Check if the server is running."); } +} - std::string SocketConnection::resolveHostname(const std::string& hostname) { - struct addrinfo hints{}; - struct addrinfo *result; +std::string SocketConnection::resolveHostname(const std::string& hostname) { + struct addrinfo hints {}; + struct addrinfo* result; - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; - if (getaddrinfo(hostname.c_str(), nullptr, &hints, &result) != 0) { - throw std::runtime_error("Failed to resolve hostname."); - } + if (getaddrinfo(hostname.c_str(), nullptr, &hints, &result) != 0) { + throw std::runtime_error("Failed to resolve hostname."); + } - auto *address = reinterpret_cast(result->ai_addr); - char ipAddress[INET_ADDRSTRLEN]; - inet_ntop(AF_INET, &(address->sin_addr), ipAddress, INET_ADDRSTRLEN); + auto* address = reinterpret_cast(result->ai_addr); + char ipAddress[INET_ADDRSTRLEN]; + inet_ntop(AF_INET, &(address->sin_addr), ipAddress, INET_ADDRSTRLEN); - std::string ipString(ipAddress); - freeaddrinfo(result); + std::string ipString(ipAddress); + freeaddrinfo(result); - return ipString; - } + return ipString; +} - void SocketConnection::send(const std::string& dataString) { - lastSent = dataString; - ssize_t result = write(socketHandle, dataString.c_str(), - dataString.length()); - if (result < 0) { - throw std::runtime_error("Failed to send data."); - } +void SocketConnection::send(const std::string& dataString) { + lastSent = dataString; + ssize_t result = + write(socketHandle, dataString.c_str(), dataString.length()); + if (result < 0) { + throw std::runtime_error("Failed to send data."); } +} - std::string SocketConnection::recv() const { - std::stringstream responseStream; - char buffer[1024]; +std::string SocketConnection::recv() const { + std::stringstream responseStream; + char buffer[1024]; - ssize_t bytesRead; - do { - bytesRead = read(socketHandle, buffer, sizeof(buffer)); - if (bytesRead < 0) { - throw std::runtime_error("Failed to receive data."); - } + ssize_t bytesRead; + do { + bytesRead = read(socketHandle, buffer, sizeof(buffer)); + if (bytesRead < 0) { + throw std::runtime_error("Failed to receive data."); + } - responseStream.write(buffer, bytesRead); - } while (buffer[bytesRead - 1] != '\n'); + responseStream.write(buffer, bytesRead); + } while (buffer[bytesRead - 1] != '\n'); - std::string response = responseStream.str(); + std::string response = responseStream.str(); - // Remove trailing \n - if (!response.empty() && response[response.length() - 1] == '\n') { - response.pop_back(); - } + // Remove trailing \n + if (!response.empty() && response[response.length() - 1] == '\n') { + response.pop_back(); + } - if (response == FAIL_RESPONSE) { - std::string errorMsg = "Server failed to execute command: "; - errorMsg += lastSent; - throw std::runtime_error(errorMsg); - } - return response; + if (response == FAIL_RESPONSE) { + std::string errorMsg = "Server failed to execute command: "; + errorMsg += lastSent; + throw std::runtime_error(errorMsg); } -} \ No newline at end of file + return response; +} +} // namespace mcpp \ No newline at end of file diff --git a/src/mcpp.cpp b/src/mcpp.cpp index 3916803c..41086593 100644 --- a/src/mcpp.cpp +++ b/src/mcpp.cpp @@ -1,7 +1,8 @@ #include "../include/mcpp/mcpp.h" + +#include #include #include -#include using std::string_view; using namespace std::string_literals; @@ -9,190 +10,168 @@ using namespace mcpp; namespace mcpp { - void splitCommaStringToInts(const std::string& str, std::vector& vec) { - std::stringstream ss(str); - std::string item; - while (std::getline(ss, item, ',')) { - // Fixes flooring issue w/ negative coordinates - double itemDouble = std::stod(item); - int itemFloored = static_cast(std::floor(itemDouble)); - vec.push_back(itemFloored); - } - } - - MinecraftConnection::MinecraftConnection(const std::string& address, - int port) { - conn = std::make_unique(address, port); - } - - void MinecraftConnection::postToChat(const std::string& message) { - conn->sendCommand("chat.post", message); +void splitCommaStringToInts(const std::string& str, std::vector& vec) { + std::stringstream ss(str); + std::string item; + while (std::getline(ss, item, ',')) { + // Fixes flooring issue w/ negative coordinates + double itemDouble = std::stod(item); + int itemFloored = static_cast(std::floor(itemDouble)); + vec.push_back(itemFloored); } +} - void MinecraftConnection::doCommand(const std::string& command) { - conn->sendCommand("player.doCommand", command); - } +MinecraftConnection::MinecraftConnection(const std::string& address, int port) { + conn = std::make_unique(address, port); +} - void MinecraftConnection::setPlayerPosition(const Coordinate& pos) { - conn->sendCommand("player.setPos", pos.x, pos.y, pos.z); - } +void MinecraftConnection::postToChat(const std::string& message) { + conn->sendCommand("chat.post", message); +} - Coordinate MinecraftConnection::getPlayerPosition() { - // TODO remove currently required empty string that ensures formatting - std::string returnString = conn->sendReceiveCommand("player.getPos", ""); - std::vector parsedInts; - splitCommaStringToInts(returnString, parsedInts); - return Coordinate(parsedInts[0], parsedInts[1], parsedInts[2]); - } +void MinecraftConnection::doCommand(const std::string& command) { + conn->sendCommand("player.doCommand", command); +} - void MinecraftConnection::setPlayerTilePosition(const Coordinate& tile){ - conn->sendCommand("player.setTile", tile.x, tile.y, tile.z); - } +void MinecraftConnection::setPlayerPosition(const Coordinate& pos) { + conn->sendCommand("player.setPos", pos.x, pos.y, pos.z); +} - Coordinate MinecraftConnection::getPlayerTilePosition(){ - std::string returnString = conn->sendReceiveCommand("player.",""); - std::vector parsedInts; - splitCommaStringToInts(returnString, parsedInts); - return Coordinate(parsedInts[0], parsedInts[1], parsedInts[2]); - } +Coordinate MinecraftConnection::getPlayerPosition() { + std::string returnString = conn->sendReceiveCommand("player.getPos", ""); + std::vector parsedInts; + splitCommaStringToInts(returnString, parsedInts); + return Coordinate(parsedInts[0], parsedInts[1], parsedInts[2]); +} - void MinecraftConnection::setBlock(const Coordinate& loc, - const BlockType& blockType) { - conn->sendCommand("world.setBlock", loc.x, loc.y, loc.z, blockType.id, - blockType.mod); - } +void MinecraftConnection::setPlayerTilePosition(const Coordinate& tile) { + conn->sendCommand("player.setTile", tile.x, tile.y, tile.z); +} +Coordinate MinecraftConnection::getPlayerTilePosition() { + std::string returnString = conn->sendReceiveCommand("player.", ""); + std::vector parsedInts; + splitCommaStringToInts(returnString, parsedInts); + return Coordinate(parsedInts[0], parsedInts[1], parsedInts[2]); +} - void MinecraftConnection::setBlocks(const Coordinate& loc1, - const Coordinate& loc2, - const BlockType& blockType) { - auto [x, y, z] = loc1; - auto [x2, y2, z2] = loc2; - conn->sendCommand("world.setBlocks", x, y, z, x2, y2, z2, blockType.id, - blockType.mod); - } +void MinecraftConnection::setBlock(const Coordinate& loc, + const BlockType& blockType) { + conn->sendCommand("world.setBlock", loc.x, loc.y, loc.z, blockType.id, + blockType.mod); +} +void MinecraftConnection::setBlocks(const Coordinate& loc1, + const Coordinate& loc2, + const BlockType& blockType) { + auto [x, y, z] = loc1; + auto [x2, y2, z2] = loc2; + conn->sendCommand("world.setBlocks", x, y, z, x2, y2, z2, blockType.id, + blockType.mod); +} - BlockType MinecraftConnection::getBlock(const Coordinate& loc) { - std::string returnString = conn->sendReceiveCommand( - "world.getBlockWithData", loc.x, loc.y, loc.z); - std::vector parsedInts; - splitCommaStringToInts(returnString, parsedInts); +BlockType MinecraftConnection::getBlock(const Coordinate& loc) { + std::string returnString = + conn->sendReceiveCommand("world.getBlockWithData", loc.x, loc.y, loc.z); + std::vector parsedInts; + splitCommaStringToInts(returnString, parsedInts); - // Values are id and mod - return {parsedInts[0], parsedInts[1]}; - } + // Values are id and mod + return {parsedInts[0], parsedInts[1]}; +} - std::vector>> - MinecraftConnection::getBlocks( - const Coordinate& loc1, const Coordinate& loc2) { - std::string returnValue = conn->sendReceiveCommand( - "world.getBlocksWithData", - loc1.x, loc1.y, loc1.z, - loc2.x, loc2.y, loc2.z); - - // Received in format 1,2;1,2;1,2 where 1,2 is a block of type 1 and mod 2 - std::vector result; - std::stringstream stream(returnValue); - - int id; - int data; - char delimiter; - while (stream >> id) { +std::vector>> +MinecraftConnection::getBlocks(const Coordinate& loc1, const Coordinate& loc2) { + std::string returnValue = + conn->sendReceiveCommand("world.getBlocksWithData", loc1.x, loc1.y, + loc1.z, loc2.x, loc2.y, loc2.z); + + // Received in format 1,2;1,2;1,2 where 1,2 is a block of type 1 and mod 2 + std::vector result; + std::stringstream stream(returnValue); + + int id; + int data; + char delimiter; + while (stream >> id) { + stream >> delimiter; + if (delimiter == ',') { + stream >> data; + result.emplace_back(id, data); stream >> delimiter; - if (delimiter == ',') { - stream >> data; - result.emplace_back(id, data); - stream >> delimiter; - } - if (delimiter == ';') { - continue; - } - if (delimiter == EOF) { - break; - } } - return unflattenBlocksArray(loc1, loc2, result); - } - - - int MinecraftConnection::getHeight(int x, int z) { - std::string returnValue = conn->sendReceiveCommand("world.getHeight", x, - z); - return stoi(returnValue); + if (delimiter == ';') { + continue; + } + if (delimiter == EOF) { + break; + } } + return unflattenBlocksArray(loc1, loc2, result); +} +int MinecraftConnection::getHeight(int x, int z) { + std::string returnValue = conn->sendReceiveCommand("world.getHeight", x, z); + return stoi(returnValue); +} - std::vector> - MinecraftConnection::getHeights(const Coordinate& loc1, - const Coordinate& loc2) { - std::string returnValue = conn->sendReceiveCommand("world.getHeights", - loc1.x, loc1.z, - loc2.x, loc2.z); - - // Returned in format "1,2,3,4,5" - std::vector returnVector; - splitCommaStringToInts(returnValue, returnVector); - - return unflattenHeightsArray(loc1, loc2, returnVector); - } - +std::vector> +MinecraftConnection::getHeights(const Coordinate& loc1, + const Coordinate& loc2) { + std::string returnValue = conn->sendReceiveCommand( + "world.getHeights", loc1.x, loc1.z, loc2.x, loc2.z); - std::vector>> - MinecraftConnection::unflattenBlocksArray(const Coordinate& loc1, - const Coordinate& loc2, - const std::vector& inVector) { - // Initialise empty vector of correct size and shape - int y_len = abs(loc2.y - loc1.y) + 1; - int x_len = abs(loc2.x - loc1.x) + 1; - int z_len = abs(loc2.z - loc1.z) + 1; - std::vector>> returnVector( - y_len, - std::vector>( - x_len, - std::vector( - z_len, - BlockType(0) - ) - ) - ); - - int index = 0; - for (int y = 0; y < y_len; y++) { - for (int x = 0; x < x_len; x++) { - for (int z = 0; z < z_len; z++) { - returnVector[y][x][z] = inVector[index]; - index++; - } - } - } + // Returned in format "1,2,3,4,5" + std::vector returnVector; + splitCommaStringToInts(returnValue, returnVector); - return returnVector; - } + return unflattenHeightsArray(loc1, loc2, returnVector); +} - std::vector> - MinecraftConnection::unflattenHeightsArray(const Coordinate& loc1, const Coordinate& loc2, - const std::vector& inVector) { - // Initialise empty vector of correct size and shape - int x_len = abs(loc2.x - loc1.x) + 1; - int z_len = abs(loc2.z - loc1.z) + 1; - - std::vector> returnVector( - x_len, - std::vector( - z_len, - 0 - ) - ); - - int index = 0; +std::vector>> +MinecraftConnection::unflattenBlocksArray( + const Coordinate& loc1, const Coordinate& loc2, + const std::vector& inVector) { + // Initialise empty vector of correct size and shape + int y_len = abs(loc2.y - loc1.y) + 1; + int x_len = abs(loc2.x - loc1.x) + 1; + int z_len = abs(loc2.z - loc1.z) + 1; + std::vector>> returnVector( + y_len, std::vector>( + x_len, std::vector(z_len, BlockType(0)))); + + int index = 0; + for (int y = 0; y < y_len; y++) { for (int x = 0; x < x_len; x++) { for (int z = 0; z < z_len; z++) { - returnVector[x][z] = inVector[index]; + returnVector[y][x][z] = inVector[index]; index++; } } + } + + return returnVector; +} - return returnVector; +std::vector> +MinecraftConnection::unflattenHeightsArray(const Coordinate& loc1, + const Coordinate& loc2, + const std::vector& inVector) { + // Initialise empty vector of correct size and shape + int x_len = abs(loc2.x - loc1.x) + 1; + int z_len = abs(loc2.z - loc1.z) + 1; + + std::vector> returnVector(x_len, + std::vector(z_len, 0)); + + int index = 0; + for (int x = 0; x < x_len; x++) { + for (int z = 0; z < z_len; z++) { + returnVector[x][z] = inVector[index]; + index++; + } } + + return returnVector; } +} // namespace mcpp diff --git a/src/util.cpp b/src/util.cpp index ed87513c..04b035c1 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -2,48 +2,48 @@ namespace mcpp { - Coordinate::Coordinate(int x, int y, int z) { - this->x = x; - this->y = y; - this->z = z; - } - - Coordinate::Coordinate(double x, double y, double z) { - this->x = static_cast(x); - this->y = static_cast(y); - this->z = static_cast(z); - } - - Coordinate Coordinate::operator+(const Coordinate& obj) const { - Coordinate result; - result.x = this->x + obj.x; - result.y = this->y + obj.y; - result.z = this->z + obj.z; - return result; - } - - bool Coordinate::operator==(const Coordinate& obj) const { - return (this->x == obj.x) && (this->y == obj.y) && (this->z == obj.z); - } - - bool Coordinate::operator!=(const Coordinate& obj) const { - return !((*this) == obj); - } - - Coordinate Coordinate::operator-(const Coordinate& obj) const { - Coordinate result; - result.x = this->x - obj.x; - result.y = this->y - obj.y; - result.z = this->z - obj.z; - return result; - } - - Coordinate Coordinate::clone() const { - return Coordinate(this->x, this->y, this->z); - } - - std::ostream& operator<< (std::ostream& out, const Coordinate& coord) { - out << "(" << coord.x << ", " << coord.y << ", " << coord.z << ")"; - return out; - } +Coordinate::Coordinate(int x, int y, int z) { + this->x = x; + this->y = y; + this->z = z; } + +Coordinate::Coordinate(double x, double y, double z) { + this->x = static_cast(x); + this->y = static_cast(y); + this->z = static_cast(z); +} + +Coordinate Coordinate::operator+(const Coordinate& obj) const { + Coordinate result; + result.x = this->x + obj.x; + result.y = this->y + obj.y; + result.z = this->z + obj.z; + return result; +} + +bool Coordinate::operator==(const Coordinate& obj) const { + return (this->x == obj.x) && (this->y == obj.y) && (this->z == obj.z); +} + +bool Coordinate::operator!=(const Coordinate& obj) const { + return !(*this == obj); +} + +Coordinate Coordinate::operator-(const Coordinate& obj) const { + Coordinate result; + result.x = this->x - obj.x; + result.y = this->y - obj.y; + result.z = this->z - obj.z; + return result; +} + +Coordinate Coordinate::clone() const { + return Coordinate(this->x, this->y, this->z); +} + +std::ostream& operator<<(std::ostream& out, const Coordinate& coord) { + out << "(" << coord.x << ", " << coord.y << ", " << coord.z << ")"; + return out; +} +} // namespace mcpp diff --git a/test/local_tests.cpp b/test/local_tests.cpp index 5a00d019..3e7ed2a1 100644 --- a/test/local_tests.cpp +++ b/test/local_tests.cpp @@ -1,14 +1,15 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include "doctest.h" -#include "../include/mcpp/util.h" #include "../include/mcpp/block.h" +#include "../include/mcpp/util.h" +#include "doctest.h" using namespace mcpp; /* - * Used to test code that is not connection dependent such as the implementation of Coordinate and various other - * utility functions as well as Block functionality. + * Used to test code that is not connection dependent such as the implementation + * of Coordinate and various other utility functions as well as Block + * functionality. */ TEST_CASE("Test Coordinate class") { @@ -77,7 +78,6 @@ TEST_CASE("Test Coordinate class") { } TEST_CASE("Test block class") { - SUBCASE("Default ctor") { BlockType def; CHECK_EQ(def.id, 0); @@ -106,7 +106,6 @@ TEST_CASE("Test block class") { BlockType testBlock(10); BlockType testBlockRHS(10, 2); CHECK_EQ(testBlock.withMod(2), testBlockRHS); - } SUBCASE("Test print") { @@ -116,12 +115,3 @@ TEST_CASE("Test block class") { CHECK_EQ(ss.str(), "[2, 3]"); } } - -//TEST_CASE("Test entity class") { -// Entity testEntity = Entities::CHICKEN; -// -// SUBCASE("Equality operator") { -// Entity testEntityRHS(93); -// CHECK_EQ(testEntity, testEntityRHS); -// } -//} diff --git a/test/minecraft_tests.cpp b/test/minecraft_tests.cpp index bf579c31..5dc6ef4c 100644 --- a/test/minecraft_tests.cpp +++ b/test/minecraft_tests.cpp @@ -1,5 +1,5 @@ -#include "doctest.h" #include "../include/mcpp/mcpp.h" +#include "doctest.h" // Set to 1 if testing with joined player on server #define PLAYER_TEST 0 @@ -12,19 +12,20 @@ SocketConnection tcp_conn("localhost", 4711); MinecraftConnection mc; /* - * All tests require a running instance of Spigot server with the ELCI Legacy plugin in order to run successfully. This - * requirement stems from the fact that it's a pain in the ass to run a local TCP server just in order to test if the - * client is sending across a string successfully, and would probably require either writing or importing that - * TCP server from somewhere and writing around it in a way that does not block code execution when waiting for a - * connection. + * All tests require a running instance of Spigot server with the ELCI Legacy + * plugin in order to run successfully. This requirement stems from the fact + * that it's a pain in the ass to run a local TCP server just in order to test + * if the client is sending across a string successfully, and would probably + * require either writing or importing that TCP server from somewhere and + * writing around it in a way that does not block code execution when waiting + * for a connection. */ // Run test_suite profile to perform tests in this file. -TEST_CASE("Socket connection test") -{ - +TEST_CASE("Socket connection test") { SUBCASE("Test send") { - // More or less manual test case used more so to check for errors sending + // More or less manual test case used more so to check for errors + // sending tcp_conn.send("chat.post(test string)\n"); tcp_conn.send("player.setTile(100,100,100)\n"); } @@ -50,8 +51,8 @@ TEST_CASE("Socket connection test") SUBCASE("Send receive command") { tcp_conn.sendCommand("world.setBlock", 100, 100, 100, 30); tcp_conn.sendCommand("world.setBlock", 100, 100, 100, 26); - auto result = tcp_conn.sendReceiveCommand("world.getBlock", 100, 100, - 100); + auto result = + tcp_conn.sendReceiveCommand("world.getBlock", 100, 100, 100); CHECK_EQ(result, "26"); tcp_conn.sendCommand("world.setBlock", 100, 100, 100, 25); @@ -62,19 +63,21 @@ TEST_CASE("Socket connection test") SUBCASE("Test receive when response size is divisible by buffer size") { // Assuming buffer size is 1024 bytes int expectedResponseSize = 4096; - + // Test coordinate 1 int x1 = 0, y1 = 0, z1 = 0; // Test coordinate 2 int x2 = 31, y2 = 100, z2 = 31; - tcp_conn.sendCommand("world.setBlocks", x1, y1, z1, x2, y2, z2, Blocks::DIRT.id, Blocks::DIRT.mod); - std::string result = tcp_conn.sendReceiveCommand("world.getHeights",x1,z1,x2,z2); + tcp_conn.sendCommand("world.setBlocks", x1, y1, z1, x2, y2, z2, + Blocks::DIRT.id, Blocks::DIRT.mod); + std::string result = + tcp_conn.sendReceiveCommand("world.getHeights", x1, z1, x2, z2); int resultSize = result.size(); - + CHECK_EQ(resultSize, expectedResponseSize - 1); } - + SUBCASE("Check fail condition") { CHECK_THROWS(tcp_conn.sendReceiveCommand("failCommand", "")); } @@ -83,13 +86,9 @@ TEST_CASE("Socket connection test") TEST_CASE("Test the main mcpp class") { Coordinate testLoc(100, 100, 100); - SUBCASE("postToChat") { - mc.postToChat("test string"); - } + SUBCASE("postToChat") { mc.postToChat("test string"); } - SUBCASE("setBlock") { - mc.setBlock(testLoc, BlockType(50)); - } + SUBCASE("setBlock") { mc.setBlock(testLoc, BlockType(50)); } SUBCASE("getBlock") { mc.setBlock(testLoc, BlockType(34)); @@ -120,13 +119,8 @@ TEST_CASE("Test the main mcpp class") { // Create even heights mc.setBlocks(platformCoord1, platformCoord2, Blocks::DIRT); - std::vector expected = std::vector>( - 10, - std::vector( - 10, - 100 - ) - ); + std::vector expected = + std::vector>(10, std::vector(10, 100)); auto resultHeights = mc.getHeights(platformCoord1, platformCoord2); CHECK_EQ(resultHeights, expected); @@ -135,23 +129,14 @@ TEST_CASE("Test the main mcpp class") { // Used for cuboid functions Coordinate testLoc2(96, 96, 96); - SUBCASE("setBlocks") { - mc.setBlocks(testLoc, testLoc2, Blocks::STONE); - } + SUBCASE("setBlocks") { mc.setBlocks(testLoc, testLoc2, Blocks::STONE); } SUBCASE("getBlocks") { mc.setBlocks(testLoc, testLoc2, Blocks::DIRT); auto expected = std::vector>>( - 5, - std::vector>( - 5, - std::vector( - 5, - Blocks::DIRT - ) - ) - ); + 5, std::vector>( + 5, std::vector(5, Blocks::DIRT))); std::vector returnVector = mc.getBlocks(testLoc, testLoc2); CHECK_EQ(returnVector, expected); @@ -161,15 +146,8 @@ TEST_CASE("Test the main mcpp class") { mc.setBlocks(testLoc, testLoc2, Blocks::GRANITE); auto expected = std::vector>>( - 5, - std::vector>( - 5, - std::vector( - 5, - Blocks::GRANITE - ) - ) - ); + 5, std::vector>( + 5, std::vector(5, Blocks::GRANITE))); std::vector returnVector = mc.getBlocks(testLoc, testLoc2); @@ -177,15 +155,14 @@ TEST_CASE("Test the main mcpp class") { } } -// Requires player joined to server, will throw serverside if player is not joined and hang execution +// Requires player joined to server, will throw serverside if player is not +// joined and hang execution #if PLAYER_TEST TEST_CASE("Player operations") { Coordinate testLoc(110, 110, 110); mc.setBlock(testLoc, Blocks::DIRT); - SUBCASE("Execute command") { - mc.doCommand("time set noon"); - } + SUBCASE("Execute command") { mc.doCommand("time set noon"); } SUBCASE("Set position") { mc.setPlayerPosition(testLoc + Coordinate(0, 1, 0)); @@ -205,7 +182,6 @@ TEST_CASE("Player operations") { #endif - TEST_CASE("Test blocks struct") { Coordinate testLoc; mc.setBlock(testLoc, Blocks::AIR); @@ -213,4 +189,3 @@ TEST_CASE("Test blocks struct") { mc.setBlock(testLoc, Blocks::STONE); CHECK_EQ(mc.getBlock(testLoc), Blocks::STONE); } -