void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { Vector3i ThisPos(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(ThisPos); Vector3i Direction = MetaDataToDirection(OldMeta & 0x3); if (OldMeta & 0x8) { // Was pillow if (a_ChunkInterface.GetBlock(ThisPos - Direction) == E_BLOCK_BED) { // First replace the bed with air a_ChunkInterface.FastSetBlock(ThisPos - Direction, E_BLOCK_AIR, 0); // Then destroy the bed entity Vector3i PillowPos(ThisPos - Direction); a_ChunkInterface.SetBlock(PillowPos.x, PillowPos.y, PillowPos.z, E_BLOCK_AIR, 0); } } else { // Was foot end if (a_ChunkInterface.GetBlock(ThisPos + Direction) == E_BLOCK_BED) { // First replace the bed with air a_ChunkInterface.FastSetBlock(ThisPos + Direction, E_BLOCK_AIR, 0); // Then destroy the bed entity Vector3i FootPos(ThisPos + Direction); a_ChunkInterface.SetBlock(FootPos.x, FootPos.y, FootPos.z, E_BLOCK_AIR, 0); } } }
void cBlockDoorHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (OldMeta & 8) { // Was upper part of door if (IsDoorBlockType(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) { a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_AIR, 0); } } else { // Was lower part if (IsDoorBlockType(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))) { a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, E_BLOCK_AIR, 0); } } }
void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ ); Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 ); if (OldMeta & 0x8) { // Was pillow if (a_ChunkInterface.GetBlock(ThisPos - Direction) == E_BLOCK_BED) { a_ChunkInterface.FastSetBlock(ThisPos - Direction, E_BLOCK_AIR, 0); } } else { // Was foot end if (a_ChunkInterface.GetBlock(ThisPos + Direction) == E_BLOCK_BED) { a_ChunkInterface.FastSetBlock(ThisPos + Direction, E_BLOCK_AIR, 0); } } }