StaticInitializerOrder.cpp 20 KB

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