No Sword Block Destroying in Creative Mode
This commit is contained in:
parent
b432f57608
commit
cc34898e45
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "Protocol/ProtocolRecognizer.h"
|
#include "Protocol/ProtocolRecognizer.h"
|
||||||
#include "CompositeChat.h"
|
#include "CompositeChat.h"
|
||||||
|
#include "Items/ItemSword.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -794,6 +795,15 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
m_Player->IsGameModeCreative() &&
|
||||||
|
cItemSwordHandler::IsSword(m_Player->GetInventory().GetEquippedItem().m_ItemType)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Players can't destroy blocks with a Sword in the hand.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta))
|
if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta))
|
||||||
{
|
{
|
||||||
// A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows:
|
// A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows:
|
||||||
|
@ -23,6 +23,25 @@ public:
|
|||||||
{
|
{
|
||||||
return (a_BlockType == E_BLOCK_COBWEB);
|
return (a_BlockType == E_BLOCK_COBWEB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static bool IsSword(int id)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case E_ITEM_WOODEN_SWORD:
|
||||||
|
case E_ITEM_STONE_SWORD:
|
||||||
|
case E_ITEM_IRON_SWORD:
|
||||||
|
case E_ITEM_GOLD_SWORD:
|
||||||
|
case E_ITEM_DIAMOND_SWORD:
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user