diff --git a/README.md b/README.md index 79aeadee..900aebf3 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ This list is non exhaustive. ![](screenshot2.png?raw=true) ![](screenshot3.png?raw=true) ![](screenshot4.png?raw=true) +![](screenshot5.png?raw=true) ## Credits diff --git a/common/source/world/Biome.cpp b/common/source/world/Biome.cpp index fc8b83e8..5d07dcf6 100644 --- a/common/source/world/Biome.cpp +++ b/common/source/world/Biome.cpp @@ -38,12 +38,14 @@ Biome::Biome(u16 id, const std::string &stringID, const std::string &label) { void Biome::serialize(sf::Packet &packet) const { packet << m_id << m_stringID << m_label << m_params << m_topBlockID << m_groundBlockID << m_deepBlockID << m_beachBlockID << m_liquidBlockID + << m_portalBlockID << m_portalFrameBlockID << m_flora << m_ores << m_trees; } void Biome::deserialize(sf::Packet &packet) { packet >> m_id >> m_stringID >> m_label >> m_params >> m_topBlockID >> m_groundBlockID >> m_deepBlockID >> m_beachBlockID >> m_liquidBlockID + >> m_portalBlockID >> m_portalFrameBlockID >> m_flora >> m_ores >> m_trees; } diff --git a/common/source/world/Biome.hpp b/common/source/world/Biome.hpp index 5246e123..d202ba0f 100644 --- a/common/source/world/Biome.hpp +++ b/common/source/world/Biome.hpp @@ -55,6 +55,8 @@ class Biome : public ISerializable { u16 getDeepBlockID() const { return m_deepBlockID; } u16 getBeachBlockID() const { return m_beachBlockID; } u16 getLiquidBlockID() const { return m_liquidBlockID; } + u16 getPortalBlockID() const { return m_portalBlockID; } + u16 getPortalFrameBlockID() const { return m_portalFrameBlockID; } const std::vector &getFlora() const { return m_flora; } const std::vector &getOres() const { return m_ores; } @@ -67,6 +69,8 @@ class Biome : public ISerializable { void setDeepBlockID(u16 value) { m_deepBlockID = value; } void setBeachBlockID(u16 value) { m_beachBlockID = value; } void setLiquidBlockID(u16 value) { m_liquidBlockID = value; } + void setPortalBlockID(u16 value) { m_portalBlockID = value; } + void setPortalFrameBlockID(u16 value) { m_portalFrameBlockID = value; } PlacementEntry::Flora &addFlora() { m_flora.emplace_back(); return m_flora.back(); } PlacementEntry::Ore &addOre() { m_ores.emplace_back(); return m_ores.back(); } @@ -85,6 +89,8 @@ class Biome : public ISerializable { u16 m_deepBlockID; u16 m_beachBlockID; u16 m_liquidBlockID; + u16 m_portalBlockID; + u16 m_portalFrameBlockID; std::vector m_flora; std::vector m_ores; diff --git a/mods/default/biomes.lua b/mods/default/biomes.lua index 3e139f11..8d8d8dfa 100644 --- a/mods/default/biomes.lua +++ b/mods/default/biomes.lua @@ -39,6 +39,8 @@ mod:biome { deep_block = "default:stone", beach_block = "default:sand", liquid_block = "default:water", + portal_block = "default:portal", + portal_frame_block = "default:obsidian", trees = { { @@ -102,7 +104,9 @@ mod:biome { ground_block = "default:sand", deep_block = "default:stone", beach_block = "default:sand", - liquid_block = "default:water" + liquid_block = "default:water", + portal_block = "default:portal", + portal_frame_block = "default:obsidian", } mod:biome { @@ -118,6 +122,8 @@ mod:biome { ground_block = "default:netherrack", deep_block = "default:netherrack", beach_block = "default:soul_sand", - liquid_block = "default:lava" + liquid_block = "default:lava", + portal_block = "default:portal", + portal_frame_block = "default:obsidian", } diff --git a/mods/default/blocks.lua b/mods/default/blocks.lua index 938a7e74..4916ecdf 100644 --- a/mods/default/blocks.lua +++ b/mods/default/blocks.lua @@ -204,11 +204,15 @@ mod:block { on_block_activated = function(pos, player, world, client, server, screen_width, screen_height, gui_scale) local dim = (player:dimension() + 1) % 2 - local pos = {x = 0, y = 0, z = 20} + local pos = { + x = math.floor(player:x()), + y = math.floor(player:y()), + z = math.floor(player:z()) + } server:send_player_change_dimension(client.id, pos.x, pos.y, pos.z, dim, client) player:set_dimension(dim) - player:set_position(pos.x, pos.y, pos.z) + -- player:set_position(pos.x, pos.y, pos.z) end, } @@ -263,3 +267,11 @@ mod:block { }, } +mod:block { + id = "obsidian", + name = "Obsidian", + tiles = "obsidian.png", + + hardness = 2, +} + diff --git a/mods/default/textures/blocks/obsidian.png b/mods/default/textures/blocks/obsidian.png new file mode 100644 index 00000000..1b8a3c60 Binary files /dev/null and b/mods/default/textures/blocks/obsidian.png differ diff --git a/mods/default/textures_mc/blocks/obsidian.png b/mods/default/textures_mc/blocks/obsidian.png new file mode 100644 index 00000000..ff0a6836 Binary files /dev/null and b/mods/default/textures_mc/blocks/obsidian.png differ diff --git a/screenshot5.png b/screenshot5.png new file mode 100644 index 00000000..95847217 Binary files /dev/null and b/screenshot5.png differ diff --git a/server/source/lua/ScriptEngine.cpp b/server/source/lua/ScriptEngine.cpp index e476d5f1..6eec48cb 100644 --- a/server/source/lua/ScriptEngine.cpp +++ b/server/source/lua/ScriptEngine.cpp @@ -90,6 +90,9 @@ void ScriptEngine::initUsertypes() { m_lua.new_usertype("Player", "inventory", &Player::inventory, + "x", &Player::x, + "y", &Player::y, + "z", &Player::z, "set_position", &Player::setPosition, "dimension", &Player::dimension, diff --git a/server/source/lua/loader/LuaBiomeLoader.cpp b/server/source/lua/loader/LuaBiomeLoader.cpp index eda5b0c8..56eed6ad 100644 --- a/server/source/lua/loader/LuaBiomeLoader.cpp +++ b/server/source/lua/loader/LuaBiomeLoader.cpp @@ -96,6 +96,8 @@ inline void LuaBiomeLoader::loadBiomeBlocks(Biome &biome, const sol::table &tabl biome.setDeepBlockID(Registry::getInstance().getBlockFromStringID(table["deep_block"]).id()); biome.setBeachBlockID(Registry::getInstance().getBlockFromStringID(table["beach_block"]).id()); biome.setLiquidBlockID(Registry::getInstance().getBlockFromStringID(table["liquid_block"]).id()); + biome.setPortalBlockID(Registry::getInstance().getBlockFromStringID(table["portal_block"]).id()); + biome.setPortalFrameBlockID(Registry::getInstance().getBlockFromStringID(table["portal_frame_block"]).id()); } inline void LuaBiomeLoader::loadTreePlacementEntries(Biome &biome, const sol::table &table) const { diff --git a/server/source/world/TerrainGenerator.cpp b/server/source/world/TerrainGenerator.cpp index df86ee64..1ccda085 100644 --- a/server/source/world/TerrainGenerator.cpp +++ b/server/source/world/TerrainGenerator.cpp @@ -118,8 +118,25 @@ void TerrainGenerator::fastNoiseGeneration(ServerChunk &chunk) const { break; } + // FIXME: This is a temporary portal generation + // This code should be replaced by a proper "feature" implementation + // which will also allow making stuff like villages easier + bool placedPortal = false; + if (chunk.getBlock(x, y, z - 1) == biome.getTopBlockID() && rand() % 4096 == 0) { + for (int ix = 0 ; ix < 4 ; ++ix) { + for (int iz = 0 ; iz < 5 ; ++iz) { + if (ix == 0 || iz == 0 || ix == 3 || iz == 4) + chunk.setBlockRaw(x + ix, y, z + iz, biome.getPortalFrameBlockID()); + else + chunk.setBlockRaw(x + ix, y, z + iz, biome.getPortalBlockID()); + } + } + + placedPortal = true; + } + // Otherwise set sunlight. - if (!placedFlora && z == CHUNK_HEIGHT - 1) { + if (!placedFlora && !placedPortal && z == CHUNK_HEIGHT - 1) { chunk.lightmap().addSunlight(x, y, z, 15); } }