123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #include "Grass.h"
- #include "Game.h"
- #include "ItemEntity.h"
- GrassBlock::GrassBlock(int typeId, Framework::Vec3<int> 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<int> 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";
- }
|