summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Server/Plugins/Debuggers/Debuggers.lua21
-rw-r--r--src/Entities/Entity.cpp6
2 files changed, 26 insertions, 1 deletions
diff --git a/Server/Plugins/Debuggers/Debuggers.lua b/Server/Plugins/Debuggers/Debuggers.lua
index 4cf825f12..1505904a8 100644
--- a/Server/Plugins/Debuggers/Debuggers.lua
+++ b/Server/Plugins/Debuggers/Debuggers.lua
@@ -30,6 +30,7 @@ function Initialize(a_Plugin)
PM:AddHook(cPluginManager.HOOK_CHUNK_UNLOADING, OnChunkUnloading);
PM:AddHook(cPluginManager.HOOK_WORLD_STARTED, OnWorldStarted);
PM:AddHook(cPluginManager.HOOK_PROJECTILE_HIT_BLOCK, OnProjectileHitBlock);
+ PM:AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, OnPlayerRightClick)
-- _X: Disabled WECUI manipulation:
-- PM:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage);
@@ -714,6 +715,26 @@ end
+function OnPlayerRightClick(a_Player)
+ -- If the player is holding a cake item, make them throw a cake block, using a FallingBlock entity:
+ if (a_Player:GetInventory():GetEquippedItem().m_ItemType == E_ITEM_CAKE) then
+ local World = a_Player:GetWorld()
+ local Position = a_Player:GetPosition() + Vector3d(0, 1.5, 0)
+ local EntityID = World:SpawnFallingBlock(Vector3i(Position), E_BLOCK_CAKE, 0)
+
+ World:DoWithEntityByID(EntityID,
+ function (Entity)
+ Entity:TeleportToCoords(Position.x, Position.y, Position.z)
+ Entity:SetSpeed(a_Player:GetLookVector() * 30)
+ end
+ )
+ end
+end
+
+
+
+
+
function OnPlayerRightClickingEntity(a_Player, a_Entity)
LOG("Player " .. a_Player:GetName() .. " right-clicking entity ID " .. a_Entity:GetUniqueID() .. ", a " .. a_Entity:GetClass());
return false;
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index e7682e6da..3ff48440c 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1893,7 +1893,11 @@ void cEntity::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
if (!cRoot::Get()->GetPluginManager()->CallHookEntityTeleport(*this, m_LastPosition, Vector3d(a_PosX, a_PosY, a_PosZ)))
{
ResetPosition({a_PosX, a_PosY, a_PosZ});
- m_World->BroadcastTeleportEntity(*this);
+ auto world = m_World;
+ if (world != nullptr) // The entity might not be in a world yet (just spawned, in cWorld::m_EntitiesToAdd)
+ {
+ world->BroadcastTeleportEntity(*this);
+ }
}
}