diff options
Diffstat (limited to 'MCServer/Plugins')
-rw-r--r-- | MCServer/Plugins/APIDump/APIDesc.lua | 2 | ||||
-rw-r--r-- | MCServer/Plugins/APIDump/Hooks/OnKilling.lua | 1 | ||||
-rw-r--r-- | MCServer/Plugins/Debuggers/Debuggers.lua | 111 | ||||
-rw-r--r-- | MCServer/Plugins/Debuggers/Info.lua | 6 |
4 files changed, 120 insertions, 0 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 4af01c0a4..161fe59d1 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1917,6 +1917,8 @@ a_Player:OpenWindow(Window); SendMessagePrivateMsg = { Params = "Message, SenderName", Return = "", Notes = "Prepends Light Blue [MSG: *SenderName*] / prepends SenderName and colours entire text (depending on ShouldUseChatPrefixes()) and sends message to player. For private messaging." }, SendMessageSuccess = { Params = "Message", Return = "", Notes = "Prepends Green [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and sends message to player. Success notification." }, SendMessageWarning = { Params = "Message, Sender", Return = "", Notes = "Prepends Rose [WARN] / colours entire text (depending on ShouldUseChatPrefixes()) and sends message to player. Denotes that something concerning, such as plugin reload, is about to happen." }, + SendAboveActionBarMessage = { Params = "Message", Return = "", Notes = "Sends the specified message to the player (shows above action bar, doesn't show for < 1.8 clients)." }, + SendSystemMessage = { Params = "Message", Return = "", Notes = "Sends the specified message to the player (doesn't show for < 1.8 clients)." }, SendRotation = { Params = "YawDegrees, PitchDegrees", Return = "", Notes = "Sends the specified rotation to the player, forcing them to look that way" }, SetBedPos = { Params = "{{Vector3i|Position}}", Return = "", Notes = "Sets the internal representation of the last bed position the player has slept in. The player will respawn at this position if they die." }, SetCanFly = { Params = "CanFly", Notes = "Sets if the player can fly or not." }, diff --git a/MCServer/Plugins/APIDump/Hooks/OnKilling.lua b/MCServer/Plugins/APIDump/Hooks/OnKilling.lua index 8ec1cfe2e..5e84009db 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnKilling.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnKilling.lua @@ -17,6 +17,7 @@ return { { Name = "Victim", Type = "{{cPawn}}", Notes = "The player or mob that is about to be killed" }, { Name = "Killer", Type = "{{cEntity}}", Notes = "The entity that has caused the victim to lose the last point of health. May be nil for environment damage" }, + { Name = "TDI", Type = "{{TakeDamageInfo}}", Notes = "The damage type, cause and effects." }, }, Returns = [[ If the function returns false or no value, MCServer calls other plugins with this event. If the diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index a49f8b5a6..bd0b94a06 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -1880,6 +1880,117 @@ end +--- Returns the square of the distance from the specified point to the specified line +local function SqDistPtFromLine(x, y, x1, y1, x2, y2) + local dx = x - x1 + local dy = y - y1 + local px = x2 - x1 + local py = y2 - y1 + local ss = px * dx + py * dy + local ds = px * px + py * py + + if (ss < 0) then + -- Return sqdistance from point 1 + return dx * dx + dy * dy + end + if (ss > ds) then + -- Return sqdistance from point 2 + return ((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)) + end + + -- Return sqdistance from the line + if ((px * px + py * py) == 0) then + return dx * dx + dy * dy + else + return (py * dx - px * dy) * (py * dx - px * dy) / (px * px + py * py) + end +end + + + + + +function HandleConsoleTestTracer(a_Split, a_EntireCmd) + -- Check required params: + if not(a_Split[7]) then + return true, "Usage: " .. a_Split[1] .. " <x1> <y1> <z1> <x2> <y2> <z2> [<WorldName>]" + end + local Coords = {} + for i = 1, 6 do + local v = tonumber(a_Split[i + 1]) + if not(v) then + return true, "Parameter " .. (i + 1) .. " (" .. tostring(a_Split[i + 1]) .. ") not a number " + end + Coords[i] = v + end + + -- Get the world in which to test: + local World + if (a_Split[8]) then + World = cRoot:GetWorld(a_Split[2]) + else + World = cRoot:Get():GetDefaultWorld() + end + if not(World) then + return true, "No such world" + end + + -- Define the callbacks to use for tracing: + local Callbacks = + { + OnNextBlock = function(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_EntryFace) + LOG(string.format("{%d, %d, %d}: %s", a_BlockX, a_BlockY, a_BlockZ, ItemToString(cItem(a_BlockType, 1, a_BlockMeta)))) + end, + OnNextBlockNoData = function(a_BlockX, a_BlockY, a_BlockZ, a_EntryFace) + LOG(string.format("{%d, %d, %d} (no data)", a_BlockX, a_BlockY, a_BlockZ)) + end, + OnNoChunk = function() + LOG("Chunk not loaded") + end, + OnNoMoreHits = function() + LOG("Trace finished") + end, + OnOutOfWorld = function() + LOG("Out of world") + end, + OnIntoWorld = function() + LOG("Into world") + end, + } + + -- Approximate the chunks needed for the trace by iterating over all chunks and measuring their center's distance from the traced line + local Chunks = {} + local sx = math.floor(Coords[1] / 16) + local sz = math.floor(Coords[3] / 16) + local ex = math.floor(Coords[4] / 16) + local ez = math.floor(Coords[6] / 16) + local sgnx = (sx < ex) and 1 or -1 + local sgnz = (sz < ez) and 1 or -1 + for z = sz, ez, sgnz do + local ChunkCenterZ = z * 16 + 8 + for x = sx, ex, sgnx do + local ChunkCenterX = x * 16 + 8 + local sqdist = SqDistPtFromLine(ChunkCenterX, ChunkCenterZ, Coords[1], Coords[3], Coords[4], Coords[6]) + if (sqdist <= 128) then + table.insert(Chunks, {x, z}) + end + end + end + + -- Load the chunks and do the trace once loaded: + World:ChunkStay(Chunks, + nil, + function() + cLineBlockTracer:Trace(World, Callbacks, Coords[1], Coords[2], Coords[3], Coords[4], Coords[5], Coords[6]) + end + ) + return true +end + + + + + function HandleConsoleBBox(a_Split) local bbox = cBoundingBox(0, 10, 0, 10, 0, 10) local v1 = Vector3d(1, 1, 1) diff --git a/MCServer/Plugins/Debuggers/Info.lua b/MCServer/Plugins/Debuggers/Info.lua index 2e170487b..a76690ea1 100644 --- a/MCServer/Plugins/Debuggers/Info.lua +++ b/MCServer/Plugins/Debuggers/Info.lua @@ -235,6 +235,12 @@ g_PluginInfo = Handler = HandleConsoleSchedule, HelpString = "Tests the world scheduling", }, + + ["testtracer"] = + { + Handler = HandleConsoleTestTracer, + HelpString = "Tests the cLineBlockTracer", + } }, -- ConsoleCommands } -- g_PluginInfo |