StaticInitializerOrder.cpp 19 KB

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