commit
48eafee823
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "BlockEntity.h"
|
#include "BlockEntity.h"
|
||||||
#include "../ItemGrid.h"
|
#include "../ItemGrid.h"
|
||||||
|
#include "../UI/WindowOwner.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ class cBlockEntityWithItems :
|
|||||||
// tolua_end
|
// tolua_end
|
||||||
// tolua doesn't seem to support multiple inheritance?
|
// tolua doesn't seem to support multiple inheritance?
|
||||||
, public cItemGrid::cListener
|
, public cItemGrid::cListener
|
||||||
|
, public cBlockEntityWindowOwner
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
{
|
{
|
||||||
typedef cBlockEntity super;
|
typedef cBlockEntity super;
|
||||||
@ -77,6 +79,11 @@ protected:
|
|||||||
ASSERT(a_Grid == &m_Contents);
|
ASSERT(a_Grid == &m_Contents);
|
||||||
if (m_World != NULL)
|
if (m_World != NULL)
|
||||||
{
|
{
|
||||||
|
if (GetWindow() != NULL)
|
||||||
|
{
|
||||||
|
GetWindow()->BroadcastWholeWindow();
|
||||||
|
}
|
||||||
|
|
||||||
m_World->MarkChunkDirty(GetChunkX(), GetChunkZ());
|
m_World->MarkChunkDirty(GetChunkX(), GetChunkZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntityWithItems.h"
|
#include "BlockEntityWithItems.h"
|
||||||
#include "../UI/WindowOwner.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -23,8 +22,7 @@ class cNBTData;
|
|||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
class cChestEntity :
|
class cChestEntity :
|
||||||
public cBlockEntityWithItems,
|
public cBlockEntityWithItems
|
||||||
public cBlockEntityWindowOwner
|
|
||||||
{
|
{
|
||||||
typedef cBlockEntityWithItems super;
|
typedef cBlockEntityWithItems super;
|
||||||
|
|
||||||
|
@ -99,13 +99,6 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir);
|
m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir);
|
||||||
m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
|
m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
|
||||||
|
|
||||||
// Update the UI window, if open:
|
|
||||||
cWindow * Window = GetWindow();
|
|
||||||
if (Window != NULL)
|
|
||||||
{
|
|
||||||
Window->BroadcastWholeWindow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntityWithItems.h"
|
#include "BlockEntityWithItems.h"
|
||||||
#include "../UI/WindowOwner.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -31,8 +30,7 @@ class cServer;
|
|||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
class cDropSpenserEntity :
|
class cDropSpenserEntity :
|
||||||
public cBlockEntityWithItems,
|
public cBlockEntityWithItems
|
||||||
public cBlockEntityWindowOwner
|
|
||||||
{
|
{
|
||||||
typedef cBlockEntityWithItems super;
|
typedef cBlockEntityWithItems super;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntityWithItems.h"
|
#include "BlockEntityWithItems.h"
|
||||||
#include "../UI/WindowOwner.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -23,8 +22,7 @@ class cNBTData;
|
|||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
class cEnderChestEntity :
|
class cEnderChestEntity :
|
||||||
public cBlockEntityWithItems,
|
public cBlockEntityWithItems
|
||||||
public cBlockEntityWindowOwner
|
|
||||||
{
|
{
|
||||||
typedef cBlockEntityWithItems super;
|
typedef cBlockEntityWithItems super;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntityWithItems.h"
|
#include "BlockEntityWithItems.h"
|
||||||
#include "../UI/WindowOwner.h"
|
|
||||||
#include "../FurnaceRecipe.h"
|
#include "../FurnaceRecipe.h"
|
||||||
|
|
||||||
|
|
||||||
@ -23,8 +22,7 @@ class cServer;
|
|||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
class cFurnaceEntity :
|
class cFurnaceEntity :
|
||||||
public cBlockEntityWithItems,
|
public cBlockEntityWithItems
|
||||||
public cBlockEntityWindowOwner
|
|
||||||
{
|
{
|
||||||
typedef cBlockEntityWithItems super;
|
typedef cBlockEntityWithItems super;
|
||||||
|
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
#include "HopperEntity.h"
|
#include "HopperEntity.h"
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
|
#include "../Entities/Pickup.h"
|
||||||
#include "../Bindings/PluginManager.h"
|
#include "../Bindings/PluginManager.h"
|
||||||
#include "ChestEntity.h"
|
#include "ChestEntity.h"
|
||||||
#include "DropSpenserEntity.h"
|
#include "DropSpenserEntity.h"
|
||||||
#include "FurnaceEntity.h"
|
#include "FurnaceEntity.h"
|
||||||
|
#include "../BoundingBox.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -190,8 +192,87 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
|
|||||||
/// Moves pickups from above this hopper into it. Returns true if the contents have changed.
|
/// Moves pickups from above this hopper into it. Returns true if the contents have changed.
|
||||||
bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
|
bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
|
||||||
{
|
{
|
||||||
// TODO
|
UNUSED(a_CurrentTick);
|
||||||
return false;
|
|
||||||
|
class cHopperPickupSearchCallback :
|
||||||
|
public cEntityCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cHopperPickupSearchCallback(const Vector3i & a_Pos, cItemGrid & a_Contents) :
|
||||||
|
m_Pos(a_Pos),
|
||||||
|
m_bFoundPickupsAbove(false),
|
||||||
|
m_Contents(a_Contents)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool Item(cEntity * a_Entity) override
|
||||||
|
{
|
||||||
|
ASSERT(a_Entity != NULL);
|
||||||
|
|
||||||
|
if (!a_Entity->IsPickup() || a_Entity->IsDestroyed())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3f EntityPos = a_Entity->GetPosition();
|
||||||
|
Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
|
||||||
|
float Distance = (EntityPos - BlockPos).Length();
|
||||||
|
|
||||||
|
if (Distance < 0.5)
|
||||||
|
{
|
||||||
|
if (TrySuckPickupIn((cPickup *)a_Entity))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TrySuckPickupIn(cPickup * a_Pickup)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ContentsWidth * ContentsHeight; i++)
|
||||||
|
{
|
||||||
|
if (m_Contents.IsSlotEmpty(i))
|
||||||
|
{
|
||||||
|
m_bFoundPickupsAbove = true;
|
||||||
|
m_Contents.SetSlot(i, a_Pickup->GetItem());
|
||||||
|
a_Pickup->Destroy(); // Kill pickup
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (m_Contents.GetSlot(i).IsEqual(a_Pickup->GetItem()) && !m_Contents.GetSlot(i).IsFullStack())
|
||||||
|
{
|
||||||
|
m_bFoundPickupsAbove = true;
|
||||||
|
|
||||||
|
int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;
|
||||||
|
a_Pickup->GetItem().m_ItemCount -= m_Contents.ChangeSlotCount(i, a_Pickup->GetItem().m_ItemCount) - PreviousCount; // Set count to however many items were added
|
||||||
|
|
||||||
|
if (a_Pickup->GetItem().IsEmpty())
|
||||||
|
{
|
||||||
|
a_Pickup->Destroy(); // Kill pickup if all items were added
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FoundPickupsAbove(void) const
|
||||||
|
{
|
||||||
|
return m_bFoundPickupsAbove;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Vector3i m_Pos;
|
||||||
|
bool m_bFoundPickupsAbove;
|
||||||
|
cItemGrid & m_Contents;
|
||||||
|
};
|
||||||
|
|
||||||
|
cHopperPickupSearchCallback HopperPickupSearchCallback(Vector3i(GetPosX(), GetPosY(), GetPosZ()), m_Contents);
|
||||||
|
a_Chunk.ForEachEntity(HopperPickupSearchCallback);
|
||||||
|
|
||||||
|
return HopperPickupSearchCallback.FoundPickupsAbove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntityWithItems.h"
|
#include "BlockEntityWithItems.h"
|
||||||
#include "../UI/WindowOwner.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -18,8 +17,7 @@
|
|||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
class cHopperEntity :
|
class cHopperEntity :
|
||||||
public cBlockEntityWithItems,
|
public cBlockEntityWithItems
|
||||||
public cBlockEntityWindowOwner
|
|
||||||
{
|
{
|
||||||
typedef cBlockEntityWithItems super;
|
typedef cBlockEntityWithItems super;
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
void EjectRecord(void);
|
void EjectRecord(void);
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
|
static const char * GetClassStatic(void) { return "cJukeboxEntity"; }
|
||||||
|
|
||||||
virtual void UsedBy(cPlayer * a_Player) override;
|
virtual void UsedBy(cPlayer * a_Player) override;
|
||||||
virtual void SendTo(cClientHandle &) override { };
|
virtual void SendTo(cClientHandle &) override { };
|
||||||
|
@ -54,6 +54,8 @@ public:
|
|||||||
virtual void UsedBy(cPlayer * a_Player) override;
|
virtual void UsedBy(cPlayer * a_Player) override;
|
||||||
virtual void SendTo(cClientHandle &) override { };
|
virtual void SendTo(cClientHandle &) override { };
|
||||||
|
|
||||||
|
static const char * GetClassStatic(void) { return "cNoteEntity"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char m_Pitch;
|
char m_Pitch;
|
||||||
} ; // tolua_export
|
} ; // tolua_export
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// SignEntity.h
|
// SignEntity.h
|
||||||
|
|
||||||
// Declares the cSignEntity class representing a single sign in the world
|
// Declares the cSignEntity class representing a single sign in the world
|
||||||
@ -56,6 +55,8 @@ public:
|
|||||||
|
|
||||||
virtual void UsedBy(cPlayer * a_Player) override;
|
virtual void UsedBy(cPlayer * a_Player) override;
|
||||||
virtual void SendTo(cClientHandle & a_Client) override;
|
virtual void SendTo(cClientHandle & a_Client) override;
|
||||||
|
|
||||||
|
static const char * GetClassStatic(void) { return "cSignEntity"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -1122,8 +1122,9 @@ void cPlayer::SetIP(const AString & a_IP)
|
|||||||
|
|
||||||
void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
|
void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
|
||||||
{
|
{
|
||||||
SetPosition( a_PosX, a_PosY, a_PosZ );
|
SetPosition(a_PosX, a_PosY, a_PosZ);
|
||||||
m_LastGroundHeight = (float)a_PosY;
|
m_LastGroundHeight = (float)a_PosY;
|
||||||
|
m_LastJumpHeight = (float)a_PosY;
|
||||||
|
|
||||||
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
|
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
|
||||||
m_ClientHandle->SendPlayerMoveLook();
|
m_ClientHandle->SendPlayerMoveLook();
|
||||||
|
@ -369,6 +369,13 @@ int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Slots[a_SlotNum].m_ItemCount += a_AddToCount;
|
m_Slots[a_SlotNum].m_ItemCount += a_AddToCount;
|
||||||
|
|
||||||
|
cItemHandler * Handler = cItemHandler::GetItemHandler(m_Slots[a_SlotNum].m_ItemType);
|
||||||
|
if (m_Slots[a_SlotNum].m_ItemCount > Handler->GetMaxStackSize())
|
||||||
|
{
|
||||||
|
m_Slots[a_SlotNum].m_ItemCount = Handler->GetMaxStackSize();
|
||||||
|
}
|
||||||
|
|
||||||
TriggerListeners(a_SlotNum);
|
TriggerListeners(a_SlotNum);
|
||||||
return m_Slots[a_SlotNum].m_ItemCount;
|
return m_Slots[a_SlotNum].m_ItemCount;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../MersenneTwister.h"
|
#include "../Tracer.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -73,6 +73,18 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
{
|
{
|
||||||
CheckEventSeePlayer();
|
CheckEventSeePlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_Target == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cTracer LineOfSight(GetWorld());
|
||||||
|
Vector3d AttackDirection(m_Target->GetPosition() - GetPosition());
|
||||||
|
|
||||||
|
if (ReachedFinalDestination() && !LineOfSight.Trace(GetPosition(), AttackDirection, (int)AttackDirection.Length()))
|
||||||
|
{
|
||||||
|
// Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls)
|
||||||
|
Attack(a_Dt / 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +93,7 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
|
|
||||||
void cAggressiveMonster::Attack(float a_Dt)
|
void cAggressiveMonster::Attack(float a_Dt)
|
||||||
{
|
{
|
||||||
super::Attack(a_Dt);
|
m_AttackInterval += a_Dt * m_AttackRate;
|
||||||
|
|
||||||
if ((m_Target != NULL) && (m_AttackInterval > 3.0))
|
if ((m_Target != NULL) && (m_AttackInterval > 3.0))
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
virtual void InStateChasing(float a_Dt) override;
|
virtual void InStateChasing(float a_Dt) override;
|
||||||
|
|
||||||
virtual void EventSeePlayer(cEntity *) override;
|
virtual void EventSeePlayer(cEntity *) override;
|
||||||
virtual void Attack(float a_Dt) override;
|
virtual void Attack(float a_Dt);
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -311,9 +311,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReachedFinalDestination() && (m_Target != NULL))
|
|
||||||
Attack(a_Dt);
|
|
||||||
|
|
||||||
SetPitchAndYawFromDestination();
|
SetPitchAndYawFromDestination();
|
||||||
HandleFalling();
|
HandleFalling();
|
||||||
|
|
||||||
@ -657,17 +654,6 @@ void cMonster::InStateEscaping(float a_Dt)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Do attack here
|
|
||||||
// a_Dt is passed so we can set attack rate
|
|
||||||
void cMonster::Attack(float a_Dt)
|
|
||||||
{
|
|
||||||
m_AttackInterval += a_Dt * m_AttackRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cMonster::GetMonsterConfig(const AString & a_Name)
|
void cMonster::GetMonsterConfig(const AString & a_Name)
|
||||||
{
|
{
|
||||||
cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, a_Name);
|
cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, a_Name);
|
||||||
|
@ -112,8 +112,6 @@ public:
|
|||||||
virtual void InStateChasing (float a_Dt);
|
virtual void InStateChasing (float a_Dt);
|
||||||
virtual void InStateEscaping(float a_Dt);
|
virtual void InStateEscaping(float a_Dt);
|
||||||
|
|
||||||
virtual void Attack(float a_Dt);
|
|
||||||
|
|
||||||
int GetAttackRate() { return (int)m_AttackRate; }
|
int GetAttackRate() { return (int)m_AttackRate; }
|
||||||
void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; }
|
void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; }
|
||||||
void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; }
|
void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; }
|
||||||
|
@ -960,7 +960,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc
|
|||||||
Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
|
Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
|
||||||
float Distance = (EntityPos - BlockPos).Length();
|
float Distance = (EntityPos - BlockPos).Length();
|
||||||
|
|
||||||
if (Distance < 0.5)
|
if (Distance <= 0.7)
|
||||||
{
|
{
|
||||||
m_Entity = a_Entity;
|
m_Entity = a_Entity;
|
||||||
return true; // Break out, we only need to know for wooden plates that at least one entity is on top
|
return true; // Break out, we only need to know for wooden plates that at least one entity is on top
|
||||||
|
@ -207,6 +207,10 @@ private:
|
|||||||
case E_BLOCK_REDSTONE_REPEATER_ON:
|
case E_BLOCK_REDSTONE_REPEATER_ON:
|
||||||
case E_BLOCK_BLOCK_OF_REDSTONE:
|
case E_BLOCK_BLOCK_OF_REDSTONE:
|
||||||
case E_BLOCK_ACTIVE_COMPARATOR:
|
case E_BLOCK_ACTIVE_COMPARATOR:
|
||||||
|
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
|
||||||
|
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
|
||||||
|
case E_BLOCK_STONE_PRESSURE_PLATE:
|
||||||
|
case E_BLOCK_WOODEN_PRESSURE_PLATE:
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user