Grass.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "BasicBlocks.h"
  3. #include "Block.h"
  4. class GrassBlockType;
  5. class GrassBlock : public AdditionalItemSpawningBlock
  6. {
  7. public:
  8. GrassBlock(int typeId, Framework::Vec3<int> pos, int dimensionId);
  9. virtual bool onTick(
  10. TickQueue* zQueue, int numTicks, bool& blocked) override;
  11. virtual void onPostTick() override;
  12. void filterPassingLight(unsigned char rgb[3]) const override;
  13. friend GrassBlockType;
  14. };
  15. class GrassBlockType : public AdditionalItemSpawningBlockType
  16. {
  17. public:
  18. GrassBlockType(ModelInfo* model,
  19. Framework::Text name,
  20. int mapColor,
  21. Framework::Array<SpawnConfig> spawns,
  22. Framework::RCArray<Framework::Text> groupNames);
  23. protected:
  24. virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
  25. virtual void loadSuperBlock(Block* zBlock,
  26. Framework::StreamReader* zReader,
  27. int dimensionId) const override;
  28. virtual void saveSuperBlock(
  29. Block* zBlock, Framework::StreamWriter* zWriter) const override;
  30. virtual Item* createItem() const override;
  31. virtual Block* createBlock(
  32. Framework::Vec3<int> position, int dimensionId) const override;
  33. public:
  34. Framework::Text getItemTypeName() const;
  35. virtual ItemType* createItemType() const override;
  36. };
  37. class GrassBlockTypeFactory : public SubTypeFactory<BlockType, GrassBlockType>
  38. {
  39. public:
  40. GrassBlockTypeFactory();
  41. GrassBlockType* fromJson(Framework::JSON::JSONObject* zJson) const override;
  42. Framework::JSON::JSONObject* toJson(GrassBlockType* zObject) const override;
  43. Framework::JSON::Validator::JSONValidator* getValidator(
  44. Framework::JSON::Validator::ObjectValidationBuilder<
  45. Framework::JSON::Validator::JSONValidator>* builder) const override;
  46. Framework::Text getTypeToken() const override;
  47. };