diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b82408 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Packages/ \ No newline at end of file diff --git a/default.project.json b/default.project.json index bddf56a..6e4980e 100644 --- a/default.project.json +++ b/default.project.json @@ -5,7 +5,16 @@ "ReplicatedStorage": { "$className": "ReplicatedStorage", "$ignoreUnknownInstances": true, - "$path": "src/ReplicatedStorage" + "$path": "src/ReplicatedStorage", + "Packages": { + "$className": "Folder", + "$path": "Packages" + } + }, + "ReplicatedFirst": { + "$className": "ReplicatedFirst", + "$ignoreUnknownInstances": true, + "$path": "src/ReplicatedFirst" }, "ServerScriptService": { "$className": "ServerScriptService", diff --git a/src/ServerScriptService/CmdrCommands/ChunkDump.lua b/src/ServerScriptService/CmdrCommands/ChunkDump.lua new file mode 100644 index 0000000..282a2cb --- /dev/null +++ b/src/ServerScriptService/CmdrCommands/ChunkDump.lua @@ -0,0 +1,23 @@ +return { + Name = "chunkdump", + Aliases = {"dumpchunk"}, + Description = "Show server-side block count for a chunk.", + Group = "Debug", + Args = { + { + Type = "integer", + Name = "cx", + Description = "Chunk X" + }, + { + Type = "integer", + Name = "cy", + Description = "Chunk Y" + }, + { + Type = "integer", + Name = "cz", + Description = "Chunk Z" + } + } +} diff --git a/src/ServerScriptService/CmdrCommands/ChunkDumpServer.lua b/src/ServerScriptService/CmdrCommands/ChunkDumpServer.lua new file mode 100644 index 0000000..077aca9 --- /dev/null +++ b/src/ServerScriptService/CmdrCommands/ChunkDumpServer.lua @@ -0,0 +1,15 @@ +return function(context, cx, cy, cz) + local terrainGen = require( + game:GetService("ServerScriptService") + :WaitForChild("Actor") + :WaitForChild("ServerChunkManager") + :WaitForChild("TerrainGen") + ) + + local chunk = terrainGen:GetChunk(cx, cy, cz) + local count = 0 + for _ in pairs(chunk.data) do + count += 1 + end + return ("Chunk %d,%d,%d has %d blocks"):format(cx, cy, cz, count) +end diff --git a/src/ServerScriptService/CmdrCommands/ResyncChunk.lua b/src/ServerScriptService/CmdrCommands/ResyncChunk.lua new file mode 100644 index 0000000..02ceb55 --- /dev/null +++ b/src/ServerScriptService/CmdrCommands/ResyncChunk.lua @@ -0,0 +1,49 @@ +return { + Name = "resyncchunk", + Aliases = {"resyncc"}, + Description = "Resync a chunk (and optional radius) for a player.", + Group = "Debug", + Args = { + { + Type = "player", + Name = "player", + Description = "Player to resync" + }, + { + Type = "integer", + Name = "cx", + Description = "Chunk X" + }, + { + Type = "integer", + Name = "cy", + Description = "Chunk Y" + }, + { + Type = "integer", + Name = "cz", + Description = "Chunk Z" + }, + { + Type = "integer", + Name = "radius", + Description = "Radius around the chunk", + Optional = true, + Default = 0 + } + }, + Run = function(context, player, cx, cy, cz, radius) + local tickRemote = game:GetService("ReplicatedStorage"):WaitForChild("Tick") + local r = radius or 0 + local count = 0 + for y = -r, r do + for x = -r, r do + for z = -r, r do + tickRemote:FireClient(player, "C_R", cx + x, cy + y, cz + z, 0, 0, 0, 0) + count += 1 + end + end + end + return ("Resync sent to %s (%d chunks)"):format(player.Name, count) + end +} diff --git a/src/ServerScriptService/CmdrCommands/ResyncNear.lua b/src/ServerScriptService/CmdrCommands/ResyncNear.lua new file mode 100644 index 0000000..f734448 --- /dev/null +++ b/src/ServerScriptService/CmdrCommands/ResyncNear.lua @@ -0,0 +1,48 @@ +return { + Name = "resyncnear", + Aliases = {"resyncnearby"}, + Description = "Resync chunks around a player's current chunk.", + Group = "Debug", + Args = { + { + Type = "player", + Name = "player", + Description = "Player to resync" + }, + { + Type = "integer", + Name = "radius", + Description = "Radius around the player chunk", + Optional = true, + Default = 1 + } + }, + Run = function(context, player, radius) + local character = player.Character + if not character then + return "Player has no character" + end + local root = character:FindFirstChild("HumanoidRootPart") + if not root then + return "Player has no HumanoidRootPart" + end + + local pos = root.Position + local cx = math.round(pos.X / 32) + local cy = math.round(pos.Y / 32) + local cz = math.round(pos.Z / 32) + + local tickRemote = game:GetService("ReplicatedStorage"):WaitForChild("Tick") + local r = radius or 1 + local count = 0 + for y = -r, r do + for x = -r, r do + for z = -r, r do + tickRemote:FireClient(player, "C_R", cx + x, cy + y, cz + z, 0, 0, 0, 0) + count += 1 + end + end + end + return ("Resync sent to %s (%d chunks around %d,%d,%d)"):format(player.Name, count, cx, cy, cz) + end +} diff --git a/src/ServerScriptService/CmdrServer.server.lua b/src/ServerScriptService/CmdrServer.server.lua new file mode 100644 index 0000000..00ab43a --- /dev/null +++ b/src/ServerScriptService/CmdrServer.server.lua @@ -0,0 +1,7 @@ +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local ServerScriptService = game:GetService("ServerScriptService") + +local Cmdr = require(ReplicatedStorage.Packages.cmdr) + +Cmdr:RegisterDefaultCommands() +Cmdr.Registry:RegisterCommandsIn(ServerScriptService.CmdrCommands) diff --git a/src/StarterGui/Crosshair/LocalScript.client.lua b/src/StarterGui/Crosshair/LocalScript.client.lua index 92b726b..76e9406 100644 --- a/src/StarterGui/Crosshair/LocalScript.client.lua +++ b/src/StarterGui/Crosshair/LocalScript.client.lua @@ -7,13 +7,16 @@ end local ReplicatedStorage = game:GetService("ReplicatedStorage") local UIS = game:GetService("UserInputService") +local TXTS = game:GetService("TextChatService") +local TXTS_CIF = TXTS:FindFirstChildOfClass("ChatInputBarConfiguration") + ReplicatedStorage:WaitForChild("Objects"):WaitForChild("MLLoaded") game:GetService("Players").LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson UIS.MouseIconEnabled = false UIS.InputEnded:Connect(function(k) - if k.KeyCode == Enum.KeyCode.M then + if k.KeyCode == Enum.KeyCode.M and UIS:GetFocusedTextBox() == nil and not TXTS_CIF.IsFocused then local v = not script.Parent.DummyButton.Modal UIS.MouseIconEnabled = v script.Parent.CrosshairLabel.Visible = not v diff --git a/src/StarterPlayer/StarterPlayerScripts/CmdrClient.client.lua b/src/StarterPlayer/StarterPlayerScripts/CmdrClient.client.lua new file mode 100644 index 0000000..66e6da3 --- /dev/null +++ b/src/StarterPlayer/StarterPlayerScripts/CmdrClient.client.lua @@ -0,0 +1,8 @@ +repeat + wait(0.1) +until game:IsLoaded() == true + +local ReplicatedStorage = game:GetService("ReplicatedStorage") + +local Cmdr = require(ReplicatedStorage:WaitForChild("CmdrClient")) +Cmdr:SetActivationKeys({ Enum.KeyCode.F2 }) diff --git a/wally.lock b/wally.lock new file mode 100644 index 0000000..acf538e --- /dev/null +++ b/wally.lock @@ -0,0 +1,13 @@ +# This file is automatically @generated by Wally. +# It is not intended for manual editing. +registry = "test" + +[[package]] +name = "evaera/cmdr" +version = "1.12.0" +dependencies = [] + +[[package]] +name = "ocbwoy3-development-studios/minecraft-roblox" +version = "0.1.0" +dependencies = [["cmdr", "evaera/cmdr@1.12.0"]] diff --git a/wally.toml b/wally.toml new file mode 100644 index 0000000..466c874 --- /dev/null +++ b/wally.toml @@ -0,0 +1,8 @@ +[package] +name = "ocbwoy3-development-studios/minecraft-roblox" +version = "0.1.0" +registry = "https://github.com/UpliftGames/wally-index" +realm = "shared" + +[dependencies] +cmdr = "evaera/cmdr@1.12.0" \ No newline at end of file