[TerrainGenerator] Tall Grass added.
This commit is contained in:
parent
cb356b4a3b
commit
949cc463cb
@ -35,7 +35,7 @@ class ItemWidget : public Widget {
|
||||
ItemWidget(Inventory &inventory, u16 x, u16 y, Widget *parent = nullptr);
|
||||
|
||||
void update() override;
|
||||
void updateImage();
|
||||
void updateImage(const Block *block = nullptr);
|
||||
|
||||
const ItemStack &stack() const { return m_inventory.getStack(m_x, m_y); }
|
||||
void setStack(const std::string &name, unsigned int amount = 1);
|
||||
|
@ -43,7 +43,7 @@ void ItemWidget::update() {
|
||||
m_isImage = false;
|
||||
}
|
||||
else
|
||||
updateImage();
|
||||
updateImage(&block);
|
||||
}
|
||||
else
|
||||
updateImage();
|
||||
@ -52,7 +52,7 @@ void ItemWidget::update() {
|
||||
m_text.setPosition(16 - 4 - 6 * floor(log10(stack().amount())), 16 - 6, 0);
|
||||
}
|
||||
|
||||
void ItemWidget::updateImage() {
|
||||
void ItemWidget::updateImage(const Block *block) {
|
||||
if (m_image.width() == 0) {
|
||||
m_image.load(m_textureAtlas.texture());
|
||||
m_image.setPosition(1, 1, 0);
|
||||
@ -63,6 +63,9 @@ void ItemWidget::updateImage() {
|
||||
m_image.setClipRect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
|
||||
m_image.setScale(16.0f / clipRect.width, 16.0f / clipRect.height);
|
||||
|
||||
if (block)
|
||||
m_image.setColor(block->colorMultiplier());
|
||||
|
||||
m_isImage = true;
|
||||
}
|
||||
|
||||
|
@ -144,3 +144,12 @@ mod:block {
|
||||
bounding_box = {0.25, 0.0, 0.25, 0.5, 0.5, 0.5},
|
||||
}
|
||||
|
||||
mod:block {
|
||||
id = "tallgrass",
|
||||
name = "Tall Grass",
|
||||
tiles = "grass.png",
|
||||
color_multiplier = {129, 191, 91, 255},
|
||||
hardness = 0.05,
|
||||
draw_type = 1, -- FIXME: Use string instead
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,8 @@ openminer:world():terrain_generator():set_blocks({
|
||||
leaves = "default:leaves",
|
||||
flower = "default:flower",
|
||||
water = "default:water",
|
||||
sand = "default:sand"
|
||||
sand = "default:sand",
|
||||
tallgrass = "default:tallgrass"
|
||||
})
|
||||
|
||||
function init(player)
|
||||
|
BIN
mods/default/textures/blocks/grass.png
Executable file
BIN
mods/default/textures/blocks/grass.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 547 B |
BIN
mods/default/textures_mc/blocks/grass.png
Normal file
BIN
mods/default/textures_mc/blocks/grass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 347 B |
@ -51,6 +51,7 @@ class TerrainGenerator {
|
||||
u16 m_flowerBlockID = 0;
|
||||
u16 m_waterBlockID = 0;
|
||||
u16 m_sandBlockID = 0;
|
||||
u16 m_tallgrassBlockID = 0;
|
||||
};
|
||||
|
||||
#endif // TERRAINGENERATOR_HPP_
|
||||
|
@ -37,14 +37,15 @@ void TerrainGenerator::generate(ServerChunk &chunk) const {
|
||||
}
|
||||
|
||||
void TerrainGenerator::setBlocksFromLuaTable(const sol::table &table) {
|
||||
m_dirtBlockID = Registry::getInstance().getBlockFromStringID(table["dirt"].get<std::string>()).id();
|
||||
m_grassBlockID = Registry::getInstance().getBlockFromStringID(table["grass"].get<std::string>()).id();
|
||||
m_stoneBlockID = Registry::getInstance().getBlockFromStringID(table["stone"].get<std::string>()).id();
|
||||
m_logBlockID = Registry::getInstance().getBlockFromStringID(table["log"].get<std::string>()).id();
|
||||
m_leavesBlockID = Registry::getInstance().getBlockFromStringID(table["leaves"].get<std::string>()).id();
|
||||
m_flowerBlockID = Registry::getInstance().getBlockFromStringID(table["flower"].get<std::string>()).id();
|
||||
m_waterBlockID = Registry::getInstance().getBlockFromStringID(table["water"].get<std::string>()).id();
|
||||
m_sandBlockID = Registry::getInstance().getBlockFromStringID(table["sand"].get<std::string>()).id();
|
||||
m_dirtBlockID = Registry::getInstance().getBlockFromStringID(table["dirt"].get<std::string>()).id();
|
||||
m_grassBlockID = Registry::getInstance().getBlockFromStringID(table["grass"].get<std::string>()).id();
|
||||
m_stoneBlockID = Registry::getInstance().getBlockFromStringID(table["stone"].get<std::string>()).id();
|
||||
m_logBlockID = Registry::getInstance().getBlockFromStringID(table["log"].get<std::string>()).id();
|
||||
m_leavesBlockID = Registry::getInstance().getBlockFromStringID(table["leaves"].get<std::string>()).id();
|
||||
m_flowerBlockID = Registry::getInstance().getBlockFromStringID(table["flower"].get<std::string>()).id();
|
||||
m_waterBlockID = Registry::getInstance().getBlockFromStringID(table["water"].get<std::string>()).id();
|
||||
m_sandBlockID = Registry::getInstance().getBlockFromStringID(table["sand"].get<std::string>()).id();
|
||||
m_tallgrassBlockID = Registry::getInstance().getBlockFromStringID(table["tallgrass"].get<std::string>()).id();
|
||||
}
|
||||
|
||||
void TerrainGenerator::fastNoiseGeneration(ServerChunk &chunk) const {
|
||||
@ -94,6 +95,10 @@ void TerrainGenerator::fastNoiseGeneration(ServerChunk &chunk) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Or tallgrass
|
||||
else if(chunk.getBlock(x, y - 1, z) == m_grassBlockID && (rand() % 32) == 0) {
|
||||
chunk.setBlockRaw(x, y, z, m_tallgrassBlockID);
|
||||
}
|
||||
// Or a flower
|
||||
else if(chunk.getBlock(x, y - 1, z) == m_grassBlockID && (rand() & 0xff) == 0) {
|
||||
chunk.setBlockRaw(x, y, z, m_flowerBlockID);
|
||||
|
Loading…
x
Reference in New Issue
Block a user