Grass.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. virtual TickSourceType isTickSource() const override;
  14. friend GrassBlockType;
  15. };
  16. class GrassBlockType : public AdditionalItemSpawningBlockType
  17. {
  18. public:
  19. GrassBlockType();
  20. protected:
  21. virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
  22. virtual void loadSuperBlock(Block* zBlock,
  23. Framework::StreamReader* zReader,
  24. int dimensionId) const override;
  25. virtual void saveSuperBlock(
  26. Block* zBlock, Framework::StreamWriter* zWriter) const override;
  27. virtual Item* createItem() const override;
  28. virtual Block* createBlock(
  29. Framework::Vec3<int> position, int dimensionId) const override;
  30. public:
  31. virtual ItemType* createItemType() const override;
  32. };
  33. class GrassBlockTypeFactory : public SubTypeFactory<BlockType, GrassBlockType>
  34. {
  35. private:
  36. AdditionalItemSpawningBlockTypeFactory super;
  37. public:
  38. GrassBlockTypeFactory();
  39. GrassBlockType* createValue(
  40. Framework::JSON::JSONObject* zJson) const override;
  41. void fromJson(GrassBlockType* zResult,
  42. Framework::JSON::JSONObject* zJson) const override;
  43. void toJson(GrassBlockType* zObject,
  44. Framework::JSON::JSONObject* zResult) const override;
  45. JSONObjectValidationBuilder* addToValidator(
  46. JSONObjectValidationBuilder* builder) const override;
  47. Framework::Text getTypeToken() const override;
  48. };