123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include "PlaceBlockUpdate.h"
- #include "Block.h"
- #include "Dimension.h"
- PlaceBlockUpdate::PlaceBlockUpdate(Framework::Either<Block*, int> block, Framework::Vec3<int> location, int dimensionId)
- : WorldUpdate(PlaceBlockUpdateType::ID, dimensionId, location, location),
- block(block)
- {}
- PlaceBlockUpdate::~PlaceBlockUpdate()
- {
- if (block.isA())
- block.getA()->release();
- }
- void PlaceBlockUpdate::onUpdate(Dimension* zDimension)
- {
- if (block.isA())
- block.getA()->getThis();
- zDimension->placeBlock(getMaxAffectedPoint(), block);
- }
- void PlaceBlockUpdate::write(Framework::StreamWriter* zWriter)
- {
- auto pos = getMinAffectedPoint();
- zWriter->schreibe((char*)&pos.x, 4);
- zWriter->schreibe((char*)&pos.y, 4);
- zWriter->schreibe((char*)&pos.z, 4);
- unsigned short blockType = block.isA() ? (unsigned short)block.getA()->zBlockType()->getId() : (unsigned short)block.getB();
- zWriter->schreibe((char*)&blockType, 2);
- }
- Block* PlaceBlockUpdate::zBlock() const
- {
- return block;
- }
- PlaceBlockUpdateType::PlaceBlockUpdateType()
- : WorldUpdateType(ID)
- {}
|