From d8072da61f8a098ea30f579034ad976cf86408f3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 15:54:43 +0200 Subject: [PATCH 01/14] Fix skull bugs. --- src/BlockEntities/MobHeadEntity.cpp | 5 ++++ src/Blocks/BlockMobHead.h | 43 +++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp index dc9c18d58..60d6a123f 100644 --- a/src/BlockEntities/MobHeadEntity.cpp +++ b/src/BlockEntities/MobHeadEntity.cpp @@ -70,6 +70,11 @@ void cMobHeadEntity::SetOwner(const AString & a_Owner) void cMobHeadEntity::SendTo(cClientHandle & a_Client) { + BLOCKTYPE Block; + NIBBLETYPE Meta; + a_Client.GetPlayer()->GetWorld()->GetBlockTypeMeta(m_PosX, m_PosY, m_PosZ, Block, Meta); + + a_Client.SendBlockChange(m_PosX, m_PosY, m_PosZ, Block, Meta); a_Client.SendUpdateBlockEntity(*this); } diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index b7629b07c..248f20d49 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -19,7 +19,46 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.push_back(cItem(E_ITEM_HEAD, 1, 0)); + // The drops spawns in OnDestroyed + } + + virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override + { + if (a_Player->IsGameModeCreative()) + { + // No drops in creative mode + return; + } + + class cCallback : public cMobHeadCallback + { + virtual bool Item(cMobHeadEntity * a_MobHeadEntity) + { + cItems Pickups; + Pickups.Add(E_ITEM_HEAD, 1, (short) a_MobHeadEntity->GetType()); + MTRand r1; + + // Mid-block position first + double MicroX, MicroY, MicroZ; + MicroX = a_MobHeadEntity->GetPosX() + 0.5; + MicroY = a_MobHeadEntity->GetPosY() + 0.5; + MicroZ = a_MobHeadEntity->GetPosZ() + 0.5; + + // Add random offset second + MicroX += r1.rand(1) - 0.5; + MicroZ += r1.rand(1) - 0.5; + + a_MobHeadEntity->GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); + return false; + } + + public: + cCallback() {} + }; + cCallback Callback; + + cWorld * World = (cWorld *) &a_WorldInterface; + World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback); } bool TrySpawnWither(cChunkInterface & a_ChunkInterface, cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) @@ -170,7 +209,7 @@ public: a_MobHeadEntity->SetType(static_cast(m_OldBlockMeta)); a_MobHeadEntity->SetRotation(static_cast(Rotation)); - a_MobHeadEntity->GetWorld()->BroadcastBlockEntity(a_MobHeadEntity->GetPosX(), a_MobHeadEntity->GetPosY(), a_MobHeadEntity->GetPosZ(), m_Player->GetClientHandle()); + a_MobHeadEntity->GetWorld()->BroadcastBlockEntity(a_MobHeadEntity->GetPosX(), a_MobHeadEntity->GetPosY(), a_MobHeadEntity->GetPosZ()); return false; } From 61b6fdde7553dac6e2d5c5a071b9a13fa0d71b2f Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 16:07:51 +0200 Subject: [PATCH 02/14] Fix right click bugs. --- src/ClientHandle.cpp | 83 ++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9b03bead9..ce7ce0cea 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1088,52 +1088,15 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e ); cWorld * World = m_Player->GetWorld(); - - if ( - (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || - (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || - (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) - ) - { - if (a_BlockFace != BLOCK_FACE_NONE) - { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things - m_Player->GetInventory().SendEquippedSlot(); - } - return; - } - - cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); - if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) - { - // A plugin doesn't agree with the action, replace the block on the client and quit: - cChunkInterface ChunkInterface(World->GetChunkMap()); - BLOCKTYPE BlockType = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); - BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - - if (a_BlockFace != BLOCK_FACE_NONE) - { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things - m_Player->GetInventory().SendEquippedSlot(); - } - return; - } - m_NumBlockChangeInteractionsThisTick++; - + if (!CheckBlockInteractionsRate()) { Kick("Too many blocks were placed/interacted with per unit time - hacked client?"); return; } - - const cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); + const cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1)) { // Only compare ItemType, not meta (torches have different metas) @@ -1156,6 +1119,46 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e NIBBLETYPE BlockMeta; World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); + cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); + + if ( + ( + BlockHandler->IsUseable() || + (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) + ) && + ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) + ) + { + if (a_BlockFace != BLOCK_FACE_NONE) + { + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things + m_Player->GetInventory().SendEquippedSlot(); + } + return; + } + + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); + if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) + { + // A plugin doesn't agree with the action, replace the block on the client and quit: + cChunkInterface ChunkInterface(World->GetChunkMap()); + BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + + if (a_BlockFace != BLOCK_FACE_NONE) + { + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things + m_Player->GetInventory().SendEquippedSlot(); + } + return; + } if (BlockHandler->IsUseable() && !m_Player->IsCrouched()) { @@ -1170,8 +1173,6 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); - if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); From d4f90259b8cd3e5d90dd419930c8635105ea4d0f Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 16:12:10 +0200 Subject: [PATCH 03/14] Fix Y-Position from arrow entity. --- src/Entities/ArrowEntity.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 8d2569125..fbc535e63 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -19,6 +19,7 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a m_bIsCollected(false), m_HitBlockPos(Vector3i(0, 0, 0)) { + SetPosY(GetPosY() + a_Creator->GetHeight() - 0.1000000014901161); SetSpeed(a_Speed); SetMass(0.1); SetYawFromSpeed(); From e7a7c45c3681e90cb9ab13d16935aae9860f1077 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 16:39:59 +0200 Subject: [PATCH 04/14] Add throw sound and fix arrow server crash. --- src/Entities/ArrowEntity.cpp | 5 ++++- src/Entities/ThrownSnowballEntity.cpp | 4 ---- src/Items/ItemThrowable.h | 11 +++++++++++ src/WorldStorage/NBTChunkSerializer.cpp | 1 + 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index fbc535e63..769750bd4 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -19,7 +19,10 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a m_bIsCollected(false), m_HitBlockPos(Vector3i(0, 0, 0)) { - SetPosY(GetPosY() + a_Creator->GetHeight() - 0.1000000014901161); + if (a_Creator != NULL) + { + SetPosY(GetPosY() + a_Creator->GetHeight() - 0.1000000014901161); + } SetSpeed(a_Speed); SetMass(0.1); SetYawFromSpeed(); diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp index 427f630f7..cefc3433c 100644 --- a/src/Entities/ThrownSnowballEntity.cpp +++ b/src/Entities/ThrownSnowballEntity.cpp @@ -36,10 +36,6 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & { TotalDamage = 3; } - else if (MobType == cMonster::mtEnderDragon) - { - TotalDamage = 1; - } } // TODO: If entity is Ender Crystal, destroy it a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index 35c2b8731..25935a1bc 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -31,6 +31,17 @@ public: Vector3d Pos = a_Player->GetThrowStartPos(); Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff; + // Play sound + cFastRandom Random; + a_World->BroadcastSoundEffect( + "random.bow", + (int)std::floor(a_Player->GetPosX() * 8.0), + (int)std::floor((a_Player->GetPosY() - a_Player->GetHeight()) * 8.0), + (int)std::floor(a_Player->GetPosZ() * 8.0), + 0.5F, + 0.4F / (Random.NextFloat(1.0F) * 0.4F + 0.8F) + ); + if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed) < 0) { return false; diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 7b7cd3c7e..cc1ffe8f9 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -608,6 +608,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) case cProjectileEntity::pkGhastFireball: { m_Writer.AddInt("ExplosionPower", 1); + break; // fall-through: } case cProjectileEntity::pkFireCharge: From 421588d25dd4e2e293d48daece27444bfbc318bf Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 16:59:51 +0200 Subject: [PATCH 05/14] Fix fire break. --- src/Blocks/BlockFire.h | 4 ++-- src/ClientHandle.cpp | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h index f9f32eb50..147e4b53e 100644 --- a/src/Blocks/BlockFire.h +++ b/src/Blocks/BlockFire.h @@ -36,8 +36,8 @@ public: - Loop through boundary variables, and fill with portal blocks based on Dir with meta from Dir */ - a_BlockY--; // Because we want the block below the fire - FindAndSetPortalFrame(a_BlockX, a_BlockY, a_BlockZ, a_ChunkInterface, a_WorldInterface); + // a_BlockY - 1: Because we want the block below the fire + FindAndSetPortalFrame(a_BlockX, a_BlockY - 1, a_BlockZ, a_ChunkInterface, a_WorldInterface); } virtual void OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index ce7ce0cea..9a7d1cd62 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -954,6 +954,23 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc m_LastDigBlockY = a_BlockY; m_LastDigBlockZ = a_BlockZ; + if (a_BlockFace != BLOCK_FACE_NONE) + { + int pX = a_BlockX; + int pY = a_BlockY; + int pZ = a_BlockZ; + + AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false) + cBlockHandler * Handler = cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(pX, pY, pZ)); + + if (Handler->IsClickedThrough()) + { + cChunkInterface ChunkInterface(m_Player->GetWorld()->GetChunkMap()); + Handler->OnDigging(ChunkInterface, *m_Player->GetWorld(), m_Player, pX, pY, pZ); + return; + } + } + if ( (m_Player->IsGameModeCreative()) || // In creative mode, digging is done immediately cBlockInfo::IsOneHitDig(a_OldBlock) // One-hit blocks get destroyed immediately, too @@ -980,22 +997,6 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); ItemHandler->OnDiggingBlock(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - - // Check for clickthrough-blocks: - if (a_BlockFace != BLOCK_FACE_NONE) - { - int pX = a_BlockX; - int pY = a_BlockY; - int pZ = a_BlockZ; - - AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false) - Handler = cBlockInfo::GetHandler(World->GetBlock(pX, pY, pZ)); - - if (Handler->IsClickedThrough()) - { - Handler->OnDigging(ChunkInterface, *World, m_Player, pX, pY, pZ); - } - } } From 9f645b2c75aa8dbfbab439e4afdf17a321072a88 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 17:05:13 +0200 Subject: [PATCH 06/14] Fix hay place sound. --- src/Blocks/BlockHandler.cpp | 3 ++- src/Blocks/BlockHayBale.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/Blocks/BlockHayBale.h diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 304e35e84..bae396ea8 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -38,6 +38,7 @@ #include "BlockGlass.h" #include "BlockGlowstone.h" #include "BlockGravel.h" +#include "BlockHayBale.h" #include "BlockMobHead.h" #include "BlockHopper.h" #include "BlockIce.h" @@ -132,7 +133,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType); case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType); case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType); - case E_BLOCK_HAY_BALE: return new cBlockSidewaysHandler (a_BlockType); + case E_BLOCK_HAY_BALE: return new cBlockHayBaleHandler (a_BlockType); case E_BLOCK_HEAD: return new cBlockMobHeadHandler (a_BlockType); case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType); case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType); diff --git a/src/Blocks/BlockHayBale.h b/src/Blocks/BlockHayBale.h new file mode 100644 index 000000000..5b646e264 --- /dev/null +++ b/src/Blocks/BlockHayBale.h @@ -0,0 +1,29 @@ + +#pragma once + +#include "BlockHandler.h" +#include "BlockSideways.h" + + + + + +class cBlockHayBaleHandler : + public cBlockSidewaysHandler +{ +public: + cBlockHayBaleHandler(BLOCKTYPE a_BlockType) + : cBlockSidewaysHandler(a_BlockType) + { + } + + + virtual const char * GetStepSound(void) override + { + return "step.grass"; + } +} ; + + + + From 142fa83124fc3b766916ac79fb037fea91a19a1e Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 19:32:20 +0200 Subject: [PATCH 07/14] Code improvements --- src/BlockEntities/MobHeadEntity.cpp | 7 ++----- src/Blocks/BlockMobHead.h | 8 ++------ src/WorldStorage/NBTChunkSerializer.cpp | 1 - 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp index 60d6a123f..ce895eb6f 100644 --- a/src/BlockEntities/MobHeadEntity.cpp +++ b/src/BlockEntities/MobHeadEntity.cpp @@ -70,11 +70,8 @@ void cMobHeadEntity::SetOwner(const AString & a_Owner) void cMobHeadEntity::SendTo(cClientHandle & a_Client) { - BLOCKTYPE Block; - NIBBLETYPE Meta; - a_Client.GetPlayer()->GetWorld()->GetBlockTypeMeta(m_PosX, m_PosY, m_PosZ, Block, Meta); - - a_Client.SendBlockChange(m_PosX, m_PosY, m_PosZ, Block, Meta); + cWorld * World = a_Client.GetPlayer()->GetWorld(); + a_Client.SendBlockChange(m_PosX, m_PosY, m_PosZ, m_BlockType, World->GetBlockMeta(m_PosX, m_PosY, m_PosZ)); a_Client.SendUpdateBlockEntity(*this); } diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index 248f20d49..fe4099835 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -19,7 +19,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - // The drops spawns in OnDestroyed + // The drop spawn is in OnDestroyed method } virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override @@ -51,11 +51,7 @@ public: a_MobHeadEntity->GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); return false; } - - public: - cCallback() {} - }; - cCallback Callback; + } Callback; cWorld * World = (cWorld *) &a_WorldInterface; World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback); diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index cc1ffe8f9..82e8ee8bd 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -609,7 +609,6 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) { m_Writer.AddInt("ExplosionPower", 1); break; - // fall-through: } case cProjectileEntity::pkFireCharge: case cProjectileEntity::pkWitherSkull: From 92d9ab0f6dbd5e6d9b23ed309daa473b00c70ebb Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 30 May 2014 22:25:57 +0200 Subject: [PATCH 08/14] Wrong arrow commit. --- src/Entities/ArrowEntity.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 769750bd4..8d2569125 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -19,10 +19,6 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a m_bIsCollected(false), m_HitBlockPos(Vector3i(0, 0, 0)) { - if (a_Creator != NULL) - { - SetPosY(GetPosY() + a_Creator->GetHeight() - 0.1000000014901161); - } SetSpeed(a_Speed); SetMass(0.1); SetYawFromSpeed(); From a89524d5330ffbdbaea1d38421dabe8d8f62999e Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 01:15:38 +0200 Subject: [PATCH 09/14] Add DoWithBlockEntityAt() to WorldInterface.h --- src/Blocks/BlockMobHead.h | 89 ++++++++++++++++++++++--------------- src/Blocks/WorldInterface.h | 9 ++++ src/ChunkMap.h | 4 +- src/World.h | 2 +- 4 files changed, 64 insertions(+), 40 deletions(-) diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index fe4099835..34a92c150 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -30,48 +30,58 @@ public: return; } - class cCallback : public cMobHeadCallback + class cCallback : public cBlockEntityCallback { - virtual bool Item(cMobHeadEntity * a_MobHeadEntity) + virtual bool Item(cBlockEntity * a_BlockEntity) { + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); + if (MobHeadEntity == NULL) + { + return false; + } + cItems Pickups; - Pickups.Add(E_ITEM_HEAD, 1, (short) a_MobHeadEntity->GetType()); + Pickups.Add(E_ITEM_HEAD, 1, (short) MobHeadEntity->GetType()); MTRand r1; // Mid-block position first double MicroX, MicroY, MicroZ; - MicroX = a_MobHeadEntity->GetPosX() + 0.5; - MicroY = a_MobHeadEntity->GetPosY() + 0.5; - MicroZ = a_MobHeadEntity->GetPosZ() + 0.5; + MicroX = MobHeadEntity->GetPosX() + 0.5; + MicroY = MobHeadEntity->GetPosY() + 0.5; + MicroZ = MobHeadEntity->GetPosZ() + 0.5; // Add random offset second MicroX += r1.rand(1) - 0.5; MicroZ += r1.rand(1) - 0.5; - a_MobHeadEntity->GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); + MobHeadEntity->GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); return false; } } Callback; - cWorld * World = (cWorld *) &a_WorldInterface; - World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback); } - bool TrySpawnWither(cChunkInterface & a_ChunkInterface, cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) + bool TrySpawnWither(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { if (a_BlockY < 2) { return false; } - class cCallback : public cMobHeadCallback + class cCallback : public cBlockEntityCallback { bool m_IsWither; - virtual bool Item (cMobHeadEntity * a_MobHeadEntity) + virtual bool Item (cBlockEntity * a_BlockEntity) { - m_IsWither = (a_MobHeadEntity->GetType() == SKULL_TYPE_WITHER); + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); + if (MobHeadEntity == NULL) + { + return false; + } + m_IsWither = (MobHeadEntity->GetType() == SKULL_TYPE_WITHER); return false; } @@ -105,7 +115,7 @@ public: } PlayerCallback(Vector3f(a_BlockX, a_BlockY, a_BlockZ)); - a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, CallbackA); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, CallbackA); if (!CallbackA.IsWither()) { @@ -122,8 +132,8 @@ public: return false; } - a_World->DoWithMobHeadAt(a_BlockX - 1, a_BlockY, a_BlockZ, CallbackA); - a_World->DoWithMobHeadAt(a_BlockX + 1, a_BlockY, a_BlockZ, CallbackB); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX - 1, a_BlockY, a_BlockZ, CallbackA); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX + 1, a_BlockY, a_BlockZ, CallbackB); BLOCKTYPE Block1 = a_ChunkInterface.GetBlock(a_BlockX - 1, a_BlockY - 1, a_BlockZ); BLOCKTYPE Block2 = a_ChunkInterface.GetBlock(a_BlockX + 1, a_BlockY - 1, a_BlockZ); @@ -136,15 +146,15 @@ public: a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0); // Block entities - a_World->SetBlock(a_BlockX + 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); - a_World->SetBlock(a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX + 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); // Spawn the wither: - a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); // Award Achievement - a_World->ForEachPlayer(PlayerCallback); + a_WorldInterface.ForEachPlayer(PlayerCallback); return true; } @@ -152,8 +162,8 @@ public: CallbackA.Reset(); CallbackB.Reset(); - a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ - 1, CallbackA); - a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ + 1, CallbackB); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ - 1, CallbackA); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ + 1, CallbackB); Block1 = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ - 1); Block2 = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ + 1); @@ -166,15 +176,15 @@ public: a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0); // Block entities - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ + 1, E_BLOCK_AIR, 0); - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ + 1, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0); // Spawn the wither: - a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); // Award Achievement - a_World->ForEachPlayer(PlayerCallback); + a_WorldInterface.ForEachPlayer(PlayerCallback); return true; } @@ -189,23 +199,29 @@ public: BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) override { - class cCallback : public cMobHeadCallback + class cCallback : public cBlockEntityCallback { cPlayer * m_Player; NIBBLETYPE m_OldBlockMeta; NIBBLETYPE m_NewBlockMeta; - virtual bool Item (cMobHeadEntity * a_MobHeadEntity) + virtual bool Item (cBlockEntity * a_BlockEntity) { + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); + if (MobHeadEntity == NULL) + { + return false; + } + int Rotation = 0; if (m_NewBlockMeta == 1) { Rotation = (int) floor(m_Player->GetYaw() * 16.0F / 360.0F + 0.5) & 0xF; } - - a_MobHeadEntity->SetType(static_cast(m_OldBlockMeta)); - a_MobHeadEntity->SetRotation(static_cast(Rotation)); - a_MobHeadEntity->GetWorld()->BroadcastBlockEntity(a_MobHeadEntity->GetPosX(), a_MobHeadEntity->GetPosY(), a_MobHeadEntity->GetPosZ()); + + MobHeadEntity->SetType(static_cast(m_OldBlockMeta)); + MobHeadEntity->SetRotation(static_cast(Rotation)); + MobHeadEntity->GetWorld()->BroadcastBlockEntity(MobHeadEntity->GetPosX(), MobHeadEntity->GetPosY(), MobHeadEntity->GetPosZ()); return false; } @@ -219,8 +235,7 @@ public: cCallback Callback(a_Player, a_BlockMeta, static_cast(a_BlockFace)); a_BlockMeta = (NIBBLETYPE)a_BlockFace; - cWorld * World = (cWorld *) &a_WorldInterface; - World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback); a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta); if (a_BlockMeta == SKULL_TYPE_WITHER) @@ -235,7 +250,7 @@ public: }; for (size_t i = 0; i < ARRAYCOUNT(Coords); ++i) { - if (TrySpawnWither(a_ChunkInterface, World, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z)) + if (TrySpawnWither(a_ChunkInterface, a_WorldInterface, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z)) { break; } diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index bfbb053d9..650a216c0 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -6,6 +6,12 @@ class cItems; +typedef cItemCallback cBlockEntityCallback; + + + + + class cWorldInterface { public: @@ -29,6 +35,9 @@ public: /** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */ virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) = 0; + /** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */ + virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) = 0; + /** Sends the block on those coords to the player */ virtual void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, cPlayer * a_Player) = 0; diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 9d973f2a9..adcf687c0 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -34,8 +34,8 @@ class cBlockArea; class cMobCensus; class cMobSpawner; -typedef std::list cClientHandleList; -typedef cChunk * cChunkPtr; +typedef std::list cClientHandleList; +typedef cChunk * cChunkPtr; typedef cItemCallback cEntityCallback; typedef cItemCallback cBlockEntityCallback; typedef cItemCallback cChestCallback; diff --git a/src/World.h b/src/World.h index 86cbb3e7e..cd465bece 100644 --- a/src/World.h +++ b/src/World.h @@ -511,7 +511,7 @@ public: virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) override; // tolua_export /** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */ - bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback); // Exported in ManualBindings.cpp + virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) override; // Exported in ManualBindings.cpp /** Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found */ bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback); // Exported in ManualBindings.cpp From 46b84aa8b63015a5a553f4b7a1905582e25cc2e1 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 01:17:35 +0200 Subject: [PATCH 10/14] The motion is already set in AddBasicEntity() --- src/WorldStorage/NBTChunkSerializer.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 82e8ee8bd..6e1bf41aa 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -614,11 +614,6 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) case cProjectileEntity::pkWitherSkull: case cProjectileEntity::pkEnderPearl: { - m_Writer.BeginList("Motion", TAG_Double); - m_Writer.AddDouble("", a_Projectile->GetSpeedX()); - m_Writer.AddDouble("", a_Projectile->GetSpeedY()); - m_Writer.AddDouble("", a_Projectile->GetSpeedZ()); - m_Writer.EndList(); break; } default: From 1086b8ba05a3ed604423f8222a8a1834324006d2 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 01:18:09 +0200 Subject: [PATCH 11/14] Revert "Fix right click bugs." This reverts commit 61b6fdde7553dac6e2d5c5a071b9a13fa0d71b2f. --- src/ClientHandle.cpp | 83 ++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9a7d1cd62..06c389d99 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1089,15 +1089,52 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e ); cWorld * World = m_Player->GetWorld(); - m_NumBlockChangeInteractionsThisTick++; + if ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) + { + if (a_BlockFace != BLOCK_FACE_NONE) + { + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things + m_Player->GetInventory().SendEquippedSlot(); + } + return; + } + + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); + if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) + { + // A plugin doesn't agree with the action, replace the block on the client and quit: + cChunkInterface ChunkInterface(World->GetChunkMap()); + BLOCKTYPE BlockType = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); + BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + + if (a_BlockFace != BLOCK_FACE_NONE) + { + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things + m_Player->GetInventory().SendEquippedSlot(); + } + return; + } + + m_NumBlockChangeInteractionsThisTick++; + if (!CheckBlockInteractionsRate()) { Kick("Too many blocks were placed/interacted with per unit time - hacked client?"); return; } - + const cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); + if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1)) { // Only compare ItemType, not meta (torches have different metas) @@ -1120,46 +1157,6 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e NIBBLETYPE BlockMeta; World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); - - if ( - ( - BlockHandler->IsUseable() || - (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) - ) && - ( - (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || - (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || - (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) - ) - ) - { - if (a_BlockFace != BLOCK_FACE_NONE) - { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things - m_Player->GetInventory().SendEquippedSlot(); - } - return; - } - - cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); - if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) - { - // A plugin doesn't agree with the action, replace the block on the client and quit: - cChunkInterface ChunkInterface(World->GetChunkMap()); - BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - - if (a_BlockFace != BLOCK_FACE_NONE) - { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things - m_Player->GetInventory().SendEquippedSlot(); - } - return; - } if (BlockHandler->IsUseable() && !m_Player->IsCrouched()) { @@ -1174,6 +1171,8 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } + cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); + if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); From da88c980347aac9562e3f4862ba76948d4d6f120 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 13:25:36 +0200 Subject: [PATCH 12/14] Add comment. --- src/ClientHandle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 06c389d99..683ee418c 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -954,6 +954,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc m_LastDigBlockY = a_BlockY; m_LastDigBlockZ = a_BlockZ; + // Check for clickthrough-blocks: if (a_BlockFace != BLOCK_FACE_NONE) { int pX = a_BlockX; From 7e985f3c7d0a301fafdef01e31553e7215c72e5b Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 13:44:07 +0200 Subject: [PATCH 13/14] Add more documentation. --- src/ClientHandle.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 683ee418c..664bcf875 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -955,6 +955,8 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc m_LastDigBlockZ = a_BlockZ; // Check for clickthrough-blocks: + /* When the user breaks a fire block, the client send the wrong block location. + We must find the right block with the face direction. */ if (a_BlockFace != BLOCK_FACE_NONE) { int pX = a_BlockX; From 8e927e6e2bfb461b26a3413cbde829f98fbcaa28 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 14:45:29 +0200 Subject: [PATCH 14/14] Check block type from cBlockEntity --- src/Blocks/BlockMobHead.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index 34a92c150..68996aa3f 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -34,11 +34,11 @@ public: { virtual bool Item(cBlockEntity * a_BlockEntity) { - cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); - if (MobHeadEntity == NULL) + if (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD) { return false; } + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); cItems Pickups; Pickups.Add(E_ITEM_HEAD, 1, (short) MobHeadEntity->GetType()); @@ -73,13 +73,13 @@ public: { bool m_IsWither; - virtual bool Item (cBlockEntity * a_BlockEntity) + virtual bool Item(cBlockEntity * a_BlockEntity) { - cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); - if (MobHeadEntity == NULL) + if (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD) { return false; } + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); m_IsWither = (MobHeadEntity->GetType() == SKULL_TYPE_WITHER); return false; @@ -205,13 +205,13 @@ public: NIBBLETYPE m_OldBlockMeta; NIBBLETYPE m_NewBlockMeta; - virtual bool Item (cBlockEntity * a_BlockEntity) + virtual bool Item(cBlockEntity * a_BlockEntity) { - cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); - if (MobHeadEntity == NULL) + if (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD) { return false; } + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); int Rotation = 0; if (m_NewBlockMeta == 1)