{"record":{"id":"970e3c25c82ae4ea","repo":"Anuken/Mindustry","slug":"player-cannot-control-a-building","errorCode":null,"errorMessage":"Player cannot control a building.","messagePattern":"Player cannot control a building\\.","errorType":"validation","errorClass":"ValidateException","httpStatus":null,"severity":"warning","filePath":"core/src/mindustry/input/InputHandler.java","lineNumber":747,"sourceCode":"        Events.fire(new ConfigEvent(build, player, value));\n    }\n\n    //only useful for servers or local mods, and is not replicated across clients\n    //uses unreliable packets due to high frequency\n    @Remote(targets = Loc.both, called = Loc.both, unreliable = true)\n    public static void tileTap(@Nullable Player player, Tile tile){\n        if(tile == null) return;\n\n        Events.fire(new TapEvent(player, tile));\n    }\n\n    @Remote(targets = Loc.both, called = Loc.server)\n    public static void buildingControlSelect(Player player, Building build){\n        if(player == null || build == null || player.dead()) return;\n\n        //make sure player is allowed to control the building\n        if(net.server() && (!state.rules.possessionAllowed && player.bestCore() != build  || !netServer.admins.allowAction(player, ActionType.buildSelect, action -> action.tile = build.tile))){\n            throw new ValidateException(player, \"Player cannot control a building.\");\n        }\n\n        if(player.team() == build.team && build.canControlSelect(player.unit())){\n            var before = player.unit();\n\n            Call.unitBuildingControlSelect(player.unit(), build);\n\n            if(!before.dead && before.spawnedByCore && !before.isPlayer()){\n                Call.unitDespawn(before);\n            }\n        }\n    }\n\n    @Remote(called = Loc.server)\n    public static void unitBuildingControlSelect(Unit unit, Building build){\n        if(unit == null || unit.dead()) return;\n\n        //client skips checks to prevent ghost units","sourceCodeStart":729,"sourceCodeEnd":765,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/input/InputHandler.java#L729-L765","documentation":"Thrown server-side as ValidateException when buildingControlSelect fails authorization: possession is not allowed by rules (state.rules.possessionAllowed is false AND player.bestCore() != build) OR netServer.admins.allowAction(buildSelect) denies it. Validates that a player may take direct control of a building (e.g. core units / turret possession).","triggerScenarios":"Client sends buildingControlSelect for a build when possession is disallowed by rules, or the admin layer denies the buildSelect action. Server-only throw (the @Remote called=Loc.server).","commonSituations":"Game mode/server disables possession (possessionAllowed=false) but a client still attempts it; permission plugin denies build control; client attempts to control an enemy-team building.","solutions":["On the server, handle ValidateException gracefully (it is an expected rejection).","Clients should check state.rules.possessionAllowed and team match before requesting control.","Review permission/admin configuration if legitimate control is blocked."],"exampleFix":"// before\nCall.buildingControlSelect(player, build);\n\n// after\nif(state.rules.possessionAllowed && player.team() == build.team()){\n    Call.buildingControlSelect(player, build);\n}","handlingStrategy":"try-catch","validationCode":"// client checks rules and team before requesting building control\nif(!state.rules.possessionAllowed && player.bestCore() != build){\n    return;\n}\nif(player.team() != build.team()){ return; }","typeGuard":null,"tryCatchPattern":"try{ Call.buildingControlSelect(player, build); }catch(mindustry.net.ValidateException e){ Log.debug(\"rejected build control from @\", e.player); }","preventionTips":["Clients: respect state.rules.possessionAllowed before requesting control.","Servers: handle ValidateException as expected.","Verify team match before requesting control.","Document which gamemodes disable possession."],"tags":["network","validation","multiplayer","server","control"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}