StaticInitializerOrder.cpp 22 KB

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