#include "Grass.h" #include "Game.h" #include "ItemEntity.h" GrassBlock::GrassBlock(int typeId, Framework::Vec3 pos, int dimensionId) : AdditionalItemSpawningBlock(typeId, pos, dimensionId) { transparent = 1; } bool GrassBlock::onTick(TickQueue* zQueue, int numTicks, bool& blocked) { // TODO: spread to neighbor blocks if light level is hight enought return 0; } void GrassBlock::onPostTick() {} void GrassBlock::filterPassingLight(unsigned char rgb[3]) const { rgb[0] = (unsigned char)(rgb[0] * 0.7); rgb[1] = (unsigned char)(rgb[1] * 0.9); rgb[2] = (unsigned char)(rgb[2] * 0.7); } TickSourceType GrassBlock::isTickSource() const { return TickSourceType::EACH_TICK; } GrassBlockType::GrassBlockType() : AdditionalItemSpawningBlockType() {} ItemType* GrassBlockType::createItemType() const { return 0; } void GrassBlockType::createSuperBlock(Block* zBlock, Item* zItem) const { AdditionalItemSpawningBlockType::createSuperBlock(zBlock, zItem); } void GrassBlockType::loadSuperBlock( Block* zBlock, Framework::StreamReader* zReader, int dimensionId) const { AdditionalItemSpawningBlockType::loadSuperBlock( zBlock, zReader, dimensionId); } void GrassBlockType::saveSuperBlock( Block* zBlock, Framework::StreamWriter* zWriter) const { AdditionalItemSpawningBlockType::saveSuperBlock(zBlock, zWriter); } Item* GrassBlockType::createItem() const { return 0; } Block* GrassBlockType::createBlock( Framework::Vec3 position, int dimensionId) const { return new GrassBlock(getId(), position, dimensionId); } GrassBlockTypeFactory::GrassBlockTypeFactory() : SubTypeFactory() {} GrassBlockType* GrassBlockTypeFactory::createValue( Framework::JSON::JSONObject* zJson) const { return new GrassBlockType(); } void GrassBlockTypeFactory::fromJson( GrassBlockType* zResult, Framework::JSON::JSONObject* zJson) const { super.fromJson(zResult, zJson); } void GrassBlockTypeFactory::toJson( GrassBlockType* zObject, Framework::JSON::JSONObject* zResult) const { super.toJson(zObject, zResult); } JSONObjectValidationBuilder* GrassBlockTypeFactory::addToValidator( JSONObjectValidationBuilder* builder) const { return super.addToValidator(builder); } Framework::Text GrassBlockTypeFactory::getTypeToken() const { return "grass"; }