StaticInitializerOrder.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. #include "BlockType.h"
  2. #include "ItemType.h"
  3. #include "StaticRegistry.h"
  4. // block types
  5. #include "BasicBlocks.h"
  6. #include "Chest.h"
  7. #include "Grass.h"
  8. #include "GrowingPlant.h"
  9. #include "NoBlock.h"
  10. #include "TreeSeblingBlock.h"
  11. // fluid blocks
  12. #include "FluidBlock.h"
  13. // dimensions
  14. #include "OverworldDimension.h"
  15. // entities
  16. #include "ItemEntity.h"
  17. #include "Player.h"
  18. // item skills
  19. #include "Axe.h"
  20. #include "Hoe.h"
  21. #include "Shovel.h"
  22. #include "BasicItems.h"
  23. #include "PlayerHand.h"
  24. // world updates
  25. #include "AddEntityUpdate.h"
  26. #include "EntityRemovedUpdate.h"
  27. // Multiblocks
  28. #include "Game.h"
  29. #include "LightSources.h"
  30. #include "MultiblockTree.h"
  31. using namespace Framework;
  32. void initializeBlockTypes()
  33. {
  34. new NoBlockBlockType(BlockTypeEnum::NO_BLOCK, &NoBlock::INSTANCE);
  35. new NoBlockBlockType(BlockTypeEnum::AIR, &AirBlock::INSTANCE);
  36. (new BasicBlockType(BlockTypeEnum::DIRT,
  37. ItemTypeEnum::DIRT,
  38. ModelInfo("cube",
  39. {"blocks.ltdb/dirt.png",
  40. "blocks.ltdb/dirt.png",
  41. "blocks.ltdb/dirt.png",
  42. "blocks.ltdb/dirt.png",
  43. "blocks.ltdb/lawn.png",
  44. "blocks.ltdb/dirt.png"}),
  45. "Dirt",
  46. 0xFF3C7C29))
  47. ->initializeDefault();
  48. (new BasicBlockType(BlockTypeEnum::STONE,
  49. ItemTypeEnum::STONE,
  50. ModelInfo("cube", "blocks.ltdb/stone.png", 6),
  51. "Stone",
  52. 0xFF8E8E8D))
  53. ->setHardness(2.f)
  54. ->initializeDefault();
  55. (new BasicBlockType(BlockTypeEnum::SAND,
  56. ItemTypeEnum::SAND,
  57. ModelInfo("cube", "blocks.ltdb/sand.png", 6),
  58. "Sand",
  59. 0xFFAE8558))
  60. ->setHardness(0.5f)
  61. ->initializeDefault();
  62. (new BasicBlockType(BlockTypeEnum::WOOD_OAK,
  63. ItemTypeEnum::WOOD_OAK,
  64. ModelInfo("cube", "blocks.ltdb/oak.png", 6),
  65. "Oak Wood",
  66. 0xFF7F7A70))
  67. ->setHardness(1.5f)
  68. ->initializeDefault();
  69. (new BasicBlockType(
  70. BlockTypeEnum::LEAVES_WOOD_OAK,
  71. ItemTypeEnum::LEAVES_WOOD_OAK,
  72. ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
  73. [](Vec3<int> pos, int dimensionId) {
  74. AdditionalItemSpawningBlock* block
  75. = new AdditionalItemSpawningBlock(
  76. BlockTypeEnum::LEAVES_WOOD_OAK, 0, pos, dimensionId);
  77. block->addSpawn({1, 1, 0.015, ItemTypeEnum::SEBLING_WOOD_OAK});
  78. return (Block*)block;
  79. },
  80. "Oak Wood Leaves",
  81. 0xFF6A7C37))
  82. ->setHardness(0.1f)
  83. ->initializeDefault();
  84. (new BasicBlockType(BlockTypeEnum::GRAVEL,
  85. ItemTypeEnum::GRAVEL,
  86. ModelInfo("cube", "blocks.ltdb/gravel.png", 6),
  87. "Gravel",
  88. 0xFF928D8C))
  89. ->setHardness(0.75f)
  90. ->initializeDefault();
  91. (new BasicBlockType(BlockTypeEnum::STONE_GRANITE,
  92. ItemTypeEnum::STONE_GRANITE,
  93. ModelInfo("cube", "blocks.ltdb/granite.png", 6),
  94. "Granite Stone",
  95. 0xFF3B3A3E))
  96. ->setHardness(3.f)
  97. ->initializeDefault();
  98. (new BasicBlockType(BlockTypeEnum::STONE_COBBLE,
  99. ItemTypeEnum::STONE_COBBLE,
  100. ModelInfo("cube", "blocks.ltdb/cobble.png", 6),
  101. "Cobble Stone",
  102. 0xFF7E7875))
  103. ->setHardness(1.f)
  104. ->initializeDefault();
  105. (new BasicBlockType(BlockTypeEnum::WOOD_BIRCH,
  106. ItemTypeEnum::WOOD_BIRCH,
  107. ModelInfo("cube", "blocks.ltdb/birch.png", 6),
  108. "Birch Wood",
  109. 0xFF99999D))
  110. ->setHardness(1.5f)
  111. ->initializeDefault();
  112. (new BasicBlockType(
  113. BlockTypeEnum::LEAVES_WOOD_BIRCH,
  114. ItemTypeEnum::LEAVES_WOOD_BIRCH,
  115. ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
  116. [](Vec3<int> pos, int dimensionId) {
  117. AdditionalItemSpawningBlock* block
  118. = new AdditionalItemSpawningBlock(
  119. BlockTypeEnum::LEAVES_WOOD_BIRCH, 0, pos, dimensionId);
  120. block->addSpawn({1, 1, 0.03, ItemTypeEnum::SEBLING_WOOD_BIRCH});
  121. return (Block*)block;
  122. },
  123. "Birch Wood Leaves",
  124. 0xFF6A7C37))
  125. ->setHardness(0.1f)
  126. ->initializeDefault();
  127. (new BasicBlockType(BlockTypeEnum::WOOD_BEECH,
  128. ItemTypeEnum::WOOD_BEECH,
  129. ModelInfo("cube", "blocks.ltdb/beech.png", 6),
  130. "Beech Wood",
  131. 0xFF778172))
  132. ->setHardness(1.5f)
  133. ->initializeDefault();
  134. (new BasicBlockType(
  135. BlockTypeEnum::LEAVES_WOOD_BEECH,
  136. ItemTypeEnum::LEAVES_WOOD_BEECH,
  137. ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
  138. [](Vec3<int> pos, int dimensionId) {
  139. AdditionalItemSpawningBlock* block
  140. = new AdditionalItemSpawningBlock(
  141. BlockTypeEnum::LEAVES_WOOD_BEECH, 0, pos, dimensionId);
  142. block->addSpawn({1, 1, 0.02, ItemTypeEnum::SEBLING_WOOD_BEECH});
  143. return (Block*)block;
  144. },
  145. "Beech Wood Leaves",
  146. 0xFF6A7C37))
  147. ->setHardness(0.1f)
  148. ->initializeDefault();
  149. (new BasicBlockType(BlockTypeEnum::STONE_BASALT,
  150. ItemTypeEnum::STONE_BASALT,
  151. ModelInfo("cube", "blocks.ltdb/basalt.png", 6),
  152. "Basalt Stone",
  153. 0xFF595552))
  154. ->setHardness(2.f)
  155. ->initializeDefault();
  156. (new BasicBlockType(BlockTypeEnum::WOOD_PINE,
  157. ItemTypeEnum::WOOD_PINE,
  158. ModelInfo("cube", "blocks.ltdb/pine.png", 6),
  159. "Pine Wood",
  160. 0xFF786C72))
  161. ->setHardness(1.4f)
  162. ->initializeDefault();
  163. (new BasicBlockType(
  164. BlockTypeEnum::LEAVES_WOOD_PINE,
  165. ItemTypeEnum::LEAVES_WOOD_PINE,
  166. ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
  167. [](Vec3<int> pos, int dimensionId) {
  168. AdditionalItemSpawningBlock* block
  169. = new AdditionalItemSpawningBlock(
  170. BlockTypeEnum::LEAVES_WOOD_PINE, 0, pos, dimensionId);
  171. block->addSpawn({1, 1, 0.025, ItemTypeEnum::SEBLING_WOOD_PINE});
  172. return (Block*)block;
  173. },
  174. "Pine Wood Leaves",
  175. 0xFF6A7C37))
  176. ->setHardness(0.1f)
  177. ->initializeDefault();
  178. (new BasicLightSourceBlockType(BlockTypeEnum::TORCH,
  179. ItemTypeEnum::TORCH,
  180. ModelInfo("blocks.m3/torch", "blocks.ltdb/torch.png", 6),
  181. "Torch"))
  182. ->setHardness(0.f)
  183. ->setColor(0x00F69A54)
  184. ->initializeDefault();
  185. (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_OAK,
  186. ItemTypeEnum::SEBLING_WOOD_OAK,
  187. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  188. BlockTypeEnum::WOOD_OAK,
  189. BlockTypeEnum::LEAVES_WOOD_OAK,
  190. "Oak Wood Sebling",
  191. 0xFD6A7B3A))
  192. ->setHardness(0.1f)
  193. ->initializeDefault();
  194. (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_BIRCH,
  195. ItemTypeEnum::SEBLING_WOOD_BIRCH,
  196. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  197. BlockTypeEnum::WOOD_BIRCH,
  198. BlockTypeEnum::LEAVES_WOOD_BIRCH,
  199. "Birch Wood Sebling",
  200. 0xFD6A7B3A))
  201. ->setHardness(0.1f)
  202. ->initializeDefault();
  203. (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_BEECH,
  204. ItemTypeEnum::SEBLING_WOOD_BEECH,
  205. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  206. BlockTypeEnum::WOOD_BEECH,
  207. BlockTypeEnum::LEAVES_WOOD_BEECH,
  208. "Beech Wood Sebling",
  209. 0xFD6A7B3A))
  210. ->setHardness(0.1f)
  211. ->initializeDefault();
  212. (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_PINE,
  213. ItemTypeEnum::SEBLING_WOOD_PINE,
  214. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  215. BlockTypeEnum::WOOD_PINE,
  216. BlockTypeEnum::LEAVES_WOOD_PINE,
  217. "Pine Wood Sebling",
  218. 0xFD6A7B3A))
  219. ->setHardness(0.1f)
  220. ->initializeDefault();
  221. (new GrassBlockType(BlockTypeEnum::GRASS,
  222. ItemTypeEnum::GRASS,
  223. ModelInfo("grass", "blocks.ltdb/grass.png", 16).setTransparent(),
  224. "Grass",
  225. 0x5076C011))
  226. ->initializeDefault();
  227. (new BasicBlockType(BlockTypeEnum::FARMLAND,
  228. ItemTypeEnum::DIRT,
  229. ModelInfo("cube",
  230. {"blocks.ltdb/dirt.png",
  231. "blocks.ltdb/dirt.png",
  232. "blocks.ltdb/dirt.png",
  233. "blocks.ltdb/dirt.png",
  234. "blocks.ltdb/farmland.png",
  235. "blocks.ltdb/dirt.png"}),
  236. "Farmland",
  237. 0xFF5E3819))
  238. ->setTransparent(1)
  239. ->setHardness(0.1f)
  240. ->initializeDefault();
  241. (new GrowingPlantBlockType(BlockTypeEnum::WHEAT_SEED,
  242. ModelInfo("grass", "plants.ltdb/wheatseeds.png", 16).setTransparent(),
  243. "WheatSeeds",
  244. BlockTypeEnum::WHEAT,
  245. "Growing wheat",
  246. 18000,
  247. 0x5076C011))
  248. ->addGrowthState(0.2f,
  249. ModelInfo("grass", "plants.ltdb/wheatseedsa.png", 16)
  250. .setTransparent())
  251. ->addGrowthState(0.4f,
  252. ModelInfo("grass", "plants.ltdb/wheatseedsb.png", 16)
  253. .setTransparent())
  254. ->addGrowthState(0.6f,
  255. ModelInfo("grass", "plants.ltdb/wheatseedsc.png", 16)
  256. .setTransparent())
  257. ->addGrowthState(0.8f,
  258. ModelInfo("grass", "plants.ltdb/wheatseedsd.png", 16)
  259. .setTransparent())
  260. ->initializeDefault();
  261. (new BasicBlockType(
  262. BlockTypeEnum::WHEAT,
  263. ItemTypeEnum::WHEAT,
  264. ModelInfo("grass", "plants.ltdb/wheat.png", 16).setTransparent(),
  265. [](Vec3<int> pos, int dimensionId) {
  266. AdditionalItemSpawningBlock* block
  267. = new AdditionalItemSpawningBlock(
  268. BlockTypeEnum::WHEAT, 0, pos, dimensionId);
  269. block->addSpawn({0, 4, 1.0, ItemTypeEnum::WHEAT});
  270. return (Block*)block;
  271. },
  272. "Wheat",
  273. 0x90A8C011))
  274. ->initializeDefault();
  275. (new FluidBlockType(BlockTypeEnum::WATER,
  276. ModelInfo("fluid", "fluids.ltdb/water.png", 6),
  277. "Water",
  278. 0xFF2323BF))
  279. ->initializeDefault();
  280. (new BasicBlockType(BlockTypeEnum::CRAFTING_TABLE,
  281. ItemTypeEnum::CRAFTING_TABLE,
  282. ModelInfo("cube",
  283. {"blocks.ltdb/woodplanks.png",
  284. "blocks.ltdb/woodplanks.png",
  285. "blocks.ltdb/woodplanks.png",
  286. "blocks.ltdb/woodplanks.png",
  287. "blocks.ltdb/craftingtable.p",
  288. "blocks.ltdb/woodplanks.png"}),
  289. "Crafting Table",
  290. 0xFFC4A783))
  291. ->initializeDefault(); // TODO: implement crafting table block type
  292. (new BasicBlockType(
  293. BlockTypeEnum::CHEST,
  294. ItemTypeEnum::CHEST,
  295. ModelInfo("blocks.m3/chest",
  296. {"blocks.ltdb/chest.png", "blocks.ltdb/chestcover.png"}),
  297. [](Framework::Vec3<int> pos, int dimensionId) {
  298. return new Chest(BlockTypeEnum::CHEST, 0, pos, dimensionId);
  299. },
  300. "Chest",
  301. 0xFFE2C292,
  302. 1))
  303. ->initializeDefault();
  304. }
  305. void initializeItemTypes()
  306. {
  307. (new BasicBlockItemType(ItemTypeEnum::DIRT,
  308. "Dirt",
  309. 0,
  310. 0,
  311. ModelInfo("itemCube", "blocks.ltdb/dirt.png", 6),
  312. BlockTypeEnum::DIRT));
  313. (new BasicBlockItemType(ItemTypeEnum::STONE,
  314. "Stone",
  315. 0,
  316. 0,
  317. ModelInfo("itemCube", "blocks.ltdb/stone.png", 6),
  318. BlockTypeEnum::STONE))
  319. ->setHardness(2.f);
  320. (new BasicBlockItemType(ItemTypeEnum::SAND,
  321. "Sand",
  322. 0,
  323. 0,
  324. ModelInfo("itemCube", "blocks.ltdb/sand.png", 6),
  325. BlockTypeEnum::SAND))
  326. ->setHardness(0.5f);
  327. (new BasicBlockItemType(ItemTypeEnum::WOOD_OAK,
  328. "Oak",
  329. 0,
  330. 0,
  331. ModelInfo("itemCube", "blocks.ltdb/oak.png", 6),
  332. BlockTypeEnum::WOOD_OAK))
  333. ->setHardness(1.5f);
  334. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_OAK,
  335. "Oak Leaves",
  336. 0,
  337. 0,
  338. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  339. BlockTypeEnum::LEAVES_WOOD_OAK))
  340. ->setHardness(0.1f);
  341. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_OAK,
  342. "Oak Sebling",
  343. 0,
  344. 0,
  345. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  346. BlockTypeEnum::SEBLING_WOOD_OAK))
  347. ->setHardness(0.1f);
  348. (new BasicBlockItemType(ItemTypeEnum::GRAVEL,
  349. "Gravel",
  350. 0,
  351. 0,
  352. ModelInfo("itemCube", "blocks.ltdb/gravel.png", 6),
  353. BlockTypeEnum::GRAVEL))
  354. ->setHardness(0.75f);
  355. (new BasicBlockItemType(ItemTypeEnum::STONE_GRANITE,
  356. "Granite",
  357. 0,
  358. 0,
  359. ModelInfo("itemCube", "blocks.ltdb/granite.png", 6),
  360. BlockTypeEnum::STONE_GRANITE))
  361. ->setHardness(3.f);
  362. (new BasicBlockItemType(ItemTypeEnum::STONE_COBBLE,
  363. "Cobble",
  364. 0,
  365. 0,
  366. ModelInfo("itemCube", "blocks.ltdb/cobble.png", 6),
  367. BlockTypeEnum::STONE_COBBLE))
  368. ->setHardness(1.f);
  369. (new BasicBlockItemType(ItemTypeEnum::WOOD_BIRCH,
  370. "Birch",
  371. 0,
  372. 0,
  373. ModelInfo("itemCube", "blocks.ltdb/birch.png", 6),
  374. BlockTypeEnum::WOOD_BIRCH))
  375. ->setHardness(1.5f);
  376. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_BIRCH,
  377. "Birch Leaves",
  378. 0,
  379. 0,
  380. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  381. BlockTypeEnum::LEAVES_WOOD_BIRCH))
  382. ->setHardness(0.1f);
  383. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_BIRCH,
  384. "Birch Sebling",
  385. 0,
  386. 0,
  387. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  388. BlockTypeEnum::SEBLING_WOOD_BIRCH))
  389. ->setHardness(0.1f);
  390. (new BasicBlockItemType(ItemTypeEnum::WOOD_BEECH,
  391. "Beech",
  392. 0,
  393. 0,
  394. ModelInfo("itemCube", "blocks.ltdb/beech.png", 6),
  395. BlockTypeEnum::WOOD_BEECH))
  396. ->setHardness(1.5f);
  397. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_BEECH,
  398. "Beech Leaves",
  399. 0,
  400. 0,
  401. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  402. BlockTypeEnum::LEAVES_WOOD_BEECH))
  403. ->setHardness(0.1f);
  404. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_BEECH,
  405. "Beech Sebling",
  406. 0,
  407. 0,
  408. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  409. BlockTypeEnum::SEBLING_WOOD_BEECH))
  410. ->setHardness(0.1f);
  411. (new BasicBlockItemType(ItemTypeEnum::STONE_BASALT,
  412. "Basalt",
  413. 0,
  414. 0,
  415. ModelInfo("itemCube", "blocks.ltdb/basalt.png", 6),
  416. BlockTypeEnum::STONE_BASALT))
  417. ->setHardness(2.f);
  418. (new BasicBlockItemType(ItemTypeEnum::WOOD_PINE,
  419. "Pine",
  420. 0,
  421. 0,
  422. ModelInfo("itemCube", "blocks.ltdb/pine.png", 6),
  423. BlockTypeEnum::WOOD_PINE))
  424. ->setHardness(1.4f);
  425. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_PINE,
  426. "Pine Leaves",
  427. 0,
  428. 0,
  429. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  430. BlockTypeEnum::LEAVES_WOOD_PINE))
  431. ->setHardness(0.1f);
  432. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_PINE,
  433. "Pine Sebling",
  434. 0,
  435. 0,
  436. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  437. BlockTypeEnum::SEBLING_WOOD_PINE))
  438. ->setHardness(0.1f);
  439. (new LightSourceItemType(ItemTypeEnum::TORCH,
  440. "Torch",
  441. ModelInfo("items.m3/stick", "blocks.ltdb/torch.png", 6),
  442. BlockTypeEnum::TORCH))
  443. ->setColor(0x00F69A54);
  444. new PlayerHandItemType();
  445. (new NoBlockItemType(ItemTypeEnum::WOOD_STICK,
  446. "WoodenStick",
  447. 0,
  448. 0,
  449. ModelInfo("items.m3/stick", "items.ltdb/stick.png", 1),
  450. []() {
  451. return ItemType::createBasicItem(ItemTypeEnum::WOOD_STICK,
  452. "Wooden Stick",
  453. 1.f,
  454. 1.f,
  455. 10.f,
  456. 10.f,
  457. 0,
  458. 0,
  459. 0,
  460. 1,
  461. 0,
  462. 50);
  463. }));
  464. (new NoBlockItemType(ItemTypeEnum::RESIN,
  465. "Resin",
  466. 0,
  467. 0,
  468. ModelInfo("itemCube", "items.ltdb/resin.png", 6),
  469. []() {
  470. return ItemType::createBasicItem(ItemTypeEnum::RESIN,
  471. "Resin",
  472. 1.f,
  473. 1.f,
  474. 10.f,
  475. 10.f,
  476. 0,
  477. 0,
  478. 0,
  479. 1,
  480. 0,
  481. 50);
  482. }));
  483. new AxeToolItemType();
  484. (new NoBlockItemType(ItemTypeEnum::AXE_BROKEN,
  485. "Broken Axe",
  486. 0,
  487. 0,
  488. ModelInfo("tools.m3/axe", "tools.ltdb/stoneaxe.png", 6),
  489. []() {
  490. return ItemType::createBasicItem(ItemTypeEnum::AXE_BROKEN,
  491. "Broken Axe",
  492. 100.f,
  493. 100.f,
  494. 100.f,
  495. 100.f,
  496. 0,
  497. 0,
  498. 0,
  499. 1,
  500. 0,
  501. 10);
  502. }));
  503. new HoeToolItemType();
  504. new NoBlockItemType(ItemTypeEnum::BROKEN_HOE,
  505. "BrokenHoe",
  506. 0,
  507. 0,
  508. ModelInfo("tools.m3/hoe", "tools.ltdb/stonehoe.png", 1),
  509. []() {
  510. return ItemType::createBasicItem(ItemTypeEnum::BROKEN_HOE,
  511. "Broken Hoe",
  512. 100.f,
  513. 100.f,
  514. 100.f,
  515. 100.f,
  516. 0,
  517. 0,
  518. 0,
  519. 1,
  520. 0,
  521. 10);
  522. });
  523. (new NoBlockItemType(ItemTypeEnum::FLINT,
  524. "Flint",
  525. 0,
  526. 0,
  527. ModelInfo("items.m3/flint", "items.ltdb/flint.png", 1),
  528. []() {
  529. return ItemType::createBasicItem(ItemTypeEnum::FLINT,
  530. "Flint",
  531. 1.f,
  532. 1.f,
  533. 10.f,
  534. 10.f,
  535. 0,
  536. 0,
  537. 0,
  538. 1,
  539. 0,
  540. 50);
  541. }));
  542. (new BasicBlockItemType(ItemTypeEnum::WHEAT_SEED,
  543. "Wheat Seeds",
  544. 0,
  545. 0,
  546. ModelInfo("grass", "plants.ltdb/wheatseeds.png", 16),
  547. BlockTypeEnum::WHEAT_SEED))
  548. ->setHardness(0.1f)
  549. ->setPlacableProof(
  550. [](const Item* self,
  551. int dimensionId,
  552. Framework::Vec3<int> worldPos) {
  553. if (worldPos.z > 0)
  554. {
  555. auto below = Game::INSTANCE->zBlockAt(
  556. worldPos + getDirection(Direction::BOTTOM),
  557. dimensionId);
  558. return (below.isA()
  559. && below.getA()->zBlockType()->getId()
  560. == BlockTypeEnum::FARMLAND)
  561. || (below.isB()
  562. && below.getB() == BlockTypeEnum::FARMLAND);
  563. }
  564. return (bool)0;
  565. },
  566. 1);
  567. (new NoBlockItemType(ItemTypeEnum::WHEAT,
  568. "Wheat",
  569. 0,
  570. 0,
  571. ModelInfo("grass", "plants.ltdb/wheat.png", 16),
  572. []() {
  573. Item* item = ItemType::createBasicItem(ItemTypeEnum::WHEAT,
  574. "Wheat",
  575. 1.f,
  576. 1.f,
  577. 10.f,
  578. 10.f,
  579. 1,
  580. 0,
  581. 0,
  582. 1,
  583. 0,
  584. 50);
  585. item->setFoodEffect([](Entity* zEntity) {
  586. zEntity->setHunger(zEntity->getHunger() + 0.5f);
  587. zEntity->setThirst(
  588. zEntity->getThirst() + 1.f); // TODO: remove thirst addition
  589. // when drinkable water exists
  590. });
  591. return item;
  592. }));
  593. (new BasicBlockItemType(ItemTypeEnum::CRAFTING_TABLE,
  594. "Crafting Table",
  595. 0,
  596. 0,
  597. ModelInfo("itemCube",
  598. {"blocks.ltdb/woodplanks.png",
  599. "blocks.ltdb/woodplanks.png",
  600. "blocks.ltdb/woodplanks.png",
  601. "blocks.ltdb/woodplanks.png",
  602. "blocks.ltdb/craftingtable.p",
  603. "blocks.ltdb/woodplanks.png"}),
  604. BlockTypeEnum::CRAFTING_TABLE)); // TODO: implement crafting table item
  605. // type
  606. (new BasicBlockItemType(ItemTypeEnum::CHEST,
  607. "Chest",
  608. 0,
  609. 0,
  610. ModelInfo("blocks.m3/chest",
  611. {"blocks.ltdb/chest.png", "blocks.ltdb/chestcover.png"}),
  612. BlockTypeEnum::CHEST));
  613. new ShovelToolItemType();
  614. (new NoBlockItemType(ItemTypeEnum::SHOVEL_BROKEN,
  615. "Broken Shovel",
  616. 0,
  617. 0,
  618. ModelInfo("tools.m3/shovel", "tools.ltdb/stonehoe.png", 6),
  619. []() {
  620. return ItemType::createBasicItem(ItemTypeEnum::SHOVEL_BROKEN,
  621. "Broken Shovel",
  622. 100.f,
  623. 100.f,
  624. 100.f,
  625. 100.f,
  626. 0,
  627. 0,
  628. 0,
  629. 1,
  630. 0,
  631. 10);
  632. }));
  633. }
  634. void initializeEntityTypes()
  635. {
  636. new PlayerEntityType();
  637. new ItemEntityType();
  638. }
  639. void initializeDimensions()
  640. {
  641. new OverworldDimension();
  642. }
  643. void initializeMultiblockTypes()
  644. {
  645. new MultiblockTreeStructureType();
  646. }