123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596 |
- #include "BlockType.h"
- #include "ItemType.h"
- #include "StaticRegistry.h"
- // block types
- #include "BasicBlocks.h"
- #include "Grass.h"
- #include "GrowingPlant.h"
- #include "NoBlock.h"
- #include "TreeSeblingBlock.h"
- // fluid blocks
- #include "FluidBlock.h"
- // dimensions
- #include "OverworldDimension.h"
- // entities
- #include "ItemEntity.h"
- #include "Player.h"
- // item skills
- #include "BasicItems.h"
- #include "PlayerHand.h"
- #include "StoneTool.h"
- // world updates
- #include "AddEntityUpdate.h"
- #include "EntityRemovedUpdate.h"
- // Multiblocks
- #include "Game.h"
- #include "Hoe.h"
- #include "LightSources.h"
- #include "MultiblockTree.h"
- using namespace Framework;
- void initializeBlockTypes()
- {
- new NoBlockBlockType(BlockTypeEnum::NO_BLOCK, &NoBlock::INSTANCE);
- new NoBlockBlockType(BlockTypeEnum::AIR, &AirBlock::INSTANCE);
- (new BasicBlockType(BlockTypeEnum::DIRT,
- ItemTypeEnum::DIRT,
- ModelInfo("cube",
- {"blocks.ltdb/dirt.png",
- "blocks.ltdb/dirt.png",
- "blocks.ltdb/dirt.png",
- "blocks.ltdb/dirt.png",
- "blocks.ltdb/lawn.png",
- "blocks.ltdb/dirt.png"}),
- "Dirt"))
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::STONE,
- ItemTypeEnum::STONE,
- ModelInfo("cube", "blocks.ltdb/stone.png", 6),
- "Stone"))
- ->setHardness(2.f)
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::SAND,
- ItemTypeEnum::SAND,
- ModelInfo("cube", "blocks.ltdb/sand.png", 6),
- "Sand"))
- ->setHardness(0.5f)
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::WOOD_OAK,
- ItemTypeEnum::WOOD_OAK,
- ModelInfo("cube", "blocks.ltdb/oak.png", 6),
- "Oak Wood"))
- ->setHardness(1.5f)
- ->initializeDefault();
- (new BasicBlockType(
- BlockTypeEnum::LEAVES_WOOD_OAK,
- ItemTypeEnum::LEAVES_WOOD_OAK,
- ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
- [](Vec3<int> pos) {
- AdditionalItemSpawningBlock* block
- = new AdditionalItemSpawningBlock(
- BlockTypeEnum::LEAVES_WOOD_OAK, 0, pos);
- block->addSpawn({1, 1, 0.015, ItemTypeEnum::SEBLING_WOOD_OAK});
- return (Block*)block;
- },
- "Oak Wood Leaves"))
- ->setHardness(0.1f)
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::GRAVEL,
- ItemTypeEnum::GRAVEL,
- ModelInfo("cube", "blocks.ltdb/gravel.png", 6),
- "Gravel"))
- ->setHardness(0.75f)
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::STONE_GRANITE,
- ItemTypeEnum::STONE_GRANITE,
- ModelInfo("cube", "blocks.ltdb/granite.png", 6),
- "Granite Stone"))
- ->setHardness(3.f)
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::STONE_COBBLE,
- ItemTypeEnum::STONE_COBBLE,
- ModelInfo("cube", "blocks.ltdb/cobble.png", 6),
- "Cobble Stone"))
- ->setHardness(1.f)
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::WOOD_BIRCH,
- ItemTypeEnum::WOOD_BIRCH,
- ModelInfo("cube", "blocks.ltdb/birch.png", 6),
- "Birch Wood"))
- ->setHardness(1.5f)
- ->initializeDefault();
- (new BasicBlockType(
- BlockTypeEnum::LEAVES_WOOD_BIRCH,
- ItemTypeEnum::LEAVES_WOOD_BIRCH,
- ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
- [](Vec3<int> pos) {
- AdditionalItemSpawningBlock* block
- = new AdditionalItemSpawningBlock(
- BlockTypeEnum::LEAVES_WOOD_BIRCH, 0, pos);
- block->addSpawn({1, 1, 0.03, ItemTypeEnum::SEBLING_WOOD_BIRCH});
- return (Block*)block;
- },
- "Birch Wood Leaves"))
- ->setHardness(0.1f)
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::WOOD_BEECH,
- ItemTypeEnum::WOOD_BEECH,
- ModelInfo("cube", "blocks.ltdb/beech.png", 6),
- "Beech Wood"))
- ->setHardness(1.5f)
- ->initializeDefault();
- (new BasicBlockType(
- BlockTypeEnum::LEAVES_WOOD_BEECH,
- ItemTypeEnum::LEAVES_WOOD_BEECH,
- ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
- [](Vec3<int> pos) {
- AdditionalItemSpawningBlock* block
- = new AdditionalItemSpawningBlock(
- BlockTypeEnum::LEAVES_WOOD_BEECH, 0, pos);
- block->addSpawn({1, 1, 0.02, ItemTypeEnum::SEBLING_WOOD_BEECH});
- return (Block*)block;
- },
- "Beech Wood Leaves"))
- ->setHardness(0.1f)
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::STONE_BASALT,
- ItemTypeEnum::STONE_BASALT,
- ModelInfo("cube", "blocks.ltdb/basalt.png", 6),
- "Basalt Stone"))
- ->setHardness(2.f)
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::WOOD_PINE,
- ItemTypeEnum::WOOD_PINE,
- ModelInfo("cube", "blocks.ltdb/pine.png", 6),
- "Pine Wood"))
- ->setHardness(1.4f)
- ->initializeDefault();
- (new BasicBlockType(
- BlockTypeEnum::LEAVES_WOOD_PINE,
- ItemTypeEnum::LEAVES_WOOD_PINE,
- ModelInfo("cube", "blocks.ltdb/leaves.png", 6),
- [](Vec3<int> pos) {
- AdditionalItemSpawningBlock* block
- = new AdditionalItemSpawningBlock(
- BlockTypeEnum::LEAVES_WOOD_PINE, 0, pos);
- block->addSpawn({1, 1, 0.025, ItemTypeEnum::SEBLING_WOOD_PINE});
- return (Block*)block;
- },
- "Pine Wood Leaves"))
- ->setHardness(0.1f)
- ->initializeDefault();
- (new BasicLightSourceBlockType(BlockTypeEnum::TORCH,
- ItemTypeEnum::TORCH,
- ModelInfo("blocks.m3/torch", "blocks.ltdb/torch.png", 6),
- "Torch"))
- ->setHardness(0.f)
- ->setColor(0x00F69A54)
- ->initializeDefault();
- (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_OAK,
- ItemTypeEnum::SEBLING_WOOD_OAK,
- ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
- BlockTypeEnum::WOOD_OAK,
- BlockTypeEnum::LEAVES_WOOD_OAK,
- "Oak Wood Sebling"))
- ->setHardness(0.1f)
- ->initializeDefault();
- (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_BIRCH,
- ItemTypeEnum::SEBLING_WOOD_BIRCH,
- ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
- BlockTypeEnum::WOOD_BIRCH,
- BlockTypeEnum::LEAVES_WOOD_BIRCH,
- "Birch Wood Sebling"))
- ->setHardness(0.1f)
- ->initializeDefault();
- (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_BEECH,
- ItemTypeEnum::SEBLING_WOOD_BEECH,
- ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
- BlockTypeEnum::WOOD_BEECH,
- BlockTypeEnum::LEAVES_WOOD_BEECH,
- "Beech Wood Sebling"))
- ->setHardness(0.1f)
- ->initializeDefault();
- (new TreeSeblingBlockType(BlockTypeEnum::SEBLING_WOOD_PINE,
- ItemTypeEnum::SEBLING_WOOD_PINE,
- ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
- BlockTypeEnum::WOOD_PINE,
- BlockTypeEnum::LEAVES_WOOD_PINE,
- "Pine Wood Sebling"))
- ->setHardness(0.1f)
- ->initializeDefault();
- (new GrassBlockType(BlockTypeEnum::GRASS,
- ItemTypeEnum::GRASS,
- ModelInfo("grass", "blocks.ltdb/grass.png", 16).setTransparent(),
- "Grass"))
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::FARMLAND,
- ItemTypeEnum::DIRT,
- ModelInfo("cube",
- {"blocks.ltdb/dirt.png",
- "blocks.ltdb/dirt.png",
- "blocks.ltdb/dirt.png",
- "blocks.ltdb/dirt.png",
- "blocks.ltdb/farmland.png",
- "blocks.ltdb/dirt.png"}),
- "Farmland"))
- ->setTransparent(1)
- ->setHardness(0.1f)
- ->initializeDefault();
- (new GrowingPlantBlockType(BlockTypeEnum::WHEAT_SEED,
- ModelInfo("grass", "plants.ltdb/wheatseeds.png", 16).setTransparent(),
- "WheatSeeds",
- BlockTypeEnum::WHEAT,
- "Growing wheat",
- 18000))
- ->addGrowthState(0.2f,
- ModelInfo("grass", "plants.ltdb/wheatseedsa.png", 16)
- .setTransparent())
- ->addGrowthState(0.4f,
- ModelInfo("grass", "plants.ltdb/wheatseedsb.png", 16)
- .setTransparent())
- ->addGrowthState(0.6f,
- ModelInfo("grass", "plants.ltdb/wheatseedsc.png", 16)
- .setTransparent())
- ->addGrowthState(0.8f,
- ModelInfo("grass", "plants.ltdb/wheatseedsd.png", 16)
- .setTransparent())
- ->initializeDefault();
- (new BasicBlockType(
- BlockTypeEnum::WHEAT,
- ItemTypeEnum::WHEAT,
- ModelInfo("grass", "plants.ltdb/wheat.png", 16).setTransparent(),
- [](Vec3<int> pos) {
- AdditionalItemSpawningBlock* block
- = new AdditionalItemSpawningBlock(
- BlockTypeEnum::WHEAT, 0, pos);
- block->addSpawn({0, 4, 1.0, ItemTypeEnum::WHEAT});
- return (Block*)block;
- },
- "Wheat"))
- ->initializeDefault();
- (new FluidBlockType(BlockTypeEnum::WATER,
- ModelInfo("fluid", "fluids.ltdb/water.png", 6),
- "Water"))
- ->initializeDefault();
- (new BasicBlockType(BlockTypeEnum::CRAFTING_TABLE,
- ItemTypeEnum::CRAFTING_TABLE,
- ModelInfo("cube",
- {"blocks.ltdb/woodplanks.png",
- "blocks.ltdb/woodplanks.png",
- "blocks.ltdb/woodplanks.png",
- "blocks.ltdb/woodplanks.png",
- "blocks.ltdb/craftingtable.p",
- "blocks.ltdb/woodplanks.png"}),
- "Crafting Table"))
- ->initializeDefault(); // TODO: implement crafting table block type
- }
- void initializeItemTypes()
- {
- (new BasicBlockItemType(ItemTypeEnum::DIRT,
- "Dirt",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/dirt.png", 6),
- BlockTypeEnum::DIRT));
- (new BasicBlockItemType(ItemTypeEnum::STONE,
- "Stone",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/stone.png", 6),
- BlockTypeEnum::STONE))
- ->setHardness(2.f);
- (new BasicBlockItemType(ItemTypeEnum::SAND,
- "Sand",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/sand.png", 6),
- BlockTypeEnum::SAND))
- ->setHardness(0.5f);
- (new BasicBlockItemType(ItemTypeEnum::WOOD_OAK,
- "Oak",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/oak.png", 6),
- BlockTypeEnum::WOOD_OAK))
- ->setHardness(1.5f);
- (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_OAK,
- "Oak Leaves",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
- BlockTypeEnum::LEAVES_WOOD_OAK))
- ->setHardness(0.1f);
- (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_OAK,
- "Oak Sebling",
- 0,
- 0,
- ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
- BlockTypeEnum::SEBLING_WOOD_OAK))
- ->setHardness(0.1f);
- (new BasicBlockItemType(ItemTypeEnum::GRAVEL,
- "Gravel",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/gravel.png", 6),
- BlockTypeEnum::GRAVEL))
- ->setHardness(0.75f);
- (new BasicBlockItemType(ItemTypeEnum::STONE_GRANITE,
- "Granite",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/granite.png", 6),
- BlockTypeEnum::STONE_GRANITE))
- ->setHardness(3.f);
- (new BasicBlockItemType(ItemTypeEnum::STONE_COBBLE,
- "Cobble",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/cobble.png", 6),
- BlockTypeEnum::STONE_COBBLE))
- ->setHardness(1.f);
- (new BasicBlockItemType(ItemTypeEnum::WOOD_BIRCH,
- "Birch",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/birch.png", 6),
- BlockTypeEnum::WOOD_BIRCH))
- ->setHardness(1.5f);
- (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_BIRCH,
- "Birch Leaves",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
- BlockTypeEnum::LEAVES_WOOD_BIRCH))
- ->setHardness(0.1f);
- (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_BIRCH,
- "Birch Sebling",
- 0,
- 0,
- ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
- BlockTypeEnum::SEBLING_WOOD_BIRCH))
- ->setHardness(0.1f);
- (new BasicBlockItemType(ItemTypeEnum::WOOD_BEECH,
- "Beech",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/beech.png", 6),
- BlockTypeEnum::WOOD_BEECH))
- ->setHardness(1.5f);
- (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_BEECH,
- "Beech Leaves",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
- BlockTypeEnum::LEAVES_WOOD_BEECH))
- ->setHardness(0.1f);
- (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_BEECH,
- "Beech Sebling",
- 0,
- 0,
- ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
- BlockTypeEnum::SEBLING_WOOD_BEECH))
- ->setHardness(0.1f);
- (new BasicBlockItemType(ItemTypeEnum::STONE_BASALT,
- "Basalt",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/basalt.png", 6),
- BlockTypeEnum::STONE_BASALT))
- ->setHardness(2.f);
- (new BasicBlockItemType(ItemTypeEnum::WOOD_PINE,
- "Pine",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/pine.png", 6),
- BlockTypeEnum::WOOD_PINE))
- ->setHardness(1.4f);
- (new BasicBlockItemType(ItemTypeEnum::LEAVES_WOOD_PINE,
- "Pine Leaves",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6),
- BlockTypeEnum::LEAVES_WOOD_PINE))
- ->setHardness(0.1f);
- (new BasicBlockItemType(ItemTypeEnum::SEBLING_WOOD_PINE,
- "Pine Sebling",
- 0,
- 0,
- ModelInfo("blocks.m3/sebling", "blocks.ltdb/sebling.png", 1),
- BlockTypeEnum::SEBLING_WOOD_PINE))
- ->setHardness(0.1f);
- (new LightSourceItemType(ItemTypeEnum::TORCH,
- "Torch",
- ModelInfo("items.m3/stick", "blocks.ltdb/torch.png", 6),
- BlockTypeEnum::TORCH))
- ->setColor(0x00F69A54);
- new PlayerHandItemType();
- new StoneToolItemType();
- (new NoBlockItemType(ItemTypeEnum::WOOD_STICK,
- "WoodenStick",
- 0,
- 0,
- ModelInfo("items.m3/stick", "items.ltdb/stick.png", 1),
- []() {
- return ItemType::createBasicItem(ItemTypeEnum::WOOD_STICK,
- "Wooden Stick",
- 1.f,
- 1.f,
- 10.f,
- 10.f,
- 0,
- 0,
- 0,
- 1,
- 0,
- 50);
- }));
- (new NoBlockItemType(ItemTypeEnum::RESIN,
- "Resin",
- 0,
- 0,
- ModelInfo("itemCube", "items.ltdb/resin.png", 6),
- []() {
- return ItemType::createBasicItem(ItemTypeEnum::RESIN,
- "Resin",
- 1.f,
- 1.f,
- 10.f,
- 10.f,
- 0,
- 0,
- 0,
- 1,
- 0,
- 50);
- }));
- (new NoBlockItemType(ItemTypeEnum::STONE_TOOL_BROKEN,
- "BrokenStoneTool",
- 0,
- 0,
- ModelInfo("itemCube", "blocks.ltdb/stone.png", 6),
- []() {
- return ItemType::createBasicItem(ItemTypeEnum::STONE_TOOL_BROKEN,
- "Broken Stone Tool",
- 100.f,
- 100.f,
- 100.f,
- 100.f,
- 0,
- 0,
- 0,
- 1,
- 0,
- 10);
- }));
- new HoeToolItemType();
- new NoBlockItemType(ItemTypeEnum::BROKEN_HOE,
- "BrokenHoe",
- 0,
- 0,
- ModelInfo("tools.m3/hoe", "tools.ltdb/stonehoe", 1),
- []() {
- return ItemType::createBasicItem(ItemTypeEnum::STONE_TOOL_BROKEN,
- "Broken Hoe",
- 100.f,
- 100.f,
- 100.f,
- 100.f,
- 0,
- 0,
- 0,
- 1,
- 0,
- 10);
- });
- (new NoBlockItemType(ItemTypeEnum::FLINT,
- "Flint",
- 0,
- 0,
- ModelInfo("items.m3/flint", "items.ltdb/flint.png", 1),
- []() {
- return ItemType::createBasicItem(ItemTypeEnum::FLINT,
- "Flint",
- 1.f,
- 1.f,
- 10.f,
- 10.f,
- 0,
- 0,
- 0,
- 1,
- 0,
- 50);
- }));
- (new BasicBlockItemType(ItemTypeEnum::WHEAT_SEED,
- "Wheat Seeds",
- 0,
- 0,
- ModelInfo("grass", "plants.ltdb/wheatseeds.png", 16),
- BlockTypeEnum::WHEAT_SEED))
- ->setHardness(0.1f)
- ->setPlacableProof(
- [](const Item* self,
- int dimensionId,
- Framework::Vec3<int> worldPos) {
- if (worldPos.z > 0)
- {
- auto below = Game::INSTANCE->zBlockAt(
- worldPos + getDirection(Direction::BOTTOM),
- dimensionId);
- return (below.isA()
- && below.getA()->zBlockType()->getId()
- == BlockTypeEnum::FARMLAND)
- || (below.isB()
- && below.getB() == BlockTypeEnum::FARMLAND);
- }
- return (bool)0;
- },
- 1);
- (new NoBlockItemType(ItemTypeEnum::WHEAT,
- "Wheat",
- 0,
- 0,
- ModelInfo("grass", "plants.ltdb/wheat.png", 16),
- []() {
- Item *item = ItemType::createBasicItem(ItemTypeEnum::WHEAT,
- "Wheat",
- 1.f,
- 1.f,
- 10.f,
- 10.f,
- 1,
- 0,
- 0,
- 1,
- 0,
- 50);
- item->setFoodEffect([](Entity* zEntity) {
- zEntity->setHunger(zEntity->getHunger() + 0.5f);
- zEntity->setThirst(zEntity->getThirst() + 1.f); // TODO: remove thirst addition when drinkable water exists
- });
- return item;
- }));
-
- (new BasicBlockItemType(ItemTypeEnum::CRAFTING_TABLE,
- "Crafting Table",
- 0,
- 0,
- ModelInfo("itemCube",
- {"blocks.ltdb/woodplanks.png",
- "blocks.ltdb/woodplanks.png",
- "blocks.ltdb/woodplanks.png",
- "blocks.ltdb/woodplanks.png",
- "blocks.ltdb/craftingtable.p",
- "blocks.ltdb/woodplanks.png"}),
- BlockTypeEnum::CRAFTING_TABLE)); // TODO: implement crafting table item
- // type
- }
- void initializeEntityTypes()
- {
- new PlayerEntityType();
- new ItemEntityType();
- }
- void initializeDimensions()
- {
- new OverworldDimension();
- }
- void initializeMultiblockTypes()
- {
- new MultiblockTreeStructureType();
- }
|