public static bool IsOwnedByNPC(this IMyTerminalBlock Block, bool AllowNobody = true, bool CheckBuilder = false) { if (!CheckBuilder) { if (Block.IsOwnedByPirates()) { return(true); } if (!AllowNobody && Block.IsOwnedByNobody()) { return(false); } IMyPlayer Owner = MyAPIGateway.Players.GetPlayerByID(Block.OwnerId); return(Owner != null ? Owner.IsBot : true); } else { if (!Block.IsOwnedByNPC(AllowNobody)) { return(false); } long BuilderID = Block.GetBuiltBy(); if (!AllowNobody && BuilderID == 0) { return(false); } IMyPlayer Owner = MyAPIGateway.Players.GetPlayerByID(BuilderID); return(Owner != null ? Owner.IsBot : true); } }