commit
0814a977f8
@ -61,22 +61,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
|
||||||
{
|
|
||||||
cBlockHandler::OnDestroyed(a_ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ);
|
|
||||||
|
|
||||||
// 0.5% chance of dropping an apple, if the leaves' type is Apple Leaves:
|
|
||||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
|
||||||
cFastRandom rand;
|
|
||||||
if (((Meta & 3) == E_META_LEAVES_APPLE) && (rand.NextInt(201) == 100))
|
|
||||||
{
|
|
||||||
cItems Drops;
|
|
||||||
Drops.push_back(cItem(E_ITEM_RED_APPLE, 1, 0));
|
|
||||||
a_WorldInterface.SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||||
|
@ -43,8 +43,9 @@ public:
|
|||||||
cItems Pickups;
|
cItems Pickups;
|
||||||
Pickups.Add(E_BLOCK_TALL_GRASS, 1, Meta);
|
Pickups.Add(E_BLOCK_TALL_GRASS, 1, Meta);
|
||||||
a_WorldInterface.SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
|
a_WorldInterface.SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
|
||||||
|
a_Player->UseEquippedItem();
|
||||||
}
|
}
|
||||||
a_Player->UseEquippedItem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +44,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||||
|
{
|
||||||
|
// Reset meta to 0
|
||||||
|
a_Pickups.push_back(cItem(E_BLOCK_VINES, 1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static NIBBLETYPE DirectionToMetaData(char a_BlockFace)
|
static NIBBLETYPE DirectionToMetaData(char a_BlockFace)
|
||||||
{
|
{
|
||||||
switch (a_BlockFace)
|
switch (a_BlockFace)
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../Bindings/PluginManager.h"
|
#include "../Bindings/PluginManager.h"
|
||||||
#include "../Tracer.h"
|
#include "../Tracer.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "Items/ItemHandler.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -289,11 +290,6 @@ void cEntity::SetPitchFromSpeed(void)
|
|||||||
|
|
||||||
bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||||
{
|
{
|
||||||
if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Health <= 0)
|
if (m_Health <= 0)
|
||||||
{
|
{
|
||||||
// Can't take damage if already dead
|
// Can't take damage if already dead
|
||||||
@ -306,10 +302,17 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
|
if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
|
||||||
{
|
{
|
||||||
cPlayer * Player = (cPlayer *)a_TDI.Attacker;
|
cPlayer * Player = (cPlayer *)a_TDI.Attacker;
|
||||||
|
|
||||||
|
Player->GetEquippedItem().GetHandler()->OnEntityAttack(Player, this);
|
||||||
|
|
||||||
// IsOnGround() only is false if the player is moving downwards
|
// IsOnGround() only is false if the player is moving downwards
|
||||||
// TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
|
// TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
|
||||||
if (!Player->IsOnGround())
|
if (!Player->IsOnGround())
|
||||||
|
@ -1929,14 +1929,14 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPlayer::UseEquippedItem(void)
|
void cPlayer::UseEquippedItem(int a_Amount)
|
||||||
{
|
{
|
||||||
if (IsGameModeCreative()) // No damage in creative
|
if (IsGameModeCreative()) // No damage in creative
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetInventory().DamageEquippedItem())
|
if (GetInventory().DamageEquippedItem(a_Amount))
|
||||||
{
|
{
|
||||||
m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
|
m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ public:
|
|||||||
|
|
||||||
const AString & GetLoadedWorldName() { return m_LoadedWorldName; }
|
const AString & GetLoadedWorldName() { return m_LoadedWorldName; }
|
||||||
|
|
||||||
void UseEquippedItem(void);
|
void UseEquippedItem(int a_Amount = 1);
|
||||||
|
|
||||||
void SendHealth(void);
|
void SendHealth(void);
|
||||||
|
|
||||||
|
@ -44,6 +44,9 @@ public:
|
|||||||
/// Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M; a_Salt is additional source of randomness
|
/// Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M; a_Salt is additional source of randomness
|
||||||
float NextFloat(float a_Range, int a_Salt);
|
float NextFloat(float a_Range, int a_Salt);
|
||||||
|
|
||||||
|
/** Returns a random float between 0 and 1. */
|
||||||
|
float NextFloat(void) { return NextFloat(1); };
|
||||||
|
|
||||||
/** Returns a random int in the range [a_Begin .. a_End] */
|
/** Returns a random int in the range [a_Begin .. a_End] */
|
||||||
int GenerateRandomInteger(int a_Begin, int a_End);
|
int GenerateRandomInteger(int a_Begin, int a_End);
|
||||||
|
|
||||||
|
@ -226,12 +226,6 @@ void cInventory::SetSlot(int a_SlotNum, const cItem & a_Item)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Grid->SetSlot(GridSlotNum, a_Item);
|
Grid->SetSlot(GridSlotNum, a_Item);
|
||||||
|
|
||||||
// Broadcast the Equipped Item, if the Slot is changed.
|
|
||||||
if ((Grid == &m_HotbarSlots) && (m_EquippedSlotNum == (a_SlotNum - invHotbarOffset)))
|
|
||||||
{
|
|
||||||
m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, a_Item, m_Owner.GetClientHandle());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -397,6 +391,10 @@ bool cInventory::DamageItem(int a_SlotNum, short a_Amount)
|
|||||||
LOGWARNING("%s: requesting an invalid slot index: %d out of %d", __FUNCTION__, a_SlotNum, invNumSlots - 1);
|
LOGWARNING("%s: requesting an invalid slot index: %d out of %d", __FUNCTION__, a_SlotNum, invNumSlots - 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (a_Amount <= 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int GridSlotNum = 0;
|
int GridSlotNum = 0;
|
||||||
cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
|
cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
|
||||||
@ -717,6 +715,12 @@ void cInventory::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
|
|||||||
m_ArmorSlots.GetSlot(a_SlotNum), m_Owner.GetClientHandle()
|
m_ArmorSlots.GetSlot(a_SlotNum), m_Owner.GetClientHandle()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Broadcast the Equipped Item, if the Slot is changed.
|
||||||
|
if ((a_ItemGrid == &m_HotbarSlots) && (m_EquippedSlotNum == a_SlotNum))
|
||||||
|
{
|
||||||
|
m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, GetEquippedItem(), m_Owner.GetClientHandle());
|
||||||
|
}
|
||||||
|
|
||||||
// Convert the grid-local a_SlotNum to our global SlotNum:
|
// Convert the grid-local a_SlotNum to our global SlotNum:
|
||||||
int Base = 0;
|
int Base = 0;
|
||||||
|
46
src/Item.cpp
46
src/Item.cpp
@ -41,33 +41,33 @@ short cItem::GetMaxDamage(void) const
|
|||||||
switch (m_ItemType)
|
switch (m_ItemType)
|
||||||
{
|
{
|
||||||
case E_ITEM_BOW: return 384;
|
case E_ITEM_BOW: return 384;
|
||||||
case E_ITEM_DIAMOND_AXE: return 1563;
|
case E_ITEM_DIAMOND_AXE: return 1561;
|
||||||
case E_ITEM_DIAMOND_HOE: return 1563;
|
case E_ITEM_DIAMOND_HOE: return 1561;
|
||||||
case E_ITEM_DIAMOND_PICKAXE: return 1563;
|
case E_ITEM_DIAMOND_PICKAXE: return 1561;
|
||||||
case E_ITEM_DIAMOND_SHOVEL: return 1563;
|
case E_ITEM_DIAMOND_SHOVEL: return 1561;
|
||||||
case E_ITEM_DIAMOND_SWORD: return 1563;
|
case E_ITEM_DIAMOND_SWORD: return 1561;
|
||||||
case E_ITEM_FLINT_AND_STEEL: return 65;
|
case E_ITEM_FLINT_AND_STEEL: return 64;
|
||||||
case E_ITEM_GOLD_AXE: return 32;
|
case E_ITEM_GOLD_AXE: return 32;
|
||||||
case E_ITEM_GOLD_HOE: return 32;
|
case E_ITEM_GOLD_HOE: return 32;
|
||||||
case E_ITEM_GOLD_PICKAXE: return 32;
|
case E_ITEM_GOLD_PICKAXE: return 32;
|
||||||
case E_ITEM_GOLD_SHOVEL: return 32;
|
case E_ITEM_GOLD_SHOVEL: return 32;
|
||||||
case E_ITEM_GOLD_SWORD: return 32;
|
case E_ITEM_GOLD_SWORD: return 32;
|
||||||
case E_ITEM_IRON_AXE: return 251;
|
case E_ITEM_IRON_AXE: return 250;
|
||||||
case E_ITEM_IRON_HOE: return 251;
|
case E_ITEM_IRON_HOE: return 250;
|
||||||
case E_ITEM_IRON_PICKAXE: return 251;
|
case E_ITEM_IRON_PICKAXE: return 250;
|
||||||
case E_ITEM_IRON_SHOVEL: return 251;
|
case E_ITEM_IRON_SHOVEL: return 250;
|
||||||
case E_ITEM_IRON_SWORD: return 251;
|
case E_ITEM_IRON_SWORD: return 250;
|
||||||
case E_ITEM_SHEARS: return 251;
|
case E_ITEM_SHEARS: return 250;
|
||||||
case E_ITEM_STONE_AXE: return 132;
|
case E_ITEM_STONE_AXE: return 131;
|
||||||
case E_ITEM_STONE_HOE: return 132;
|
case E_ITEM_STONE_HOE: return 131;
|
||||||
case E_ITEM_STONE_PICKAXE: return 132;
|
case E_ITEM_STONE_PICKAXE: return 131;
|
||||||
case E_ITEM_STONE_SHOVEL: return 132;
|
case E_ITEM_STONE_SHOVEL: return 131;
|
||||||
case E_ITEM_STONE_SWORD: return 132;
|
case E_ITEM_STONE_SWORD: return 131;
|
||||||
case E_ITEM_WOODEN_AXE: return 60;
|
case E_ITEM_WOODEN_AXE: return 59;
|
||||||
case E_ITEM_WOODEN_HOE: return 60;
|
case E_ITEM_WOODEN_HOE: return 59;
|
||||||
case E_ITEM_WOODEN_PICKAXE: return 60;
|
case E_ITEM_WOODEN_PICKAXE: return 59;
|
||||||
case E_ITEM_WOODEN_SHOVEL: return 60;
|
case E_ITEM_WOODEN_SHOVEL: return 59;
|
||||||
case E_ITEM_WOODEN_SWORD: return 60;
|
case E_ITEM_WOODEN_SWORD: return 59;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ bool cItem::DamageItem(short a_Amount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_ItemDamage += a_Amount;
|
m_ItemDamage += a_Amount;
|
||||||
return (m_ItemDamage >= MaxDamage);
|
return (m_ItemDamage > MaxDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -332,8 +332,21 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const
|
|||||||
cBlockInServerPluginInterface PluginInterface(*a_World);
|
cBlockInServerPluginInterface PluginInterface(*a_World);
|
||||||
Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block), a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0);
|
Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block), a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
a_Player->UseEquippedItem();
|
if (!cBlockInfo::IsOneHitDig(Block))
|
||||||
|
{
|
||||||
|
a_Player->UseEquippedItem(GetDurabilityLossByAction(dlaBreakBlock));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity)
|
||||||
|
{
|
||||||
|
UNUSED(a_AttackedEntity);
|
||||||
|
a_Attacker->UseEquippedItem(GetDurabilityLossByAction(dlaAttackEntity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -351,6 +364,20 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action)
|
||||||
|
{
|
||||||
|
switch (a_Action)
|
||||||
|
{
|
||||||
|
case dlaAttackEntity: return 2;
|
||||||
|
case dlaBreakBlock: return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char cItemHandler::GetMaxStackSize(void)
|
char cItemHandler::GetMaxStackSize(void)
|
||||||
{
|
{
|
||||||
if (m_ItemType < 256)
|
if (m_ItemType < 256)
|
||||||
@ -502,6 +529,7 @@ bool cItemHandler::IsPlaceable(void)
|
|||||||
|
|
||||||
bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType)
|
bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType)
|
||||||
{
|
{
|
||||||
|
UNUSED(a_ItemType);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,6 +576,8 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
|
|||||||
case E_BLOCK_IRON_ORE:
|
case E_BLOCK_IRON_ORE:
|
||||||
case E_BLOCK_LAPIS_ORE:
|
case E_BLOCK_LAPIS_ORE:
|
||||||
case E_BLOCK_LAPIS_BLOCK:
|
case E_BLOCK_LAPIS_BLOCK:
|
||||||
|
case E_BLOCK_SNOW:
|
||||||
|
case E_BLOCK_VINES:
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,13 @@ class cPlayer;
|
|||||||
class cItemHandler
|
class cItemHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum eDurabilityLostAction
|
||||||
|
{
|
||||||
|
dlaBreakBlock,
|
||||||
|
dlaAttackEntity,
|
||||||
|
};
|
||||||
|
|
||||||
cItemHandler(int a_ItemType);
|
cItemHandler(int a_ItemType);
|
||||||
|
|
||||||
/** Force virtual destructor */
|
/** Force virtual destructor */
|
||||||
@ -48,11 +55,17 @@ public:
|
|||||||
virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace);
|
virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace);
|
||||||
|
|
||||||
/** Called when the player destroys a block using this item. This also calls the drop function for the destroyed block */
|
/** Called when the player destroys a block using this item. This also calls the drop function for the destroyed block */
|
||||||
virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_X, int a_Y, int a_Z);
|
virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
|
|
||||||
|
/** Called when a player attacks a other entity. */
|
||||||
|
virtual void OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity);
|
||||||
|
|
||||||
/** Called after the player has eaten this item. */
|
/** Called after the player has eaten this item. */
|
||||||
virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item);
|
virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item);
|
||||||
|
|
||||||
|
/** Get the durability lost which the item will get, when a specified action was performed. */
|
||||||
|
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action);
|
||||||
|
|
||||||
/** Returns the maximum stack size for a given item */
|
/** Returns the maximum stack size for a given item */
|
||||||
virtual char GetMaxStackSize(void);
|
virtual char GetMaxStackSize(void);
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ public:
|
|||||||
cItemHoeHandler(int a_ItemType)
|
cItemHoeHandler(int a_ItemType)
|
||||||
: cItemHandler(a_ItemType)
|
: cItemHandler(a_ItemType)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
|
virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
|
||||||
@ -26,13 +25,18 @@ public:
|
|||||||
if ((Block == E_BLOCK_DIRT) || (Block == E_BLOCK_GRASS))
|
if ((Block == E_BLOCK_DIRT) || (Block == E_BLOCK_GRASS))
|
||||||
{
|
{
|
||||||
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FARMLAND, 0);
|
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FARMLAND, 0);
|
||||||
|
|
||||||
a_Player->UseEquippedItem();
|
a_Player->UseEquippedItem();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
class cItemPickaxeHandler :
|
class cItemPickaxeHandler :
|
||||||
public cItemHandler
|
public cItemHandler
|
||||||
{
|
{
|
||||||
|
typedef cItemHandler super;
|
||||||
public:
|
public:
|
||||||
cItemPickaxeHandler(int a_ItemType)
|
cItemPickaxeHandler(int a_ItemType)
|
||||||
: cItemHandler(a_ItemType)
|
: cItemHandler(a_ItemType)
|
||||||
@ -84,7 +85,7 @@ public:
|
|||||||
return PickaxeLevel() >= 1;
|
return PickaxeLevel() >= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return super::CanHarvestBlock(a_BlockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
class cItemShearsHandler :
|
class cItemShearsHandler :
|
||||||
public cItemHandler
|
public cItemHandler
|
||||||
{
|
{
|
||||||
|
typedef cItemHandler super;
|
||||||
public:
|
public:
|
||||||
cItemShearsHandler(int a_ItemType) :
|
cItemShearsHandler(int a_ItemType) :
|
||||||
cItemHandler(a_ItemType)
|
cItemHandler(a_ItemType)
|
||||||
@ -30,8 +31,12 @@ public:
|
|||||||
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
if ((Block == E_BLOCK_LEAVES) || (Block == E_BLOCK_NEW_LEAVES))
|
if ((Block == E_BLOCK_LEAVES) || (Block == E_BLOCK_NEW_LEAVES))
|
||||||
{
|
{
|
||||||
|
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
cBlockHandler * Handler = cBlockInfo::GetHandler(Block);
|
||||||
|
|
||||||
cItems Drops;
|
cItems Drops;
|
||||||
Drops.push_back(cItem(Block, 1, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x03));
|
Handler->ConvertToPickups(Drops, Meta);
|
||||||
|
Drops.push_back(cItem(Block, 1, Meta & 3));
|
||||||
a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
|
a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
|
||||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
||||||
@ -54,7 +59,25 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} // switch (a_BlockType)
|
} // switch (a_BlockType)
|
||||||
return false;
|
return super::CanHarvestBlock(a_BlockType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||||
|
{
|
||||||
|
super::OnBlockDestroyed(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
|
||||||
|
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
if ((Block == E_BLOCK_TRIPWIRE) || (Block == E_BLOCK_VINES))
|
||||||
|
{
|
||||||
|
a_Player->UseEquippedItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
class cItemShovelHandler : public cItemHandler
|
class cItemShovelHandler : public cItemHandler
|
||||||
{
|
{
|
||||||
|
typedef cItemHandler super;
|
||||||
public:
|
public:
|
||||||
cItemShovelHandler(int a_ItemType)
|
cItemShovelHandler(int a_ItemType)
|
||||||
: cItemHandler(a_ItemType)
|
: cItemHandler(a_ItemType)
|
||||||
@ -39,7 +40,11 @@ public:
|
|||||||
|
|
||||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
||||||
{
|
{
|
||||||
return (a_BlockType == E_BLOCK_SNOW);
|
if (a_BlockType == E_BLOCK_SNOW)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super::CanHarvestBlock(a_BlockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
||||||
|
@ -12,17 +12,24 @@
|
|||||||
class cItemSwordHandler :
|
class cItemSwordHandler :
|
||||||
public cItemHandler
|
public cItemHandler
|
||||||
{
|
{
|
||||||
|
typedef cItemHandler super;
|
||||||
public:
|
public:
|
||||||
cItemSwordHandler(int a_ItemType)
|
cItemSwordHandler(int a_ItemType)
|
||||||
: cItemHandler(a_ItemType)
|
: cItemHandler(a_ItemType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
||||||
{
|
{
|
||||||
return (a_BlockType == E_BLOCK_COBWEB);
|
if (a_BlockType == E_BLOCK_COBWEB)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super::CanHarvestBlock(a_BlockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
||||||
{
|
{
|
||||||
switch (m_ItemType)
|
switch (m_ItemType)
|
||||||
@ -35,6 +42,17 @@ public:
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
|
||||||
|
{
|
||||||
|
switch (a_Action)
|
||||||
|
{
|
||||||
|
case dlaAttackEntity: return 1;
|
||||||
|
case dlaBreakBlock: return 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,11 +52,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
|
|||||||
{
|
{
|
||||||
m_IsSheared = true;
|
m_IsSheared = true;
|
||||||
m_World->BroadcastEntityMetadata(*this);
|
m_World->BroadcastEntityMetadata(*this);
|
||||||
|
a_Player.UseEquippedItem();
|
||||||
if (!a_Player.IsGameModeCreative())
|
|
||||||
{
|
|
||||||
a_Player.UseEquippedItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
cItems Drops;
|
cItems Drops;
|
||||||
int NumDrops = m_World->GetTickRandomNumber(2) + 1;
|
int NumDrops = m_World->GetTickRandomNumber(2) + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user