StaticInitializerOrder.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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 "BasicItems.h"
  21. #include "Hoe.h"
  22. #include "PlayerHand.h"
  23. #include "Shovel.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, "Air");
  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", 1),
  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", 1).setTransparent(),
  243. "WheatSeeds",
  244. BlockTypeEnum::WHEAT,
  245. "Growing wheat",
  246. 18000,
  247. 0x5076C011))
  248. ->addGrowthState(0.2f,
  249. ModelInfo("grass", "plants.ltdb/wheatseedsa.png", 1)
  250. .setTransparent())
  251. ->addGrowthState(0.4f,
  252. ModelInfo("grass", "plants.ltdb/wheatseedsb.png", 1)
  253. .setTransparent())
  254. ->addGrowthState(0.6f,
  255. ModelInfo("grass", "plants.ltdb/wheatseedsc.png", 1)
  256. .setTransparent())
  257. ->addGrowthState(0.8f,
  258. ModelInfo("grass", "plants.ltdb/wheatseedsd.png", 1)
  259. .setTransparent())
  260. ->initializeDefault();
  261. (new BasicBlockType(
  262. BlockTypeEnum::WHEAT,
  263. ItemTypeEnum::WHEAT,
  264. ModelInfo("grass", "plants.ltdb/wheat.png", 1),
  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. Vec3<float>(0.8f, 0.8f, 0.95f), 20, 8))
  280. ->initializeDefault();
  281. (new BasicBlockType(BlockTypeEnum::CRAFTING_TABLE,
  282. ItemTypeEnum::CRAFTING_TABLE,
  283. ModelInfo("cube",
  284. {"blocks.ltdb/woodplanks.png",
  285. "blocks.ltdb/woodplanks.png",
  286. "blocks.ltdb/woodplanks.png",
  287. "blocks.ltdb/woodplanks.png",
  288. "blocks.ltdb/craftingtable.p",
  289. "blocks.ltdb/woodplanks.png"}),
  290. "Crafting Table",
  291. 0xFFC4A783))
  292. ->initializeDefault(); // TODO: implement crafting table block type
  293. (new BasicBlockType(
  294. BlockTypeEnum::CHEST,
  295. ItemTypeEnum::CHEST,
  296. ModelInfo("blocks.m3/chest",
  297. {"blocks.ltdb/chest.png", "blocks.ltdb/chestcover.png"}),
  298. [](Framework::Vec3<int> pos, int dimensionId) {
  299. return new Chest(BlockTypeEnum::CHEST, 0, pos, dimensionId);
  300. },
  301. "Chest",
  302. 0xFFE2C292,
  303. 1))
  304. ->initializeDefault();
  305. }
  306. void initializeItemTypes()
  307. {
  308. (new BasicBlockItemType(ItemTypeEnum::DIRT,
  309. "Dirt",
  310. 0,
  311. 0,
  312. ModelInfo("itemCube", "blocks.ltdb/dirt.png", 6),
  313. BlockTypeEnum::DIRT));
  314. (new BasicBlockItemType(ItemTypeEnum::STONE,
  315. "Stone",
  316. 0,
  317. 0,
  318. ModelInfo("itemCube", "blocks.ltdb/stone.png", 6),
  319. BlockTypeEnum::STONE))
  320. ->setHardness(2.f);
  321. (new BasicBlockItemType(ItemTypeEnum::SAND,
  322. "Sand",
  323. 0,
  324. 0,
  325. ModelInfo("itemCube", "blocks.ltdb/sand.png", 6),
  326. BlockTypeEnum::SAND))
  327. ->setHardness(0.5f);
  328. (new BasicBlockItemType(ItemTypeEnum::WOOD_OAK,
  329. "Oak",
  330. 0,
  331. 0,
  332. ModelInfo("itemCube", "blocks.ltdb/oak.png", 6),
  333. BlockTypeEnum::WOOD_OAK))
  334. ->setHardness(1.5f);
  335. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_OAK,
  336. "Oak Leaves",
  337. 0,
  338. 0,
  339. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  340. BlockTypeEnum::LEAVES_WOOD_OAK))
  341. ->setHardness(0.1f);
  342. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_OAK,
  343. "Oak Sebling",
  344. 0,
  345. 0,
  346. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  347. BlockTypeEnum::SEBLING_WOOD_OAK))
  348. ->setHardness(0.1f);
  349. (new BasicBlockItemType(ItemTypeEnum::GRAVEL,
  350. "Gravel",
  351. 0,
  352. 0,
  353. ModelInfo("itemCube", "blocks.ltdb/gravel.png", 6),
  354. BlockTypeEnum::GRAVEL))
  355. ->setHardness(0.75f);
  356. (new BasicBlockItemType(ItemTypeEnum::STONE_GRANITE,
  357. "Granite",
  358. 0,
  359. 0,
  360. ModelInfo("itemCube", "blocks.ltdb/granite.png", 6),
  361. BlockTypeEnum::STONE_GRANITE))
  362. ->setHardness(3.f);
  363. (new BasicBlockItemType(ItemTypeEnum::STONE_COBBLE,
  364. "Cobble",
  365. 0,
  366. 0,
  367. ModelInfo("itemCube", "blocks.ltdb/cobble.png", 6),
  368. BlockTypeEnum::STONE_COBBLE))
  369. ->setHardness(1.f);
  370. (new BasicBlockItemType(ItemTypeEnum::WOOD_BIRCH,
  371. "Birch",
  372. 0,
  373. 0,
  374. ModelInfo("itemCube", "blocks.ltdb/birch.png", 6),
  375. BlockTypeEnum::WOOD_BIRCH))
  376. ->setHardness(1.5f);
  377. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_BIRCH,
  378. "Birch Leaves",
  379. 0,
  380. 0,
  381. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  382. BlockTypeEnum::LEAVES_WOOD_BIRCH))
  383. ->setHardness(0.1f);
  384. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_BIRCH,
  385. "Birch Sebling",
  386. 0,
  387. 0,
  388. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  389. BlockTypeEnum::SEBLING_WOOD_BIRCH))
  390. ->setHardness(0.1f);
  391. (new BasicBlockItemType(ItemTypeEnum::WOOD_BEECH,
  392. "Beech",
  393. 0,
  394. 0,
  395. ModelInfo("itemCube", "blocks.ltdb/beech.png", 6),
  396. BlockTypeEnum::WOOD_BEECH))
  397. ->setHardness(1.5f);
  398. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_BEECH,
  399. "Beech Leaves",
  400. 0,
  401. 0,
  402. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  403. BlockTypeEnum::LEAVES_WOOD_BEECH))
  404. ->setHardness(0.1f);
  405. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_BEECH,
  406. "Beech Sebling",
  407. 0,
  408. 0,
  409. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  410. BlockTypeEnum::SEBLING_WOOD_BEECH))
  411. ->setHardness(0.1f);
  412. (new BasicBlockItemType(ItemTypeEnum::STONE_BASALT,
  413. "Basalt",
  414. 0,
  415. 0,
  416. ModelInfo("itemCube", "blocks.ltdb/basalt.png", 6),
  417. BlockTypeEnum::STONE_BASALT))
  418. ->setHardness(2.f);
  419. (new BasicBlockItemType(ItemTypeEnum::WOOD_PINE,
  420. "Pine",
  421. 0,
  422. 0,
  423. ModelInfo("itemCube", "blocks.ltdb/pine.png", 6),
  424. BlockTypeEnum::WOOD_PINE))
  425. ->setHardness(1.4f);
  426. (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_PINE,
  427. "Pine Leaves",
  428. 0,
  429. 0,
  430. ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
  431. BlockTypeEnum::LEAVES_WOOD_PINE))
  432. ->setHardness(0.1f);
  433. (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_PINE,
  434. "Pine Sebling",
  435. 0,
  436. 0,
  437. ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
  438. BlockTypeEnum::SEBLING_WOOD_PINE))
  439. ->setHardness(0.1f);
  440. (new LightSourceItemType(ItemTypeEnum::TORCH,
  441. "Torch",
  442. ModelInfo("items.m3/stick", "blocks.ltdb/torch.png", 6),
  443. BlockTypeEnum::TORCH))
  444. ->setColor(0x00F69A54);
  445. new PlayerHandItemType();
  446. (new NoBlockItemType(ItemTypeEnum::WOOD_STICK,
  447. "WoodenStick",
  448. 0,
  449. 0,
  450. ModelInfo("items.m3/stick", "items.ltdb/stick.png", 1),
  451. []() {
  452. return ItemType::createBasicItem(ItemTypeEnum::WOOD_STICK,
  453. "Wooden Stick",
  454. 1.f,
  455. 1.f,
  456. 10.f,
  457. 10.f,
  458. 0,
  459. 0,
  460. 0,
  461. 1,
  462. 0,
  463. 50);
  464. }));
  465. (new NoBlockItemType(ItemTypeEnum::RESIN,
  466. "Resin",
  467. 0,
  468. 0,
  469. ModelInfo("itemCube", "items.ltdb/resin.png", 6),
  470. []() {
  471. return ItemType::createBasicItem(ItemTypeEnum::RESIN,
  472. "Resin",
  473. 1.f,
  474. 1.f,
  475. 10.f,
  476. 10.f,
  477. 0,
  478. 0,
  479. 0,
  480. 1,
  481. 0,
  482. 50);
  483. }));
  484. new AxeToolItemType();
  485. (new NoBlockItemType(ItemTypeEnum::AXE_BROKEN,
  486. "Broken Axe",
  487. 0,
  488. 0,
  489. ModelInfo("tools.m3/axe", "tools.ltdb/stoneaxe.png", 6),
  490. []() {
  491. return ItemType::createBasicItem(ItemTypeEnum::AXE_BROKEN,
  492. "Broken Axe",
  493. 100.f,
  494. 100.f,
  495. 100.f,
  496. 100.f,
  497. 0,
  498. 0,
  499. 0,
  500. 1,
  501. 0,
  502. 10);
  503. }));
  504. new HoeToolItemType();
  505. new NoBlockItemType(ItemTypeEnum::BROKEN_HOE,
  506. "BrokenHoe",
  507. 0,
  508. 0,
  509. ModelInfo("tools.m3/hoe", "tools.ltdb/stonehoe.png", 1),
  510. []() {
  511. return ItemType::createBasicItem(ItemTypeEnum::BROKEN_HOE,
  512. "Broken Hoe",
  513. 100.f,
  514. 100.f,
  515. 100.f,
  516. 100.f,
  517. 0,
  518. 0,
  519. 0,
  520. 1,
  521. 0,
  522. 10);
  523. });
  524. (new NoBlockItemType(ItemTypeEnum::FLINT,
  525. "Flint",
  526. 0,
  527. 0,
  528. ModelInfo("items.m3/flint", "items.ltdb/flint.png", 1),
  529. []() {
  530. return ItemType::createBasicItem(ItemTypeEnum::FLINT,
  531. "Flint",
  532. 1.f,
  533. 1.f,
  534. 10.f,
  535. 10.f,
  536. 0,
  537. 0,
  538. 0,
  539. 1,
  540. 0,
  541. 50);
  542. }));
  543. (new BasicBlockItemType(ItemTypeEnum::WHEAT_SEED,
  544. "Wheat Seeds",
  545. 0,
  546. 0,
  547. ModelInfo("grass", "plants.ltdb/wheatseeds.png", 1),
  548. BlockTypeEnum::WHEAT_SEED))
  549. ->setHardness(0.1f)
  550. ->setPlacableProof(
  551. [](const Item* self,
  552. int dimensionId,
  553. Framework::Vec3<int> worldPos) {
  554. if (worldPos.z > 0)
  555. {
  556. auto below = Game::INSTANCE->zBlockAt(
  557. worldPos + getDirection(Direction::BOTTOM),
  558. dimensionId);
  559. return (below.isA()
  560. && below.getA()->zBlockType()->getId()
  561. == BlockTypeEnum::FARMLAND)
  562. || (below.isB()
  563. && below.getB() == BlockTypeEnum::FARMLAND);
  564. }
  565. return (bool)0;
  566. },
  567. 1);
  568. (new NoBlockItemType(ItemTypeEnum::WHEAT,
  569. "Wheat",
  570. 0,
  571. 0,
  572. ModelInfo("grass", "plants.ltdb/wheat.png", 1),
  573. []() {
  574. Item* item = ItemType::createBasicItem(ItemTypeEnum::WHEAT,
  575. "Wheat",
  576. 1.f,
  577. 1.f,
  578. 10.f,
  579. 10.f,
  580. 1,
  581. 0,
  582. 0,
  583. 1,
  584. 0,
  585. 50);
  586. item->setFoodEffect(
  587. [](Item* zItem, Entity* zEntity) {
  588. float added = zItem->getHp() / 2.f;
  589. if (zEntity->getHunger() + added > zEntity->getMaxHunger())
  590. {
  591. added = zEntity->getMaxHunger() - zEntity->getHunger();
  592. }
  593. zEntity->setHunger(zEntity->getHunger() + added);
  594. zEntity->setThirst(
  595. zEntity->getThirst()
  596. + added * 2); // TODO: remove thirst addition
  597. // when drinkable water exists
  598. zItem->setHp(zItem->getHp() - added * 2.f);
  599. return added != 0.f;
  600. },
  601. [](const Item* zItem, Entity* zEntity) {
  602. float addable = zItem->getHp() / 2.f;
  603. if (zEntity->getHunger() + addable
  604. > zEntity->getMaxHunger())
  605. {
  606. return 0;
  607. }
  608. return 1;
  609. });
  610. return item;
  611. }));
  612. (new BasicBlockItemType(ItemTypeEnum::CRAFTING_TABLE,
  613. "Crafting Table",
  614. 0,
  615. 0,
  616. ModelInfo("itemCube",
  617. {"blocks.ltdb/woodplanks.png",
  618. "blocks.ltdb/woodplanks.png",
  619. "blocks.ltdb/woodplanks.png",
  620. "blocks.ltdb/woodplanks.png",
  621. "blocks.ltdb/craftingtable.p",
  622. "blocks.ltdb/woodplanks.png"}),
  623. BlockTypeEnum::CRAFTING_TABLE)); // TODO: implement crafting table item
  624. // type
  625. (new BasicBlockItemType(ItemTypeEnum::CHEST,
  626. "Chest",
  627. 0,
  628. 0,
  629. ModelInfo("blocks.m3/chest",
  630. {"blocks.ltdb/chest.png", "blocks.ltdb/chestcover.png"}),
  631. BlockTypeEnum::CHEST));
  632. new ShovelToolItemType();
  633. (new NoBlockItemType(ItemTypeEnum::SHOVEL_BROKEN,
  634. "Broken Shovel",
  635. 0,
  636. 0,
  637. ModelInfo("tools.m3/shovel", "tools.ltdb/stonehoe.png", 6),
  638. []() {
  639. return ItemType::createBasicItem(ItemTypeEnum::SHOVEL_BROKEN,
  640. "Broken Shovel",
  641. 100.f,
  642. 100.f,
  643. 100.f,
  644. 100.f,
  645. 0,
  646. 0,
  647. 0,
  648. 1,
  649. 0,
  650. 10);
  651. }));
  652. }
  653. void initializeEntityTypes()
  654. {
  655. new PlayerEntityType();
  656. new ItemEntityType();
  657. }
  658. void initializeDimensions()
  659. {
  660. // new OverworldDimension();
  661. }
  662. void initializeMultiblockTypes()
  663. {
  664. new MultiblockTreeStructureType();
  665. }