Grass.h 1.7 KB

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