core: improved building system
This commit is contained in:
@@ -160,30 +160,41 @@ placeRemote.OnServerEvent:Connect(function(player, cx, cy, cz, x, y, z, blockId)
|
||||
end)
|
||||
|
||||
breakRemote.OnServerEvent:Connect(function(player, cx, cy, cz, x, y, z)
|
||||
--print("del",player, cx, cy, cz, x, y, z)
|
||||
print("[DEBUG] Server breakRemote received - Player:", player.Name, "Chunk:", cx, cy, cz, "Block:", x, y, z)
|
||||
|
||||
if typeof(cx) ~= "number" or typeof(cy) ~= "number" or typeof(cz) ~= "number" then
|
||||
print("[DEBUG] Invalid chunk coordinate types")
|
||||
return
|
||||
end
|
||||
if typeof(x) ~= "number" or typeof(y) ~= "number" or typeof(z) ~= "number" then
|
||||
print("[DEBUG] Invalid block coordinate types")
|
||||
return
|
||||
end
|
||||
if x < 1 or x > 8 or y < 1 or y > 8 or z < 1 or z > 8 then
|
||||
print("[DEBUG] Block coordinates out of range:", x, y, z)
|
||||
return
|
||||
end
|
||||
if math.abs(cx) > MAX_CHUNK_DIST or math.abs(cy) > MAX_CHUNK_DIST or math.abs(cz) > MAX_CHUNK_DIST then
|
||||
print("[DEBUG] Chunk coordinates out of range:", cx, cy, cz)
|
||||
return
|
||||
end
|
||||
if not isWithinReach(player, cx, cy, cz, x, y, z) then
|
||||
print("[DEBUG] Block not within player reach")
|
||||
return
|
||||
end
|
||||
|
||||
local chunk = getServerChunk(cx, cy, cz)
|
||||
if not chunk:GetBlockAt(x, y, z) then
|
||||
print("[DEBUG] No block found at specified location")
|
||||
task.synchronize()
|
||||
tickRemote:FireClient(player, "C_R", cx, cy, cz, 0, 0, 0, 0)
|
||||
task.desynchronize()
|
||||
return
|
||||
end
|
||||
print("[DEBUG] All validations passed, removing block")
|
||||
chunk:RemoveBlock(x, y, z)
|
||||
propogate("B_D", cx, cy, cz, x, y, z, 0)
|
||||
print("[DEBUG] Block removal propagated to clients")
|
||||
end)
|
||||
|
||||
task.desynchronize()
|
||||
|
||||
Reference in New Issue
Block a user