MCPcopy Create free account
hub / github.com/cuberite/cuberite / HandleCommandBlockMessage

Method HandleCommandBlockMessage

src/ClientHandle.cpp:626–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624
625
626void cClientHandle::HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length)
627{
628 if (a_Length < 14)
629 {
630 SendChat("Failure setting command block command; bad request", mtFailure);
631 LOGD("Malformed MC|AdvCdm packet.");
632 return;
633 }
634
635 cByteBuffer Buffer(a_Length);
636 Buffer.Write(a_Data, a_Length);
637
638 int BlockX, BlockY, BlockZ;
639
640 AString Command;
641
642 char Mode;
643
644 Buffer.ReadChar(Mode);
645
646 switch (Mode)
647 {
648 case 0x00:
649 {
650 Buffer.ReadBEInt(BlockX);
651 Buffer.ReadBEInt(BlockY);
652 Buffer.ReadBEInt(BlockZ);
653
654 Buffer.ReadVarUTF8String(Command);
655 break;
656 }
657
658 default:
659 {
660 SendChat("Failure setting command block command; unhandled mode", mtFailure);
661 LOGD("Unhandled MC|AdvCdm packet mode.");
662 return;
663 }
664 }
665
666 cWorld * World = m_Player->GetWorld();
667
668 if (World->AreCommandBlocksEnabled())
669 {
670 World->SetCommandBlockCommand(BlockX, BlockY, BlockZ, Command);
671
672 SendChat("Successfully set command block command", mtSuccess);
673 }
674 else
675 {
676 SendChat("Command blocks are not enabled on this server", mtFailure);
677 }
678}
679
680
681

Callers

nothing calls this directly

Calls 7

ReadCharMethod · 0.80
ReadBEIntMethod · 0.80
ReadVarUTF8StringMethod · 0.80
WriteMethod · 0.45
GetWorldMethod · 0.45

Tested by

no test coverage detected